Bugfix #21757: Crash when setting up cyclic tracking dependencies (with old tracking)
authorJoshua Leung <aligorith@gmail.com>
Fri, 26 Mar 2010 01:11:03 +0000 (01:11 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 26 Mar 2010 01:11:03 +0000 (01:11 +0000)
Note that users should not be doing this anyway (and to some degree, I wish that they have to learn this the hard way - i.e. a crash as was before) since it is always bound to cause troubles of various sorts.

Having said this, the old tracking code was previously crashing if this sort of setup was created since a stack overflow would happen while bouncing between each object being recursively recalculated. I've fixed this by commenting out that recursive recalculation (solving the cyclic problems for n >= 2, while n=1 should still be fine without this pre-depsgraph hack), and also removing such cyclic dependencies in the n=2 case.

(PS: Perhaps this is just a good opportunity to just remove this old feature instead ;)

source/blender/blenkernel/intern/object.c

index e4350cfde7ff7e2dfe6dc53e90fcc79e09866d01..2026bb3da6e6d18d9894df77cac3432ef82bba02 100644 (file)
@@ -2039,8 +2039,27 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
 
        /* Handle tracking */
        if(ob->track) {
-               if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime);
-               solve_tracking (ob, ob->track->obmat);
+               /* Try to remove this tracking relationship if we can easily detect that
+                * it is cyclic (i.e. direct tracking), and bound to cause us troubles.
+                * For the other cases (i.e. a cyclic triangle, and higher orders), we can't
+                * easily detect or know how to remove those relationships, safely, so just
+                * let them be (with warnings).
+                * Of course, this could also be a simple track that doesn't do anything bad either :)
+                */
+               if (ob->track->track == ob) {
+                       printf("Removed direct cyclic tracking between %s and %s\n", ob->id.name+2, ob->track->id.name+2);
+                       ob->track->track = NULL;
+                       ob->track = NULL;
+               }
+               else {
+                       /* NOTE: disabled recursive recalc for tracking for now, since this causes crashes
+                        * when users create cyclic dependencies (stack overflow). Really, this step ought
+                        * not to be needed anymore with the depsgraph, though this may not be the case.
+                        * -- Aligorith, 2010 Mar 26
+                        */
+                       //if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime);
+                       solve_tracking(ob, ob->track->obmat);
+               }
        }
 
        /* solve constraints */