diff options
author | Ton Roosendaal <ton@blender.org> | 2005-11-29 15:45:18 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-11-29 15:45:18 +0300 |
commit | 0140c36df9fcb99945caa5f473dea6a41f74a635 (patch) | |
tree | 2a626c3d35749c75f7cf7a8bf7606e953ab24666 /source/gameengine | |
parent | 65ce2c2cee5d4d382ecef61f25f6abc348944290 (diff) |
Cleanup & preparation commit for getting Armatures/Poses/Actions working
in the game engine again.
All files in source/gameengine/ I've committed below have a comment like
/* XXX note .... */
where something needs to be done. This is pretty straightforward for Erwin,
who has been notified in person too about this. :)
Diffstat (limited to 'source/gameengine')
-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 |
4 files changed, 49 insertions, 40 deletions
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; |