Commit: dbbe721c2afda4a3b5c8ea7e60cf3f2b011cc857
Author: Sergey Sharybin
Date:   Tue May 12 12:50:24 2015 +0500
Branches: master
https://developer.blender.org/rBdbbe721c2afda4a3b5c8ea7e60cf3f2b011cc857

Depsgraph: Move update-related functions into own files

Currently it is just moving existing functions into a new file,
but in the future those new files will be grown much more due
to upcoming more granular scene updates.

Should be no functional changes.

===================================================================

M       source/blender/blenkernel/BKE_armature.h
M       source/blender/blenkernel/BKE_object.h
M       source/blender/blenkernel/CMakeLists.txt
M       source/blender/blenkernel/intern/armature.c
A       source/blender/blenkernel/intern/armature_update.c
M       source/blender/blenkernel/intern/object.c
A       source/blender/blenkernel/intern/object_update.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index de767d3..ada0781 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -142,6 +142,11 @@ void b_bone_spline_setup(struct bPoseChannel *pchan, int 
rest, Mat4 result_array
 #define PBONE_SELECTABLE(arm, bone) \
        (PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE))
 
+/* Evaluation helpers */
+
+void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float 
ctime);
+void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct 
bPoseChannel *pchan_root, float ctime);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 0e0c779..d287eb4 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -178,6 +178,10 @@ void BKE_object_tfm_protected_restore(struct Object *ob,
                                       const ObjectTfmProtectedChannels *obtfm,
                                       const short protectflag);
 
