Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2006-05-11 21:58:23 +0400
committerErwin Coumans <blender@erwincoumans.com>2006-05-11 21:58:23 +0400
commitede20c166a4fcaedaaf5c5392d00e3a99ecc8ad2 (patch)
treed3aa15cd27cffd73bb970ea58c898ddc56c21532 /source
parentd3dd1da8d429ea72ad42afe4b34692c345ef8c78 (diff)
- Charlie provided a work-around for some armature related crashes
- fixed some Bullet raycasting (hitfraction was not properly updated for static meshes) - removed some cvs tags in Bullet's BMF _Font files (they keep on conflicting when duplicated in different repositories) - set default linearsleepingtreshold explicitly
Diffstat (limited to 'source')
-rw-r--r--source/blender/src/usiblender.c1
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h1
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp3
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h6
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp105
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp4
6 files changed, 91 insertions, 29 deletions
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index 8bfa493364a..ccc32c33a6e 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -397,6 +397,7 @@ int BIF_read_homefile(void)
} else {
success = BKE_read_file_from_memory(datatoc_B_blend, datatoc_B_blend_size, NULL);
}
+
BLI_clean(scestr);
strcpy(G.sce, scestr);
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index af0212d77a8..aafc8271dd6 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -77,6 +77,7 @@ public:
/// Returns the bone length. The end of the bone is in the local y direction.
float GetBoneLength(Bone* bone) const;
+ virtual int GetGameObjectType() { return OBJ_ARMATURE; }
protected:
Object *m_objArma;
struct bArmature *m_armature;
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index bc2352d713e..20498167021 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -300,6 +300,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
{
CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment();
ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
+ ccdPhysEnv->setDeactivationLinearTreshold(0.8f); // default, can be overridden by Python
+ ccdPhysEnv->setDeactivationAngularTreshold(1.0f); // default, can be overridden by Python
+
//todo: get a button in blender ?
//disable / enable debug drawing (contact points, aabb's etc)
//ccdPhysEnv->setDebugMode(1);
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index f57201ba59d..aed1d87b929 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -116,7 +116,13 @@ public:
// here come the python forwarded methods
virtual PyObject* _getattr(const STR_String& attr);
+
+ virtual int GetGameObjectType() {return -1;}
+ typedef enum ObjectTypes {
+ OBJ_ARMATURE=0
+ }ObjectTypes;
+
};
#endif //SCA_IOBJECT_H
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 1f37f07902e..bdeffd79a60 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -732,43 +732,92 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj)
{
- KX_GameObject* newobj = (KX_GameObject*) gameobj;
- RAS_MeshObject* mesh = (RAS_MeshObject*) meshobj;
+ KX_GameObject* newobj = static_cast<KX_GameObject*>(gameobj);
+ RAS_MeshObject* mesh = static_cast<RAS_MeshObject*>(meshobj);
+
+ const STR_String origMeshName = newobj->GetMesh(0)->GetName();
+
+ if( !newobj || !mesh )
+ {
+ std::cout << "warning: invalid object, mesh will not be replaced" << std::endl;
+ return;
+ }
newobj->RemoveMeshes();
newobj->AddMesh(mesh);
- if (newobj->m_isDeformable && mesh->m_class == 1) {
- Object* blendobj = (struct Object*)m_logicmgr->FindBlendObjByGameObj(newobj);
- Object* oldblendobj = (struct Object*)m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName());
-
- if (blendobj->parent && blendobj->parent->type == OB_ARMATURE &&
- blendobj->partype==PARSKEL &&
- ((Mesh*)blendobj->data)->dvert)
+ bool isDeformer = (newobj->m_isDeformable && mesh->m_class == 1);
+ if(isDeformer)
+ {
+ /* FindBlendObjByGameObj() can return 0...
+ In the case of 0 here,
+ the replicated object that is calling this function
+ is some how not in the map. (which is strange because it's added)
+ So we will search the map by the first mesh name
+ to try to locate it there. If its still not found
+ spit some message rather than crash
+ */
+ Object* blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameObj(newobj));
+ Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
+
+ bool parSkin = blendobj && blendobj->parent && blendobj->parent->type == OB_ARMATURE && blendobj->partype==PARSKEL;
+ bool releaseParent = true;
+ KX_GameObject* parentobj = newobj->GetParent();
+
+
+ // lookup by mesh name if blendobj is 0
+ if( !blendobj && parentobj )
{
- // FIXME: should the old m_pDeformer be deleted?
- // it shouldn't be a problem to delete it now.
- // if we are constructing this on the fly like here,
- // make sure to release newobj->GetParent(), and things will run shipshape
- delete static_cast<BL_DeformableGameObject*>( newobj )->m_pDeformer;
-
- BL_SkinDeformer* skindeformer = new BL_SkinDeformer(
- oldblendobj, blendobj,
- static_cast<BL_SkinMeshObject*>(mesh),
- true, // release ref count to BL_ArmatureObject, leak otherwise
- static_cast<BL_ArmatureObject*>(newobj->GetParent())
- );
- static_cast<BL_DeformableGameObject*>( newobj )->m_pDeformer = skindeformer;
+ blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(origMeshName));
+
+ // replace the mesh on the parent armature
+ if( blendobj )
+ parSkin = parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE;
+
+ // can't do it
+ else
+ std::cout << "warning: child object for " << parentobj->GetName().ReadPtr()
+ << " not found, and can't create!" << std::endl;
}
- else if (((Mesh*)blendobj->data)->dvert) {
- BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(oldblendobj, (BL_SkinMeshObject*)mesh );
- // FIXME: should the old m_pDeformer be deleted?
- // delete ((BL_DeformableGameObject*)newobj)->m_pDeformer
- ((BL_DeformableGameObject*)newobj)->m_pDeformer = meshdeformer;
+ if( blendobj && oldblendobj )
+ {
+ isDeformer = (static_cast<Mesh*>(blendobj->data)->dvert != 0);
+ BL_DeformableGameObject* deformIter =0;
+
+ // armature parent
+ if( parSkin && isDeformer )
+ {
+ deformIter = static_cast<BL_DeformableGameObject*>( newobj );
+ delete deformIter->m_pDeformer;
+
+ BL_SkinDeformer* skinDeformer = new BL_SkinDeformer(
+ oldblendobj, blendobj,
+ static_cast<BL_SkinMeshObject*>(mesh),
+ true,
+ static_cast<BL_ArmatureObject*>( parentobj )
+ );
+ releaseParent= false;
+ deformIter->m_pDeformer = skinDeformer;
+ }
+
+ // normal deformer
+ if( !parSkin && isDeformer)
+ {
+ deformIter = static_cast<BL_DeformableGameObject*>( newobj );
+ delete deformIter->m_pDeformer;
+
+ BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(
+ oldblendobj, static_cast<BL_SkinMeshObject*>(mesh)
+ );
+
+ deformIter->m_pDeformer = meshdeformer;
+ }
}
+ // release parent reference if its not being used
+ if( releaseParent && parentobj)
+ parentobj->Release();
}
-
newobj->Bucketize();
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 7afd7bf8fc5..cb4adc77d76 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1529,7 +1529,9 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(),
- body->getLinearVelocity(),body->getAngularVelocity(),
+ body->getLinearVelocity(),
+ //body->getAngularVelocity(),
+ SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(),
timeStep,minAabb,maxAabb);