Revision: 23299
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23299
Author: ben2610
Date: 2009-09-17 13:04:10 +0200 (Thu, 17 Sep 2009)
Log Message:
-----------
iTaSC: add joint rotation constraint.
Joint rotation constraint is the capability of taking the
pose channel rotation computed from action as the target
for the joint value. The rotation constraint is integrated
in the IK tree and solved at the same time as the cartesian
constraints. This allows fine control over the armature
configuration during the animation. The control is provided
per channel and each channel can have a different weight for
the constraint. The option appears in the Inverse Kinematics
panels (i.e. it requires that you define at least one
cartesian space IK constraint).
Other improvements:
- Fix a bug in IK tree construction in certain tree configuration
with more than one IK constraint were defined on a channel.
- Detect ill defined armature and avoid crash.
- Prepare plugin and solver for other joint space constraint.
- Fix bug with joint weight incorrectly computed from stiffness .
- Increase feedback range up to 100.
Modified Paths:
--------------
branches/itasc/intern/itasc/Armature.cpp
branches/itasc/intern/itasc/CopyPose.cpp
branches/itasc/intern/itasc/Distance.cpp
branches/itasc/intern/itasc/Scene.cpp
branches/itasc/release/ui/buttons_data_bone.py
branches/itasc/source/blender/blenkernel/intern/action.c
branches/itasc/source/blender/editors/armature/editarmature.c
branches/itasc/source/blender/editors/armature/poseobject.c
branches/itasc/source/blender/editors/object/object_constraint.c
branches/itasc/source/blender/ikplugin/BIK_api.h
branches/itasc/source/blender/ikplugin/intern/ikplugin_api.c
branches/itasc/source/blender/ikplugin/intern/ikplugin_api.h
branches/itasc/source/blender/ikplugin/intern/itasc_plugin.cpp
branches/itasc/source/blender/ikplugin/intern/itasc_plugin.h
branches/itasc/source/blender/makesdna/DNA_action_types.h
branches/itasc/source/blender/makesrna/intern/rna_pose.c
branches/itasc/source/gameengine/Converter/BL_ArmatureChannel.cpp
branches/itasc/source/gameengine/PyDoc/GameTypes.py
Modified: branches/itasc/intern/itasc/Armature.cpp
===================================================================
--- branches/itasc/intern/itasc/Armature.cpp 2009-09-17 10:14:56 UTC (rev
23298)
+++ branches/itasc/intern/itasc/Armature.cpp 2009-09-17 11:04:10 UTC (rev
23299)
@@ -696,7 +696,7 @@
*(double*)&pConstraint->value[i].y = m_qKdl(nr);
*(double*)&pConstraint->value[i].ydot = m_qdotKdl(nr);
}
- if (pConstraint->function && (!timestamp.substep ||
pConstraint->substep)) {
+ if (pConstraint->function && (pConstraint->substep ||
(!timestamp.reiterate && !timestamp.substep))) {
(*pConstraint->function)(timestamp,
pConstraint->values, pConstraint->v_nr, pConstraint->param);
}
// recompute the weight in any case, that's the most likely
modification
Modified: branches/itasc/intern/itasc/CopyPose.cpp
===================================================================
--- branches/itasc/intern/itasc/CopyPose.cpp 2009-09-17 10:14:56 UTC (rev
23298)
+++ branches/itasc/intern/itasc/CopyPose.cpp 2009-09-17 11:04:10 UTC (rev
23299)
@@ -430,7 +430,7 @@
found = popPose(timestamp.cacheTimestamp);
}
}
- if (m_constraintCallback && (!timestamp.substep || m_substep)) {
+ if (m_constraintCallback && (m_substep || (!timestamp.reiterate &&
!timestamp.substep))) {
// initialize first callback the application to get the current
values
int i=0;
if (m_outputControl & CTL_POSITION) {
Modified: branches/itasc/intern/itasc/Distance.cpp
===================================================================
--- branches/itasc/intern/itasc/Distance.cpp 2009-09-17 10:14:56 UTC (rev
23298)
+++ branches/itasc/intern/itasc/Distance.cpp 2009-09-17 11:04:10 UTC (rev
23299)
@@ -296,7 +296,7 @@
if (!timestamp.reiterate)
cacheAvail = popDist(timestamp.cacheTimestamp);
}
- if (m_constraintCallback && (m_substep || !timestamp.substep)) {
+ if (m_constraintCallback && (m_substep || (!timestamp.reiterate &&
!timestamp.substep))) {
// initialize first callback the application to get the current
values
*(double*)&m_data.y = m_chi(2);
*(double*)&m_data.ydot = m_ydot(0);
Modified: branches/itasc/intern/itasc/Scene.cpp
===================================================================
--- branches/itasc/intern/itasc/Scene.cpp 2009-09-17 10:14:56 UTC (rev
23298)
+++ branches/itasc/intern/itasc/Scene.cpp 2009-09-17 11:04:10 UTC (rev
23299)
@@ -183,6 +183,9 @@
bool Scene::initialize(){
//prepare all matrices:
+ if (m_ncTotal == 0 || m_nqTotal == 0 || m_nsets == 0)
+ return false;
+
m_A = e_zero_matrix(m_ncTotal,m_nqTotal);
if (m_nuTotal > 0) {
m_B = e_zero_matrix(m_ncTotal,m_nuTotal);
Modified: branches/itasc/release/ui/buttons_data_bone.py
===================================================================
--- branches/itasc/release/ui/buttons_data_bone.py 2009-09-17 10:14:56 UTC
(rev 23298)
+++ branches/itasc/release/ui/buttons_data_bone.py 2009-09-17 11:04:10 UTC
(rev 23299)
@@ -221,10 +221,25 @@
row.itemR(pchan, "ik_max_z", text="")
row.active = pchan.ik_dof_z and pchan.ik_limit_z
- split = layout.split()
- split.itemR(pchan, "ik_stretch", text="Stretch")
- split.itemL()
+ layout.itemR(pchan, "ik_stretch", text="Stretch")
+ if ob.pose.ik_solver == "ITASC":
+ layout.itemL(text="Joint constraint:")
+ split = layout.split(percentage=0.3)
+ row = split.row()
+ row.itemR(pchan, "ik_rot_control", text="Rotation")
+ row = split.row()
+ row.itemR(pchan, "ik_rot_weight", text="Weight",
slider=True)
+ row.active = pchan.ik_rot_control
+ # not supported yet
+ #split = layout.split(percentage=0.3)
+ #row = split.row()
+ #row.itemR(pchan, "ik_lin_control", text="Size")
+ #row = split.row()
+ #row.itemR(pchan, "ik_lin_weight", text="Weight",
slider=True)
+ #row.active = pchan.ik_lin_control
+
+
class BONE_PT_deform(BoneButtonsPanel):
__label__ = "Deform"
__default_closed__ = True
@@ -295,8 +310,10 @@
layout.row().itemR(itasc, "simulation")
if itasc.simulation:
- layout.row().itemR(itasc, "reiteration")
- row = layout.row()
+ split = layout.split()
+ row = split.row()
+ row.itemR(itasc, "reiteration")
+ row = split.row()
if itasc.reiteration:
itasc.initial_reiteration = True
row.itemR(itasc, "initial_reiteration")
Modified: branches/itasc/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/itasc/source/blender/blenkernel/intern/action.c 2009-09-17
10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/blenkernel/intern/action.c 2009-09-17
11:04:10 UTC (rev 23299)
@@ -451,7 +451,7 @@
chan->limitmin[0]= chan->limitmin[1]= chan->limitmin[2]= -180.0f;
chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f;
chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f;
-
+ chan->ikrotweight = chan->iklinweight = 0.0f;
Mat4One(chan->constinv);
BLI_addtail(&pose->chanbase, chan);
Modified: branches/itasc/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/itasc/source/blender/editors/armature/editarmature.c
2009-09-17 10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/editors/armature/editarmature.c
2009-09-17 11:04:10 UTC (rev 23299)
@@ -2539,6 +2539,8 @@
VECCOPY(channew->limitmax,
chanold->limitmax);
VECCOPY(channew->stiffness,
chanold->stiffness);
channew->ikstretch= chanold->ikstretch;
+ channew->ikrotweight=
chanold->ikrotweight;
+ channew->iklinweight=
chanold->iklinweight;
/* constraints */
listnew = &channew->constraints;
@@ -2639,6 +2641,8 @@
VECCOPY(channew->limitmax, chanold->limitmax);
VECCOPY(channew->stiffness, chanold->stiffness);
channew->ikstretch= chanold->ikstretch;
+
channew->ikrotweight= chanold->ikrotweight;
+
channew->iklinweight= chanold->iklinweight;
/* constraints
*/
listnew =
&channew->constraints;
Modified: branches/itasc/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/itasc/source/blender/editors/armature/poseobject.c 2009-09-17
10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/editors/armature/poseobject.c 2009-09-17
11:04:10 UTC (rev 23299)
@@ -798,6 +798,8 @@
VECCOPY(pchan->limitmax,
pchanact->limitmax);
VECCOPY(pchan->stiffness,
pchanact->stiffness);
pchan->ikstretch=
pchanact->ikstretch;
+ pchan->ikrotweight=
pchanact->ikrotweight;
+ pchan->iklinweight=
pchanact->iklinweight;
}
break;
case 8: /* Custom Bone Shape */
Modified: branches/itasc/source/blender/editors/object/object_constraint.c
===================================================================
--- branches/itasc/source/blender/editors/object/object_constraint.c
2009-09-17 10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/editors/object/object_constraint.c
2009-09-17 11:04:10 UTC (rev 23299)
@@ -56,6 +56,7 @@
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_utildefines.h"
+#include "BIK_api.h"
#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
@@ -334,6 +335,7 @@
* optional... otherwise
poletarget must exist too or else
* the constraint is deemed invalid
*/
+ /* default IK check ... */
if (exist_object(data->tar) == 0) {
data->tar = NULL;
curcon->flag |= CONSTRAINT_DISABLE;
@@ -355,7 +357,8 @@
}
}
}
-
+ /* ... can be overwritten here */
+ BIK_test_constraint(owner, curcon);
/* targets have already been checked for this */
continue;
}
Modified: branches/itasc/source/blender/ikplugin/BIK_api.h
===================================================================
--- branches/itasc/source/blender/ikplugin/BIK_api.h 2009-09-17 10:14:56 UTC
(rev 23298)
+++ branches/itasc/source/blender/ikplugin/BIK_api.h 2009-09-17 11:04:10 UTC
(rev 23299)
@@ -64,6 +64,7 @@
void BIK_clear_data(struct bPose *pose);
void BIK_clear_cache(struct bPose *pose);
void BIK_update_param(struct bPose *pose);
+void BIK_test_constraint(struct Object *ob, struct bConstraint *cons);
// not yet implemented
int BIK_get_constraint_param(struct bPose *pose, struct bConstraint *cons, int
id, BIK_ParamValue *value);
int BIK_get_channel_param(struct bPose *pose, struct bPoseChannel *pchan, int
id, BIK_ParamValue *value);
Modified: branches/itasc/source/blender/ikplugin/intern/ikplugin_api.c
===================================================================
--- branches/itasc/source/blender/ikplugin/intern/ikplugin_api.c
2009-09-17 10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/ikplugin/intern/ikplugin_api.c
2009-09-17 11:04:10 UTC (rev 23299)
@@ -55,6 +55,7 @@
NULL,
NULL,
NULL,
+ NULL,
},
/* iTaSC IK solver */
{
@@ -64,6 +65,7 @@
itasc_clear_data,
itasc_clear_cache,
itasc_update_param,
+ itasc_test_constraint,
}
};
@@ -128,3 +130,11 @@
if (plugin && plugin->update_param)
plugin->update_param(pose);
}
+
+void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
+{
+ IKPlugin *plugin = get_plugin(ob->pose);
+
+ if (plugin && plugin->test_constraint)
+ plugin->test_constraint(ob, cons);
+}
Modified: branches/itasc/source/blender/ikplugin/intern/ikplugin_api.h
===================================================================
--- branches/itasc/source/blender/ikplugin/intern/ikplugin_api.h
2009-09-17 10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/ikplugin/intern/ikplugin_api.h
2009-09-17 11:04:10 UTC (rev 23299)
@@ -47,6 +47,7 @@
void (*remove_armature_func)(struct bPose *pose);
void (*clear_cache)(struct bPose *pose);
void (*update_param)(struct bPose *pose);
+ void (*test_constraint)(struct Object *ob, struct bConstraint *cons);
};
typedef struct IKPlugin IKPlugin;
Modified: branches/itasc/source/blender/ikplugin/intern/itasc_plugin.cpp
===================================================================
--- branches/itasc/source/blender/ikplugin/intern/itasc_plugin.cpp
2009-09-17 10:14:56 UTC (rev 23298)
+++ branches/itasc/source/blender/ikplugin/intern/itasc_plugin.cpp
2009-09-17 11:04:10 UTC (rev 23299)
@@ -95,7 +95,8 @@
ErrorCallback errorCallback;
std::string targetName;
std::string constraintName;
- unsigned int controlType;
+ unsigned short controlType;
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs