Skip to content

Commit

Permalink
updates from external repos
Browse files Browse the repository at this point in the history
  • Loading branch information
sambler committed Sep 20, 2019
1 parent 59256dc commit 22ae699
Show file tree
Hide file tree
Showing 464 changed files with 11,257 additions and 54,718 deletions.
3 changes: 1 addition & 2 deletions BlenderGIS/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Blender GIS
==========
A new version for Blender 2.80 beta is already available in the dedicated branch.
Until official 2.8 release, the master branch is for Blender 2.79 only.
Blender minimal version : 2.8


[Full documentation](https://github.com/domlysz/BlenderGIS/wiki/Home)
Expand Down
8 changes: 7 additions & 1 deletion BlenderGIS/prefs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
log = logging.getLogger(__name__)

import bpy
from bpy.props import StringProperty, IntProperty, FloatProperty, BoolProperty, EnumProperty, FloatVectorProperty
Expand Down Expand Up @@ -529,7 +530,12 @@ def execute(self, context):

def register():
for cls in classes:
bpy.utils.register_class(cls)
try:
bpy.utils.register_class(cls)
except ValueError:
log.error('Cannot register {}'.format(cls), exc_info=True)



def unregister():
for cls in classes:
Expand Down
55 changes: 50 additions & 5 deletions BlenderTextureTools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ def rt_glcompute():

from .bpy_amb import raycast
import importlib

importlib.reload(raycast)

rc = raycast.Raycaster(tris)
Expand All @@ -1064,12 +1065,13 @@ def rt_glcompute():

return res.reshape((rw, rw, 4))

result = rt_glcompute()[:, :, 0]
result = np.where(result < 50.0, (result - 4.0) / 2.0, 1.0)
result = rt_glcompute()
dist = result[:, :, 0]
dist = np.where(dist < 50.0, (dist - 4.0) / 2.0, 1.0)

image[:, :, 0] = result
image[:, :, 1] = result
image[:, :, 2] = result
image[:, :, 0] = dist
image[:, :, 1] = result[:, :, 1]
image[:, :, 2] = result[:, :, 2]

bm.free()
return image
Expand Down Expand Up @@ -1407,6 +1409,49 @@ def _pl2(self, image, context):
self.payload = _pl2


class Base64_16x16_IOP(image_ops.ImageOperatorGenerator):
def generate(self):
self.prefix = "base64"
self.info = "Base64"
self.category = "Debug"

def _pl(self, image, context):
print(image.shape)
if image.shape[0] != 16 or image.shape[0] != 16:
print("Wrong image size.")
return image

# to icon text
base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
icon = []
for v in image.reshape((image.shape[0] * image.shape[1], 4)):
icon.append(base64[int(v[0] * 64)])
icon.append(base64[int(v[1] * 64)])
icon.append(base64[int(v[2] * 64)])

icon_text = "".join(icon)
assert len(icon_text) == 768
print(icon_text)

# to image from icon text
to_value = {v: i for i, v in enumerate(base64)}
values = []
counter = 0
for v in icon_text:
values.append(to_value[v] / 64)
counter += 1
if counter == 3:
counter = 0
values.append(1.0)

# image = image.reshape((image.shape[0] * image.shape[1], 4))
image = np.array(values, dtype=image.dtype).reshape(image.shape)

return image

self.payload = _pl


class MGLRender_IOP(image_ops.ImageOperatorGenerator):
def generate(self):
self.prefix = "test_mgl_render"
Expand Down
4 changes: 3 additions & 1 deletion coa_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class COAToolsPreferences(bpy.types.AddonPreferences):

def draw(self, context):
layout = self.layout
layout.prop(self, "show_donate_icon")
# layout.prop(self, "show_donate_icon")
layout.prop(self, "sprite_import_export_scale")

addon_updater_ops.update_settings_ui(self, context)
Expand All @@ -148,6 +148,7 @@ def draw(self, context):

#operator
create_sprite_object.COATOOLS_OT_CreateSpriteObject,
create_sprite_object.COATOOLS_OT_DefineSpriteObject,
import_sprites.JsonImportData,
import_sprites.COATOOLS_OT_CreateMaterialGroup,
import_sprites.COATOOLS_OT_ImportSprite,
Expand Down Expand Up @@ -226,6 +227,7 @@ def draw(self, context):
version_converter.COATOOLS_OT_VersionConverter,

change_alpha_mode.COATOOLS_OT_ChangeAlphaMode,
change_alpha_mode.COATOOLS_OT_ChangeTextureInterpolationMode,

# exporter
export_dragonbones.COATOOLS_OT_DragonBonesExport,
Expand Down
34 changes: 17 additions & 17 deletions coa_tools/addon_updater_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,23 +772,23 @@ def update_settings_ui(self, context):
row.label(text="Restart blender to complete update", icon="ERROR")
return

split = row.split(factor=0.3, align=False)
subcol = split.column()
subcol.prop(settings, "auto_check_update")
subcol = split.column()

if settings.auto_check_update==False: subcol.enabled = False
subrow = subcol.row()
subrow.label(text="Interval between checks")
subrow = subcol.row(align=True)
checkcol = subrow.column(align=True)
checkcol.prop(settings,"updater_intrval_months")
checkcol = subrow.column(align=True)
checkcol.prop(settings,"updater_intrval_days")
checkcol = subrow.column(align=True)
checkcol.prop(settings,"updater_intrval_hours")
checkcol = subrow.column(align=True)
checkcol.prop(settings,"updater_intrval_minutes")
# split = row.split(factor=0.3, align=False)
# subcol = split.column()
# subcol.prop(settings, "auto_check_update")
# subcol = split.column()

# if settings.auto_check_update==False: subcol.enabled = False
# subrow = subcol.row()
# subrow.label(text="Interval between checks")
# subrow = subcol.row(align=True)
# checkcol = subrow.column(align=True)
# checkcol.prop(settings,"updater_intrval_months")
# checkcol = subrow.column(align=True)
# checkcol.prop(settings,"updater_intrval_days")
# checkcol = subrow.column(align=True)
# checkcol.prop(settings,"updater_intrval_hours")
# checkcol = subrow.column(align=True)
# checkcol.prop(settings,"updater_intrval_minutes")


# checking / managing updates
Expand Down
75 changes: 38 additions & 37 deletions coa_tools/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,43 +277,44 @@ def set_weights(self,context,obj):

def hide_base_sprite(obj):
context = bpy.context
selected_object = bpy.data.objects[context.active_object.name]
if "sprite" in obj.coa_tools and obj.type == "MESH":
orig_mode = obj.mode
context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.object.mode_set(mode="EDIT")
me = obj.data
bm = bmesh.from_edit_mesh(me)
bm.verts.ensure_lookup_table()

vertex_idxs = []
if "coa_base_sprite" in obj.vertex_groups:
v_group_idx = obj.vertex_groups["coa_base_sprite"].index
for i,vert in enumerate(obj.data.vertices):
for g in vert.groups:
if g.group == v_group_idx:
vertex_idxs.append(i)

for idx in vertex_idxs:
vert = bm.verts[idx]
vert.hide = True
vert.select = False
for edge in vert.link_edges:
edge.hide = True
edge.select = False
for face in vert.link_faces:
face.hide = obj.data.coa_tools.hide_base_sprite
face.select = False

if "coa_base_sprite" in obj.modifiers:
mod = obj.modifiers["coa_base_sprite"]
mod.show_viewport = obj.data.coa_tools.hide_base_sprite
mod.show_render = obj.data.coa_tools.hide_base_sprite

bmesh.update_edit_mesh(me)
bpy.ops.object.mode_set(mode=orig_mode)
context.view_layer.objects.active = selected_object
selected_object = bpy.data.objects[context.active_object.name] if bpy.context.active_object != None else None
if selected_object != None:
if obj.type == "MESH" and "coa_base_sprite" in obj.vertex_groups:
orig_mode = obj.mode
context.view_layer.objects.active = obj
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.object.mode_set(mode="EDIT")
me = obj.data
bm = bmesh.from_edit_mesh(me)
bm.verts.ensure_lookup_table()

vertex_idxs = []
if "coa_base_sprite" in obj.vertex_groups:
v_group_idx = obj.vertex_groups["coa_base_sprite"].index
for i,vert in enumerate(obj.data.vertices):
for g in vert.groups:
if g.group == v_group_idx:
vertex_idxs.append(i)

for idx in vertex_idxs:
vert = bm.verts[idx]
vert.hide = True
vert.select = False
for edge in vert.link_edges:
edge.hide = True
edge.select = False
for face in vert.link_faces:
face.hide = obj.data.coa_tools.hide_base_sprite
face.select = False

if "coa_base_sprite" in obj.modifiers:
mod = obj.modifiers["coa_base_sprite"]
mod.show_viewport = obj.data.coa_tools.hide_base_sprite
mod.show_render = obj.data.coa_tools.hide_base_sprite

bmesh.update_edit_mesh(me)
bpy.ops.object.mode_set(mode=orig_mode)
context.view_layer.objects.active = selected_object

def get_uv_from_vert(uv_layer, v):
for l in v.link_loops:
Expand Down
29 changes: 29 additions & 0 deletions coa_tools/operators/change_alpha_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ def execute(self, context):
mat.blend_method = self.blend_method
return {"FINISHED"}

def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)


