From be282bdf3f70a0feba65523c418f8b1134bff35a Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 28 Apr 2006 17:35:03 +0000 Subject: [PATCH] - Charlie fixed some bugs related to copying armature-constraint data (these are different from Bullet rigidbody constraints like the hinge, and point 2 point!) - fixed a crashing bug related to objects without meshes (tried to get material info from it) --- .../Converter/BL_ActionActuator.cpp | 5 +---- .../Converter/BL_ArmatureObject.cpp | 12 ++++++++++-- .../gameengine/Converter/BL_SkinDeformer.cpp | 19 ++++--------------- .../Ketsji/KX_ConvertPhysicsObjects.cpp | 15 +++++++++++---- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 293845c51b3..2a7503d610d 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -58,8 +58,7 @@ BL_ActionActuator::~BL_ActionActuator() { - //todo Charlie, can you look into this? - /* + if (m_pose) { free_pose_channels(m_pose); MEM_freeN(m_pose); @@ -76,8 +75,6 @@ BL_ActionActuator::~BL_ActionActuator() MEM_freeN(m_blendpose); m_blendpose = NULL; }; - */ - } diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 7497f10724d..91c527f1980 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -146,8 +146,16 @@ void BL_ArmatureObject::GetPose(bPose **pose) { /* If the caller supplies a null pose, create a new one. */ /* Otherwise, copy the armature's pose channels into the caller-supplied pose */ - if (!*pose) - copy_pose(pose, m_pose, 0); + + if (!*pose) { + /* probably not to good of an idea to + duplicate everying, but it clears up + a crash and memory leakage when + &BL_ActionActuator::m_pose is freed + */ + int copy_constraint_channels_hack = 1; + copy_pose(pose, m_pose, copy_constraint_channels_hack); + } else extract_pose_from_pose(*pose, m_pose); diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index dc35221335a..3645491412e 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -164,28 +164,18 @@ void BL_SkinDeformer::Update(void) /* 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); -// where_is_pose (m_blenderArmatureObj); - - /* store verts locally */ -// for (int v =0; vtotvert; v++){ - /* XXX note, dunno about this line */ -// m_transverts[v]=MT_Point3(m_bmesh->mvert[v].co); -// } - -// float test[1000][3]; - -// armature_deform_verts(m_blenderArmatureObj,m_blenderMeshObject,test,m_bmesh->totvert,ARM_DEF_VGROUP); - Object* par_arma = m_armobj->GetArmatureObject(); where_is_pose( par_arma ); + /* store verts locally */ VerifyStorage(); + + /* duplicate */ for (int v =0; vtotvert; v++) VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); - armature_deform_verts( par_arma, m_objMesh,m_transverts, m_bmesh->totvert, ARM_DEF_VGROUP ); + armature_deform_verts( par_arma, m_objMesh, m_transverts, m_bmesh->totvert, ARM_DEF_VGROUP ); RecalcNormals(); /* Update the current frame */ @@ -196,7 +186,6 @@ void BL_SkinDeformer::Update(void) /* XXX note: I propose to drop this function */ void BL_SkinDeformer::SetArmature(BL_ArmatureObject *armobj) { - // -- // only used to set the object now m_armobj = armobj; } diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index ddf6c5bb321..7a01849d1a1 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -890,7 +890,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, struct KX_ObjectProperties* objprop) { - CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment(); + CcdPhysicsEnvironment* env = (CcdPhysicsEnvironment*)kxscene->GetPhysicsEnvironment(); assert(env); @@ -900,7 +900,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (objprop->m_ghost) { + ci.m_collisionFlags |= CollisionObject::noContactResponse; + } if (!objprop->m_dyna) @@ -1111,9 +1113,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, bool isActor = objprop->m_isactor; gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC); // store materialname in auxinfo, needed for touchsensors - const STR_String& matname=meshobj->GetMaterialName(0); - gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL); - + if (meshobj) + { + const STR_String& matname=meshobj->GetMaterialName(0); + gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL); + } else + { + gameobj->getClientInfo()->m_auxilary_info = 0; + } gameobj->GetSGNode()->AddSGController(physicscontroller);