Revision: 21030
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21030
Author:   aligorith
Date:     2009-06-20 13:44:56 +0200 (Sat, 20 Jun 2009)

Log Message:
-----------
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. 

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/object.c
    branches/soc-2009-aligorith/source/blender/makesdna/DNA_curve_types.h
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_curve.c

Modified: 
branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c     
2009-06-20 09:36:55 UTC (rev 21029)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c     
2009-06-20 11:44:56 UTC (rev 21030)
@@ -1341,10 +1341,22 @@
        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...

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c  
2009-06-20 09:36:55 UTC (rev 21029)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c  
2009-06-20 11:44:56 UTC (rev 21030)
@@ -827,6 +827,10 @@
        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 @@
                        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 @@
                        
                /* 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 */

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/object.c       
2009-06-20 09:36:55 UTC (rev 21029)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/object.c       
2009-06-20 11:44:56 UTC (rev 21030)
@@ -1569,14 +1569,14 @@
        }
        /* 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);

Modified: branches/soc-2009-aligorith/source/blender/makesdna/DNA_curve_types.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesdna/DNA_curve_types.h       
2009-06-20 09:36:55 UTC (rev 21029)
+++ branches/soc-2009-aligorith/source/blender/makesdna/DNA_curve_types.h       
2009-06-20 11:44:56 UTC (rev 21030)
@@ -148,7 +148,7 @@
        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 @@
 
        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;   

Modified: branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_curve.c      
2009-06-20 09:36:55 UTC (rev 21029)
+++ branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_curve.c      
2009-06-20 11:44:56 UTC (rev 21030)
@@ -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 @@
        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");


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to