class COATOOLS_OT_ChangeTextureInterpolationMode(bpy.types.Operator):
bl_idname = "coa_tools.change_texture_interpolation_mode"
bl_label = "Change Texture Interpolation Mode"
bl_description = ""
bl_options = {"REGISTER"}

items = (("Linear","Linear","Linear"),("Closest","Closest","Closest"),("Cubic","Cubic","Cubic"),("Smart","Smart","Smart"))
interpolation_method: EnumProperty(name="Interpolation Method", items=items)

@classmethod
def poll(cls, context):
return True

def execute(self, context):
sprite_object = functions.get_sprite_object(context.active_object)
for sprite in sprite_object.children:
if sprite.type == "MESH":
for mat in sprite.data.materials:
if mat.node_tree != None:
for node in mat.node_tree.nodes:
if node.type == "TEX_IMAGE":
node.interpolation = self.interpolation_method
return {"FINISHED"}

def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
2 changes: 0 additions & 2 deletions coa_tools/operators/create_ortho_cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def draw(self,context):
def execute(self, context):
cam = context.active_object
if cam.type == "CAMERA":
print(self.align)
if self.align == "TOP_LEFT":
self.x_multiplier = -1
self.y_multiplier = 1
Expand All @@ -144,7 +143,6 @@ def execute(self, context):
self.y_multiplier = 1
self.offset_x = 0.5
self.offset_y = 0.5
print("baam")
elif self.align == "CENTER_LEFT":
self.x_multiplier = -1
self.y_multiplier = -1
Expand Down
30 changes: 28 additions & 2 deletions coa_tools/operators/create_sprite_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
from bpy.app.handlers import persistent
from .. functions import *


