NLA SoC: Conversion fixes - Curve 'Speed' Curves + Constraints

These fixes get the 'pathJumper.blend' file from our testing suite workable in 2.5 (with a few minor tweaks still needed *)

Changes required:
- Added a 'ctime' var to curve structs for storing the value that used to be obtained by specially evaluating the 'speed' curve when evaluating objects parented to the curve. This can now be animated as a 'proper' var as per normal.
- Added a special hack for detecting constraint blocks, as the old method resulted in paths for Objects instead...

(*) Issues:
- Unfortunately, the paths still don't work out of the box. For some reason, the constraint names in the paths are spelt incorrectly - "Ar" and "Br" instead of "Ap" and "Bp". I'm not sure where this problem is coming from, but changing the paths manually in the Datablocks viewer fixes this error...
- I noticed that in the buttons view, only 1st of the constraints gets shown. This seems a bit like some of the intermittent problems I've had with some arrays/lists not expanding properly in Datablocks view.
This commit is contained in:
Joshua Leung 2009-06-20 11:44:56 +00:00
parent ef7860ed9a
commit 6ff4a7229f
5 changed files with 39 additions and 13 deletions

View File

@ -1341,10 +1341,22 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM);
/* shapekeys */
// TODO: we probably need the same hack as for curves (ctime-hack)
EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM);
/* curves */
// TODO...
/* we need to perform a special hack here to ensure that the ctime
* value of the curve gets set in case there's no animation for that
* - it needs to be set before animation is evaluated just so that
* animation can successfully override...
*/
for (id= main->curve.first; id; id= id->next) {
AnimData *adt= BKE_animdata_from_id(id);
Curve *cu= (Curve *)id;
cu->ctime= ctime;
BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM);
}
/* meshes */
// TODO...

View File

@ -827,6 +827,10 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
char buf[512];
int dummy_index= 0;
/* hack: if constname is set, we can only be dealing with an Constraint curve */
if (constname)
blocktype= ID_CO;
/* get property name based on blocktype */
switch (blocktype) {
case ID_OB: /* object */
@ -842,7 +846,7 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
break;
case ID_CO: /* constraint */
propname= constraint_adrcodes_to_paths(adrcode, &dummy_index);
propname= constraint_adrcodes_to_paths(adrcode, &dummy_index);
break;
case ID_TE: /* texture */
@ -872,7 +876,10 @@ char *get_rna_access (int blocktype, int adrcode, char actname[], char constname
/* XXX problematic blocktypes */
case ID_CU: /* curve */
propname= "speed"; // XXX this was a 'dummy curve' that didn't really correspond to any real var...
/* this used to be a 'dummy' curve which got evaluated on the fly...
* now we've got real var for this!
*/
propname= "eval_time";
break;
case ID_SEQ: /* sequencer strip */

View File

@ -1569,14 +1569,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
}
/* catch exceptions: curve paths used as a duplicator */
else if(enable_cu_speed) {
ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0);
#if 0 // XXX old animation system
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
ctime /= cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
}
#endif // XXX old animation system
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
*
* we firstly calculate the modulus of cu->ctime/cu->pathlen to clamp ctime within the 0.0 to 1.0 times pathlen
* range, then divide this (the modulus) by pathlen to get a value between 0.0 and 1.0
*/
ctime= fmod(cu->ctime, cu->pathlen) / cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
}
else {
ctime= scene->r.cfra - give_timeoffset(ob);

View File

@ -148,7 +148,7 @@ typedef struct Curve {
ListBase *editnurb; /* edited data, not in file, use pointer so we can check for it */
struct Object *bevobj, *taperobj, *textoncurve;
struct Ipo *ipo;
struct Ipo *ipo; // XXX depreceated... old animation system
Path *path;
struct Key *key;
struct Material **mat;
@ -193,7 +193,8 @@ typedef struct Curve {
int sepchar;
int totbox, actbox, pad;
float ctime; /* current evaltime - for use by Objects parented to curves */
int totbox, actbox;
struct TextBox *tb;
int selstart, selend;

View File

@ -31,6 +31,7 @@
#include "DNA_curve_types.h"
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
EnumPropertyItem beztriple_handle_type_items[] = {
{HD_FREE, "FREE", 0, "Free", ""},
@ -558,6 +559,11 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 1, 1024, 1, 0);
RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property.");
prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ctime");
RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at.");
/* pointers */
prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bevobj");