Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-10 10:19:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-10 14:04:51 +0300
commit2abfcebb0eb7989e3d1e7d03f37ecf5c088210af (patch)
treee7a1ad5912b4661d4ece743f4f7fd86e6bf4d3c4 /source/blender/ikplugin
parentc735aca42e9f5961fec7e5d5fc196b5bd6b85f56 (diff)
Cleanup: use C comments for descriptive text
Follow our code style guide by using C-comments for text descriptions.
Diffstat (limited to 'source/blender/ikplugin')
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c14
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp490
2 files changed, 252 insertions, 252 deletions
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index a4381f0ca8f..f569634defc 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -89,12 +89,12 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
for (curchan = pchan_tip; curchan; curchan = curchan->parent) {
pchan_root = curchan;
- curchan->flag |= POSE_CHAIN; // don't forget to clear this
+ curchan->flag |= POSE_CHAIN; /* don't forget to clear this */
chanlist[segcount] = curchan;
segcount++;
if (segcount == data->rootbone || segcount > 255) {
- break; // 255 is weak
+ break; /* 255 is weak */
}
}
if (!segcount) {
@@ -220,7 +220,7 @@ static void make_dmats(bPoseChannel *pchan)
if (pchan->parent) {
float iR_parmat[4][4];
invert_m4_m4(iR_parmat, pchan->parent->pose_mat);
- mul_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); // delta mat
+ mul_m4_m4m4(pchan->chan_mat, iR_parmat, pchan->pose_mat); /* delta mat */
}
else {
copy_m4_m4(pchan->chan_mat, pchan->pose_mat);
@@ -231,7 +231,7 @@ static void make_dmats(bPoseChannel *pchan)
/* formula: pose_mat(b) = pose_mat(b-1) * diffmat(b-1, b) * ik_mat(b) */
/* to make this work, the diffmats have to be precalculated! Stored in chan_mat */
static void where_is_ik_bone(bPoseChannel *pchan,
- float ik_mat[3][3]) // nr = to detect if this is first bone
+ float ik_mat[3][3]) /* nr = to detect if this is first bone */
{
float vec[3], ikmat[4][4];
@@ -594,8 +594,8 @@ void iksolver_initialize_tree(struct Depsgraph *UNUSED(depsgraph),
bPoseChannel *pchan;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->constflag & PCHAN_HAS_IK) { // flag is set on editing constraints
- initialize_posetree(ob, pchan); // will attach it to root!
+ if (pchan->constflag & PCHAN_HAS_IK) { /* flag is set on editing constraints */
+ initialize_posetree(ob, pchan); /* will attach it to root! */
}
}
ob->pose->flag &= ~POSE_WAS_REBUILT;
@@ -618,7 +618,7 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph,
/* 4. walk over the tree for regular solving */
for (a = 0; a < tree->totchannel; a++) {
- if (!(tree->pchan[a]->flag & POSE_DONE)) { // successive trees can set the flag
+ if (!(tree->pchan[a]->flag & POSE_DONE)) { /* successive trees can set the flag */
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->pchan[a], ctime, 1);
}
/* Tell blender that this channel was controlled by IK,
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 0bc73d4812b..e127e377858 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -27,7 +27,7 @@
#include <string.h>
#include <vector>
-// iTaSC headers
+/* iTaSC headers */
#ifdef WITH_IK_ITASC
# include "Armature.hpp"
# include "Cache.hpp"
@@ -58,17 +58,17 @@
#include "itasc_plugin.h"
-// default parameters
+/* default parameters */
static bItasc DefIKParam;
-// in case of animation mode, feedback and timestep is fixed
+/* in case of animation mode, feedback and timestep is fixed */
// #define ANIM_TIMESTEP 1.0
#define ANIM_FEEDBACK 0.8
// #define ANIM_QMAX 0.52
-// Structure pointed by bPose.ikdata
-// It contains everything needed to simulate the armatures
-// There can be several simulation islands independent to each other
+/* Structure pointed by bPose.ikdata
+ * It contains everything needed to simulate the armatures
+ * There can be several simulation islands independent to each other */
struct IK_Data {
struct IK_Scene *first;
};
@@ -80,7 +80,7 @@ typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values,
unsigned int nvalues,
IK_Target *iktarget);
-// one structure for each target in the scene
+/* one structure for each target in the scene */
struct IK_Target {
struct Depsgraph *bldepsgraph;
struct Scene *blscene;
@@ -88,16 +88,16 @@ struct IK_Target {
iTaSC::ConstraintSet *constraint;
struct bConstraint *blenderConstraint;
struct bPoseChannel *rootChannel;
- Object *owner; // for auto IK
+ Object *owner; /* for auto IK */
ErrorCallback errorCallback;
std::string targetName;
std::string constraintName;
unsigned short controlType;
- short channel; // index in IK channel array of channel on which this target is defined
- short ee; // end effector number
- bool simulation; // true when simulation mode is used (update feedback)
- bool eeBlend; // end effector affected by enforce blending
- float eeRest[4][4]; // end effector initial pose relative to armature
+ short channel; /* index in IK channel array of channel on which this target is defined */
+ short ee; /* end effector number */
+ bool simulation; /* true when simulation mode is used (update feedback) */
+ bool eeBlend; /* end effector affected by enforce blending */
+ float eeRest[4][4]; /* end effector initial pose relative to armature */
IK_Target()
{
@@ -124,17 +124,17 @@ struct IK_Target {
};
struct IK_Channel {
- bPoseChannel *pchan; // channel where we must copy matrix back
- KDL::Frame frame; // frame of the bone relative to object base, not armature base
- std::string tail; // segment name of the joint from which we get the bone tail
- std::string head; // segment name of the joint from which we get the bone head
- int parent; // index in this array of the parent channel
- short jointType; // type of joint, combination of IK_SegmentFlag
- char ndof; // number of joint angles for this channel
- char jointValid; // set to 1 when jointValue has been computed
- // for joint constraint
- Object *owner; // for pose and IK param
- double jointValue[4]; // computed joint value
+ bPoseChannel *pchan; /* channel where we must copy matrix back */
+ KDL::Frame frame; /* frame of the bone relative to object base, not armature base */
+ std::string tail; /* segment name of the joint from which we get the bone tail */
+ std::string head; /* segment name of the joint from which we get the bone head */
+ int parent; /* index in this array of the parent channel */
+ short jointType; /* type of joint, combination of IK_SegmentFlag */
+ char ndof; /* number of joint angles for this channel */
+ char jointValid; /* set to 1 when jointValue has been computed */
+ /* for joint constraint */
+ Object *owner; /* for pose and IK param */
+ double jointValue[4]; /* computed joint value */
IK_Channel()
{
@@ -155,20 +155,20 @@ struct IK_Scene {
struct Depsgraph *bldepsgraph;
struct Scene *blscene;
IK_Scene *next;
- int numchan; // number of channel in pchan
- int numjoint; // number of joint in jointArray
- // array of bone information, one per channel in the tree
+ int numchan; /* number of channel in pchan */
+ int numjoint; /* number of joint in jointArray */
+ /* array of bone information, one per channel in the tree */
IK_Channel *channels;
iTaSC::Armature *armature;
iTaSC::Cache *cache;
iTaSC::Scene *scene;
- iTaSC::MovingFrame *base; // armature base object
- KDL::Frame baseFrame; // frame of armature base relative to blArmature
- KDL::JntArray jointArray; // buffer for storing temporary joint array
+ iTaSC::MovingFrame *base; /* armature base object */
+ KDL::Frame baseFrame; /* frame of armature base relative to blArmature */
+ KDL::JntArray jointArray; /* buffer for storing temporary joint array */
iTaSC::Solver *solver;
Object *blArmature;
- float blScale; // scale of the Armature object (assume uniform scaling)
- float blInvScale; // inverse of Armature object scale
+ float blScale; /* scale of the Armature object (assume uniform scaling) */
+ float blInvScale; /* inverse of Armature object scale */
struct bConstraint *polarConstraint;
std::vector<IK_Target *> targets;
@@ -192,7 +192,7 @@ struct IK_Scene {
~IK_Scene()
{
- // delete scene first
+ /* delete scene first */
delete scene;
for (std::vector<IK_Target *>::iterator it = targets.begin(); it != targets.end(); ++it) {
delete (*it);
@@ -202,12 +202,12 @@ struct IK_Scene {
delete solver;
delete armature;
delete base;
- // delete cache last
+ /* delete cache last */
delete cache;
}
};
-// type of IK joint, can be combined to list the joints corresponding to a bone
+/* type of IK joint, can be combined to list the joints corresponding to a bone */
enum IK_SegmentFlag {
IK_XDOF = 1,
IK_YDOF = 2,
@@ -246,13 +246,13 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
for (curchan = pchan_tip; curchan; curchan = curchan->parent) {
pchan_root = curchan;
- if (++segcount > 255) { // 255 is weak
+ if (++segcount > 255) { /* 255 is weak */
break;
}
if (segcount == rootbone) {
- // reached this end of the chain but if the chain is overlapping with a
- // previous one, we must go back up to the root of the other chain
+ /* reached this end of the chain but if the chain is overlapping with a
+ * previous one, we must go back up to the root of the other chain */
if ((curchan->flag & POSE_CHAIN) && BLI_listbase_is_empty(&curchan->iktree)) {
rootbone++;
continue;
@@ -261,21 +261,21 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
}
if (BLI_listbase_is_empty(&curchan->iktree) == false) {
- // Oh oh, there is already a chain starting from this channel and our chain is longer...
- // Should handle this by moving the previous chain up to the beginning of our chain
- // For now we just stop here
+ /* Oh oh, there is already a chain starting from this channel and our chain is longer...
+ * Should handle this by moving the previous chain up to the beginning of our chain
+ * For now we just stop here */
break;
}
}
if (!segcount) {
return 0;
}
- // we reached a limit and still not the end of a previous chain, quit
+ /* we reached a limit and still not the end of a previous chain, quit */
if ((pchan_root->flag & POSE_CHAIN) && BLI_listbase_is_empty(&pchan_root->iktree)) {
return 0;
}
- // now that we know how many segment we have, set the flag
+ /* now that we know how many segment we have, set the flag */
for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone;
segcount++, curchan = curchan->parent) {
chanlist[segcount] = curchan;
@@ -286,8 +286,8 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* create a target */
target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget");
target->con = con;
- // by construction there can be only one tree per channel
- // and each channel can be part of at most one tree.
+ /* by construction there can be only one tree per channel
+ * and each channel can be part of at most one tree. */
tree = (PoseTree *)pchan_root->iktree.first;
if (tree == NULL) {
@@ -308,7 +308,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* AND! link the tree to the root */
BLI_addtail(&pchan_root->iktree, tree);
- // new tree
+ /* new tree */
treecount = 1;
}
else {
@@ -319,7 +319,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
size = MIN2(segcount, tree->totchannel);
a = t = 0;
while (a < size && t < tree->totchannel) {
- // locate first matching channel
+ /* locate first matching channel */
for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) {
/* pass */
}
@@ -368,7 +368,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
tree->totchannel = newsize;
}
- // reusing tree
+ /* reusing tree */
treecount = 0;
}
@@ -431,8 +431,8 @@ static IK_Data *get_ikdata(bPose *pose)
return (IK_Data *)pose->ikdata;
}
pose->ikdata = MEM_callocN(sizeof(IK_Data), "iTaSC ikdata");
- // here init ikdata if needed
- // now that we have scene, make sure the default param are initialized
+ /* here init ikdata if needed
+ * now that we have scene, make sure the default param are initialized */
if (!DefIKParam.iksolver) {
BKE_pose_itasc_init(&DefIKParam);
}
@@ -466,7 +466,7 @@ static double EulerAngleFromMatrix(const KDL::Rotation &R, int axis)
static double ComputeTwist(const KDL::Rotation &R)
{
- // qy and qw are the y and w components of the quaternion from R
+ /* qy and qw are the y and w components of the quaternion from R */
double qy = R(0, 2) - R(2, 0);
double qw = R(0, 0) + R(1, 1) + R(2, 2) + 1;
@@ -477,7 +477,7 @@ static double ComputeTwist(const KDL::Rotation &R)
static void RemoveEulerAngleFromMatrix(KDL::Rotation &R, double angle, int axis)
{
- // compute twist parameter
+ /* compute twist parameter */
KDL::Rotation T;
switch (axis) {
case 0:
@@ -492,7 +492,7 @@ static void RemoveEulerAngleFromMatrix(KDL::Rotation &R, double angle, int axis)
default:
return;
}
- // remove angle
+ /* remove angle */
R = R * T;
}
@@ -530,18 +530,18 @@ static void GetJointRotation(KDL::Rotation &boneRot, int type, double *rot)
{
switch (type & ~IK_TRANSY) {
default:
- // fixed bone, no joint
+ /* fixed bone, no joint */
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
rot[0] = EulerAngleFromMatrix(boneRot, 0);
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
rot[0] = ComputeTwist(boneRot);
break;
case IK_ZDOF:
- // RZ only, get the Z rotation
+ /* RZ only, get the Z rotation */
rot[0] = EulerAngleFromMatrix(boneRot, 2);
break;
case IK_XDOF | IK_YDOF:
@@ -550,11 +550,11 @@ static void GetJointRotation(KDL::Rotation &boneRot, int type, double *rot)
rot[0] = EulerAngleFromMatrix(boneRot, 0);
break;
case IK_SWING:
- // RX+RZ
+ /* RX+RZ */
boneRot.GetXZRot().GetValue(rot);
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
rot[1] = ComputeTwist(boneRot);
RemoveEulerAngleFromMatrix(boneRot, rot[1], 1);
rot[0] = EulerAngleFromMatrix(boneRot, 2);
@@ -576,8 +576,8 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
void *param)
{
IK_Target *target = (IK_Target *)param;
- // compute next target position
- // get target matrix from constraint.
+ /* compute next target position
+ * get target matrix from constraint. */
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
@@ -590,12 +590,12 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
tarmat,
1.0);
- // rootmat contains the target pose in world coordinate
- // if enforce is != 1.0, blend the target position with the end effector position
- // if the armature was in rest position. This information is available in eeRest
+ /* rootmat contains the target pose in world coordinate
+ * if enforce is != 1.0, blend the target position with the end effector position
+ * if the armature was in rest position. This information is available in eeRest */
if (constraint->enforce != 1.0f && target->eeBlend) {
- // eeRest is relative to the reference frame of the IK root
- // get this frame in world reference
+ /* eeRest is relative to the reference frame of the IK root
+ * get this frame in world reference */
float restmat[4][4];
bPoseChannel *pchan = target->rootChannel;
if (pchan->parent) {
@@ -608,7 +608,7 @@ static bool target_callback(const iTaSC::Timestamp &timestamp,
else {
mul_m4_m4m4(restmat, target->owner->obmat, target->eeRest);
}
- // blend the target
+ /* blend the target */
blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce);
}
next.setValue(&tarmat[0][0]);
@@ -621,11 +621,11 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
void *param)
{
IK_Scene *ikscene = (IK_Scene *)param;
- // compute next armature base pose
- // algorithm:
- // ikscene->pchan[0] is the root channel of the tree
- // if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail
- // then multiply by the armature matrix to get ikscene->armature base position
+ /* compute next armature base pose
+ * algorithm:
+ * ikscene->pchan[0] is the root channel of the tree
+ * if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail
+ * then multiply by the armature matrix to get ikscene->armature base position */
bPoseChannel *pchan = ikscene->channels[0].pchan;
float rootmat[4][4];
if (pchan->parent) {
@@ -633,9 +633,9 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
float chanmat[4][4];
copy_m4_m4(chanmat, pchan->pose_mat);
copy_v3_v3(chanmat[3], pchan->pose_tail);
- // save the base as a frame too so that we can compute deformation after simulation
+ /* save the base as a frame too so that we can compute deformation after simulation */
ikscene->baseFrame.setValue(&chanmat[0][0]);
- // iTaSC armature is scaled to object scale, scale the base frame too
+ /* iTaSC armature is scaled to object scale, scale the base frame too */
ikscene->baseFrame.p *= ikscene->blScale;
mul_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat);
}
@@ -644,22 +644,22 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
ikscene->baseFrame = iTaSC::F_identity;
}
next.setValue(&rootmat[0][0]);
- // if there is a polar target (only during solving otherwise we don't have end efffector)
+ /* if there is a polar target (only during solving otherwise we don't have end efffector) */
if (ikscene->polarConstraint && timestamp.update) {
- // compute additional rotation of base frame so that armature follows the polar target
- float imat[4][4]; // IK tree base inverse matrix
- float polemat[4][4]; // polar target in IK tree base frame
- float goalmat[4][4]; // target in IK tree base frame
- float mat[4][4]; // temp matrix
+ /* compute additional rotation of base frame so that armature follows the polar target */
+ float imat[4][4]; /* IK tree base inverse matrix */
+ float polemat[4][4]; /* polar target in IK tree base frame */
+ float goalmat[4][4]; /* target in IK tree base frame */
+ float mat[4][4]; /* temp matrix */
bKinematicConstraint *poledata = (bKinematicConstraint *)ikscene->polarConstraint->data;
invert_m4_m4(imat, rootmat);
- // polar constraint imply only one target
+ /* polar constraint imply only one target */
IK_Target *iktarget = ikscene->targets[0];
- // root channel from which we take the bone initial orientation
+ /* root channel from which we take the bone initial orientation */
IK_Channel &rootchan = ikscene->channels[0];
- // get polar target matrix in world space
+ /* get polar target matrix in world space */
BKE_constraint_target_matrix_get(ikscene->bldepsgraph,
ikscene->blscene,
ikscene->polarConstraint,
@@ -668,23 +668,23 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
ikscene->blArmature,
mat,
1.0);
- // convert to armature space
+ /* convert to armature space */
mul_m4_m4m4(polemat, imat, mat);
- // get the target in world space
- // (was computed before as target object are defined before base object).
+ /* get the target in world space
+ * (was computed before as target object are defined before base object). */
iktarget->target->getPose().getValue(mat[0]);
- // convert to armature space
+ /* convert to armature space */
mul_m4_m4m4(goalmat, imat, mat);
- // take position of target, polar target, end effector, in armature space
+ /* take position of target, polar target, end effector, in armature space */
KDL::Vector goalpos(goalmat[3]);
KDL::Vector polepos(polemat[3]);
KDL::Vector endpos = ikscene->armature->getPose(iktarget->ee).p;
- // get root bone orientation
+ /* get root bone orientation */
KDL::Frame rootframe;
ikscene->armature->getRelativeFrame(rootframe, rootchan.tail);
KDL::Vector rootx = rootframe.M.UnitX();
KDL::Vector rootz = rootframe.M.UnitZ();
- // and compute root bone head
+ /* and compute root bone head */
double q_rest[3], q[3], length;
const KDL::Joint *joint;
const KDL::Frame *tip;
@@ -692,27 +692,27 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
length = (joint->getType() == KDL::Joint::TransY) ? q[0] : tip->p(1);
KDL::Vector rootpos = rootframe.p - length * rootframe.M.UnitY();
- // compute main directions
+ /* compute main directions */
KDL::Vector dir = KDL::Normalize(endpos - rootpos);
KDL::Vector poledir = KDL::Normalize(goalpos - rootpos);
- // compute up directions
+ /* compute up directions */
KDL::Vector poleup = KDL::Normalize(polepos - rootpos);
KDL::Vector up = rootx * KDL::cos(poledata->poleangle) + rootz * KDL::sin(poledata->poleangle);
- // from which we build rotation matrix
+ /* from which we build rotation matrix */
KDL::Rotation endrot, polerot;
- // for the armature, using the root bone orientation
+ /* for the armature, using the root bone orientation */
KDL::Vector x = KDL::Normalize(dir * up);
endrot.UnitX(x);
endrot.UnitY(KDL::Normalize(x * dir));
endrot.UnitZ(-dir);
- // for the polar target
+ /* for the polar target */
x = KDL::Normalize(poledir * poleup);
polerot.UnitX(x);
polerot.UnitY(KDL::Normalize(x * poledir));
polerot.UnitZ(-poledir);
- // the difference between the two is the rotation we want to apply
+ /* the difference between the two is the rotation we want to apply */
KDL::Rotation result(polerot * endrot.Inverse());
- // apply on base frame as this is an artificial additional rotation
+ /* apply on base frame as this is an artificial additional rotation */
next.M = next.M * result;
ikscene->baseFrame.M = ikscene->baseFrame.M * result;
}
@@ -729,7 +729,7 @@ static bool copypose_callback(const iTaSC::Timestamp &timestamp,
iTaSC::ConstraintValues *values = _values;
bItasc *ikparam = (bItasc *)iktarget->owner->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
@@ -748,14 +748,14 @@ static bool copypose_callback(const iTaSC::Timestamp &timestamp,
}
else {
if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) {
- // update error
+ /* update error */
values->alpha = condata->weight;
values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK;
values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK;
values++;
}
if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) {
- // update error
+ /* update error */
values->alpha = condata->orientweight;
values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK;
values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK;
@@ -774,7 +774,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values,
int i;
if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) {
- // update error
+ /* update error */
for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) {
error += KDL::sqr(value->y - value->yd);
}
@@ -782,7 +782,7 @@ static void copypose_error(const iTaSC::ConstraintValues *values,
values++;
}
if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) {
- // update error
+ /* update error */
for (i = 0, error = 0.0, value = values->values; i < values->number; i++, value++) {
error += KDL::sqr(value->y - value->yd);
}
@@ -800,12 +800,12 @@ static bool distance_callback(const iTaSC::Timestamp &timestamp,
bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data;
iTaSC::ConstraintValues *values = _values;
bItasc *ikparam = (bItasc *)iktarget->owner->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
- // update weight according to mode
+ /* update weight according to mode */
if (iktarget->blenderConstraint->flag & CONSTRAINT_OFF) {
values->alpha = 0.0;
}
@@ -822,7 +822,7 @@ static bool distance_callback(const iTaSC::Timestamp &timestamp,
break;
}
if (!timestamp.substep) {
- // only update value on first timestep
+ /* only update value on first timestep */
switch (condata->mode) {
case LIMITDIST_INSIDE:
values->values[0].yd = condata->dist * 0.95;
@@ -859,11 +859,11 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
bPoseChannel *chan = ikchan->pchan;
int dof;
- // a channel can be split into multiple joints, so we get called multiple
- // times for one channel (this callback is only for 1 joint in the armature)
- // the IK_JointTarget structure is shared between multiple joint constraint
- // and the target joint values is computed only once, remember this in jointValid
- // Don't forget to reset it before each frame
+ /* a channel can be split into multiple joints, so we get called multiple
+ * times for one channel (this callback is only for 1 joint in the armature)
+ * the IK_JointTarget structure is shared between multiple joint constraint
+ * and the target joint values is computed only once, remember this in jointValid
+ * Don't forget to reset it before each frame */
if (!ikchan->jointValid) {
float rmat[3][3];
@@ -894,8 +894,8 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
GetJointRotation(jointRot, ikchan->jointType, ikchan->jointValue);
ikchan->jointValid = 1;
}
- // determine which part of jointValue is used for this joint
- // closely related to the way the joints are defined
+ /* determine which part of jointValue is used for this joint
+ * closely related to the way the joints are defined */
switch (ikchan->jointType & ~IK_TRANSY) {
case IK_XDOF:
case IK_YDOF:
@@ -903,19 +903,19 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
dof = 0;
break;
case IK_XDOF | IK_YDOF:
- // X + Y
+ /* X + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1;
break;
case IK_SWING:
- // XZ
+ /* XZ */
dof = 0;
break;
case IK_YDOF | IK_ZDOF:
- // Z + Y
+ /* Z + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1;
break;
case IK_SWING | IK_YDOF:
- // XZ + Y
+ /* XZ + Y */
dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0;
break;
case IK_REVOLUTE:
@@ -935,7 +935,7 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
return true;
}
-// build array of joint corresponding to IK chain
+/* build array of joint corresponding to IK chain */
static int convert_channels(struct Depsgraph *depsgraph,
IK_Scene *ikscene,
PoseTree *tree,
@@ -952,14 +952,14 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->parent = (a > 0) ? tree->parent[a] : -1;
ikchan->owner = ikscene->blArmature;
- // the constraint and channels must be applied before we build the iTaSC scene,
- // this is because some of the pose data (e.g. pose head) don't have corresponding
- // joint angles and can't be applied to the iTaSC armature dynamically
+ /* the constraint and channels must be applied before we build the iTaSC scene,
+ * this is because some of the pose data (e.g. pose head) don't have corresponding
+ * joint angles and can't be applied to the iTaSC armature dynamically */
if (!(pchan->flag & POSE_DONE)) {
BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
}
- // tell blender that this channel was controlled by IK,
- // it's cleared on each BKE_pose_where_is()
+ /* tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is() */
pchan->flag |= (POSE_DONE | POSE_CHAIN);
/* set DoF flag */
@@ -1016,17 +1016,17 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->ndof = 0;
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
ikchan->jointType = IK_XDOF;
ikchan->ndof = 1;
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
ikchan->jointType = IK_YDOF;
ikchan->ndof = 1;
break;
case IK_ZDOF:
- // RZ only, get the Zz rotation
+ /* RZ only, get the Zz rotation */
ikchan->jointType = IK_ZDOF;
ikchan->ndof = 1;
break;
@@ -1035,19 +1035,19 @@ static int convert_channels(struct Depsgraph *depsgraph,
ikchan->ndof = 2;
break;
case IK_XDOF | IK_ZDOF:
- // RX+RZ
+ /* RX+RZ */
ikchan->jointType = IK_SWING;
ikchan->ndof = 2;
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
ikchan->jointType = IK_ZDOF | IK_YDOF;
ikchan->ndof = 2;
break;
case IK_XDOF | IK_YDOF | IK_ZDOF:
- // spherical joint
+ /* spherical joint */
if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_YLIMIT | BONE_IK_ZLIMIT)) {
- // decompose in a Swing+RotY joint
+ /* decompose in a Swing+RotY joint */
ikchan->jointType = IK_SWING | IK_YDOF;
}
else {
@@ -1062,26 +1062,26 @@ static int convert_channels(struct Depsgraph *depsgraph,
}
njoint += ikchan->ndof;
}
- // njoint is the joint coordinate, create the Joint Array
+ /* njoint is the joint coordinate, create the Joint Array */
ikscene->jointArray.resize(njoint);
ikscene->numjoint = njoint;
return njoint;
}
-// compute array of joint value corresponding to current pose
+/* compute array of joint value corresponding to current pose */
static void convert_pose(IK_Scene *ikscene)
{
KDL::Rotation boneRot;
bPoseChannel *pchan;
IK_Channel *ikchan;
Bone *bone;
- float rmat[4][4]; // rest pose of bone with parent taken into account
- float bmat[4][4]; // difference
+ float rmat[4][4]; /* rest pose of bone with parent taken into account */
+ float bmat[4][4]; /* difference */
float scale;
double *rot;
int a, joint;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
scale = len_v3(ikscene->blArmature->obmat[1]);
rot = ikscene->jointArray(0);
for (joint = a = 0, ikchan = ikscene->channels;
@@ -1103,7 +1103,7 @@ static void convert_pose(IK_Scene *ikscene)
boneRot.setValue(bmat[0]);
GetJointRotation(boneRot, ikchan->jointType, rot);
if (ikchan->jointType & IK_TRANSY) {
- // compute actual length
+ /* compute actual length */
rot[ikchan->ndof - 1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale;
}
rot += ikchan->ndof;
@@ -1111,7 +1111,7 @@ static void convert_pose(IK_Scene *ikscene)
}
}
-// compute array of joint value corresponding to current pose
+/* compute array of joint value corresponding to current pose */
static void BKE_pose_rest(IK_Scene *ikscene)
{
bPoseChannel *pchan;
@@ -1121,11 +1121,11 @@ static void BKE_pose_rest(IK_Scene *ikscene)
double *rot;
int a, joint;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
scale = len_v3(ikscene->blArmature->obmat[1]);
- // rest pose is 0
+ /* rest pose is 0 */
SetToZero(ikscene->jointArray);
- // except for transY joints
+ /* except for transY joints */
rot = ikscene->jointArray(0);
for (joint = a = 0, ikchan = ikscene->channels;
a < ikscene->numchan && joint < ikscene->numjoint;
@@ -1178,12 +1178,12 @@ static IK_Scene *convert_tree(
ikparam = (bItasc *)ob->pose->ikparam;
if (!ikparam) {
- // you must have our own copy
+ /* you must have our own copy */
ikparam = &DefIKParam;
}
if (ikparam->flag & ITASC_SIMULATION) {
- // no cache in animation mode
+ /* no cache in animation mode */
ikscene->cache = new iTaSC::Cache();
}
@@ -1199,7 +1199,7 @@ static IK_Scene *convert_tree(
return NULL;
}
ikscene->blArmature = ob;
- // assume uniform scaling and take Y scale as general scale for the armature
+ /* assume uniform scaling and take Y scale as general scale for the armature */
ikscene->blScale = len_v3(ob->obmat[1]);
ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale;
@@ -1208,9 +1208,9 @@ static IK_Scene *convert_tree(
std::string parent;
std::vector<double> weights;
double weight[3];
- // build the array of joints corresponding to the IK chain
+ /* build the array of joints corresponding to the IK chain */
convert_channels(depsgraph, ikscene, tree, ctime);
- // in Blender, the rest pose is always 0 for joints
+ /* in Blender, the rest pose is always 0 for joints */
BKE_pose_rest(ikscene);
rot = ikscene->jointArray(0);
@@ -1219,13 +1219,13 @@ static IK_Scene *convert_tree(
bone = pchan->bone;
KDL::Frame tip(iTaSC::F_identity);
- // compute the position and rotation of the head from previous segment
+ /* compute the position and rotation of the head from previous segment */
Vector3 *fl = bone->bone_mat;
KDL::Rotation brot(
fl[0][0], fl[1][0], fl[2][0], fl[0][1], fl[1][1], fl[2][1], fl[0][2], fl[1][2], fl[2][2]);
- // if the bone is disconnected, the head is movable in pose mode
- // take that into account by using pose matrix instead of bone
- // Note that pose is expressed in armature space, convert to previous bone space
+ /* if the bone is disconnected, the head is movable in pose mode
+ * take that into account by using pose matrix instead of bone
+ * Note that pose is expressed in armature space, convert to previous bone space */
{
float R_parmat[3][3];
float iR_parmat[3][3];
@@ -1249,10 +1249,10 @@ static IK_Scene *convert_tree(
bpos *= ikscene->blScale;
KDL::Frame head(brot, bpos);
- // rest pose length of the bone taking scaling into account
+ /* rest pose length of the bone taking scaling into account */
length = bone->length * ikscene->blScale;
parent = (a > 0) ? ikscene->channels[tree->parent[a]].tail : root;
- // first the fixed segment to the bone head
+ /* first the fixed segment to the bone head */
if (!(ikchan->pchan->bone->flag & BONE_CONNECTED) || head.M.GetRot().Norm() > KDL::epsilon) {
joint = bone->name;
joint += ":H";
@@ -1260,7 +1260,7 @@ static IK_Scene *convert_tree(
parent = joint;
}
if (!(ikchan->jointType & IK_TRANSY)) {
- // fixed length, put it in tip
+ /* fixed length, put it in tip */
tip.p[1] = length;
}
joint = bone->name;
@@ -1269,24 +1269,24 @@ static IK_Scene *convert_tree(
weight[2] = (1.0 - pchan->stiffness[2]);
switch (ikchan->jointType & ~IK_TRANSY) {
case 0:
- // fixed bone
+ /* fixed bone */
joint += ":F";
ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip);
break;
case IK_XDOF:
- // RX only, get the X rotation
+ /* RX only, get the X rotation */
joint += ":RX";
ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip);
weights.push_back(weight[0]);
break;
case IK_YDOF:
- // RY only, get the Y rotation
+ /* RY only, get the Y rotation */
joint += ":RY";
ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip);
weights.push_back(weight[1]);
break;
case IK_ZDOF:
- // RZ only, get the Zz rotation
+ /* RZ only, get the Zz rotation */
joint += ":RZ";
ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip);
weights.push_back(weight[2]);
@@ -1310,7 +1310,7 @@ static IK_Scene *convert_tree(
weights.push_back(weight[2]);
break;
case IK_YDOF | IK_ZDOF:
- // RZ+RY
+ /* RZ+RY */
joint += ":RZ";
ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]);
weights.push_back(weight[2]);
@@ -1323,7 +1323,7 @@ static IK_Scene *convert_tree(
}
break;
case IK_SWING | IK_YDOF:
- // decompose in a Swing+RotY joint
+ /* decompose in a Swing+RotY joint */
joint += ":SW";
ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]);
weights.push_back(weight[0]);
@@ -1355,13 +1355,13 @@ static IK_Scene *convert_tree(
weights.push_back(weight[1]);
}
if (!ret) {
- // error making the armature??
+ /* error making the armature?? */
break;
}
- // joint points to the segment that correspond to the bone per say
+ /* joint points to the segment that correspond to the bone per say */
ikchan->tail = joint;
ikchan->head = parent;
- // in case of error
+ /* in case of error */
ret = false;
if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ROTCTL))) {
joint = bone->name;
@@ -1432,7 +1432,7 @@ static IK_Scene *convert_tree(
break;
}
}
- // no error, so restore
+ /* no error, so restore */
ret = true;
rot += ikchan->ndof;
}
@@ -1440,7 +1440,7 @@ static IK_Scene *convert_tree(
delete ikscene;
return NULL;
}
- // for each target, we need to add an end effector in the armature
+ /* for each target, we need to add an end effector in the armature */
for (numtarget = 0, polarcon = NULL, ret = true, target = (PoseTarget *)tree->targets.first;
target;
target = (PoseTarget *)target->next) {
@@ -1448,7 +1448,7 @@ static IK_Scene *convert_tree(
pchan = tree->pchan[target->tip];
if (is_cartesian_constraint(target->con)) {
- // add the end effector
+ /* add the end effector */
IK_Target *iktarget = new IK_Target();
ikscene->targets.push_back(iktarget);
iktarget->ee = arm->addEndEffector(ikscene->channels[target->tip].tail);
@@ -1456,7 +1456,7 @@ static IK_Scene *convert_tree(
ret = false;
break;
}
- // initialize all the fields that we can set at this time
+ /* initialize all the fields that we can set at this time */
iktarget->blenderConstraint = target->con;
iktarget->channel = target->tip;
iktarget->simulation = (ikparam->flag & ITASC_SIMULATION);
@@ -1470,18 +1470,18 @@ static IK_Scene *convert_tree(
iktarget->constraintName += target->con->name;
numtarget++;
if (condata->poletar) {
- // this constraint has a polar target
+ /* this constraint has a polar target */
polarcon = target->con;
}
}
}
- // deal with polar target if any
+ /* deal with polar target if any */
if (numtarget == 1 && polarcon) {
ikscene->polarConstraint = polarcon;
}
- // we can now add the armature
- // the armature is based on a moving frame.
- // initialize with the correct position in case there is no cache
+ /* we can now add the armature
+ * the armature is based on a moving frame.
+ * initialize with the correct position in case there is no cache */
base_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
ikscene->base = new iTaSC::MovingFrame(initPose);
ikscene->base->setCallback(base_callback, ikscene);
@@ -1498,31 +1498,31 @@ static IK_Scene *convert_tree(
delete ikscene;
return NULL;
}
- // set the weight
+ /* set the weight */
e_matrix &Wq = arm->getWq();
assert(Wq.cols() == (int)weights.size());
for (int q = 0; q < Wq.cols(); q++) {
Wq(q, q) = weights[q];
}
- // get the inverse rest pose frame of the base to compute relative rest pose of end effectors
- // this is needed to handle the enforce parameter
- // ikscene->pchan[0] is the root channel of the tree
- // if it has no parent, then it's just the identify Frame
+ /* get the inverse rest pose frame of the base to compute relative rest pose of end effectors
+ * this is needed to handle the enforce parameter
+ * ikscene->pchan[0] is the root channel of the tree
+ * if it has no parent, then it's just the identify Frame */
float invBaseFrame[4][4];
pchan = ikscene->channels[0].pchan;
if (pchan->parent) {
- // it has a parent, get the pose matrix from it
+ /* it has a parent, get the pose matrix from it */
float baseFrame[4][4];
pchan = pchan->parent;
copy_m4_m4(baseFrame, pchan->bone->arm_mat);
- // move to the tail and scale to get rest pose of armature base
+ /* move to the tail and scale to get rest pose of armature base */
copy_v3_v3(baseFrame[3], pchan->bone->arm_tail);
invert_m4_m4(invBaseFrame, baseFrame);
}
else {
unit_m4(invBaseFrame);
}
- // finally add the constraint
+ /* finally add the constraint */
for (t = 0; t < ikscene->targets.size(); t++) {
IK_Target *iktarget = ikscene->targets[t];
iktarget->blscene = blscene;
@@ -1533,23 +1533,23 @@ static IK_Scene *convert_tree(
double bonelen;
float mat[4][4];
- // add the end effector
- // estimate the average bone length, used to clamp feedback error
+ /* add the end effector
+ * estimate the average bone length, used to clamp feedback error */
for (bonecnt = 0, bonelen = 0.f, a = iktarget->channel; a >= 0;
a = tree->parent[a], bonecnt++) {
bonelen += ikscene->blScale * tree->pchan[a]->bone->length;
}
bonelen /= bonecnt;
- // store the rest pose of the end effector to compute enforce target
+ /* store the rest pose of the end effector to compute enforce target */
copy_m4_m4(mat, pchan->bone->arm_mat);
copy_v3_v3(mat[3], pchan->bone->arm_tail);
- // get the rest pose relative to the armature base
+ /* get the rest pose relative to the armature base */
mul_m4_m4m4(iktarget->eeRest, invBaseFrame, mat);
iktarget->eeBlend = (!ikscene->polarConstraint && condata->type == CONSTRAINT_IK_COPYPOSE) ?
true :
false;
- // use target_callback to make sure the initPose includes enforce coefficient
+ /* use target_callback to make sure the initPose includes enforce coefficient */
target_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, iktarget);
iktarget->target = new iTaSC::MovingFrame(initPose);
iktarget->target->setCallback(target_callback, iktarget);
@@ -1585,7 +1585,7 @@ static IK_Scene *convert_tree(
}
if (controltype) {
iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen);
- // set the gain
+ /* set the gain */
if (controltype & iTaSC::CopyPose::CTL_POSITION) {
iktarget->constraint->setControlParameter(
iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight);
@@ -1597,7 +1597,7 @@ static IK_Scene *convert_tree(
iktarget->constraint->registerCallback(copypose_callback, iktarget);
iktarget->errorCallback = copypose_error;
iktarget->controlType = controltype;
- // add the constraint
+ /* add the constraint */
if (condata->flag & CONSTRAINT_IK_TARGETAXIS) {
ret = scene->addConstraintSet(iktarget->constraintName,
iktarget->constraint,
@@ -1621,9 +1621,9 @@ static IK_Scene *convert_tree(
iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist);
iktarget->constraint->registerCallback(distance_callback, iktarget);
iktarget->errorCallback = distance_error;
- // we can update the weight on each substep
+ /* we can update the weight on each substep */
iktarget->constraint->substep(true);
- // add the constraint
+ /* add the constraint */
ret = scene->addConstraintSet(iktarget->constraintName,
iktarget->constraint,
armname,
@@ -1647,20 +1647,20 @@ static void create_scene(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
{
bPoseChannel *pchan;
- // create the IK scene
+ /* create the IK scene */
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan;
pchan = (bPoseChannel *)pchan->next) {
- // by construction there is only one tree
+ /* by construction there is only one tree */
PoseTree *tree = (PoseTree *)pchan->iktree.first;
if (tree) {
IK_Data *ikdata = get_ikdata(ob->pose);
- // convert tree in iTaSC::Scene
+ /* convert tree in iTaSC::Scene */
IK_Scene *ikscene = convert_tree(depsgraph, scene, ob, pchan, ctime);
if (ikscene) {
ikscene->next = ikdata->first;
ikdata->first = ikscene;
}
- // delete the trees once we are done
+ /* delete the trees once we are done */
while (tree) {
BLI_remlink(&pchan->iktree, tree);
BLI_freelistN(&tree->targets);
@@ -1683,7 +1683,7 @@ static void create_scene(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
/* returns 1 if scaling has changed and tree must be reinitialized */
static int init_scene(Object *ob)
{
- // check also if scaling has changed
+ /* check also if scaling has changed */
float scale = len_v3(ob->obmat[1]);
IK_Scene *scene;
@@ -1709,26 +1709,26 @@ static void execute_scene(struct Depsgraph *depsgraph,
IK_Channel *ikchan;
if (ikparam->flag & ITASC_SIMULATION) {
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ikchan++) {
- // In simulation mode we don't allow external constraint to change our bones,
- // mark the channel done also tell Blender that this channel is part of IK tree.
- // Cleared on each BKE_pose_where_is()
+ /* In simulation mode we don't allow external constraint to change our bones,
+ * mark the channel done also tell Blender that this channel is part of IK tree.
+ * Cleared on each BKE_pose_where_is() */
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
}
else {
- // in animation mode, we must get the bone position from action and constraints
+ /* in animation mode, we must get the bone position from action and constraints */
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ikchan++) {
if (!(ikchan->pchan->flag & POSE_DONE)) {
BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
}
- // tell blender that this channel was controlled by IK,
- // it's cleared on each BKE_pose_where_is()
+ /* tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is() */
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
}
- // only run execute the scene if at least one of our target is enabled
+ /* only run execute the scene if at least one of our target is enabled */
for (i = ikscene->targets.size(); i > 0; i--) {
IK_Target *iktarget = ikscene->targets[i - 1];
if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) {
@@ -1736,11 +1736,11 @@ static void execute_scene(struct Depsgraph *depsgraph,
}
}
if (i == 0 && ikscene->armature->getNrOfConstraints() == 0) {
- // all constraint disabled
+ /* all constraint disabled */
return;
}
- // compute timestep
+ /* compute timestep */
double timestamp = ctime * frtime + 2147483.648;
double timestep = frtime;
bool reiterate = (ikparam->flag & ITASC_REITERATION) ? true : false;
@@ -1751,16 +1751,16 @@ static void execute_scene(struct Depsgraph *depsgraph,
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, ikparam->maxvel);
}
else {
- // in animation mode we start from the pose after action and constraint
+ /* in animation mode we start from the pose after action and constraint */
convert_pose(ikscene);
ikscene->armature->setJointArray(ikscene->jointArray);
- // and we don't handle velocity
+ /* and we don't handle velocity */
reiterate = true;
simulation = false;
- // time is virtual, so take fixed value for velocity parameters (see itasc_update_param)
- // and choose 1s timestep to allow having velocity parameters in radiant
+ /* time is virtual, so take fixed value for velocity parameters (see itasc_update_param)
+ * and choose 1s timestep to allow having velocity parameters in radiant */
timestep = 1.0;
- // use auto setup to let the solver test the variation of the joints
+ /* use auto setup to let the solver test the variation of the joints */
numstep = 0;
}
@@ -1768,21 +1768,21 @@ static void execute_scene(struct Depsgraph *depsgraph,
iTaSC::CacheTS sts, cts;
sts = cts = (iTaSC::CacheTS)std::round(timestamp * 1000.0);
if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == NULL || cts == 0) {
- // the cache is empty before this time, reiterate
+ /* the cache is empty before this time, reiterate */
if (ikparam->flag & ITASC_INITIAL_REITERATION) {
reiterate = true;
}
}
else {
- // can take the cache as a start point.
+ /* can take the cache as a start point. */
sts -= cts;
timestep = sts / 1000.0;
}
}
- // don't cache if we are reiterating because we don't want to destroy the cache unnecessarily
+ /* don't cache if we are reiterating because we don't want to destroy the cache unnecessarily */
ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation);
if (reiterate) {
- // how many times do we reiterate?
+ /* how many times do we reiterate? */
for (i = 0; i < ikparam->numiter; i++) {
if (ikscene->armature->getMaxJointChange() < ikparam->precision ||
ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) {
@@ -1791,11 +1791,11 @@ static void execute_scene(struct Depsgraph *depsgraph,
ikscene->scene->update(timestamp, timestep, numstep, true, false, simulation);
}
if (simulation) {
- // one more fake iteration to cache
+ /* one more fake iteration to cache */
ikscene->scene->update(timestamp, 0.0, 1, true, true, true);
}
}
- // compute constraint error
+ /* compute constraint error */
for (i = ikscene->targets.size(); i > 0; i--) {
IK_Target *iktarget = ikscene->targets[i - 1];
if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF) && iktarget->constraint) {
@@ -1805,12 +1805,12 @@ static void execute_scene(struct Depsgraph *depsgraph,
iktarget->errorCallback(values, nvalues, iktarget);
}
}
- // Apply result to bone:
- // walk the ikscene->channels
- // for each, get the Frame of the joint corresponding to the bone relative to its parent
- // combine the parent and the joint frame to get the frame relative to armature
- // a backward translation of the bone length gives the head
- // if TY, compute the scale as the ratio of the joint length with rest pose length
+ /* Apply result to bone:
+ * walk the ikscene->channels
+ * for each, get the Frame of the joint corresponding to the bone relative to its parent
+ * combine the parent and the joint frame to get the frame relative to armature
+ * a backward translation of the bone length gives the head
+ * if TY, compute the scale as the ratio of the joint length with rest pose length */
iTaSC::Armature *arm = ikscene->armature;
KDL::Frame frame;
double q_rest[3], q[3];
@@ -1825,59 +1825,59 @@ static void execute_scene(struct Depsgraph *depsgraph,
if (!arm->getRelativeFrame(frame, ikchan->tail)) {
break;
}
- // this frame is relative to base, make it relative to object
+ /* this frame is relative to base, make it relative to object */
ikchan->frame = ikscene->baseFrame * frame;
}
else {
if (!arm->getRelativeFrame(frame, ikchan->tail, ikscene->channels[ikchan->parent].tail)) {
break;
}
- // combine with parent frame to get frame relative to object
+ /* combine with parent frame to get frame relative to object */
ikchan->frame = ikscene->channels[ikchan->parent].frame * frame;
}
- // ikchan->frame is the tail frame relative to object
- // get bone length
+ /* ikchan->frame is the tail frame relative to object
+ * get bone length */
if (!arm->getSegment(ikchan->tail, 3, joint, q_rest[0], q[0], tip)) {
break;
}
if (joint->getType() == KDL::Joint::TransY) {
- // stretch bones have a TY joint, compute the scale
+ /* stretch bones have a TY joint, compute the scale */
scale = (float)(q[0] / q_rest[0]);
- // the length is the joint itself
+ /* the length is the joint itself */
length = (float)q[0];
}
else {
scale = 1.0f;
- // for fixed bone, the length is in the tip (always along Y axis)
+ /* for fixed bone, the length is in the tip (always along Y axis) */
length = tip->p(1);
}
- // ready to compute the pose mat
+ /* ready to compute the pose mat */
pchan = ikchan->pchan;
- // tail mat
+ /* tail mat */
ikchan->frame.getValue(&pchan->pose_mat[0][0]);
- // the scale of the object was included in the ik scene, take it out now
- // because the pose channels are relative to the object
+ /* the scale of the object was included in the ik scene, take it out now
+ * because the pose channels are relative to the object */
mul_v3_fl(pchan->pose_mat[3], ikscene->blInvScale);
length *= ikscene->blInvScale;
copy_v3_v3(pchan->pose_tail, pchan->pose_mat[3]);
- // shift to head
+ /* shift to head */
copy_v3_v3(yaxis, pchan->pose_mat[1]);
mul_v3_fl(yaxis, length);
sub_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], yaxis);
copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
- // add scale
+ /* add scale */
mul_v3_fl(pchan->pose_mat[0], scale);
mul_v3_fl(pchan->pose_mat[1], scale);
mul_v3_fl(pchan->pose_mat[2], scale);
}
if (i < ikscene->numchan) {
- // big problem
+ /* big problem */
}
}
-//---------------------------------------------------
-// plugin interface
-//
+/*---------------------------------------------------
+ * plugin interface
+ * */
void itasc_initialize_tree(struct Depsgraph *depsgraph,
struct Scene *scene,
Object *ob,
@@ -1891,23 +1891,23 @@ void itasc_initialize_tree(struct Depsgraph *depsgraph,
return;
}
}
- // first remove old scene
+ /* first remove old scene */
itasc_clear_data(ob->pose);
- // we should handle all the constraint and mark them all disabled
- // for blender but we'll start with the IK constraint alone
+ /* we should handle all the constraint and mark them all disabled
+ * for blender but we'll start with the IK constraint alone */
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan;
pchan = (bPoseChannel *)pchan->next) {
if (pchan->constflag & PCHAN_HAS_IK) {
count += initialize_scene(ob, pchan);
}
}
- // if at least one tree, create the scenes from the PoseTree stored in the channels
- // postpone until execute_tree: this way the pose constraint are included
+ /* if at least one tree, create the scenes from the PoseTree stored in the channels
+ * postpone until execute_tree: this way the pose constraint are included */
if (count) {
create_scene(depsgraph, scene, ob, ctime);
}
itasc_update_param(ob->pose);
- // make sure we don't rebuilt until the user changes something important
+ /* make sure we don't rebuilt until the user changes something important */
ob->pose->flag &= ~POSE_WAS_REBUILT;
}
@@ -1920,7 +1920,7 @@ void itasc_execute_tree(struct Depsgraph *depsgraph,
if (ob->pose->ikdata) {
IK_Data *ikdata = (IK_Data *)ob->pose->ikdata;
bItasc *ikparam = (bItasc *)ob->pose->ikparam;
- // we need default parameters
+ /* we need default parameters */
if (!ikparam) {
ikparam = &DefIKParam;
}
@@ -1937,7 +1937,7 @@ void itasc_execute_tree(struct Depsgraph *depsgraph,
void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime)
{
- // not used for iTaSC
+ /* not used for iTaSC */
}
void itasc_clear_data(struct bPose *pose)
@@ -1959,7 +1959,7 @@ void itasc_clear_cache(struct bPose *pose)
IK_Data *ikdata = (IK_Data *)pose->ikdata;
for (IK_Scene *scene = ikdata->first; scene; scene = scene->next) {
if (scene->cache) {
- // clear all cache but leaving the timestamp 0 (=rest pose)
+ /* clear all cache but leaving the timestamp 0 (=rest pose) */
scene->cache->clearCacheFrom(NULL, 1);
}
}
@@ -1983,8 +1983,8 @@ void itasc_update_param(struct bPose *pose)
CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback);
}
else {
- // in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
- // becomes fraction of error gap corrected in one iteration.
+ /* in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
+ * becomes fraction of error gap corrected in one iteration. */
ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0);
ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0);
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, 0.52);