[Bf-blender-cvs] [a87a4de7b1d] temp-nla-strip-alignment: - rna for preblend bones (rna path not working properly)
Wayde Moss
noreply at git.blender.org
Thu Dec 10 06:13:37 CET 2020
Commit: a87a4de7b1d504ad6d501f014672f8dded878640
Author: Wayde Moss
Date: Thu Nov 26 00:11:49 2020 -0500
Branches: temp-nla-strip-alignment
https://developer.blender.org/rBa87a4de7b1d504ad6d501f014672f8dded878640
- rna for preblend bones (rna path not working properly)
===================================================================
M release/scripts/startup/bl_ui/properties_nla.py
M source/blender/blenkernel/BKE_nla.h
M source/blender/blenkernel/intern/nla.c
M source/blender/makesrna/intern/rna_nla.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_nla.py b/release/scripts/startup/bl_ui/properties_nla.py
index 8939ae955c3..3fa55ef6f7e 100644
--- a/release/scripts/startup/bl_ui/properties_nla.py
+++ b/release/scripts/startup/bl_ui/properties_nla.py
@@ -61,7 +61,7 @@ class OBJECT_OT_nla_remove_preblend(bpy.types.Operator):
def execute(self, context):
active_strip = get_active_strip(context)
- active_strip.preblend_transforms.remove(active_strip.preblend_transforms[self.preblend_index])
+ active_strip.preblend_transforms.remove_at(self.preblend_index)
return {'FINISHED'}
@@ -79,8 +79,8 @@ class OBJECT_OT_nla_preblend_add_bone(bpy.types.Operator):
def execute(self, context):
active_strip = get_active_strip(context)
preblend = active_strip.preblend_transforms[self.preblend_index]
- preblend.bones.add()
-
+ bone = preblend.bones.add()
+ bone.name ="Hips"
return {'FINISHED'}
class OBJECT_OT_nla_preblend_remove_bone(bpy.types.Operator):
bl_idname = "object.preblend_remove_bone"
@@ -97,7 +97,7 @@ class OBJECT_OT_nla_preblend_remove_bone(bpy.types.Operator):
def execute(self, context):
active_strip = get_active_strip(context)
preblend = active_strip.preblend_transforms[self.preblend_index]
- preblend.bones.remove(self.bone_index)
+ preblend.bones.remove_at(self.bone_index)
return {'FINISHED'}
@@ -135,7 +135,9 @@ class OBJECT_PT_nla_alignment(Panel):
row.operator(OBJECT_OT_nla_preblend_add_bone.bl_idname,text='',icon='ADD').preblend_index = i
for j,bone in enumerate(preblend.bones):
row = col.row(align=True)
- row.prop_search(bone,"name",context.active_object.data,"bones",text='')
+ # print([b for b in context.active_object.data.bones])
+ # row.prop_search(bone,"name",context.active_object.data,"bones",text='')
+ row.prop(bone,"name")
op = row.operator(OBJECT_OT_nla_preblend_remove_bone.bl_idname,text='',icon='REMOVE')
op.preblend_index = i
op.bone_index = j
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index 162d8c5ac6d..398265c709a 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -70,6 +70,14 @@ struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt,
struct NlaStripPreBlendTransform *BKE_nlastrip_new_preblend_transform(struct NlaStrip *strip);
void BKE_nlastrip_free_preblend_transform(struct NlaStrip *strip,
struct NlaStripPreBlendTransform *preblend);
+void BKE_nlastrip_free_preblend_transform_at(struct NlaStrip *strip, int preblend_index);
+
+struct NlaStripPreBlendTransform_BoneName *BKE_preblend_transform_new_bone(
+ struct NlaStripPreBlendTransform *preblend);
+void BKE_preblend_transform_free_bone(struct NlaStripPreBlendTransform *preblend,
+ struct NlaStripPreBlendTransform_BoneName *bone_name);
+void BKE_preblend_transform_free_bone_at(struct NlaStripPreBlendTransform *preblend,
+ int bone_name_index);
struct NlaStrip *BKE_nla_add_soundstrip(struct Main *bmain,
struct Scene *scene,
struct Speaker *speaker);
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 3764c25c5fb..8f136057c17 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -421,6 +421,37 @@ void BKE_nlastrip_free_preblend_transform(NlaStrip *strip, NlaStripPreBlendTrans
BLI_remlink(&strip->preblend_transforms, preblend);
MEM_freeN(preblend);
}
+void BKE_nlastrip_free_preblend_transform_at(NlaStrip *strip, int preblend_index)
+{
+ NlaStripPreBlendTransform *preblend = BLI_findlink(&strip->preblend_transforms, preblend_index);
+ if (preblend) {
+ BKE_nlastrip_free_preblend_transform(strip, preblend);
+ }
+}
+
+NlaStripPreBlendTransform_BoneName *BKE_preblend_transform_new_bone(NlaStripPreBlendTransform *preblend)
+{
+ NlaStripPreBlendTransform_BoneName *bone_name = MEM_callocN(
+ sizeof(NlaStripPreBlendTransform_BoneName), __func__);
+
+ BLI_addtail(&preblend->bones, bone_name);
+
+ return bone_name;
+}
+void BKE_preblend_transform_free_bone(NlaStripPreBlendTransform *preblend,
+ NlaStripPreBlendTransform_BoneName *bone_name)
+{
+ // todo: ensure pattern of add/removal matches others (assumptions, that remove also frees, etc)
+ BLI_remlink(&preblend->bones, bone_name);
+ MEM_freeN(bone_name);
+}
+void BKE_preblend_transform_free_bone_at(NlaStripPreBlendTransform *preblend, int bone_name_index)
+{
+ NlaStripPreBlendTransform_BoneName *bone_name = BLI_findlink(&preblend->bones, bone_name_index);
+ if (bone_name) {
+ BKE_preblend_transform_free_bone(preblend, bone_name);
+ }
+}
/* Add a NLA Strip referencing the given speaker's sound */
NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker)
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index a8baaaf6fc4..869c2ac10bf 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -655,6 +655,32 @@ static void rna_NlaStrip_preblend_remove(NlaStrip *strip,
{
BKE_nlastrip_free_preblend_transform(strip, (NlaStripPreBlendTransform *)preblend->data);
}
+static void rna_NlaStrip_preblend_remove_at(NlaStrip *strip,
+ ReportList *reports,
+ int preblend_index)
+{
+ BKE_nlastrip_free_preblend_transform_at(strip, preblend_index);
+}
+
+static NlaStripPreBlendTransform_BoneName *rna_preblend_bone_name_new(
+ NlaStripPreBlendTransform *preblend, ReportList *reports)
+{
+ return BKE_preblend_transform_new_bone(preblend);
+}
+
+static void rna_preblend_bone_name_remove(NlaStripPreBlendTransform *preblend,
+ ReportList *reports,
+ PointerRNA *bone_name)
+{
+ BKE_preblend_transform_free_bone(preblend,
+ (NlaStripPreBlendTransform_BoneName *)bone_name->data);
+}
+static void rna_preblend_bone_name_remove_at(NlaStripPreBlendTransform *preblend,
+ ReportList *reports,
+ int bone_name_index)
+{
+ BKE_preblend_transform_free_bone_at(preblend, bone_name_index);
+}
#else
@@ -694,8 +720,8 @@ static void rna_def_nlastrip_blendXforms(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
- RNA_def_property_srna(cprop, "NlaStripPreblendTransforms");
- srna = RNA_def_struct(brna, "NlaStripPreblendTransforms", NULL);
+ RNA_def_property_srna(cprop, "NlaStripPreBlendTransforms");
+ srna = RNA_def_struct(brna, "NlaStripPreBlendTransforms", NULL);
RNA_def_struct_sdna(srna, "NlaStrip");
RNA_def_struct_ui_text(
srna, "Nla Strip Preblend Transforms", "Collection of Preblend Transforms");
@@ -718,6 +744,14 @@ static void rna_def_nlastrip_blendXforms(BlenderRNA *brna, PropertyRNA *cprop)
func, "preblend", "NlaStripPreBlendTransform", "", "NlaStripPreBlendTransform to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ /* remove target */
+ func = RNA_def_function(srna, "remove_at", "rna_NlaStrip_preblend_remove_at");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove an existing bone from the armature");
+
+ /* target to remove*/
+ parm = RNA_def_int(func, "preblend_index", 0, 0, INT_MAX, "preblend_index", "", 0, INT_MAX);
}
static void rna_def_nlastrip(BlenderRNA *brna)
@@ -970,6 +1004,7 @@ static void rna_def_nlastrip(BlenderRNA *brna)
prop, "Use Alignment", "Mark strip as aligned with other marked overlapping strips");
prop = RNA_def_property(srna, "preblend_transforms", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "preblend_transforms", NULL);
RNA_def_property_struct_type(prop, "NlaStripPreBlendTransform");
RNA_def_property_ui_text(prop, "PreBlendTransforms", "");
rna_def_nlastrip_blendXforms(
@@ -1083,6 +1118,51 @@ static void rna_def_nlatrack(BlenderRNA *brna)
RNA_define_lib_overridable(false);
}
+static void rna_def_preblend_bones(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "NlaStripPreBlendTransform_BoneNames");
+ srna = RNA_def_struct(brna, "NlaStripPreBlendTransform_BoneNames", NULL);
+ RNA_def_struct_sdna(srna, "NlaStripPreBlendTransform");
+ RNA_def_struct_ui_text(srna,
+ "Nla Strip Preblend Transform Bone Names",
+ "Collection of Preblend Transform Bone Names");
+
+ /* add target */
+ func = RNA_def_function(srna, "add", "rna_preblend_bone_name_new");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Add a new bone");
+ /* return type */
+ parm = RNA_def_pointer(func, "bone_name", "NlaStripPreBlendTransform_BoneName", "", "");
+ RNA_def_function_return(func, parm);
+
+ /* remove target */
+ func = RNA_def_function(srna, "remove", "rna_preblend_bone_name_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove an existing bone from the armature");
+
+ /* target to remove*/
+ parm = RNA_def_pointer(func,
+ "bone_name",
+ "NlaStripPreBlendTransform_BoneName",
+ "",
+ "NlaStripPreBlendTransform to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ /* remove ta
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list