code cleanning pass
parent
6bfd815d37
commit
02a62406d9
|
@ -1,7 +1,7 @@
|
|||
bl_info = {
|
||||
"name": "GP Interpolate",
|
||||
"author": "Christophe Seux, Samuel Bernou",
|
||||
"version": (0, 8, 3),
|
||||
"version": (0, 8, 4),
|
||||
"blender": (4, 0, 2),
|
||||
"location": "Sidebar > Gpencil Tab > Interpolate",
|
||||
"description": "Interpolate Grease pencil strokes over 3D",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import bpy
|
||||
from time import perf_counter, time
|
||||
from mathutils import Vector, Matrix
|
||||
from time import time
|
||||
from mathutils import Vector
|
||||
|
||||
from mathutils.geometry import (barycentric_transform,
|
||||
intersect_line_plane)
|
||||
|
||||
from ..utils import (plane_on_bone,
|
||||
ray_cast_point,
|
||||
|
@ -11,9 +14,6 @@ from ..utils import (plane_on_bone,
|
|||
create_plane,
|
||||
following_keys)
|
||||
|
||||
from mathutils.geometry import (barycentric_transform,
|
||||
intersect_line_plane)
|
||||
|
||||
|
||||
class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
||||
bl_idname = "gp.interpolate_stroke_base"
|
||||
|
@ -39,8 +39,7 @@ class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
|||
return f"Interpolate Stroke Backward"
|
||||
|
||||
def apply_and_store(self):
|
||||
# self.store = []
|
||||
# item = (prop, attr, [new_val])
|
||||
'''individual item in self.store_list: (prop, attr, [new_val])'''
|
||||
for item in self.store_list:
|
||||
prop, attr = item[:2]
|
||||
self.store.append( (prop, attr, getattr(prop, attr)) )
|
||||
|
@ -124,14 +123,10 @@ class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
|||
if not len(self.frames_to_jump):
|
||||
return self.exit(context, status='WARNING', text='No keyframe available in this direction')
|
||||
|
||||
active_layer = self.gp.data.layers.active
|
||||
## Change active layer if strokes are selected only on this layer
|
||||
layer_count = 0
|
||||
|
||||
layers = [l for l in self.gp.data.layers
|
||||
if (not l.lock and l.active_frame)
|
||||
and next((s for s in l.active_frame.strokes if s.select), None)]
|
||||
|
||||
|
||||
if not layers:
|
||||
return self.exit(context, status='ERROR', text='No stroke selected!')
|
||||
|
@ -322,7 +317,6 @@ class GP_OT_interpolate_stroke(GP_OT_interpolate_stroke_base):
|
|||
frame_num = len(self.frames_to_jump)
|
||||
percentage = (self.loop_count) / (frame_num) * 100
|
||||
context.area.header_text_set(f'Interpolation {percentage:.0f}% {self.loop_count + 1}/{frame_num} | Esc: Cancel')
|
||||
# (frame: {self.frames_to_jump[self.loop_count]})
|
||||
|
||||
if event.type in {'RIGHTMOUSE', 'ESC'}:
|
||||
context.area.header_text_set(f'Cancelling')
|
||||
|
@ -397,7 +391,6 @@ class GP_OT_interpolate_stroke(GP_OT_interpolate_stroke_base):
|
|||
return self.exit(context)
|
||||
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
# context.area.tag_redraw()
|
||||
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import bpy
|
||||
from time import perf_counter, time
|
||||
from mathutils import Vector, Matrix
|
||||
|
||||
from ..utils import (triangle_normal,
|
||||
get_gp_draw_plane)
|
||||
from time import time
|
||||
|
||||
from mathutils.geometry import (barycentric_transform,
|
||||
intersect_line_plane)
|
||||
|
||||
from ..utils import (triangle_normal,
|
||||
get_gp_draw_plane)
|
||||
|
||||
from .operators import GP_OT_interpolate_stroke_base
|
||||
## Converted to modal from "operator_single"
|
||||
|
||||
|
||||
class GP_OT_interpolate_stroke_tri(GP_OT_interpolate_stroke_base):
|
||||
bl_idname = "gp.interpolate_stroke_tri"
|
||||
|
@ -22,7 +20,6 @@ class GP_OT_interpolate_stroke_tri(GP_OT_interpolate_stroke_base):
|
|||
if state := super().invoke(context, event):
|
||||
return state
|
||||
|
||||
## START
|
||||
if not context.window_manager.get(f'tri_{self.gp.name}'):
|
||||
return self.exit(context, status='ERROR', text='Need to bind coordinate first. Use "Bind Tri Point" button')
|
||||
|
||||
|
@ -46,7 +43,6 @@ class GP_OT_interpolate_stroke_tri(GP_OT_interpolate_stroke_base):
|
|||
|
||||
point_dict = context.window_manager.get(f'tri_{self.gp.name}')
|
||||
## point_dict -> {'0': {'object': object_name_as_str, 'index': 450}, ...}
|
||||
|
||||
## Get triangle dumped in context.window_manager
|
||||
self.source_object_list = [bpy.context.scene.objects.get(point_dict[str(i)]['object']) for i in range(3)]
|
||||
self.source_tri_indices = [point_dict[str(i)]['index'] for i in range(3)] # List of vertices index corresponding to tri coordinates
|
||||
|
|
Loading…
Reference in New Issue