diff options
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 67 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ArmatureObject.cpp | 19 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_SkinDeformer.cpp | 48 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_SkinDeformer.h | 16 |
6 files changed, 49 insertions, 116 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 336ba823520..1ce5f7d0f03 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -95,19 +95,11 @@ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[] void vec_roll_to_mat3(float *vec, float roll, float mat[][3]); void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); - /* Animation functions */ - struct PoseTree *ik_tree_to_posetree(struct Object *ob, struct Bone *bone); void solve_posetree(PoseTree *tree); void free_posetree(PoseTree *tree); -/* Gameblender hacks */ -void GB_init_armature_deform(struct ListBase *defbase, float premat[][4], float postmat[][4]); -void GB_calc_armature_deform (float *co, struct MDeformVert *dvert); -void GB_build_mats (float parmat[][4], float obmat[][4], float premat[][4], float postmat[][4]); -void GB_validate_defgroups (struct Mesh *mesh, struct ListBase *defbase); - /* B-Bone support */ typedef struct Mat4 { float mat[4][4]; @@ -115,7 +107,6 @@ typedef struct Mat4 { Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan); - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 991370c798b..95a39c29a54 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1642,70 +1642,3 @@ void where_is_pose (Object *ob) } } } - -/* ****************** Game Blender functions, called by engine ************** */ - -/* NOTE: doesn't work at the moment!!! (ton) */ - -/* ugly Globals */ -static float g_premat[4][4]; -static float g_postmat[4][4]; - -void GB_build_mats (float parmat[][4], float obmat[][4], float premat[][4], float postmat[][4]) -{ - float obinv[4][4]; - - Mat4Invert(obinv, obmat); - Mat4CpyMat4(premat, obmat); - Mat4MulMat4(postmat, parmat, obinv); - - Mat4Invert (premat, postmat); -} - -void GB_init_armature_deform(ListBase *defbase, float premat[][4], float postmat[][4]) -{ -// g_defbase = defbase; - Mat4CpyMat4 (g_premat, premat); - Mat4CpyMat4 (g_postmat, postmat); - -} - -void GB_validate_defgroups (Mesh *mesh, ListBase *defbase) -{ - /* Should only be called when the mesh or armature changes */ -// int j, i; -// MDeformVert *dvert; - -// for (j=0; j<mesh->totvert; j++){ -// dvert = mesh->dvert+j; -// for (i=0; i<dvert->totweight; i++) -// dvert->dw[i].data = ((bDeformGroup*)BLI_findlink (defbase, dvert->dw[i].def_nr))->data; -// } -} - -void GB_calc_armature_deform (float *co, MDeformVert *dvert) -{ - float vec[3]={0, 0, 0}; - float contrib = 0; - int i; -// bPoseChannel *pchan; - - Mat4MulVecfl(g_premat, co); - - for (i=0; i<dvert->totweight; i++){ -// pchan = (bPoseChannel *)dvert->dw[i].data; -// if (pchan) pchan_bone_deform(pchan, dvert->dw[i].weight, vec, co, &contrib); - } - - if (contrib){ - vec[0]/=contrib; - vec[1]/=contrib; - vec[2]/=contrib; - } - - VecAddf (co, vec, co); - Mat4MulVecfl(g_postmat, co); -} - -/* ****************** END Game Blender functions, called by engine ************** */ - diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 7f870e368bd..113556f0b11 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -59,18 +59,18 @@ BL_ActionActuator::~BL_ActionActuator() { if (m_pose) { -// clear_pose(m_pose); + free_pose_channels(m_pose); MEM_freeN(m_pose); m_pose = NULL; }; if (m_userpose){ -// clear_pose(m_userpose); + free_pose_channels(m_userpose); MEM_freeN(m_userpose); m_userpose=NULL; } if (m_blendpose) { -// clear_pose(m_blendpose); + free_pose_channels(m_blendpose); MEM_freeN(m_blendpose); m_blendpose = NULL; }; diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 0c0034bb4af..f0c58f1d989 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -68,15 +68,16 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica) BL_ArmatureObject::~BL_ArmatureObject() { if (m_mrdPose){ -// clear_pose(m_mrdPose); + free_pose_channels(m_mrdPose); MEM_freeN(m_mrdPose); } } +/* note, you can only call this for exisiting Armature objects, and not mix it with other Armatures */ +/* there is only 1 unique Pose per Armature */ void BL_ArmatureObject::ApplyPose() { if (m_pose){ -// apply_pose_armature(GetArmature(), m_pose, 1); if (!m_mrdPose) copy_pose (&m_mrdPose, m_pose, 0); else @@ -160,18 +161,16 @@ bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const { // ton hack bPoseChannel *pchan= get_pose_channel(m_pose, bone->name); - -// MT_assert(verify_boneptr((bArmature*) GetArmature(), bone) && "Bone is not part of this armature."); - - matrix.setValue(&pchan->pose_mat[0][0]); - - return true; + + if(pchan) { + matrix.setValue(&pchan->pose_mat[0][0]); + return true; + } + return false; } float BL_ArmatureObject::GetBoneLength(Bone* bone) const { -// MT_assert(verify_boneptr((bArmature*) GetArmature(), bone) && "Bone is not part of this armature."); - return (MT_Point3(bone->head) - MT_Point3(bone->tail)).length(); } diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 9bd6e54c6d8..ee298d70baf 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -59,6 +59,8 @@ BL_SkinDeformer::~BL_SkinDeformer() { }; +/* XXX note, this __NLA_OLDDEFORM define seems to be obsolete */ + bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) { size_t i, j, index; @@ -113,7 +115,8 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) co[2]=mvert->co[2]; // Do the deformation - GB_calc_armature_deform(co, dvert); +/* XXX note, doesnt exist anymore */ +// GB_calc_armature_deform(co, dvert); tv->SetXYZ(co); #else // Set the data @@ -149,27 +152,30 @@ void BL_SkinDeformer::Update(void) if (m_lastUpdate!=m_armobj->GetLastFrame()){ /* Do all of the posing necessary */ - GB_init_armature_deform (m_defbase, m_premat, m_postmat); m_armobj->ApplyPose(); -// precalc_armature_posemats (m_armobj->GetArmature()); -// for (Bone *curBone=(Bone*)m_armobj->GetArmature()->bonebase.first; curBone; curBone=(Bone*)curBone->next) -// precalc_bone_defmat(curBone); -// note: where_is_pose() does it all... - VerifyStorage(); - - /* Transform the verts & store locally */ + /* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */ + /* but it requires the blender object pointer... */ +// void where_is_pose (Object *ob); + + /* store verts locally */ for (int v =0; v<m_bmesh->totvert; v++){ float co[3]; - - co[0]=m_bmesh->mvert[v].co[0]; - co[1]=m_bmesh->mvert[v].co[1]; - co[2]=m_bmesh->mvert[v].co[2]; - GB_calc_armature_deform(co, &m_bmesh->dvert[v]); - - m_transverts[v]=MT_Point3(co); + /* XXX note, dunno about this line */ + m_transverts[v]=MT_Point3(m_bmesh->mvert[v].co); } + /* XXX note: now use this call instead */ +// void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag) + // - armOb = armature object + // - target = Mesh + // - vertexCos[3] = array of numVerts float vectors (3 floats) + // - set deformflag to ARM_DEF_VGROUP + // example (after having filled the m_transverts array): + // armature_deform_verts(m_armobj, m_meshobj, m_transverts, m_bmesh->totvert, ARM_DEF_VGROUP); + + VerifyStorage(); + RecalcNormals(); @@ -178,15 +184,17 @@ void BL_SkinDeformer::Update(void) } } +/* XXX note: I propose to drop this function */ + void BL_SkinDeformer::SetArmature(BL_ArmatureObject *armobj) { - m_armobj = armobj; +// m_armobj = armobj; - for (bDeformGroup *dg=(bDeformGroup*)m_defbase->first; dg; dg=(bDeformGroup*)dg->next) { +// for (bDeformGroup *dg=(bDeformGroup*)m_defbase->first; dg; dg=(bDeformGroup*)dg->next) { /* dg->data no longer exists needs update dg->data = (void*)get_named_bone(m_armobj->GetArmature(), dg->name); */ - } +// } - GB_validate_defgroups(m_bmesh, m_defbase); +// GB_validate_defgroups(m_bmesh, m_defbase); } diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 416266fef9c..a61ebf59b22 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -71,9 +71,9 @@ public: m_defbase(&bmeshobj->defbase) { /* Build all precalculatable matrices for bones */ - - GB_build_mats(bmeshobj->parent->obmat, bmeshobj->obmat, m_premat, m_postmat); - GB_validate_defgroups((Mesh*)bmeshobj->data, m_defbase); +/* XXX note: obsolete */ +// GB_build_mats(bmeshobj->parent->obmat, bmeshobj->obmat, m_premat, m_postmat); +// GB_validate_defgroups((Mesh*)bmeshobj->data, m_defbase); // Validate bone data in bDeformGroups /* for (bDeformGroup *dg=(bDeformGroup*)m_defbase->first; dg; dg=(bDeformGroup*)dg->next) @@ -91,8 +91,9 @@ public: m_lastUpdate(-1), m_defbase(&bmeshobj_old->defbase) { - GB_build_mats(bmeshobj_new->parent->obmat, bmeshobj_new->obmat, m_premat, m_postmat); - GB_validate_defgroups((Mesh*)bmeshobj_old->data, m_defbase); +/* XXX note: obsolete */ +// GB_build_mats(bmeshobj_new->parent->obmat, bmeshobj_new->obmat, m_premat, m_postmat); +// GB_validate_defgroups((Mesh*)bmeshobj_old->data, m_defbase); }; virtual void ProcessReplica(); @@ -103,8 +104,9 @@ public: protected: BL_ArmatureObject *m_armobj; // Our parent object - float m_premat[4][4]; - float m_postmat[4][4]; +/* XXX note obsolete */ +// float m_premat[4][4]; +// float m_postmat[4][4]; float m_time; double m_lastUpdate; ListBase *m_defbase; |