report [#30814] Absolute Shape Keys not working in 2.6
This report points out thet absolute shape keys are unusable. The problem is there was no way to adjust the play time of a shape key (all absolte shape keys would start at frame zero with no way to change the speed). Added an 'eval_time' property to the key block that works like the curve path evaluation time, so the time in the keyblock can be controlled.
This commit is contained in:
parent
62b254e42a
commit
db562488d6
@ -259,8 +259,9 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
|
|||||||
col.prop_search(kb, "relative_key", key, "key_blocks", text="")
|
col.prop_search(kb, "relative_key", key, "key_blocks", text="")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
row = layout.row()
|
row = layout.column()
|
||||||
row.active = enable_edit_value
|
row.active = enable_edit_value
|
||||||
|
row.prop(key, "eval_time")
|
||||||
row.prop(key, "slurph")
|
row.prop(key, "slurph")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1106,36 +1106,28 @@ static float *get_weights_array(Object *ob, char *vgroup)
|
|||||||
static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
|
static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot)
|
||||||
{
|
{
|
||||||
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
||||||
float cfra, ctime, t[4], delta;
|
float cfra, t[4], delta;
|
||||||
int a, flag = 0, step;
|
int a, flag = 0;
|
||||||
|
|
||||||
if (key->slurph && key->type!=KEY_RELATIVE ) {
|
if (key->slurph && key->type != KEY_RELATIVE) {
|
||||||
delta= key->slurph;
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
delta/= tot;
|
int step;
|
||||||
|
|
||||||
step= 1;
|
delta = (float)key->slurph / tot;
|
||||||
if (tot>100 && slurph_opt) {
|
|
||||||
step= tot/50;
|
if (tot > 100 && slurph_opt) {
|
||||||
delta*= step;
|
step = tot / 50;
|
||||||
|
delta *= step;
|
||||||
/* in do_key and cp_key the case a>tot is handled */
|
/* in do_key and cp_key the case a>tot is handled */
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
|
||||||
cfra= (float)scene->r.cfra;
|
cfra= (float)scene->r.cfra;
|
||||||
|
|
||||||
for (a=0; a<tot; a+=step, cfra+= delta) {
|
for (a=0; a<tot; a+=step, cfra+= delta) {
|
||||||
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
ctime= BKE_curframe(scene);
|
|
||||||
#if 0 // XXX old animation system
|
|
||||||
if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
|
||||||
ctime /= 100.0;
|
|
||||||
CLAMP(ctime, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
#endif // XXX old animation system
|
|
||||||
// XXX for now... since speed curve cannot be directly ported yet
|
|
||||||
ctime /= 100.0f;
|
|
||||||
CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing
|
|
||||||
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
|
||||||
|
|
||||||
if (flag==0)
|
if (flag==0)
|
||||||
do_key(a, a+step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
do_key(a, a+step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
||||||
@ -1158,19 +1150,9 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctime= BKE_curframe(scene);
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
|
|
||||||
#if 0 // XXX old animation system
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
|
||||||
ctime /= 100.0;
|
|
||||||
CLAMP(ctime, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
#endif // XXX old animation system
|
|
||||||
// XXX for now... since speed curve cannot be directly ported yet
|
|
||||||
ctime /= 100.0f;
|
|
||||||
CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing
|
|
||||||
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
|
||||||
|
|
||||||
if (flag==0)
|
if (flag==0)
|
||||||
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
||||||
@ -1199,7 +1181,7 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, const int tot)
|
static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, char *out, const int tot)
|
||||||
{
|
{
|
||||||
Nurb *nu;
|
Nurb *nu;
|
||||||
int a, step;
|
int a, step;
|
||||||
@ -1222,21 +1204,24 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
|
|||||||
{
|
{
|
||||||
Curve *cu= ob->data;
|
Curve *cu= ob->data;
|
||||||
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
||||||
float cfra, ctime, t[4], delta;
|
float cfra, t[4], delta;
|
||||||
int a, flag = 0, step = 0;
|
int a, flag = 0;
|
||||||
|
|
||||||
if (key->slurph && key->type!=KEY_RELATIVE) {
|
if (key->slurph && key->type != KEY_RELATIVE) {
|
||||||
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
Nurb *nu;
|
Nurb *nu;
|
||||||
int mode=0, i= 0, remain= 0, estep=0, count=0;
|
int mode = 0, i = 0, remain = 0, step, estep = 0, count = 0;
|
||||||
|
|
||||||
delta= (float)key->slurph / tot;
|
delta = (float)key->slurph / tot;
|
||||||
|
|
||||||
step= 1;
|
if (tot > 100 && slurph_opt) {
|
||||||
if (tot>100 && slurph_opt) {
|
step = tot / 50;
|
||||||
step= tot/50;
|
delta *= step;
|
||||||
delta*= step;
|
|
||||||
/* in do_key and cp_key the case a>tot has been handled */
|
/* in do_key and cp_key the case a>tot has been handled */
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
|
||||||
cfra= (float)scene->r.cfra;
|
cfra= (float)scene->r.cfra;
|
||||||
|
|
||||||
@ -1250,17 +1235,13 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
|
|||||||
estep= 3*nu->pntsu;
|
estep= 3*nu->pntsu;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
step= 0;
|
step= 0; /* XXX - is this some mistake??? - the estep from last iter could be used - campbell */
|
||||||
|
|
||||||
a= 0;
|
a= 0;
|
||||||
while (a < estep) {
|
while (a < estep) {
|
||||||
if (remain <= 0) {
|
if (remain <= 0) {
|
||||||
cfra+= delta;
|
cfra+= delta;
|
||||||
ctime= BKE_curframe(scene);
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
|
|
||||||
ctime /= 100.0f;
|
|
||||||
CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
|
||||||
|
|
||||||
remain= step;
|
remain= step;
|
||||||
}
|
}
|
||||||
@ -1282,22 +1263,14 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
ctime= BKE_curframe(scene);
|
|
||||||
|
|
||||||
if (key->type==KEY_RELATIVE) {
|
if (key->type==KEY_RELATIVE) {
|
||||||
do_rel_cu_key(cu, cu->key, actkb, ctime, out, tot);
|
do_rel_cu_key(cu, cu->key, actkb, out, tot);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if 0 // XXX old animation system
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
|
||||||
ctime /= 100.0;
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
CLAMP(ctime, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
#endif // XXX old animation system
|
|
||||||
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
|
||||||
|
|
||||||
if (flag==0) do_cu_key(cu, key, actkb, k, t, out, tot);
|
if (flag==0) do_cu_key(cu, key, actkb, k, t, out, tot);
|
||||||
else cp_cu_key(cu, key, actkb, k[2], 0, tot, out, tot);
|
else cp_cu_key(cu, key, actkb, k[2], 0, tot, out, tot);
|
||||||
}
|
}
|
||||||
@ -1308,26 +1281,18 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
|
|||||||
{
|
{
|
||||||
Lattice *lt= ob->data;
|
Lattice *lt= ob->data;
|
||||||
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
||||||
float delta, cfra, ctime, t[4];
|
float delta, cfra, t[4];
|
||||||
int a, flag;
|
int a, flag;
|
||||||
|
|
||||||
if (key->slurph) {
|
if (key->slurph && key->type != KEY_RELATIVE) {
|
||||||
delta= key->slurph;
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
delta/= (float)tot;
|
|
||||||
|
delta = (float)key->slurph / tot;
|
||||||
|
|
||||||
cfra= (float)scene->r.cfra;
|
cfra = (float)scene->r.cfra;
|
||||||
|
|
||||||
for (a=0; a<tot; a++, cfra+= delta) {
|
for (a=0; a<tot; a++, cfra+= delta) {
|
||||||
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
ctime= BKE_curframe(scene);
|
|
||||||
#if 0 // XXX old animation system
|
|
||||||
if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
|
||||||
ctime /= 100.0;
|
|
||||||
CLAMP(ctime, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
#endif // XXX old animation system
|
|
||||||
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
|
||||||
|
|
||||||
if (flag==0)
|
if (flag==0)
|
||||||
do_key(a, a+1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY);
|
do_key(a, a+1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY);
|
||||||
@ -1350,16 +1315,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctime= BKE_curframe(scene);
|
const float ctime_scaled = key->ctime / 100.0f;
|
||||||
|
|
||||||
#if 0 // XXX old animation system
|
|
||||||
if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
|
||||||
ctime /= 100.0;
|
|
||||||
CLAMP(ctime, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
#endif // XXX old animation system
|
|
||||||
|
|
||||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
flag = setkeys(ctime_scaled, &key->block, k, t, 0);
|
||||||
|
|
||||||
if (flag==0)
|
if (flag==0)
|
||||||
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
|
||||||
@ -1446,7 +1404,7 @@ float *do_ob_key(Scene *scene, Object *ob)
|
|||||||
else {
|
else {
|
||||||
/* do shapekey local drivers */
|
/* do shapekey local drivers */
|
||||||
float ctime= (float)scene->r.cfra; // XXX this needs to be checked
|
float ctime= (float)scene->r.cfra; // XXX this needs to be checked
|
||||||
|
|
||||||
BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
|
BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
|
||||||
|
|
||||||
if (ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
|
if (ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
|
||||||
|
@ -74,9 +74,10 @@ typedef struct Key {
|
|||||||
|
|
||||||
short type, totkey;
|
short type, totkey;
|
||||||
short slurph, flag;
|
short slurph, flag;
|
||||||
|
float ctime;
|
||||||
|
|
||||||
/*can never be 0, this is used for detecting old data*/
|
/*can never be 0, this is used for detecting old data*/
|
||||||
int uidgen, pad; /*current free uid for keyblocks*/
|
int uidgen; /*current free uid for keyblocks*/
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
/* **************** KEY ********************* */
|
/* **************** KEY ********************* */
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "rna_internal.h"
|
#include "rna_internal.h"
|
||||||
|
|
||||||
#include "DNA_ID.h"
|
#include "DNA_ID.h"
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_curve_types.h"
|
#include "DNA_curve_types.h"
|
||||||
#include "DNA_key_types.h"
|
#include "DNA_key_types.h"
|
||||||
#include "DNA_lattice_types.h"
|
#include "DNA_lattice_types.h"
|
||||||
@ -620,7 +621,15 @@ static void rna_def_key(BlenderRNA *brna)
|
|||||||
|
|
||||||
prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
|
RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
|
||||||
RNA_def_property_ui_text(prop, "Relative", "Make shape keys relative");
|
RNA_def_property_ui_text(prop, "Relative",
|
||||||
|
"Make shape keys relative, "
|
||||||
|
"otherwise play through shapes as a sequence using the evaluation time");
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
|
||||||
|
RNA_def_property_float_sdna(prop, NULL, "ctime");
|
||||||
|
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
|
||||||
|
RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time for absolute shape keys");
|
||||||
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
RNA_def_property_update(prop, 0, "rna_Key_update_data");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
|
prop = RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
|
||||||
|
Loading…
Reference in New Issue
Block a user