new addon simple_deform_helper #104464

Closed
EMM wants to merge 29 commits from Guai_Wo_Ge_EMM/blender-addons:simple_deform_helper into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 31 additions and 41 deletions
Showing only changes of commit 6d8cd27cca - Show all commits

View File

@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from . import gizmo, operators, preferences, data,timers,translate
from . import gizmo, operators, preferences, data, update, translate
bl_info = {
"name": "SimpleDeformHelper",
@ -14,7 +14,7 @@ bl_info = {
module_tuple = (
gizmo,
timers,
update,
translate,
operators,
preferences,

View File

@ -1,5 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import bgl
import blf
import bpy
import gpu
@ -131,7 +130,6 @@ class Draw3D(Pref, Data):
if 'draw_limits_bound_box' in handler_dit:
# draw limits_bound_box
mat, data = handler_dit['draw_limits_bound_box']
bgl.glEnable(bgl.GL_DEPTH_TEST)
coords = Utils.matrix_calculation(mat, cls.data_to_calculation(data))
cls.draw_3d_shader(coords,
G_INDICES,
@ -142,7 +140,6 @@ class Draw3D(Pref, Data):
handler_dit = cls.G_SimpleDeformGizmoHandlerDit
if 'draw_line' in handler_dit:
line_pos, limits_pos, = handler_dit['draw_line']
bgl.glDisable(bgl.GL_DEPTH_TEST)
# draw limits line
cls.draw_3d_shader(limits_pos, ((1, 0),), (1, 1, 0, 0.5))
# draw line
@ -161,7 +158,6 @@ class Draw3D(Pref, Data):
pos, indices, mat, mod_data, limits = handler_dit['draw']
if ([getattr(active, i) for i in G_MODIFIERS_PROPERTY] == mod_data) and (
ob.matrix_world == mat) and limits == active.limits[:]:
bgl.glEnable(bgl.GL_DEPTH_TEST)
cls.draw_3d_shader(
pos, indices, pref.deform_wireframe_color)
@ -180,7 +176,7 @@ class Draw3D(Pref, Data):
pref = cls._pref()
simple_poll = Utils.simple_deform_poll(context)
bend = modifier and (modifier.deform_method == 'BEND')
display_switch_axis = False == pref.display_bend_axis_switch_gizmo
display_switch_axis = not pref.display_bend_axis_switch_gizmo
cls.draw_scale_text(obj)
Utils.update_co_data(obj, modifier)
@ -194,7 +190,6 @@ class Draw3D(Pref, Data):
cls.draw_limits_line()
cls.draw_limits_bound_box()
elif simple_poll and (bend and not display_switch_axis):
bgl.glDisable(bgl.GL_DEPTH_TEST)
cls.draw_box(co_data, matrix)
Utils.new_empty(obj, modifier)
@ -202,9 +197,9 @@ class Draw3D(Pref, Data):
def draw_bound_box(cls):
gpu.state.blend_set('ALPHA')
gpu.state.line_width_set(1)
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_ALPHA)
bgl.glDisable(bgl.GL_DEPTH_TEST)
gpu.state.blend_set('ALPHA')
gpu.state.depth_test_set('ALWAYS')
context = bpy.context
if Utils.simple_deform_poll(context):

View File

@ -1,30 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.app import timers
def remove_not_use_empty(remove_name: str = "ViewSimpleDeformGizmo__Empty_"):
"""循环场景内的所有物体,找出没用的空物体并删掉
"""
context = bpy.context
for obj in context.scene.objects:
is_empty = obj.type == "EMPTY"
not_parent = not obj.parent
name_ok = obj.name.count(remove_name)
if name_ok and not_parent and is_empty:
bpy.data.objects.remove(obj) # remove object
def update_timers() -> float:
remove_not_use_empty()
return 3
def register():
timers.register(update_timers, persistent=True)
def unregister():
if timers.is_registered(update_timers):
timers.unregister(update_timers)

View File

@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.app.handlers import depsgraph_update_post, persistent
@persistent
def remove_not_use_empty(scene, dep):
"""循环场景内的所有物体,找出没用的空物体并删掉
"""
remove_name: str = "ViewSimpleDeformGizmo__Empty_"
context = bpy.context
for obj in context.scene.objects:
is_empty = obj.type == "EMPTY"
not_parent = not obj.parent
if remove_name in obj.name and not_parent and is_empty:
bpy.data.objects.remove(obj) # remove object
def register():
depsgraph_update_post.append(remove_not_use_empty)
def unregister():
depsgraph_update_post.remove(remove_not_use_empty)