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
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-05-14 17:47:08 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-14 17:47:08 +0400
commitd95a10999052ad308599cb0fbbe7ed4f59870c9c (patch)
treec8ab32463f7e774319e35ab23855743dd0dea341 /source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
parent003534513645576215092b79f1aa46e85c89e3bd (diff)
BGE modifier: generate correct physic shape, share static derived mesh, share display list.
This commit completes the support for modifiers in the BGE. - The physic shape is generated according to the derived mesh. This is true for all types of shapes and all types of objects except soft body. - Optimization for static derived mesh (mesh with modifiers but no armature and no shape keys). Replicas will share the derived mesh and the display list: less memory and faster rendering. With this optimization, the static derived mesh will render as fast as if the modifiers were applied. Known Limits: - Sharing of mesh and display list is only possible between in-game replicas or dupligroup. If you want to instantiate multiple objects with modifiers, use dupligroup to ensure best memory and GPU utilization. - rayCast() will interact with the derived mesh as follow: Hit position and hit normal are the real values according to the derived mesh but the KX_PolyProxy object refers to the original mesh. You should use it only to retrieve the material. - Dynamic derived mesh have very poor performance: They use direct openGL calls for rendering (no support for display list and vertex array) and they dont't share the derived mesh memory. Always apply modifiers on dynamic mesh for best performance. - Time dependent modifiers are not supported. - Modifiers are not supported for Bullet soft body.
Diffstat (limited to 'source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 07fdc8ec41b..f18ffb56ccb 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -52,6 +52,10 @@
#include "KX_MotionState.h" // bridge between motionstate and scenegraph node
+extern "C"{
+ #include "BKE_DerivedMesh.h"
+}
+
#ifdef USE_ODE
#include "KX_OdePhysicsController.h"
@@ -792,6 +796,7 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
+ struct DerivedMesh* dm,
class KX_Scene* kxscene,
struct PHY_ShapeProps* shapeprops,
struct PHY_MaterialProps* smmaterial,
@@ -884,42 +889,36 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
}
case KX_BOUNDPOLYTOPE:
{
- shapeInfo->SetMesh(meshobj, true,false);
+ shapeInfo->SetMesh(meshobj, dm,true,false);
bm = shapeInfo->CreateBulletShape();
break;
}
case KX_BOUNDMESH:
{
-
- if (!ci.m_mass ||objprop->m_softbody)
- {
- // mesh shapes can be shared, check first if we already have a shape on that mesh
- class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, false);
- if (sharedShapeInfo != NULL)
- {
- delete shapeInfo;
- shapeInfo = sharedShapeInfo;
- shapeInfo->AddRef();
- } else
- {
- shapeInfo->SetMesh(meshobj, false,false);
- }
+ bool useGimpact = (ci.m_mass && !objprop->m_softbody);
- // Soft bodies require welding. Only avoid remove doubles for non-soft bodies!
- if (objprop->m_softbody)
- {
- shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
- }
-
- bm = shapeInfo->CreateBulletShape();
- //no moving concave meshes, so don't bother calculating inertia
- //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ // mesh shapes can be shared, check first if we already have a shape on that mesh
+ class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, dm, false,useGimpact);
+ if (sharedShapeInfo != NULL)
+ {
+ delete shapeInfo;
+ shapeInfo = sharedShapeInfo;
+ shapeInfo->AddRef();
} else
{
- shapeInfo->SetMesh(meshobj, false,true);
- bm = shapeInfo->CreateBulletShape();
+ shapeInfo->SetMesh(meshobj, dm, false,useGimpact);
}
+ // Soft bodies require welding. Only avoid remove doubles for non-soft bodies!
+ if (objprop->m_softbody)
+ {
+ shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
+ }
+
+ bm = shapeInfo->CreateBulletShape();
+ //should we compute inertia for dynamic shape?
+ //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+
break;
}
}