######################################################################################################################################### Create Sprite Object
class COATOOLS_OT_CreateSpriteObject(bpy.types.Operator):
bl_idname = "coa_tools.create_sprite_object"
bl_label = "Create Sprite Object"
bl_options = {"REGISTER","UNDO"}
bl_options = {"REGISTER", "UNDO"}

def execute(self, context):
obj = context.active_object
Expand All @@ -59,4 +60,29 @@ def execute(self, context):
sprite_object.data.edit_bones.remove(bone)
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.ed.undo_push(message="Create Sprite Object")
return{"FINISHED"}
return {"FINISHED"}


######################################################################################################################################### Create Sprite Object
class COATOOLS_OT_DefineSpriteObject(bpy.types.Operator):
bl_idname = "coa_tools.define_sprite_object"
bl_label = "Define as Sprite Object"
bl_options = {"REGISTER", "UNDO"}

@classmethod
def poll(cls, context):
if context.active_object.type == "ARMATURE":
return context.active_object
return False

def execute(self, context):
obj = context.active_object
obj.coa_tools["sprite_object"] = True
mode = obj.mode
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.object.mode_set(mode=mode)

bpy.ops.ed.undo_push(message="Define as Sprite Object")
return {"FINISHED"}


23 changes: 13 additions & 10 deletions coa_tools/operators/draw_bone_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ def draw(self,context):
row.prop(self,"bone_shapes")

def invoke(self,context,event):


self.bone_shapes = "NEW_SHAPE"
shape_name = context.active_pose_bone.name + "_custom_shape"
if context.active_object.type == "ARMATURE" and (context.active_pose_bone.custom_shape != None or shape_name in bpy.data.objects):
shape_name = context.active_pose_bone.custom_shape.name if context.active_pose_bone.custom_shape != None else context.active_pose_bone.name + "_custom_shape"
print(shape_name)
self.bone_shapes = shape_name
if context.active_pose_bone != None:
shape_name = context.active_pose_bone.name + "_custom_shape"
if context.active_object.type == "ARMATURE" and (context.active_pose_bone.custom_shape != None or shape_name in bpy.data.objects):
shape_name = context.active_pose_bone.custom_shape.name if context.active_pose_bone.custom_shape != None else context.active_pose_bone.name + "_custom_shape"
self.bone_shapes = shape_name

wm = context.window_manager
return wm.invoke_props_dialog(self)

wm = context.window_manager
return wm.invoke_props_dialog(self)
else:
self.report({'WARNING'}, "Select Bone in Pose Mode.")
return {'FINISHED'}

def execute(self, context):
if context.active_object.type == "ARMATURE" and context.active_object.mode == "POSE":
if self.bone_shapes == "NEW_SHAPE":
Expand Down
Loading

0 comments on commit 22ae699

Please sign in to comment.