BGE: some more cleanup in GetReplica/ProcessReplica of deformers: make them consistent with the other classes.

This commit is contained in:
Benoit Bolsee 2009-04-22 16:26:22 +00:00
parent 5553d2c014
commit 076d1910f5
10 changed files with 34 additions and 33 deletions

@ -46,7 +46,7 @@ void BL_DeformableGameObject::ProcessReplica()
KX_GameObject::ProcessReplica(); KX_GameObject::ProcessReplica();
if (m_pDeformer) if (m_pDeformer)
m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica(this); m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica();
} }
CValue* BL_DeformableGameObject::GetReplica() CValue* BL_DeformableGameObject::GetReplica()

@ -64,7 +64,8 @@ public:
virtual void SetSimulatedTime(double time){}; virtual void SetSimulatedTime(double time){};
virtual bool Apply(class RAS_IPolyMaterial *mat); virtual bool Apply(class RAS_IPolyMaterial *mat);
virtual bool Update(void){ return false; }; virtual bool Update(void){ return false; };
virtual RAS_Deformer* GetReplica(class KX_GameObject* replica){return NULL;}; virtual RAS_Deformer* GetReplica(){return NULL;};
virtual void ProcessReplica() { };
struct Mesh* GetMesh() { return m_bmesh; }; struct Mesh* GetMesh() { return m_bmesh; };
// virtual void InitDeform(double time){}; // virtual void InitDeform(double time){};

@ -76,7 +76,7 @@ BL_ModifierDeformer::~BL_ModifierDeformer()
} }
}; };
RAS_Deformer *BL_ModifierDeformer::GetReplica(class KX_GameObject* replica) RAS_Deformer *BL_ModifierDeformer::GetReplica()
{ {
BL_ModifierDeformer *result; BL_ModifierDeformer *result;

@ -73,7 +73,7 @@ public:
}; };
virtual void ProcessReplica(); virtual void ProcessReplica();
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica); virtual RAS_Deformer *GetReplica();
virtual ~BL_ModifierDeformer(); virtual ~BL_ModifierDeformer();
virtual bool UseVertexArray() virtual bool UseVertexArray()
{ {

@ -68,7 +68,7 @@ BL_ShapeDeformer::~BL_ShapeDeformer()
{ {
}; };
RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica) RAS_Deformer *BL_ShapeDeformer::GetReplica()
{ {
BL_ShapeDeformer *result; BL_ShapeDeformer *result;
@ -77,11 +77,6 @@ RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica)
return result; return result;
} }
void BL_ShapeDeformer::ProcessReplica()
{
BL_SkinDeformer::ProcessReplica();
}
bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma) bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
{ {
IpoCurve *icu; IpoCurve *icu;

@ -66,8 +66,7 @@ public:
{ {
}; };
virtual void ProcessReplica(); virtual RAS_Deformer *GetReplica();
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
virtual ~BL_ShapeDeformer(); virtual ~BL_ShapeDeformer();
bool Update (void); bool Update (void);

@ -108,7 +108,7 @@ void BL_SkinDeformer::Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
void **h_obj = (*map)[m_armobj]; void **h_obj = (*map)[m_armobj];
if (h_obj) if (h_obj)
SetArmature( (BL_ArmatureObject*)(*h_obj) ); m_armobj = (BL_ArmatureObject*)(*h_obj);
else else
m_armobj=NULL; m_armobj=NULL;
} }
@ -151,21 +151,16 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
return true; return true;
} }
RAS_Deformer *BL_SkinDeformer::GetReplica(class KX_GameObject* replica) RAS_Deformer *BL_SkinDeformer::GetReplica()
{ {
BL_SkinDeformer *result; BL_SkinDeformer *result;
result = new BL_SkinDeformer(*this); result = new BL_SkinDeformer(*this);
/* Not inherited from PyObjectPlus so this isnt needed */ /* there is m_armobj that must be fixed but we cannot do it now, it will be done in Relink */
/* Just call a dummy function below, will be optimized out */
result->ProcessReplica(); result->ProcessReplica();
return result; return result;
} }
void BL_SkinDeformer::ProcessReplica()
{
}
//void where_is_pose (Object *ob); //void where_is_pose (Object *ob);
//void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag); //void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag);
bool BL_SkinDeformer::Update(void) bool BL_SkinDeformer::Update(void)

