[Bf-blender-cvs] [465eeddc04d] temp-nla-strip-alignment: - fixed preblend xform struct byte alignment - fixed rna collection to support add/removal of preblend xforms - removed C-based nla alignment UI

Wayde Moss noreply at git.blender.org
Thu Dec 10 06:13:36 CET 2020


Commit: 465eeddc04d29fdb2d6d3472ff615a2395fb7519
Author: Wayde Moss
Date:   Wed Nov 25 19:04:49 2020 -0500
Branches: temp-nla-strip-alignment
https://developer.blender.org/rB465eeddc04d29fdb2d6d3472ff615a2395fb7519

- fixed preblend xform struct byte alignment
- fixed rna collection to support add/removal of preblend xforms
- removed C-based nla alignment UI

===================================================================

M	release/scripts/startup/bl_ui/__init__.py
M	release/scripts/startup/bl_ui/properties_nla.py
M	source/blender/blenkernel/BKE_nla.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/nla.c
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/makesdna/DNA_anim_types.h
M	source/blender/makesrna/intern/rna_nla.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index e782ff7bfe3..4fe848a420f 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -49,7 +49,7 @@ _modules = [
     "properties_mask_common",
     "properties_material",
     "properties_material_gpencil",
-    "properties_nla",
+    #"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
index 88040a5f671..8939ae955c3 100644
--- a/release/scripts/startup/bl_ui/properties_nla.py
+++ b/release/scripts/startup/bl_ui/properties_nla.py
@@ -17,6 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
+import bpy 
 from bpy.types import Panel
 from bpy.props import (StringProperty,
                        BoolProperty,
@@ -29,11 +30,44 @@ from bpy.props import (StringProperty,
                        IntVectorProperty,
                        )
 def get_active_strip(context):
-    return next([strip for strip in context.selected_nla_strips if strip.active],None)
+    items =  [strip for strip in context.selected_nla_strips if strip.active]
+    return items[0] if items else None 
+
+class OBJECT_OT_nla_add_preblend(bpy.types.Operator):
+    bl_idname = "object.nla_add_preblend"
+    bl_label = "Add Preblend Transform"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(cls,context):
+        return context.selected_nla_strips
+
+    def execute(self, context):
+        active_strip = get_active_strip(context)
+        print(dict(active_strip.preblend_transforms))
+        active_strip.preblend_transforms.add()
+
+        return {'FINISHED'}
+class OBJECT_OT_nla_remove_preblend(bpy.types.Operator):
+    bl_idname = "object.nla_remove_preblend"
+    bl_label = "Remove Preblend Transform"
+    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(context)
+        active_strip.preblend_transforms.remove(active_strip.preblend_transforms[self.preblend_index])
+
+        return {'FINISHED'}
 
 class OBJECT_OT_nla_preblend_add_bone(bpy.types.Operator):
-    bl_idname = "pose.null_op"
-    bl_label = "NULL OP"
+    bl_idname = "object.preblend_add_bone"
+    bl_label = "Preblend Add Bone"
     bl_options = {'REGISTER', 'UNDO'}
 
     preblend_index : IntProperty()
@@ -43,14 +77,14 @@ class OBJECT_OT_nla_preblend_add_bone(bpy.types.Operator):
         return context.selected_nla_strips
 
     def execute(self, context):
-        active_strip = get_active_strip()
+        active_strip = get_active_strip(context)
         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_idname = "object.preblend_remove_bone"
+    bl_label = "Preblend Remove Bone"
     bl_options = {'REGISTER', 'UNDO'}
 
     preblend_index : IntProperty()
@@ -61,15 +95,17 @@ class OBJECT_OT_nla_preblend_remove_bone(bpy.types.Operator):
         return context.selected_nla_strips
 
     def execute(self, context):
-        active_strip = get_active_strip()
+        active_strip = get_active_strip(context)
         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"
+    bl_category = "Alignment"
     
 
     def draw(self, context):
@@ -78,11 +114,16 @@ class OBJECT_PT_nla_alignment(Panel):
             return 
 
         layout = self.layout
-        active_strip = get_active_strip()
+        active_strip = get_active_strip(context)
 
 
+        layout.operator(OBJECT_OT_nla_add_preblend.bl_idname,text='New Transform',icon='ADD')
         box = layout.box()
         for i,preblend in enumerate(active_strip.preblend_transforms):
+            row = box.row(align=True)
+            row.label(text="World Transform")
+            row.operator(OBJECT_OT_nla_remove_preblend.bl_idname,text='',icon='REMOVE').preblend_index = i 
+
             box.prop(preblend,"location")
             box.prop(preblend,"euler")
             box.prop(preblend,"scale")
@@ -93,7 +134,7 @@ class OBJECT_PT_nla_alignment(Panel):
             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 = col.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 
@@ -103,6 +144,8 @@ class OBJECT_PT_nla_alignment(Panel):
 classes = (
     # Object Panels
     OBJECT_PT_nla_alignment,
+    OBJECT_OT_nla_add_preblend,
+    OBJECT_OT_nla_remove_preblend,
     OBJECT_OT_nla_preblend_remove_bone,
     OBJECT_OT_nla_preblend_add_bone,
 )
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 16d48024d07..162d8c5ac6d 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -67,6 +67,9 @@ struct NlaStrip *BKE_nlastrip_new(struct bAction *act);
 struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt,
                                         struct bAction *act,
                                         const bool is_liboverride);
+struct NlaStripPreBlendTransform *BKE_nlastrip_new_preblend_transform(struct NlaStrip *strip);
+void BKE_nlastrip_free_preblend_transform(struct NlaStrip *strip,
+                                          struct NlaStripPreBlendTransform *preblend);
 struct NlaStrip *BKE_nla_add_soundstrip(struct Main *bmain,
                                         struct Scene *scene,
                                         struct Speaker *speaker);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 3d709a41657..cf16544b6eb 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -55,6 +55,7 @@
 #include "BKE_action.h"
 #include "BKE_anim_data.h"
 #include "BKE_animsys.h"
+#include "BKE_constraint.h"
 #include "BKE_context.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
@@ -2950,9 +2951,9 @@ static void nlaeval_snapshot_blend(NlaEvalData *nlaeval,
       continue;
     }
 
+    NlaEvalChannel *nec = c_upper->channel;
     NlaEvalChannelSnapshot *c_lower = nlaeval_snapshot_ensure_channel(lower, nec);
 
-    NlaEvalChannel *nec = c_lower->channel;
     int mix_mode = c_lower->channel->mix_mode;
     if (upper_blendmode == NLASTRIP_MODE_COMBINE) {
       if (mix_mode == NEC_MIX_QUATERNION) {
@@ -3010,9 +3011,9 @@ void nlastrip_evaluate(PointerRNA *ptr,
    */
   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);
+    loc_eul_size_to_mat4(world, preblend->location, preblend->euler, preblend->scale);
 
-    LISTBASE_FOREACH (NlaStripPreBlendTransform_BoneName *, bone, &preblend_xform->bones) {
+    LISTBASE_FOREACH (NlaStripPreBlendTransform_BoneName *, bone, &preblend->bones) {
 
       char name_esc[sizeof(bone->name) * 2];
       BLI_strescape(name_esc, bone->name, sizeof(name_esc));
@@ -3031,7 +3032,7 @@ void nlastrip_evaluate(PointerRNA *ptr,
       char *location_path = BLI_sprintfN("pose.bones[\"\s\"].location", name_esc);
       NlaEvalChannel *location_channel = nlaevalchan_verify(ptr, channels, location_path);
       float *location_values =
-          nlaeval_snapshot_ensure_channel(snapshot_raw, location_channel)->values;
+          nlaeval_snapshot_ensure_channel(&snapshot_raw, location_channel)->values;
 
       char *rotation_path;
       switch (pose_channel->rotmode) {
@@ -3047,11 +3048,11 @@ void nlastrip_evaluate(PointerRNA *ptr,
       }
       NlaEvalChannel *rotation_channel = nlaevalchan_verify(ptr, channels, rotation_path);
       float *rotation_values =
-          nlaeval_snapshot_ensure_channel(snapshot_raw, rotation_channel)->values;
+          nlaeval_snapshot_ensure_channel(&snapshot_raw, rotation_channel)->values;
 
       char *scale_path = BLI_sprintfN("pose.bones[\"\s\"].scale", name_esc);
       NlaEvalChannel *scale_channel = nlaevalchan_verify(ptr, channels, scale_path);
-      float *scale_values = nlaeval_snapshot_ensure_channel(snapshot_raw, scale_channel)->values;
+      float *scale_values = nlaeval_snapshot_ensure_channel(&snapshot_raw, scale_channel)->values;
 
       /* Apply preblend transform as a parent transform to bone's action channels.
        * Results written directly back to raw snapshot. */
@@ -3066,8 +3067,11 @@ void nlastrip_evaluate(PointerRNA *ptr,
 
           break;
         case ROT_MODE_AXISANGLE:
-          loc_axisangle_size_to_mat4(
-              raw_snapshot_matrix, location_values, rotation_values, scale_values);
+          loc_axisangle_size_to_mat4(raw_snapshot_matrix,
+                                     location_values,
+                                     rotation_values,
+                                     rotation_values[3],
+                                     scale_values);
           mul_m4_m4m4(raw_snapshot_matrix, bone_preblend_matrix, raw_snapshot_matrix);
           mat4_decompose(location_values, decomposed_quat, scale_values, raw_snapshot_matrix);
           quat_to_axis_angle(rotation_values, &rotation_values[3], decomposed_quat);
@@ -3632,84 +3636,6 @@ static bool animsys_evaluate_nla_for_flush(NlaEvalData *echannels,
                       true);
   }
 
-  /

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list