Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayde Moss <wbmoss_dev@yahoo.com>2020-11-26 00:46:32 +0300
committerWayde Moss <wbmoss_dev@yahoo.com>2020-12-10 07:14:13 +0300
commita586fd4e3d54a4fc1b079fb53d6e1634b3414c1b (patch)
tree6d41d4fb688f727b38f2059ebc65c6a7f4a96634
parent27388587e66ab68f44fe34fe688bda6916b165f5 (diff)
- WIP add nla alignment UI in python
-rw-r--r--release/scripts/startup/bl_ui/__init__.py1
-rw-r--r--release/scripts/startup/bl_ui/properties_nla.py113
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c12
-rw-r--r--source/blender/blenkernel/nla_private.h8
4 files changed, 126 insertions, 8 deletions
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 7d3ecceca41..e782ff7bfe3 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -49,6 +49,7 @@ _modules = [
"properties_mask_common",
"properties_material",
"properties_material_gpencil",
+ "properties_nla",
"properties_object",
"properties_paint_common",
"properties_grease_pencil_common",
diff --git a/release/scripts/startup/bl_ui/properties_nla.py b/release/scripts/startup/bl_ui/properties_nla.py
new file mode 100644
index 00000000000..88040a5f671
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_nla.py
@@ -0,0 +1,113 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+from bpy.types import Panel
+from bpy.props import (StringProperty,
+ BoolProperty,
+ IntProperty,
+ FloatProperty,
+ EnumProperty,
+ PointerProperty,
+ CollectionProperty,
+ FloatVectorProperty,
+ IntVectorProperty,
+ )
+def get_active_strip(context):
+ return next([strip for strip in context.selected_nla_strips if strip.active],None)
+
+class OBJECT_OT_nla_preblend_add_bone(bpy.types.Operator):
+ bl_idname = "pose.null_op"
+ bl_label = "NULL OP"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ preblend_index : IntProperty()
+
+ @classmethod
+ def poll(cls,context):
+ return context.selected_nla_strips
+
+ def execute(self, context):
+ active_strip = get_active_strip()
+ preblend = active_strip.preblend_transforms[self.preblend_index]
+ preblend.bones.add()
+
+ return {'FINISHED'}
+class OBJECT_OT_nla_preblend_remove_bone(bpy.types.Operator):
+ bl_idname = "pose.null_op"
+ bl_label = "NULL OP"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ preblend_index : IntProperty()
+ bone_index : IntProperty()
+
+ @classmethod
+ def poll(cls,context):
+ return context.selected_nla_strips
+
+ def execute(self, context):
+ active_strip = get_active_strip()
+ preblend = active_strip.preblend_transforms[self.preblend_index]
+ preblend.bones.remove(self.bone_index)
+
+ return {'FINISHED'}
+class OBJECT_PT_nla_alignment(Panel):
+ bl_space_type = 'NLA_EDITOR'
+ bl_region_type = 'UI'
+ bl_label = "Alignment"
+
+
+ def draw(self, context):
+ #Q: not in a poll() so it doesnt disappear on nla strip deselection (annoying)
+ if not context.selected_nla_strips:
+ return
+
+ layout = self.layout
+ active_strip = get_active_strip()
+
+
+ box = layout.box()
+ for i,preblend in enumerate(active_strip.preblend_transforms):
+ box.prop(preblend,"location")
+ box.prop(preblend,"euler")
+ box.prop(preblend,"scale")
+
+ col = box.column(align=True)
+ row = col.row(align=True)
+ #todo: support for objects?
+ row.label(text="Bones")
+ row.operator(OBJECT_OT_nla_preblend_add_bone.bl_idname,text='',icon='ADD').preblend_index = i
+ for j,bone in enumerate(preblend.bones):
+ row = box.row(align=True)
+ row.prop_search(bone,"name",context.active_object.data,"bones",text='')
+ op = row.operator(OBJECT_OT_nla_preblend_remove_bone.bl_idname,text='',icon='REMOVE')
+ op.preblend_index = i
+ op.bone_index = j
+
+
+classes = (
+ # Object Panels
+ OBJECT_PT_nla_alignment,
+ OBJECT_OT_nla_preblend_remove_bone,
+ OBJECT_OT_nla_preblend_add_bone,
+)
+
+if __name__ == "__main__": # only for live edit.
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a1d577259f7..3d709a41657 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -2996,6 +2996,18 @@ void nlastrip_evaluate(PointerRNA *ptr,
/* Apply preblend transforms to each bone's raw snapshot values. */
Object *object = (Object *)ptr->owner_id;
bPose *pose = object->pose;
+ /**
+ * Assumes preblend xformed bones are root bones with no parents. ( I think that would affect
+ * conversion to bone local space?). If it has an animated parent, then preblend xforms generally
+ * won't make sense anyways (not a usecase situation).
+ *
+ * Q: maybe the preblend xform should be stored per bone and already in local space?
+ *
+ * todo: make preblend xform UI in python... alot easier.
+ * todo: if strip has cycled, then apply preblend xform based on how far each bone moves per
+ * cycle. Probably need a toggle per preblend xform for whether cyclic offset if applied (no need
+ * to be per bone).
+ */
LISTBASE_FOREACH (NlaStripPreBlendTransform *, preblend, &nes->strip->preblend_transforms) {
float world[4][4];
loc_eul_size_to_mat4(world, preblend->location, preblend->rotation_euler, preblend->scale);
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index b8c0dd5d9f1..420411b12f3 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -154,14 +154,6 @@ typedef struct NlaEvalData {
NlaEvalSnapshot eval_snapshot;
} NlaEvalData;
-typedef struct NlaPoseChannelPreBlend {
- // char *bone_name;
- NlaEvalChannel *location;
- NlaEvalChannel *rotation;
- NlaEvalChannel *scale;
-
-} NlaPoseChannelPreBlend;
-
/* Information about the currently edited strip and ones below it for keyframing. */
typedef struct NlaKeyframingContext {
struct NlaKeyframingContext *next, *prev;