@ -67,8 +67,7 @@ public:
bool recalc_normal, bool recalc_normal,
BL_ArmatureObject* arma = NULL); BL_ArmatureObject* arma = NULL);
virtual void ProcessReplica(); virtual RAS_Deformer *GetReplica();
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
virtual ~BL_SkinDeformer(); virtual ~BL_SkinDeformer();
bool Update (void); bool Update (void);
bool Apply (class RAS_IPolyMaterial *polymat); bool Apply (class RAS_IPolyMaterial *polymat);

@ -34,7 +34,7 @@
// defines USE_ODE to choose physics engine // defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h" #include "KX_ConvertPhysicsObject.h"
#include "KX_GameObject.h" #include "BL_DeformableGameObject.h"
#include "RAS_MeshObject.h" #include "RAS_MeshObject.h"
#include "KX_Scene.h" #include "KX_Scene.h"
#include "SYS_System.h" #include "SYS_System.h"
@ -670,11 +670,11 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
class KX_SoftBodyDeformer : public RAS_Deformer class KX_SoftBodyDeformer : public RAS_Deformer
{ {
class RAS_MeshObject* m_pMeshObject; class RAS_MeshObject* m_pMeshObject;
class KX_GameObject* m_gameobj; class BL_DeformableGameObject* m_gameobj;
public: public:
KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,KX_GameObject* gameobj) KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj)
:m_pMeshObject(pMeshObject), :m_pMeshObject(pMeshObject),
m_gameobj(gameobj) m_gameobj(gameobj)
{ {
@ -687,7 +687,15 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
}; };
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map) virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
{ {
//printf("relink\n"); void **h_obj = (*map)[m_gameobj];
if (h_obj) {
m_gameobj = (BL_DeformableGameObject*)(*h_obj);
m_pMeshObject = m_gameobj->GetMesh(0);
} else {
m_gameobj = NULL;
m_pMeshObject = NULL;
}
} }
virtual bool Apply(class RAS_IPolyMaterial *polymat) virtual bool Apply(class RAS_IPolyMaterial *polymat)
{ {
@ -751,12 +759,16 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
//printf("update\n"); //printf("update\n");
return true;//?? return true;//??
} }
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica) virtual RAS_Deformer *GetReplica()
{ {
KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(replica->GetMesh(0),replica); KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(*this);
deformer->ProcessReplica();
return deformer; return deformer;
} }
virtual void ProcessReplica()
{
// we have two pointers to deal with but we cannot do it now, will be done in Relink
}
virtual bool SkipVertexTransform() virtual bool SkipVertexTransform()
{ {
return true; return true;
@ -1187,9 +1199,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
if (softBody && gameobj->GetMesh(0))//only the first mesh, if any if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
{ {
//should be a mesh then, so add a soft body deformer //should be a mesh then, so add a soft body deformer
KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),gameobj); KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj);
gameobj->SetDeformer(softbodyDeformer); gameobj->SetDeformer(softbodyDeformer);
} }
} }

@ -44,7 +44,8 @@ public:
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)=0; virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)=0;
virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; virtual bool Apply(class RAS_IPolyMaterial *polymat)=0;
virtual bool Update(void)=0; virtual bool Update(void)=0;
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)=0; virtual RAS_Deformer *GetReplica()=0;
virtual void ProcessReplica()=0;
virtual bool SkipVertexTransform() virtual bool SkipVertexTransform()
{ {
return false; return false;