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:
authorCampbell Barton <ideasman42@gmail.com>2009-04-22 16:16:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-22 16:16:41 +0400
commita8592d09d0173bab0e3eb66a315146e164cf14a4 (patch)
treef73a0f025a2a673ad3d9f22273d02f72225e1e52 /source/gameengine
parentc09b1a985c29e59736eef619e2dae1a1dcf2d73a (diff)
BGE C++ API
Some functions used ProcessReplica(replica); others replica->ProcessReplica() Use the second method everywhere so the PyObjectPlus's ProcessReplica() can be called from its subclasses. Note that PyObjectPlus's ProcessReplica isnt used yet.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp11
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h2
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.cpp14
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.h2
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp8
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h6
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp7
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h9
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp20
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h4
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp2
11 files changed, 40 insertions, 45 deletions
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index d2001212f7d..04e2c55e7dd 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -74,16 +74,17 @@ CValue* BL_ArmatureObject::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
-void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica)
+void BL_ArmatureObject::ProcessReplica()
{
- KX_GameObject::ProcessReplica(replica);
+ bPose *pose= m_pose;
+ KX_GameObject::ProcessReplica();
- replica->m_pose = NULL;
- game_copy_pose(&replica->m_pose, m_pose);
+ m_pose = NULL;
+ game_copy_pose(&m_pose, pose);
}
BL_ArmatureObject::~BL_ArmatureObject()
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index d68e37d9e37..d5402cfd126 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -45,7 +45,7 @@ class BL_ArmatureObject : public KX_GameObject
public:
double GetLastFrame ();
short GetActivePriority();
- virtual void ProcessReplica(BL_ArmatureObject *replica);
+ virtual void ProcessReplica();
class BL_ActionActuator * GetActiveAction();
BL_ArmatureObject(
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp
index e2610d2b405..618744dc1f3 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.cpp
+++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp
@@ -41,16 +41,12 @@ BL_DeformableGameObject::~BL_DeformableGameObject()
delete m_pDeformer; // __NLA : Temporary until we decide where to put this
}
-void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica)
+void BL_DeformableGameObject::ProcessReplica()
{
- BL_MeshDeformer *deformer;
- KX_GameObject::ProcessReplica(replica);
-
- if (m_pDeformer) {
- deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(replica);
- ((BL_DeformableGameObject*)replica)->m_pDeformer = deformer;
- }
+ KX_GameObject::ProcessReplica();
+ if (m_pDeformer)
+ m_pDeformer= (BL_MeshDeformer*)m_pDeformer->GetReplica(this);
}
CValue* BL_DeformableGameObject::GetReplica()
@@ -61,7 +57,7 @@ CValue* BL_DeformableGameObject::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h
index 126a1fcb1e7..dbc89bd2a20 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.h
+++ b/source/gameengine/Converter/BL_DeformableGameObject.h
@@ -62,7 +62,7 @@ public:
m_pDeformer->Relink (map);
KX_GameObject::Relink(map);
};
- void ProcessReplica(KX_GameObject* replica);
+ void ProcessReplica();
BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) :
KX_GameObject(sgReplicationInfo,callbacks),
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 30495fc2a45..57a61ac37ae 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -810,6 +810,14 @@ PyObject *PyObjectPlus::PyisA(PyObject *value) // Python wrapper for isA
return NULL;
}
+
+void PyObjectPlus::ProcessReplica()
+{
+ /* Clear the proxy, will be created again if needed with GetProxy()
+ * otherwise the PyObject will point to the wrong reference */
+ m_proxy= NULL;
+}
+
/* Utility function called by the macro py_getattro_up()
* for getting ob.__dict__() values from our PyObject
* this is used by python for doing dir() on an object, so its good
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index a3b3952a6d1..52e59f7730c 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -450,6 +450,12 @@ public:
static PyObject *GetProxy_Ext(PyObjectPlus *self, PyTypeObject *tp);
static PyObject *NewProxy_Ext(PyObjectPlus *self, PyTypeObject *tp, bool py_owns);
+
+ /**
+ * Makes sure any internal data owned by this class is deep copied.
+ */
+ virtual void ProcessReplica();
+
};
PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict);
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index f84ce23b7dd..e1784a4cd37 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -72,15 +72,10 @@ CValue* KX_Camera::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
-
-void KX_Camera::ProcessReplica(KX_Camera* replica)
-{
- KX_GameObject::ProcessReplica(replica);
-}
MT_Transform KX_Camera::GetWorldToCamera() const
{
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
index 6f818cb2c57..d570fac213a 100644
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ b/source/gameengine/Ketsji/KX_Camera.h
@@ -146,15 +146,6 @@ public:
virtual CValue*
GetReplica(
);
-
- /**
- * Inherited from CValue -- Makes sure any internal
- * data owned by this class is deep copied. Called internally
- */
- virtual void
- ProcessReplica(
- KX_Camera* replica
- );
MT_Transform GetWorldToCamera() const;
MT_Transform GetCameraToWorld() const;
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index eb20cfa1131..fe7f96d9fac 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -331,16 +331,16 @@ void KX_GameObject::RemoveParent(KX_Scene *scene)
}
}
-void KX_GameObject::ProcessReplica(KX_GameObject* replica)
-{
- replica->m_pPhysicsController1 = NULL;
- replica->m_pGraphicController = NULL;
- replica->m_pSGNode = NULL;
- replica->m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
- replica->m_pClient_info->m_gameobject = replica;
- replica->m_state = 0;
+void KX_GameObject::ProcessReplica()
+{
+ m_pPhysicsController1 = NULL;
+ m_pGraphicController = NULL;
+ m_pSGNode = NULL;
+ m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
+ m_pClient_info->m_gameobject = this;
+ m_state = 0;
if(m_attr_dict)
- replica->m_attr_dict= PyDict_Copy(m_attr_dict);
+ m_attr_dict= PyDict_Copy(m_attr_dict);
}
@@ -352,7 +352,7 @@ CValue* KX_GameObject::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
return replica;
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index e81429dff5a..479a3c1b574 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -279,9 +279,7 @@ public:
* data owned by this class is deep copied. Called internally
*/
virtual void
- ProcessReplica(
- KX_GameObject* replica
- );
+ ProcessReplica();
/**
* Return the linear velocity of the game object.
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index c5189907714..a426953602b 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -85,7 +85,7 @@ CValue* KX_LightObject::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
- ProcessReplica(replica);
+ replica->ProcessReplica();
replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr();
m_rendertools->AddLight(&replica->m_lightobj);