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:
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h2
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp46
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp6
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp9
4 files changed, 42 insertions, 21 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 909229b04c2..8631048dc4a 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -111,6 +111,8 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
struct KX_ObjectProperties* objprop);
void KX_ClearSumoSharedShapes();
+bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj);
+
#endif
#endif //KX_CONVERTPHYSICSOBJECTS
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index b72d17aa3b5..ed2f2100589 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -77,14 +77,32 @@
#include "KX_SumoPhysicsController.h"
+struct KX_PhysicsInstance
+{
+ DT_VertexBaseHandle m_vertexbase;
+ int m_vtxarray;
+ RAS_IPolyMaterial* m_material;
+
+ KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, int vtxarray, RAS_IPolyMaterial* mat)
+ : m_vertexbase(vertex_base),
+ m_vtxarray(vtxarray),
+ m_material(mat)
+ {
+ }
+
+ ~KX_PhysicsInstance()
+ {
+ DT_DeleteVertexBase(m_vertexbase);
+ }
+};
+
static GEN_Map<GEN_HashedPtr,DT_ShapeHandle> map_gamemesh_to_sumoshape;
-static GEN_Map<GEN_HashedPtr, DT_VertexBaseHandle> map_gamemesh_to_vertex_base_handle;
+static GEN_Map<GEN_HashedPtr, KX_PhysicsInstance*> map_gamemesh_to_instance;
// forward declarations
static void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope);
-
void KX_ConvertSumoObject( KX_GameObject* gameobj,
RAS_MeshObject* meshobj,
KX_Scene* kxscene,
@@ -339,7 +357,7 @@ static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarr
//DT_VertexIndices(indices.size(), &indices[0]);
DT_EndComplexShape();
- map_gamemesh_to_vertex_base_handle.insert(GEN_HashedPtr(meshobj), vertex_base);
+ map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
return shape;
}
@@ -371,20 +389,20 @@ static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxar
DT_VertexIndices(indices.size(), &indices[0]);
DT_EndPolytope();
- map_gamemesh_to_vertex_base_handle.insert(GEN_HashedPtr(meshobj), vertex_base);
+ map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
return shape;
}
// This will have to be a method in a class somewhere...
// Update SOLID with a changed physics mesh.
// not used... yet.
-bool ReInstanceShapeFromMesh(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat)
+bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj)
{
- DT_VertexBaseHandle *vertex_base = map_gamemesh_to_vertex_base_handle[GEN_HashedPtr(meshobj)];
- if (vertex_base)
+ KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)];
+ if (instance)
{
- const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]);
- DT_ChangeVertexBase(*vertex_base, vertex_array[0].getLocalXYZ());
+ const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(instance->m_material)[instance->m_vtxarray])[0]);
+ DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getLocalXYZ());
return true;
}
return false;
@@ -554,16 +572,12 @@ void KX_ClearSumoSharedShapes()
map_gamemesh_to_sumoshape.clear();
- for (i=0; i < map_gamemesh_to_vertex_base_handle.size(); i++)
- DT_DeleteVertexBase(*map_gamemesh_to_vertex_base_handle.at(i));
+ for (i=0; i < map_gamemesh_to_instance.size(); i++)
+ delete *map_gamemesh_to_instance.at(i);
- map_gamemesh_to_vertex_base_handle.clear();
+ map_gamemesh_to_instance.clear();
}
-
-
-
-
#endif //USE_SUMO_SOLID
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index efd3a491784..f2dc7535010 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -201,8 +201,14 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa
/* __NLA Do the deformation */
if (ms.m_pDeformer)
+ {
ms.m_pDeformer->Apply(m_material);
+ // KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_)
+ }
/* End __NLA */
+
+ if (rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
+ ms.m_mesh->SortPolygons(cameratrans*MT_Transform(ms.m_OpenGLMatrix));
rendertools->PushMatrix();
rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index bfc4c3012c3..a28cbac2580 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -596,6 +596,9 @@ struct RAS_MeshObject::fronttoback
void RAS_MeshObject::SortPolygons(const MT_Transform &transform)
{
+ if (!m_zsort)
+ return;
+
// Extract camera Z plane...
const MT_Vector3 pnorm(transform.getBasis()[2]);
const MT_Scalar pval = transform.getOrigin()[2];
@@ -665,6 +668,7 @@ void RAS_MeshObject::SchedulePolygons(const MT_Transform &transform, int drawing
,poly->GetMaterial()->GetPolyMaterial());
}
+ m_zsort = false;
}
else
{
@@ -683,9 +687,4 @@ void RAS_MeshObject::SchedulePolygons(const MT_Transform &transform, int drawing
m_bModified = false;
}
-
- if (m_zsort && drawingmode >= RAS_IRasterizer::KX_SOLID)
- {
- SortPolygons(transform);
- }
}