[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23778] trunk/blender/source/blender: Bugfix #19616: vertex group select as IK target cause crash in Blender2.5
Joshua Leung
aligorith at gmail.com
Mon Oct 12 11:39:58 CEST 2009
Revision: 23778
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23778
Author: aligorith
Date: 2009-10-12 11:39:57 +0200 (Mon, 12 Oct 2009)
Log Message:
-----------
Bugfix #19616: vertex group select as IK target cause crash in Blender2.5
Thanks to Masahito Takahashi (mato) for the report and patch to fix this!
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_constraint.h
trunk/blender/source/blender/blenkernel/intern/constraint.c
trunk/blender/source/blender/editors/object/object_relations.c
trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c
trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp
Modified: trunk/blender/source/blender/blenkernel/BKE_constraint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_constraint.h 2009-10-12 06:45:55 UTC (rev 23777)
+++ trunk/blender/source/blender/blenkernel/BKE_constraint.h 2009-10-12 09:39:57 UTC (rev 23778)
@@ -131,7 +131,7 @@
void constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, float mat[][4], short from, short to);
-void get_constraint_target_matrix(struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime);
+void get_constraint_target_matrix(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime);
void solve_constraints(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus
Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c 2009-10-12 06:45:55 UTC (rev 23777)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c 2009-10-12 09:39:57 UTC (rev 23778)
@@ -3553,7 +3553,7 @@
* None of the actual calculations of the matricies should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
*/
-void get_constraint_target_matrix (bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime)
+void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime)
{
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
@@ -3564,6 +3564,7 @@
/* make 'constraint-ob' */
cob= MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
cob->type= ownertype;
+ cob->scene = scene;
switch (ownertype) {
case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */
{
Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c 2009-10-12 06:45:55 UTC (rev 23777)
+++ trunk/blender/source/blender/editors/object/object_relations.c 2009-10-12 09:39:57 UTC (rev 23778)
@@ -618,7 +618,7 @@
add_constraint_to_object(con, ob);
- get_constraint_target_matrix(con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob));
+ get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob));
VecSubf(vec, ob->obmat[3], cmat[3]);
ob->loc[0] = vec[0];
Modified: trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c
===================================================================
--- trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c 2009-10-12 06:45:55 UTC (rev 23777)
+++ trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c 2009-10-12 09:39:57 UTC (rev 23778)
@@ -210,7 +210,7 @@
/* called from within the core where_is_pose loop, all animsystems and constraints
were executed & assigned. Now as last we do an IK pass */
-static void execute_posetree(Object *ob, PoseTree *tree)
+static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
{
float R_parmat[3][3], identity[3][3];
float iR_parmat[3][3];
@@ -347,7 +347,7 @@
/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
* strictly speaking, it is a posechannel)
*/
- get_constraint_target_matrix(target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
/* and set and transform goal */
Mat4MulMat4(goal, rootmat, goalinv);
@@ -357,7 +357,7 @@
/* same for pole vector target */
if(data->poletar) {
- get_constraint_target_matrix(target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+ get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
if(data->flag & CONSTRAINT_IK_SETANGLE) {
/* don't solve IK when we are setting the pole angle */
@@ -511,7 +511,7 @@
tree->pchan[a]->flag |= POSE_CHAIN;
}
/* 5. execute the IK solver */
- execute_posetree(ob, tree);
+ execute_posetree(scene, ob, tree);
/* 6. apply the differences to the channels,
we need to calculate the original differences first */
Modified: trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp
===================================================================
--- trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp 2009-10-12 06:45:55 UTC (rev 23777)
+++ trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp 2009-10-12 09:39:57 UTC (rev 23778)
@@ -89,6 +89,7 @@
// one structure for each target in the scene
struct IK_Target
{
+ struct Scene *blscene;
iTaSC::MovingFrame* target;
iTaSC::ConstraintSet* constraint;
struct bConstraint* blenderConstraint;
@@ -105,6 +106,7 @@
float eeRest[4][4]; //end effector initial pose relative to armature
IK_Target() {
+ blscene = NULL;
target = NULL;
constraint = NULL;
blenderConstraint = NULL;
@@ -155,6 +157,7 @@
struct IK_Scene
{
+ struct Scene *blscene;
IK_Scene* next;
int numchan; // number of channel in pchan
int numjoint; // number of joint in jointArray
@@ -172,6 +175,7 @@
std::vector<IK_Target*> targets;
IK_Scene() {
+ blscene = NULL;
next = NULL;
channels = NULL;
armature = NULL;
@@ -533,7 +537,7 @@
bConstraint* constraint = (bConstraint*)target->blenderConstraint;
float tarmat[4][4];
- get_constraint_target_matrix(constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+ get_constraint_target_matrix(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, 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
@@ -601,7 +605,7 @@
IK_Channel &rootchan = ikscene->channels[0];
// get polar target matrix in world space
- get_constraint_target_matrix(ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+ get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
Mat4MulMat4(polemat, mat, imat);
// get the target in world space (was computed before as target object are defined before base object)
@@ -1050,6 +1054,7 @@
return NULL;
ikscene = new IK_Scene;
+ ikscene->blscene = blscene;
arm = new iTaSC::Armature();
scene = new iTaSC::Scene();
ikscene->channels = new IK_Channel[tree->totchannel];
@@ -1382,6 +1387,7 @@
// finally add the constraint
for (t=0; t<ikscene->targets.size(); t++) {
IK_Target* iktarget = ikscene->targets[t];
+ iktarget->blscene = blscene;
condata= (bKinematicConstraint*)iktarget->blenderConstraint->data;
pchan = tree->pchan[iktarget->channel];
unsigned int controltype, bonecnt;
More information about the Bf-blender-cvs
mailing list