def draw_debug_visuals():
if not bpy.context.scene.debug_mode:
return
demo_obj_name = "SpringDemoCube"
if demo_obj_name not in bpy.data.objects:
return
obj = bpy.data.objects[demo_obj_name]
# Используем 'UNIFORM_COLOR'
shader = gpu.shader.from_builtin('UNIFORM_COLOR')
# Включаем прозрачность
gpu.state.blend_set('ALPHA')
# 1. Отображаем head и tail как голографические точки
head_pos = Vector(obj.wiggle_head)
tail_pos = Vector(obj.wiggle_tail)
point_size = 6.0
gpu.state.point_size_set(point_size)
# Head
shader.bind()
shader.uniform_float("color", DEBUG_COLORS["head"])
batch = batch_for_shader(shader, 'POINTS', {"pos": [head_pos]})
batch.draw(shader)
# Tail
shader.uniform_float("color", DEBUG_COLORS["tail"])
batch = batch_for_shader(shader, 'POINTS', {"pos": [tail_pos]})
batch.draw(shader)
# 2. Линия между head и tail (пружина)
shader.uniform_float("color", DEBUG_COLORS["spring"])
batch = batch_for_shader(shader, 'LINES', {"pos": [head_pos, tail_pos]})
batch.draw(shader)
# 3. Векторы скоростей (как голографические стрелки)
velocity_scale = 0.1 # Масштаб для отображения скоростей
head_velocity_end = head_pos + Vector(obj.wiggle_velocity_head) * velocity_scale
tail_velocity_end = tail_pos + Vector(obj.wiggle_velocity_tail) * velocity_scale
shader.uniform_float("color", DEBUG_COLORS["velocity"])
batch = batch_for_shader(shader, 'LINES', {"pos": [head_pos, head_velocity_end]})
batch.draw(shader)
batch = batch_for_shader(shader, 'LINES', {"pos": [tail_pos, tail_velocity_end]})
batch.draw(shader)
# 4. Целевая позиция head (как голографическая точка)
target_head = Vector((bpy.context.scene.wiggle_target_x, bpy.context.scene.wiggle_target_y, bpy.context.scene.wiggle_target_z))
shader.uniform_float("color", DEBUG_COLORS["target"])
batch = batch_for_shader(shader, 'POINTS', {"pos": [target_head]})
batch.draw(shader)
# 5. Линия от head к целевой позиции
shader.uniform_float("color", DEBUG_COLORS["target"])
batch = batch_for_shader(shader, 'LINES', {"pos": [head_pos, target_head]})
batch.draw(shader)