+/* Dependency graph evaluation callbacks. */
+void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx,
+                                   struct Scene *scene,
+                                   struct Object *ob);
 void BKE_object_handle_update(struct EvaluationContext *eval_ctx, struct Scene 
*scene, struct Object *ob);
 void BKE_object_handle_update_ex(struct EvaluationContext *eval_ctx,
                                  struct Scene *scene, struct Object *ob,
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 67c8f0f..fe713e6 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -67,6 +67,7 @@ set(SRC
        intern/anim_sys.c
        intern/appdir.c
        intern/armature.c
+       intern/armature_update.c
        intern/autoexec.c
        intern/blender.c
        intern/bmfont.c
@@ -134,6 +135,7 @@ set(SRC
        intern/object.c
        intern/object_deform.c
        intern/object_dupli.c
+       intern/object_update.c
        intern/ocean.c
        intern/outliner_treehash.c
        intern/packedFile.c
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index dc11bcb..d5416b4 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1835,494 +1835,6 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm)
        BKE_pose_channels_hash_make(ob->pose);
 }
 
-
-/* ********************** SPLINE IK SOLVER ******************* */
-
-/* Temporary evaluation tree data used for Spline IK */
-typedef struct tSplineIK_Tree {
-       struct tSplineIK_Tree *next, *prev;
-
-       int type;                    /* type of IK that this serves 
(CONSTRAINT_TYPE_KINEMATIC or ..._SPLINEIK) */
-
-       bool free_points;            /* free the point positions array */
-       short chainlen;              /* number of bones in the chain */
-
-       float *points;               /* parametric positions for the joints 
along the curve */
-       bPoseChannel **chain;        /* chain of bones to affect using Spline 
IK (ordered from the tip) */
-
-       bPoseChannel *root;          /* bone that is the root node of the chain 
*/
-
-       bConstraint *con;            /* constraint for this chain */
-       bSplineIKConstraint *ikData; /* constraint settings for this chain */
-} tSplineIK_Tree;
-
-/* ----------- */
-
-/* Tag the bones in the chain formed by the given bone for IK */
-static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), 
bPoseChannel *pchan_tip)
-{
-       bPoseChannel *pchan, *pchanRoot = NULL;
-       bPoseChannel *pchanChain[255];
-       bConstraint *con = NULL;
-       bSplineIKConstraint *ikData = NULL;
-       float boneLengths[255], *jointPoints;
-       float totLength = 0.0f;
-       bool free_joints = 0;
-       int segcount = 0;
-
-       /* find the SplineIK constraint */
-       for (con = pchan_tip->constraints.first; con; con = con->next) {
-               if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
-                       ikData = con->data;
-
-                       /* target can only be curve */
-                       if ((ikData->tar == NULL) || (ikData->tar->type != 
OB_CURVE))
-                               continue;
-                       /* skip if disabled */
-                       if ((con->enforce == 0.0f) || (con->flag & 
(CONSTRAINT_DISABLE | CONSTRAINT_OFF)))
-                               continue;
-
-                       /* otherwise, constraint is ok... */
-                       break;
-               }
-       }
-       if (con == NULL)
-               return;
-
-       /* make sure that the constraint targets are ok
-        *     - this is a workaround for a depsgraph bug...
-        */
-       if (ikData->tar) {
-               /* note: when creating constraints that follow path, the curve 
gets the CU_PATH set now,
-                *       currently for paths to work it needs to go through the 
bevlist/displist system (ton)
-                */
-
-               /* only happens on reload file, but violates depsgraph still... 
fix! */
-               if (ELEM(NULL,  ikData->tar->curve_cache, 
ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
-                       BKE_displist_make_curveTypes(scene, ikData->tar, 0);
-                       
-                       /* path building may fail in EditMode after removing 
verts [#33268]*/
-                       if (ELEM(NULL, ikData->tar->curve_cache->path, 
ikData->tar->curve_cache->path->data)) {
-                               /* BLI_assert(cu->path != NULL); */
-                               return;
-                       }
-               }
-       }
-
-       /* find the root bone and the chain of bones from the root to the tip
-        * NOTE: this assumes that the bones are connected, but that may not be 
true... */
-       for (pchan = pchan_tip; pchan && (segcount < ikData->chainlen); pchan = 
pchan->parent, segcount++) {
-               /* store this segment in the chain */
-               pchanChain[segcount] = pchan;
-
-               /* if performing rebinding, calculate the length of the bone */
-               boneLengths[segcount] = pchan->bone->length;
-               totLength += boneLengths[segcount];
-       }
-
-       if (segcount == 0)
-               return;
-       else
-               pchanRoot = pchanChain[segcount - 1];
-
-       /* perform binding step if required */
-       if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
-               float segmentLen = (1.0f / (float)segcount);
-               int i;
-
-               /* setup new empty array for the points list */
-               if (ikData->points)
-                       MEM_freeN(ikData->points);
-               ikData->numpoints = ikData->chainlen + 1;
-               ikData->points = MEM_mallocN(sizeof(float) * ikData->numpoints, 
"Spline IK Binding");
-
-               /* bind 'tip' of chain (i.e. first joint = tip of bone with the 
Spline IK Constraint) */
-               ikData->points[0] = 1.0f;
-
-               /* perform binding of the joints to parametric positions along 
the curve based
-                * proportion of the total length that each bone occupies
-                */
-               for (i = 0; i < segcount; i++) {
-                       /* 'head' joints, traveling towards the root of the 
chain
-                        *  - 2 methods; the one chosen depends on whether 
we've got usable lengths
-                        */
-                       if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || 
(totLength == 0.0f)) {
-                               /* 1) equi-spaced joints */
-                               ikData->points[i + 1] = ikData->points[i] - 
segmentLen;
-                       }
-                       else {
-                               /* 2) to find this point on the curve, we take 
a step from the previous joint
-                                *    a distance given by the proportion that 
this bone takes
-                                */
-                               ikData->points[i + 1] = ikData->points[i] - 
(boneLengths[i] / totLength);
-                       }
-               }
-
-               /* spline has now been bound */
-               ikData->flag |= CONSTRAINT_SPLINEIK_BOUND;
-       }
-
-       /* disallow negative values (happens with float precision) */
-       CLAMP_MIN(ikData->points[segcount], 0.0f);
-
-       /* apply corrections for sensitivity to scaling on a copy of the bind 
points,
-        * since it's easier to determine the positions of all the joints 
beforehand this way
-        */
-       if ((ikData->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) && (totLength != 
0.0f)) {
-               float splineLen, maxScale;
-               int i;
-
-               /* make a copy of the points array, that we'll store in the tree
-                *     - although we could just multiply the points on the fly, 
this approach means that
-                *       we can introduce per-segment stretchiness later if it 
is necessary
-                */
-               jointPoints = MEM_dupallocN(ikData->points);
-               free_joints = 1;
-
-               /* get the current length of the curve */
-               /* NOTE: this is assumed to be correct even after the curve was 
resized */
-               splineLen = ikData->tar->curve_cache->path->totdist;
-
-               /* calculate the scale factor to multiply all the path values 
by so that the
-                * bone chain retains its current length, such that
-                *     maxScale * splineLen = totLength
-                */
-               maxScale = totLength / splineLen;
-
-               /* apply scaling correction to all of the temporary points */
-               /* TODO: this is really not adequate enough on really short 
chains */
-               for (i = 0; i < segcount; i++)
-                       jointPoints[i] *= maxScale;
-       }
-       else {
-               /* just use the existing points array */
-               jointPoints = ikData->points;
-               free_joints = 0;
-       }
-
-       /* make a new Spline-IK chain, and store it in the IK chains */
-       /* TODO: we should check if there is already an IK chain on this, since 
that would take presidence... */
-       {
-               /* make new tree */
-               tSplineIK_Tree *tree = MEM_callocN(sizeof(tSplineIK_Tree), 
"SplineIK Tree");
-               tree->type = CONSTRAINT_TYPE_SPLINEIK;
-
-               tree->chainlen = segcount;
-
-               /* copy over the array of links to bones in the chain (from tip 
to root) */
-               tree->chain = MEM_mallocN(sizeof(bPoseChannel *) * segcount, 
"SplineIK Chain");
-               memcpy(tree->chain, pchanChain, sizeof(bPoseChannel *) * 
segcount);
-
-               /* store reference to joint position array */
-               tree->points = jointPoints;
-               tree->free_points = free_joints;
-
-               /* store references to different parts of the chain */
-               tree->root = pchanRoot;
-               tree->con = con;
-               tree->ikData = ikData;
-
-               /* AND! link the tree to the root */
-               BLI_addtail(&pchanRoot->siktree, tree);
-       }
-
-       /* mark root channel having an IK tree */
-       pchanRoot->flag |= POSE_IKSPLINE;
-}
-
-/* Tag which bones are members of Spline IK chains */
-static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
-{
-       bPoseChannel *pchan;
-
-       /* find the tips of Spline IK chains, which are simply the bones which 
have been tagged as such */
-       for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-               if (pchan->constflag & PCHAN_HAS_SPLINEIK)
-                       splineik_init_tree_from_pchan(scene, ob, pchan);
-       }
-}
-
-/* ----------- */
-
-/* Evaluate spline IK for a given bone */
-static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object 
*ob, bPoseC

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to