[Bf-blender-cvs] [d40ea0b3f46] temp-nla-strip-alignment: support for file read/writing new preblend xform data
Wayde Moss
noreply at git.blender.org
Thu Dec 10 06:13:37 CET 2020
Commit: d40ea0b3f46e48efc7ef657a9fede502dce8619f
Author: Wayde Moss
Date: Thu Nov 26 21:13:40 2020 -0500
Branches: temp-nla-strip-alignment
https://developer.blender.org/rBd40ea0b3f46e48efc7ef657a9fede502dce8619f
support for file read/writing new preblend xform data
===================================================================
M release/scripts/startup/bl_ui/properties_nla.py
M source/blender/blenkernel/intern/anim_sys.c
M source/blender/blenkernel/intern/nla.c
M source/blender/editors/space_nla/nla_buttons.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_nla.py b/release/scripts/startup/bl_ui/properties_nla.py
index 4276cf7f17b..e8fafb51722 100644
--- a/release/scripts/startup/bl_ui/properties_nla.py
+++ b/release/scripts/startup/bl_ui/properties_nla.py
@@ -123,13 +123,13 @@ class OBJECT_PT_nla_alignment(Panel):
layout.prop(active_strip,"preblend_transforms")
- layout.prop(active_strip,"frame_start")
- layout.prop(context.active_object,"location")
- layout.prop(context.active_object.pose.bones["Hips"],"location")
- if(context.active_pose_bone):
- c = context.active_pose_bone.constraints
- if(c):
- layout.prop(c[0],'type')
+ # layout.prop(active_strip,"frame_start")
+ # layout.prop(context.active_object,"location")
+ # layout.prop(context.active_object.pose.bones["Hips"],"location")
+ # if(context.active_pose_bone):
+ # c = context.active_pose_bone.constraints
+ # if(c):
+ # layout.prop(c[0],'type')
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):
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index d5da4100b48..96613de471d 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -2288,11 +2288,10 @@ static void nlastrip_evaluate_actionclip_raw_value(PointerRNA *ptr,
continue;
/** Only fill values for existing channels in snapshot, those that caller wants inverted. */
- //if (nlaevalchan_try_get(upper_eval_data, fcu->rna_path, &nec)) {
- if (true){
+ // if (nlaevalchan_try_get(upper_eval_data, fcu->rna_path, &nec)) {
+ if (true) {
-
- /* Get an NLA evaluation channel to work with, and accumulate the evaluated value with the
+ /* Get an NLA evaluation channel to work with, and accumulate the evaluated value with the
* value(s) stored in this channel if it has been used already. */
NlaEvalChannel *nec = NULL;
if (allow_alloc_channels) {
@@ -3005,7 +3004,20 @@ void nlastrip_evaluate(PointerRNA *ptr,
const bool flush_to_original,
bool allow_alloc_channels)
{
-
+ /**
+ * Todo: for blending rotation channels, its sometimes important to choose whether to ipo
+ * through shorter or longer angle- maybe make it a toggle on preblend data? Otherwise can't
+ * properly align character flips due to it rotating in wrong direction... would need to be
+ * applied using quaternion which means doing similar rotation grabbing and manipulation from/to
+ * nla channels again which sucks..but doable..
+ * -....and maybe it would need to be a per bone's rotation component set toggle?
+ * -because some bones may flip while others may not...?
+ *
+ * What if we just stored the rotation channels as NLA quaternion channels (conversion on read
+ * from fcurves) Then right before flushing to property, we convert to proper rotation type?
+ * Unsure how itll affect keyframe remapping exactly
+ *
+ */
NlaEvalSnapshot snapshot_raw;
nlaeval_snapshot_init(&snapshot_raw, channels, NULL);
@@ -3038,18 +3050,32 @@ void nlastrip_evaluate(PointerRNA *ptr,
char name_esc[sizeof(bone->name) * 2];
BLI_strescape(name_esc, bone->name, sizeof(name_esc));
- /* Get preblend transform in bone's non-animated local space. */
- float bone_preblend_matrix[4][4];
- copy_m4_m4(bone_preblend_matrix, world);
bPoseChannel *pose_channel = BKE_pose_channel_find_name(pose, name_esc);
+
+ float rest_matrix[4][4];
+ unit_m4(rest_matrix);
BKE_constraint_mat_convertspace(object,
pose_channel,
- bone_preblend_matrix,
- CONSTRAINT_SPACE_WORLD,
+ rest_matrix,
CONSTRAINT_SPACE_LOCAL,
+ CONSTRAINT_SPACE_WORLD,
false);
+ float rest_matrix_inv[4][4];
+ invert_m4_m4(rest_matrix_inv, rest_matrix);
- char *location_path = BLI_sprintfN("pose.bones[\"\s\"].location", name_esc);
+ /* Get preblend transform in bone's non-animated local space. */
+ float bone_preblend_matrix[4][4];
+ mul_m4_m4m4(bone_preblend_matrix, rest_matrix_inv, world);
+ mul_m4_m4m4(bone_preblend_matrix, bone_preblend_matrix, rest_matrix);
+ // copy_m4_m4(bone_preblend_matrix, world);
+ // BKE_constraint_mat_convertspace(object,
+ // pose_channel,
+ // bone_preblend_matrix,
+ // CONSTRAINT_SPACE_WORLD,
+ // CONSTRAINT_SPACE_LOCAL,
+ // false);
+
+ 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;
@@ -3057,20 +3083,20 @@ void nlastrip_evaluate(PointerRNA *ptr,
char *rotation_path;
switch (pose_channel->rotmode) {
case ROT_MODE_QUAT:
- rotation_path = BLI_sprintfN("pose.bones[\"\s\"].rotation_quaternion", name_esc);
+ rotation_path = BLI_sprintfN("pose.bones[\"%s\"].rotation_quaternion", name_esc);
break;
case ROT_MODE_AXISANGLE:
- rotation_path = BLI_sprintfN("pose.bones[\"\s\"].rotation_axis_angle", name_esc);
+ rotation_path = BLI_sprintfN("pose.bones[\"%s\"].rotation_axis_angle", name_esc);
break;
default:
- rotation_path = BLI_sprintfN("pose.bones[\"\s\"].rotation_euler", name_esc);
+ rotation_path = BLI_sprintfN("pose.bones[\"%s\"].rotation_euler", name_esc);
break;
}
NlaEvalChannel *rotation_channel = nlaevalchan_verify(ptr, channels, rotation_path);
float *rotation_values =
nlaeval_snapshot_ensure_channel(&snapshot_raw, rotation_channel)->values;
- char *scale_path = BLI_sprintfN("pose.bones[\"\s\"].scale", name_esc);
+ 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;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 8f136057c17..ee56d1aa7f0 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -429,7 +429,8 @@ void BKE_nlastrip_free_preblend_transform_at(NlaStrip *strip, int preblend_index
}
}
-NlaStripPreBlendTransform_BoneName *BKE_preblend_transform_new_bone(NlaStripPreBlendTransform *preblend)
+NlaStripPreBlendTransform_BoneName *BKE_preblend_transform_new_bone(
+ NlaStripPreBlendTransform *preblend)
{
NlaStripPreBlendTransform_BoneName *bone_name = MEM_callocN(
sizeof(NlaStripPreBlendTransform_BoneName), __func__);
@@ -2271,6 +2272,11 @@ static void blend_write_nla_strips(BlendWriter *writer, ListBase *strips)
BKE_fcurve_blend_write(writer, &strip->fcurves);
BKE_fmodifiers_blend_write(writer, &strip->modifiers);
+ BLO_write_struct_list(writer, NlaStripPreBlendTransform, &strip->preblend_transforms);
+ LISTBASE_FOREACH (NlaStripPreBlendTransform *, preblend, &strip->preblend_transforms) {
+
+ BLO_write_struct_list(writer, NlaStripPreBlendTransform_BoneName, &preblend->bones);
+ }
/* write the strip's children */
blend_write_nla_strips(writer, &strip->strips);
}
@@ -2290,6 +2296,12 @@ static void blend_data_read_nla_strips(BlendDataReader *reader, ListBase *strips
/* strip's F-Modifiers */
BLO_read_list(reader, &strip->modifiers);
BKE_fmodifiers_blend_read_data(reader, &strip->modifiers, NULL);
+
+ BLO_read_list(reader, &strip->preblend_transforms);
+ LISTBASE_FOREACH (NlaStripPreBlendTransform *, preblend, &strip->preblend_transforms) {
+
+ BLO_read_list(reader, &preblend->bones);
+ }
}
}
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index fe26f0ba069..255093c0bc6 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -377,20 +377,6 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
uiItemR(column, &strip_ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
uiItemR(column, &strip_ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
-
-
- NlaStrip *strip = ((NlaStrip *)strip_ptr.data);
-
- if (strip->preblend_transforms.first) {
-
- PointerRNA preblend_rna;
- RNA_pointer_create(strip_ptr.owner_id,
- &RNA_NlaStripPreBlendTransform,
- strip->preblend_transforms.first,
- &preblend_rna);
-
- uiItemR(column, &preblend_rna, "location", 0, NULL, ICON_NONE);
- }
/* Evaluation-Related Strip Properties ------------------ */
/* sound properties strips don't have these settings */
@@ -429,6 +415,27 @@ static void nla_panel_properties(const bContext *C, Panel *panel)
uiItemR(row, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
uiItemR(column, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE);
+
+ /** GG: I don't know why, but implementing UI in python results in wrong rna path (rooting from
+ * RNA Scene type) for preblend xform properties and updates don't work properly.
+ *
+ * Here, i guess since we specify the pointerRNA as a strip, it will be correct?
+ */
+ NlaStrip *strip = ((NlaStrip *)strip_ptr.data);
+
+ // temporary: only show 1st one for testing purposes, so when xform changes, it up
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list