code cleanning pass
parent
6bfd815d37
commit
02a62406d9
|
@ -1,7 +1,7 @@
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "GP Interpolate",
|
"name": "GP Interpolate",
|
||||||
"author": "Christophe Seux, Samuel Bernou",
|
"author": "Christophe Seux, Samuel Bernou",
|
||||||
"version": (0, 8, 3),
|
"version": (0, 8, 4),
|
||||||
"blender": (4, 0, 2),
|
"blender": (4, 0, 2),
|
||||||
"location": "Sidebar > Gpencil Tab > Interpolate",
|
"location": "Sidebar > Gpencil Tab > Interpolate",
|
||||||
"description": "Interpolate Grease pencil strokes over 3D",
|
"description": "Interpolate Grease pencil strokes over 3D",
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import bpy
|
import bpy
|
||||||
from time import perf_counter, time
|
from time import time
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector
|
||||||
|
|
||||||
|
from mathutils.geometry import (barycentric_transform,
|
||||||
|
intersect_line_plane)
|
||||||
|
|
||||||
from ..utils import (plane_on_bone,
|
from ..utils import (plane_on_bone,
|
||||||
ray_cast_point,
|
ray_cast_point,
|
||||||
|
@ -11,9 +14,6 @@ from ..utils import (plane_on_bone,
|
||||||
create_plane,
|
create_plane,
|
||||||
following_keys)
|
following_keys)
|
||||||
|
|
||||||
from mathutils.geometry import (barycentric_transform,
|
|
||||||
intersect_line_plane)
|
|
||||||
|
|
||||||
|
|
||||||
class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
||||||
bl_idname = "gp.interpolate_stroke_base"
|
bl_idname = "gp.interpolate_stroke_base"
|
||||||
|
@ -39,8 +39,7 @@ class GP_OT_interpolate_stroke_base(bpy.types.Operator):
|
||||||
return f"Interpolate Stroke Backward"
|
return f"Interpolate Stroke Backward"
|
||||||
|
|
||||||
def apply_and_store(self):
|
def apply_and_store(self):
|
||||||
# self.store = []
|
'''individual item in self.store_list: (prop, attr, [new_val])'''
|
||||||
# item = (prop, attr, [new_val])
|
|
||||||
for item in self.store_list:
|
for item in self.store_list:
|
||||||
prop, attr = item[:2]
|
prop, attr = item[:2]
|
||||||
self.store.append( (prop, attr, getattr(prop, attr)) )
|
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):
|
if not len(self.frames_to_jump):
|
||||||
return self.exit(context, status='WARNING', text='No keyframe available in this direction')
|
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
|
## Change active layer if strokes are selected only on this layer
|
||||||
layer_count = 0
|
|
||||||
|
|
||||||
layers = [l for l in self.gp.data.layers
|
layers = [l for l in self.gp.data.layers
|
||||||
if (not l.lock and l.active_frame)
|
if (not l.lock and l.active_frame)
|
||||||
and next((s for s in l.active_frame.strokes if s.select), None)]
|
and next((s for s in l.active_frame.strokes if s.select), None)]
|
||||||
|
|
||||||
|
|
||||||
if not layers:
|
if not layers:
|
||||||
return self.exit(context, status='ERROR', text='No stroke selected!')
|
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)
|
frame_num = len(self.frames_to_jump)
|
||||||
percentage = (self.loop_count) / (frame_num) * 100
|
percentage = (self.loop_count) / (frame_num) * 100
|
||||||
context.area.header_text_set(f'Interpolation {percentage:.0f}% {self.loop_count + 1}/{frame_num} | Esc: Cancel')
|
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'}:
|
if event.type in {'RIGHTMOUSE', 'ESC'}:
|
||||||
context.area.header_text_set(f'Cancelling')
|
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)
|
return self.exit(context)
|
||||||
|
|
||||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||||
# context.area.tag_redraw()
|
|
||||||
|
|
||||||
return {'RUNNING_MODAL'}
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
import bpy
|
import bpy
|
||||||
from time import perf_counter, time
|
from time import time
|
||||||
from mathutils import Vector, Matrix
|
|
||||||
|
|
||||||
from ..utils import (triangle_normal,
|
|
||||||
get_gp_draw_plane)
|
|
||||||
|
|
||||||
from mathutils.geometry import (barycentric_transform,
|
from mathutils.geometry import (barycentric_transform,
|
||||||
intersect_line_plane)
|
intersect_line_plane)
|
||||||
|
|
||||||
|
from ..utils import (triangle_normal,
|
||||||
|
get_gp_draw_plane)
|
||||||
|
|
||||||
from .operators import GP_OT_interpolate_stroke_base
|
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):
|
class GP_OT_interpolate_stroke_tri(GP_OT_interpolate_stroke_base):
|
||||||
bl_idname = "gp.interpolate_stroke_tri"
|
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):
|
if state := super().invoke(context, event):
|
||||||
return state
|
return state
|
||||||
|
|
||||||
## START
|
|
||||||
if not context.window_manager.get(f'tri_{self.gp.name}'):
|
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')
|
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 = context.window_manager.get(f'tri_{self.gp.name}')
|
||||||
## point_dict -> {'0': {'object': object_name_as_str, 'index': 450}, ...}
|
## point_dict -> {'0': {'object': object_name_as_str, 'index': 450}, ...}
|
||||||
|
|
||||||
## Get triangle dumped in context.window_manager
|
## 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_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
|
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