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();
if (m_pDeformer)
m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica(this);
m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica();
}
CValue* BL_DeformableGameObject::GetReplica()

@ -64,7 +64,8 @@ public:
virtual void SetSimulatedTime(double time){};
virtual bool Apply(class RAS_IPolyMaterial *mat);
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; };
// 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;

@ -73,7 +73,7 @@ public:
};
virtual void ProcessReplica();
virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
virtual RAS_Deformer *GetReplica();
virtual ~BL_ModifierDeformer();
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;
@ -77,11 +77,6 @@ RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica)
return result;
}
void BL_ShapeDeformer::ProcessReplica()
{
BL_SkinDeformer::ProcessReplica();
}
bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
{
IpoCurve *icu;

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

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

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

@ -34,7 +34,7 @@
// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
#include "KX_GameObject.h"
#include "BL_DeformableGameObject.h"
#include "RAS_MeshObject.h"
#include "KX_Scene.h"
#include "SYS_System.h"
@ -670,11 +670,11 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
class KX_SoftBodyDeformer : public RAS_Deformer
{
class RAS_MeshObject* m_pMeshObject;
class KX_GameObject* m_gameobj;
class RAS_MeshObject* m_pMeshObject;
class BL_DeformableGameObject* m_gameobj;
public:
KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,KX_GameObject* gameobj)
KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj)
:m_pMeshObject(pMeshObject),
m_gameobj(gameobj)
{
@ -687,7 +687,15 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
};
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)
{
@ -751,12 +759,16 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
//printf("update\n");
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;
}
virtual void ProcessReplica()
{
// we have two pointers to deal with but we cannot do it now, will be done in Relink
}
virtual bool SkipVertexTransform()
{
return true;
@ -1187,9 +1199,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
{
//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);
}
}

@ -44,7 +44,8 @@ public:
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)=0;
virtual bool Apply(class RAS_IPolyMaterial *polymat)=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()
{
return false;