[Bf-blender-cvs] [fca6f2a] depsgraph_refactor: Ported over build functions for armatures and IK solvers.
Lukas Tönne
noreply at git.blender.org
Thu Apr 10 11:44:40 CEST 2014
Commit: fca6f2a3738b04a01863446ae8d1b7f272b41717
Author: Lukas Tönne
Date: Thu Apr 10 11:38:40 2014 +0200
https://developer.blender.org/rBfca6f2a3738b04a01863446ae8d1b7f272b41717
Ported over build functions for armatures and IK solvers.
===================================================================
M source/blender/depsgraph/intern/depsgraph_build.h
M source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M source/blender/depsgraph/intern/depsgraph_types.h
M source/blender/depsgraph/intern/depsnode.cpp
M source/blender/depsgraph/intern/depsnode.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 020ccb3..03dc742 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -33,6 +33,7 @@
#include "depsgraph_util_rna.h"
#include "depsgraph_util_string.h"
+struct bConstraint;
struct ListBase;
struct ID;
struct FCurve;
@@ -42,6 +43,7 @@ struct Material;
struct MTex;
struct bNodeTree;
struct Object;
+struct bPoseChannel;
struct Scene;
struct Tex;
struct World;
@@ -74,6 +76,9 @@ struct DepsgraphNodeBuilder {
void build_rigidbody(IDDepsNode *scene_node, Scene *scene);
void build_animdata(IDDepsNode *id_node);
OperationDepsNode *build_driver(ComponentDepsNode *adt_node, FCurve *fcurve);
+ void build_ik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con);
+ void build_splineik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con);
+ void build_rig(IDDepsNode *ob_node, Object *ob);
void build_nodetree(DepsNode *owner_node, bNodeTree *ntree);
void build_material(DepsNode *owner_node, Material *ma);
void build_texture(DepsNode *owner_node, Tex *tex);
@@ -112,8 +117,14 @@ struct ComponentKey
struct OperationKey
{
- OperationKey(IDPtr id, eDepsNode_Type type, const string &name) : id(id), type(type), name(name) {}
+ OperationKey(IDPtr id, eDepsNode_Type type, const string &name) :
+ id(id), component_subdata(""), type(type), name(name)
+ {}
+ OperationKey(IDPtr id, const string &component_subdata, eDepsNode_Type type, const string &name) :
+ id(id), component_subdata(component_subdata), type(type), name(name)
+ {}
IDPtr id;
+ string component_subdata;
eDepsNode_Type type;
string name;
};
@@ -137,11 +148,14 @@ struct DepsgraphRelationBuilder {
void build_scene(Scene *scene);
void build_object(Scene *scene, Object *ob);
void build_object_parent(Object *ob);
- void build_constraints(Scene *scene, IDPtr id, eDepsNode_Type constraint_op_type, ListBase *constraints);
- void build_rigidbody(Scene *scene);
+ void build_constraints(Scene *scene, IDPtr id, const string &component_subdata, eDepsNode_Type constraint_op_type, ListBase *constraints);
void build_animdata(IDPtr id);
void build_driver(IDPtr id, FCurve *fcurve);
void build_world(Scene *scene, World *world);
+ void build_rigidbody(Scene *scene);
+ void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
+ void build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
+ void build_rig(Scene *scene, Object *ob);
void build_nodetree(IDPtr owner, bNodeTree *ntree);
void build_material(IDPtr owner, Material *ma);
void build_texture(IDPtr owner, Tex *tex);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index cea443e..f6c1454 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -433,6 +433,223 @@ void DepsgraphNodeBuilder::build_rigidbody(IDDepsNode *scene_node, Scene *scene)
}
}
+/* IK Solver Eval Steps */
+void DepsgraphNodeBuilder::build_ik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con)
+{
+ bKinematicConstraint *data = (bKinematicConstraint *)con->data;
+
+ /* find the chain's root */
+ bPoseChannel *rootchan = pchan;
+ /* exclude tip from chain? */
+ if (!(data->flag & CONSTRAINT_IK_TIP)) {
+ rootchan = rootchan->parent;
+ }
+
+ if (rootchan) {
+ size_t segcount = 0;
+ while (rootchan->parent) {
+ /* continue up chain, until we reach target number of items... */
+ segcount++;
+ if ((segcount == data->rootbone) || (segcount > 255)) break; /* XXX 255 is weak */
+
+ rootchan = rootchan->parent;
+ }
+ }
+
+ /* operation node for evaluating/running IK Solver */
+ add_operation_node(bone_node, DEPSNODE_TYPE_OP_POSE,
+ DEPSOP_TYPE_SIM, BKE_pose_iktree_evaluate,
+ deg_op_name_ik_solver, make_rna_pointer(ob, &RNA_PoseBone, rootchan));
+
+#if 0
+ /* attach owner to IK Solver too
+ * - assume that owner is always part of chain
+ * - see notes on direction of rel below...
+ */
+ graph->add_new_relation(owner_node, solver_node, DEPSREL_TYPE_TRANSFORM, "IK Solver Owner");
+
+
+ /* exclude tip from chain? */
+ if ((data->flag & CONSTRAINT_IK_TIP) == 0)
+ parchan = pchan->parent;
+ else
+ parchan = pchan;
+
+ /* Walk to the chain's root */
+ while (parchan) {
+ /* Make IK-solver dependent on this bone's result,
+ * since it can only run after the standard results
+ * of the bone are know. Validate links step on the
+ * bone will ensure that users of this bone only
+ * grab the result with IK solver results...
+ */
+ DepsNode *parchan_node = graph->get_node(&ob->id, parchan->name, DEPSNODE_TYPE_BONE, NULL);
+ graph->add_new_relation(parchan_node, solver_node, DEPSREL_TYPE_TRANSFORM, "IK Solver Update");
+
+ /* continue up chain, until we reach target number of items... */
+ segcount++;
+ if ((segcount == data->rootbone) || (segcount > 255)) break; /* 255 is weak */
+
+ rootchan = parchan;
+ parchan = parchan->parent;
+ }
+#endif
+}
+
+/* Spline IK Eval Steps */
+void DepsgraphNodeBuilder::build_splineik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con)
+{
+ bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
+
+ /* find the chain's root */
+ bPoseChannel *rootchan = pchan;
+ size_t segcount = 0;
+ while (rootchan->parent) {
+ /* continue up chain, until we reach target number of items... */
+ segcount++;
+ if ((segcount == data->chainlen) || (segcount > 255)) break; /* XXX 255 is weak */
+
+ rootchan = rootchan->parent;
+ }
+
+ /* operation node for evaluating/running IK Solver
+ * store the "root bone" of this chain in the solver, so it knows where to start
+ */
+ add_operation_node(bone_node, DEPSNODE_TYPE_OP_POSE,
+ DEPSOP_TYPE_SIM, BKE_pose_splineik_evaluate, deg_op_name_spline_ik_solver,
+ make_rna_pointer(ob, &RNA_PoseBone, rootchan));
+ // XXX: what sort of ID-data is needed?
+
+#if 0
+ DepsNode *curve_node;
+
+ /* component for spline-path geometry that this uses */
+ // XXX: target may not exist!
+ curve_node = graph->get_node((ID *)data->tar, NULL, DEPSNODE_TYPE_GEOMETRY, "Path");
+
+ /* attach owner to IK Solver too
+ * - assume that owner is always part of chain
+ * - see notes on direction of rel below...
+ */
+ graph->add_new_relation(owner_node, solver_node, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Owner");
+
+ /* attach path dependency to solver */
+ graph->add_new_relation(curve_node, solver_node, DEPSREL_TYPE_GEOMETRY_EVAL, "[Curve.Path -> Spline IK] DepsRel");
+
+ /* --------------- */
+
+ /* Walk to the chain's root */
+ bPoseChannel *rootchan = pchan;
+ for (bPoseChannel *parchan = pchan->parent;
+ parchan;
+ rootchan = parchan, parchan = parchan->parent)
+ {
+ /* Make Spline IK solver dependent on this bone's result,
+ * since it can only run after the standard results
+ * of the bone are know. Validate links step on the
+ * bone will ensure that users of this bone only
+ * grab the result with IK solver results...
+ */
+ DepsNode *parchan_node = graph->get_node(&ob->id, parchan->name, DEPSNODE_TYPE_BONE, NULL);
+ graph->add_new_relation(parchan_node, solver_node, DEPSREL_TYPE_TRANSFORM, "Spline IK Solver Update");
+
+ /* continue up chain, until we reach target number of items... */
+ segcount++;
+ if ((segcount == data->chainlen) || (segcount > 255)) break; /* 255 is weak */
+ }
+#endif
+}
+
+/* Pose/Armature Bones Graph */
+void DepsgraphNodeBuilder::build_rig(IDDepsNode *ob_node, Object *ob)
+{
+ bArmature *arm = (bArmature *)ob->data;
+
+ /* Armature-Data */
+ IDDepsNode *arm_node = add_id_node(arm);
+
+ // TODO: bone names?
+ /* animation and/or drivers linking posebones to base-armature used to define them
+ * NOTE: AnimData here is really used to control animated deform properties,
+ * which ideally should be able to be unique across different instances.
+ * Eventually, we need some type of proxy/isolation mechanism inbetween here
+ * to ensure that we can use same rig multiple times in same scene...
+ */
+ build_animdata(arm_node);
+
+ /* == Pose Rig Graph ==
+ * Pose Component:
+ * - Mainly used for referencing Bone components.
+ * - This is where the evaluation operations for init/exec/cleanup
+ * (ik) solvers live, and are later hooked up (so that they can be
+ * interleaved during runtime) with bone-operations they depend on/affect.
+ * - init_pose_eval() and cleanup_pose_eval() are absolute first and last
+ * steps of pose eval process. ALL bone operations must be performed
+ * between these two...
+ *
+ * Bone Component:
+ * - Used for representing each bone within the rig
+ * - Acts to encapsulate the evaluation operations (base matrix + parenting,
+ * and constraint stack) so that they can be easily found.
+ * - Everything else which depends on bone-results hook up to the component only
+ * so that we can redirect those to point at either the the post-IK/
+ * post-constraint/post-matrix steps, as needed.
+ */
+ // TODO: rest pose/editmode handling!
+
+ /* pose eval context
+ * NOTE: init/cleanup steps for this are handled as part of the node's code
+ */
+ /*PoseComponentDepsNode *pose_node = (PoseComponentDepsNode *)*/add_component_node(ob_node, DEPSNODE_TYPE_EVAL_POSE);
+
+ /* bones */
+ for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ /* component for hosting bone operations */
+ BoneComponentDepsNode *bone_node = (BoneComponentDepsNode *)add_component_node(ob_node, DEPSNODE_TYPE_BONE, pchan->name);
+ bone_node->pchan = pchan;
+
+ /* node for bone eval */
+ add_operation_node(bone_node, DEPSNODE_TYPE_OP_BONE,
+ DEPSOP_TYPE_EXEC, BKE_pose_eval_bone,
+ "Bone Transforms", make_rna_pointer(ob, &RNA_PoseBone, pchan));
+
+#if 0
+ /* bone parent */
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list