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-11 00:53:58 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-05-11 00:53:58 +0400
commit386122ada6432b29437c3ca7f1eea2b5b919d377 (patch)
tree88923d82aaf1b87c1498db6112d027297ff1c492 /source/gameengine/Ketsji
parent6f5ef6044dabdd383a91a14c65a2f9f454fb5c42 (diff)
BGE performance, 4th round: logic
This commit extends the technique of dynamic linked list to the logic system to eliminate as much as possible temporaries, map lookup or full scan. The logic engine is now free of memory allocation, which is an important stability factor. The overhead of the logic system is reduced by a factor between 3 and 6 depending on the logic setup. This is the speed-up you can expect on a logic setup using simple bricks. Heavy bricks like python controllers and ray sensors will still take about the same time to execute so the speed up will be less important. The core of the logic engine has been much reworked but the functionality is still the same except for one thing: the priority system on the execution of controllers. The exact same remark applies to actuators but I'll explain for controllers only: Previously, it was possible, with the "executePriority" attribute to set a controller to run before any other controllers in the game. Other than that, the sequential execution of controllers, as defined in Blender was guaranteed by default. With the new system, the sequential execution of controllers is still guaranteed but only within the controllers of one object. the user can no longer set a controller to run before any other controllers in the game. The "executePriority" attribute controls the execution of controllers within one object. The priority is a small number starting from 0 for the first controller and incrementing for each controller. If this missing feature is a must, a special method can be implemented to set a controller to run before all other controllers. Other improvements: - Systematic use of reference in parameter passing to avoid unnecessary data copy - Use pre increment in iterator instead of post increment to avoid temporary allocation - Use const char* instead of STR_String whenever possible to avoid temporary allocation - Fix reference counting bugs (memory leak) - Fix a crash in certain cases of state switching and object deletion - Minor speed up in property sensor - Removal of objects during the game is a lot faster
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KXNetwork/CMakeLists.txt1
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp8
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp10
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h2
-rw-r--r--source/gameengine/Ketsji/KXNetwork/Makefile1
-rw-r--r--source/gameengine/Ketsji/KXNetwork/SConscript2
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp2
-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_IpoActuator.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp13
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h6
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.h6
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.cpp8
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp26
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp64
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h7
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.h1
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp25
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h2
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp17
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.h6
36 files changed, 148 insertions, 157 deletions
diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
index fa0ca378c6b..eb1d5fc67a3 100644
--- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
+++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt
@@ -33,6 +33,7 @@ SET(INC
../../../../source/gameengine/Ketsji
../../../../source/gameengine/GameLogic
../../../../source/gameengine/Expressions
+ ../../../../source/gameengine/Scenegraph
../../../../source/gameengine/Network
${PYTHON_INC}
)
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
index eee8e9f6827..738f64713b0 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
@@ -61,12 +61,12 @@ void KX_NetworkEventManager::NextFrame()
// each frame, the logicmanager will call the network
// eventmanager to look for network events, and process it's
// 'network' sensors
- set<class SCA_ISensor*>::iterator it;
-
- for (it = m_sensors.begin(); !(it==m_sensors.end()); it++) {
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
+ {
// printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime);
// process queue
- (*it)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
// now a list of triggerer sensors has been built
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
index 7f21c490e67..63773352d96 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
@@ -75,7 +75,7 @@ bool KX_NetworkMessageActuator::Update()
m_toPropName,
GetParent()->GetName(),
m_subject,
- GetParent()->GetPropertyText(m_body,""));
+ GetParent()->GetPropertyText(m_body));
} else
{
m_networkscene->SendMessage(
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
index 82e2437064b..8ddcd87b66f 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
@@ -85,7 +85,7 @@ CValue* KX_NetworkMessageSensor::GetReplica() {
}
// Return true only for flank (UP and DOWN)
-bool KX_NetworkMessageSensor::Evaluate(CValue* event)
+bool KX_NetworkMessageSensor::Evaluate()
{
bool result = false;
bool WasUp = m_IsUp;
@@ -102,8 +102,8 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
m_SubjectList = NULL;
}
- STR_String toname=GetParent()->GetName();
- STR_String subject = this->m_subject;
+ STR_String& toname=GetParent()->GetName();
+ STR_String& subject = this->m_subject;
vector<NG_NetworkMessage*> messages =
m_NetworkScene->FindMessages(toname,"",subject,true);
@@ -123,9 +123,9 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
for (mesit=messages.begin();mesit!=messages.end();mesit++)
{
// save the body
- STR_String body = (*mesit)->GetMessageText();
+ const STR_String& body = (*mesit)->GetMessageText();
// save the subject
- STR_String messub = (*mesit)->GetSubject();
+ const STR_String& messub = (*mesit)->GetSubject();
#ifdef NAN_NET_DEBUG
if (body) {
cout << "body [" << body << "]\n";
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
index 3abba7cfffd..53183f33826 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
@@ -63,7 +63,7 @@ public:
virtual ~KX_NetworkMessageSensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
void EndFrame();
diff --git a/source/gameengine/Ketsji/KXNetwork/Makefile b/source/gameengine/Ketsji/KXNetwork/Makefile
index ddcb03600d5..ec3099611e0 100644
--- a/source/gameengine/Ketsji/KXNetwork/Makefile
+++ b/source/gameengine/Ketsji/KXNetwork/Makefile
@@ -40,6 +40,7 @@ CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I../../Expressions
CPPFLAGS += -I../../GameLogic
+CPPFLAGS += -I../../Scenegraph
CPPFLAGS += -I../../Network
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I..
diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript
index 2476ed1f275..26f95fab8af 100644
--- a/source/gameengine/Ketsji/KXNetwork/SConscript
+++ b/source/gameengine/Ketsji/KXNetwork/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('*.cpp')
incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Ketsji'
incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions'
-incs += ' #source/gameengine/Network'
+incs += ' #source/gameengine/Network #source/gameengine/Scenegraph'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index 65a026656c5..3b8917efe90 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -643,8 +643,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
if (mode &USECUSTOMUV)
{
- STR_String str = mMaterial->mapping[i].uvCoName;
- if (!str.IsEmpty())
+ if (!mMaterial->mapping[i].uvCoName.IsEmpty())
ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV2, i);
continue;
}
@@ -717,6 +716,8 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras)
if(!obj) return;
obj->Release(); /* FindValue() AddRef's */
+ obj->Release();
+
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp
index e701a680511..5f7197e31f1 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp
@@ -454,7 +454,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName());
+ return PyString_FromString(m_ob->GetName().ReadPtr());
else
return m_ob->GetProxy();
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 2f5b5631761..4d01d96ced4 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -188,14 +188,14 @@ double KX_GameObject::GetNumber()
-STR_String KX_GameObject::GetName()
+STR_String& KX_GameObject::GetName()
{
return m_name;
}
-void KX_GameObject::SetName(STR_String name)
+void KX_GameObject::SetName(const char *name)
{
m_name = name;
}; // Set the name of the value
@@ -452,14 +452,6 @@ void KX_GameObject::AddMeshUser()
double* fl = GetOpenGLMatrixPtr()->getPointer();
RAS_Deformer *deformer = GetDeformer();
- //RAS_MeshSlot *ms;
- //for(ms =static_cast<RAS_MeshSlot*>(m_meshSlots.QPeek());
- // ms!=static_cast<RAS_MeshSlot*>(m_meshSlots.Self());
- // ms =static_cast<RAS_MeshSlot*>(ms->QPeek()))
- //{
- // ms->m_OpenGLMatrix = fl;
- // ms->SetDeformer(deformer);
- //}
SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
for(mit.begin(); !mit.end(); ++mit)
{
@@ -493,9 +485,7 @@ void KX_GameObject::UpdateBuckets( bool recursive )
if (GetSGNode()->IsDirty())
GetOpenGLMatrix();
- //for(ms =static_cast<RAS_MeshSlot*>(m_meshSlots.QPeek());
- // ms!=static_cast<RAS_MeshSlot*>(m_meshSlots.Self());
- // ms =static_cast<RAS_MeshSlot*>(ms->QPeek()))
+
SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
for(mit.begin(); !mit.end(); ++mit)
{
@@ -1844,7 +1834,7 @@ int KX_GameObject::py_setattro(PyObject *attr, PyObject *value) // py_setattro m
if (ret==PY_SET_ATTR_COERCE_FAIL) {
/* CValue attribute exists, remove CValue and add PyDict value */
- RemoveProperty(STR_String(PyString_AsString(attr)));
+ RemoveProperty(PyString_AsString(attr));
ret= PY_SET_ATTR_MISSING;
}
@@ -1871,7 +1861,7 @@ int KX_GameObject::py_delattro(PyObject *attr)
{
char *attr_str= PyString_AsString(attr);
- if (RemoveProperty(STR_String(attr_str))) // XXX - should call CValues instead but its only 2 lines here
+ if (RemoveProperty(attr_str)) // XXX - should call CValues instead but its only 2 lines here
return 0;
if (m_attr_dict && (PyDict_DelItem(m_attr_dict, attr) == 0))
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 8fafcc1f9b6..e5b26539d4d 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -241,7 +241,7 @@ public:
/**
* Inherited from CValue -- returns the name of this object.
*/
- STR_String
+ STR_String&
GetName(
);
@@ -250,7 +250,7 @@ public:
*/
void
SetName(
- STR_String name
+ const char *name
);
/**
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp
index efe01993b08..5e1785e9c21 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.cpp
+++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp
@@ -164,14 +164,14 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
bool bNegativeEvent = false;
- int numevents = 0;
+ bool numevents = false;
bool bIpoStart = false;
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
if (frame)
{
- numevents = m_events.size();
+ numevents = m_posevent || m_negevent;
bNegativeEvent = IsNegativeEvent();
RemoveAllEvents();
}
@@ -273,7 +273,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
{
result = false;
m_bNegativeEvent = false;
- numevents = 0;
+ numevents = false;
}
if (!m_bIpoPlaying)
{
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index c0b05859539..0d1bc289a5c 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -71,7 +71,6 @@ PyTypeObject KX_MeshProxy::Type = {
PyParentObject KX_MeshProxy::Parents[] = {
&KX_MeshProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
&PyObjectPlus::Type,
NULL
@@ -110,21 +109,21 @@ void KX_MeshProxy::SetMeshModified(bool v)
PyObject* KX_MeshProxy::py_getattro(PyObject *attr)
{
- py_getattro_up(SCA_IObject);
+ py_getattro_up(CValue);
}
PyObject* KX_MeshProxy::py_getattro_dict() {
- py_getattro_dict_up(SCA_IObject);
+ py_getattro_dict_up(CValue);
}
int KX_MeshProxy::py_setattro(PyObject *attr, PyObject* value)
{
- py_setattro_up(SCA_IObject);
+ py_setattro_up(CValue);
}
KX_MeshProxy::KX_MeshProxy(RAS_MeshObject* mesh)
- : SCA_IObject(&Type), m_meshobj(mesh)
+ : CValue(&Type), m_meshobj(mesh)
{
}
@@ -140,8 +139,8 @@ CValue* KX_MeshProxy::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValu
const STR_String & KX_MeshProxy::GetText() {return m_meshobj->GetName();};
double KX_MeshProxy::GetNumber() { return -1;}
-STR_String KX_MeshProxy::GetName() { return m_meshobj->GetName();}
-void KX_MeshProxy::SetName(STR_String name) { };
+STR_String& KX_MeshProxy::GetName() { return m_meshobj->GetName();}
+void KX_MeshProxy::SetName(const char *name) { };
CValue* KX_MeshProxy::GetReplica() { return NULL;}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
index f775c963c1e..bfdd4be4118 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ b/source/gameengine/Ketsji/KX_MeshProxy.h
@@ -34,7 +34,7 @@
/* utility conversion function */
bool ConvertPythonToMesh(PyObject * value, class RAS_MeshObject **object, bool py_none_ok, const char *error_prefix);
-class KX_MeshProxy : public SCA_IObject
+class KX_MeshProxy : public CValue
{
Py_Header;
@@ -51,8 +51,8 @@ public:
virtual const STR_String & GetText();
virtual double GetNumber();
virtual RAS_MeshObject* GetMesh() { return m_meshobj; }
- virtual STR_String GetName();
- virtual void SetName(STR_String name); // Set the name of the value
+ virtual STR_String& GetName();
+ virtual void SetName(const char *name); // Set the name of the value
virtual CValue* GetReplica();
// stuff for python integration
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 8b7c3cb928b..74b5c923db8 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -86,7 +86,7 @@ void KX_MouseFocusSensor::Init()
m_hitNormal.setValue(0,0,1);
}
-bool KX_MouseFocusSensor::Evaluate(CValue* event)
+bool KX_MouseFocusSensor::Evaluate()
{
bool result = false;
bool obHasFocus = false;
@@ -119,7 +119,7 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event)
* mode is never used, because the converter never makes this
* sensor for a mouse-key event. It is here for
* completeness. */
- result = SCA_MouseSensor::Evaluate(event);
+ result = SCA_MouseSensor::Evaluate();
m_positive_event = (m_val!=0);
}
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
index 350fda198db..29d674eb305 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
@@ -69,7 +69,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
/**
* @attention Overrides default evaluate.
*/
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void Init();
virtual bool IsPositiveTrigger() {
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index e7f05555b64..a3c4e95ae24 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -160,7 +160,7 @@ KX_NearSensor::~KX_NearSensor()
}
-bool KX_NearSensor::Evaluate(CValue* event)
+bool KX_NearSensor::Evaluate()
{
bool result = false;
// KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
index 5b65312472a..35136b79d13 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -71,7 +71,7 @@ public:
virtual void SynchronizeTransform();
virtual CValue* GetReplica();
virtual void ProcessReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void ReParent(SCA_IObject* parent);
virtual bool NewHandleCollision(void* obj1,void* obj2,
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp
index f55ffd4f69a..c5248785b12 100644
--- a/source/gameengine/Ketsji/KX_ParentActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp
@@ -267,7 +267,7 @@ PyObject* KX_ParentActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_ob->GetName());
+ return PyString_FromString(m_ob->GetName().ReadPtr());
else
return m_ob->GetProxy();
}
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
index ca38117a9e7..b56b5500c39 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.cpp
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -64,8 +64,8 @@ PyTypeObject KX_PolyProxy::Type = {
PyParentObject KX_PolyProxy::Parents[] = {
&KX_PolyProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
+ &PyObjectPlus::Type,
NULL
};
@@ -162,11 +162,11 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
{
return PyInt_FromLong(m_polygon->IsCollider());
}
- py_getattro_up(SCA_IObject);
+ py_getattro_up(CValue);
}
PyObject* KX_PolyProxy::py_getattro_dict() {
- py_getattro_dict_up(SCA_IObject);
+ py_getattro_dict_up(CValue);
}
KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
@@ -186,8 +186,8 @@ CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { re
STR_String sPolyName="polygone";
const STR_String & KX_PolyProxy::GetText() {return sPolyName;};
double KX_PolyProxy::GetNumber() { return -1;}
-STR_String KX_PolyProxy::GetName() { return sPolyName;}
-void KX_PolyProxy::SetName(STR_String) { };
+STR_String& KX_PolyProxy::GetName() { return sPolyName;}
+void KX_PolyProxy::SetName(const char *) { };
CValue* KX_PolyProxy::GetReplica() { return NULL;}
// stuff for python integration
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h
index 223193ec519..d8fd36fec6c 100644
--- a/source/gameengine/Ketsji/KX_PolyProxy.h
+++ b/source/gameengine/Ketsji/KX_PolyProxy.h
@@ -31,7 +31,7 @@
#include "SCA_IObject.h"
-class KX_PolyProxy : public SCA_IObject
+class KX_PolyProxy : public CValue
{
Py_Header;
protected:
@@ -46,8 +46,8 @@ public:
CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
const STR_String & GetText();
double GetNumber();
- STR_String GetName();
- void SetName(STR_String name); // Set the name of the value
+ STR_String& GetName();
+ void SetName(const char *name); // Set the name of the value
CValue* GetReplica();
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp
index 039cf640a6f..42b1850a454 100644
--- a/source/gameengine/Ketsji/KX_PythonSeq.cpp
+++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp
@@ -91,7 +91,7 @@ static PyObject *KX_PythonSeq_getIndex(KX_PythonSeq * self, int index)
switch(self->type) {
case KX_PYGENSEQ_CONT_TYPE_SENSORS:
{
- vector<SCA_ISensor*> linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
+ vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
if(index<0) index += linkedsensors.size();
if(index<0 || index>= linkedsensors.size()) {
PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
@@ -101,7 +101,7 @@ static PyObject *KX_PythonSeq_getIndex(KX_PythonSeq * self, int index)
}
case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
{
- vector<SCA_IActuator*> linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
+ vector<SCA_IActuator*>& linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
if(index<0) index += linkedactuators.size();
if(index<0 || index>= linkedactuators.size()) {
PyErr_SetString(PyExc_IndexError, "seq[i]: index out of range");
@@ -168,7 +168,7 @@ static PyObject * KX_PythonSeq_subscript(KX_PythonSeq * self, PyObject *key)
switch(self->type) {
case KX_PYGENSEQ_CONT_TYPE_SENSORS:
{
- vector<SCA_ISensor*> linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
+ vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
SCA_ISensor* sensor;
for (unsigned int index=0;index<linkedsensors.size();index++) {
sensor = linkedsensors[index];
@@ -179,7 +179,7 @@ static PyObject * KX_PythonSeq_subscript(KX_PythonSeq * self, PyObject *key)
}
case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
{
- vector<SCA_IActuator*> linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
+ vector<SCA_IActuator*>& linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
SCA_IActuator* actuator;
for (unsigned int index=0;index<linkedactuators.size();index++) {
actuator = linkedactuators[index];
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp
index 1af29151adf..50fa4f5e310 100644
--- a/source/gameengine/Ketsji/KX_RayEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp
@@ -44,9 +44,10 @@ using namespace std;
void KX_RayEventManager::NextFrame()
{
- for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ SG_DList::iterator<SCA_ISensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- (*i)->Activate(m_logicmgr, NULL);
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 43d8806fc68..fdde5fdcf7b 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -178,7 +178,7 @@ bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo* client)
return true;
}
-bool KX_RaySensor::Evaluate(CValue* event)
+bool KX_RaySensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index 558840e2f17..9efb046742f 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -67,7 +67,7 @@ public:
virtual ~KX_RaySensor();
virtual CValue* GetReplica();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual bool IsPositiveTrigger();
virtual void Init();
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index 2fd786e44e3..3c72eac3e62 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -87,7 +87,7 @@ KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator()
if (m_OriginalObject)
m_OriginalObject->UnregisterActuator(this);
if (m_lastCreatedObject)
- m_lastCreatedObject->Release();
+ m_lastCreatedObject->UnregisterActuator(this);
}
@@ -145,6 +145,12 @@ bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj)
m_OriginalObject = NULL;
return true;
}
+ if (clientobj == m_lastCreatedObject)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_lastCreatedObject = NULL;
+ return true;
+ }
return false;
}
@@ -356,7 +362,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* args)
Py_RETURN_NONE;
if (ret_name_only)
- return PyString_FromString(m_OriginalObject->GetName());
+ return PyString_FromString(m_OriginalObject->GetName().ReadPtr());
else
return m_OriginalObject->GetProxy();
}
@@ -464,13 +470,21 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
// keep a copy of the last object, to allow python scripters to change it
if (m_lastCreatedObject)
{
- //careful with destruction, it might still have outstanding collision callbacks
- m_scene->DelayedReleaseObject(m_lastCreatedObject);
- m_lastCreatedObject->Release();
+ //Let's not keep a reference to the object: it's bad, if the object is deleted
+ //this will force to keep a "zombie" in the game for no good reason.
+ //m_scene->DelayedReleaseObject(m_lastCreatedObject);
+ //m_lastCreatedObject->Release();
+
+ //Instead we use the registration mechanism
+ m_lastCreatedObject->UnregisterActuator(this);
+ m_lastCreatedObject = NULL;
}
m_lastCreatedObject = replica;
- m_lastCreatedObject->AddRef();
+ // no reference
+ //m_lastCreatedObject->AddRef();
+ // but registration
+ m_lastCreatedObject->RegisterActuator(this);
// finished using replica? then release it
replica->Release();
}
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 208f8fc9461..84c6d374386 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -164,7 +164,6 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_lightlist= new CListValue();
m_inactivelist = new CListValue();
m_euthanasyobjects = new CListValue();
- m_delayReleaseObjects = new CListValue();
m_logicmgr = new SCA_LogicManager();
@@ -223,8 +222,6 @@ KX_Scene::~KX_Scene()
// It's still there but we remove all properties here otherwise some
// reference might be hanging and causing late release of objects
RemoveAllDebugProperties();
- // early removal of sensor map to avoid massive slow down when there are many objects
- m_logicmgr->RemoveSensorMap();
while (GetRootParentList()->GetCount() > 0)
{
@@ -249,8 +246,6 @@ KX_Scene::~KX_Scene()
if (m_euthanasyobjects)
m_euthanasyobjects->Release();
- if (m_delayReleaseObjects)
- m_delayReleaseObjects->Release();
if (m_logicmgr)
delete m_logicmgr;
@@ -419,11 +414,11 @@ void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gam
KX_GameObject* orgobj = (KX_GameObject*)gameobj;
if (NewRemoveObject(orgobj) != 0)
{
- // object is not yet deleted (this can happen when it hangs in an add object actuator
- // last object created reference. It's a bad situation, don't know how to fix it exactly
- // The least I can do, is remove the reference to the node in the object as the node
- // will in any case be deleted. This ensures that the object will not try to use the node
- // when it is finally deleted (see KX_GameObject destructor)
+ // object is not yet deleted because a reference is hanging somewhere.
+ // This should not happen anymore since we use proxy object for Python
+ // confident enough to put an assert?
+ //assert(false);
+ printf("Zombie object! name=%s\n", orgobj->GetName().ReadPtr());
orgobj->SetSGNode(NULL);
PHY_IGraphicController* ctrl = orgobj->GetGraphicController();
if (ctrl)
@@ -550,8 +545,9 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
vector<SCA_IActuator*> linkedactuators = cont->GetLinkedActuators();
// disconnect the sensors and actuators
- cont->UnlinkAllSensors();
- cont->UnlinkAllActuators();
+ // do it directly on the list at this controller is not connected to anything at this stage
+ cont->GetLinkedSensors().clear();
+ cont->GetLinkedActuators().clear();
// now relink each sensor
for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++)
@@ -908,14 +904,6 @@ void KX_Scene::RemoveObject(class CValue* gameobj)
{
KX_GameObject* newobj = (KX_GameObject*) gameobj;
- /* Invalidate the python reference, since the object may exist in script lists
- * its possible that it wont be automatically invalidated, so do it manually here,
- *
- * if for some reason the object is added back into the scene python can always get a new Proxy
- */
- gameobj->InvalidateProxy();
-
-
// disconnect child from parent
SG_Node* node = newobj->GetSGNode();
@@ -930,12 +918,6 @@ void KX_Scene::RemoveObject(class CValue* gameobj)
//newobj->SetSGNode(0);
}
-void KX_Scene::DelayedReleaseObject(CValue* gameobj)
-{
- m_delayReleaseObjects->Add(gameobj->AddRef());
-}
-
-
void KX_Scene::DelayedRemoveObject(class CValue* gameobj)
{
//KX_GameObject* newobj = (KX_GameObject*) gameobj;
@@ -952,6 +934,13 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
int ret;
KX_GameObject* newobj = (KX_GameObject*) gameobj;
+ /* Invalidate the python reference, since the object may exist in script lists
+ * its possible that it wont be automatically invalidated, so do it manually here,
+ *
+ * if for some reason the object is added back into the scene python can always get a new Proxy
+ */
+ newobj->InvalidateProxy();
+
// keep the blender->game object association up to date
// note that all the replicas of an object will have the same
// blender object, that's why we need to check the game object
@@ -981,7 +970,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
for (SCA_ActuatorList::iterator ita = actuators.begin();
!(ita==actuators.end());ita++)
{
- m_logicmgr->RemoveDestroyedActuator(*ita);
+ m_logicmgr->RemoveActuator(*ita);
}
// the sensors/controllers/actuators must also be released, this is done in ~SCA_IObject
@@ -1464,23 +1453,16 @@ void KX_Scene::LogicEndFrame()
m_logicmgr->EndFrame();
int numobj = m_euthanasyobjects->GetCount();
int i;
- for (i = numobj - 1; i >= 0; i--)
- {
- KX_GameObject* gameobj = (KX_GameObject*)m_euthanasyobjects->GetValue(i);
- // KX_Scene::RemoveObject will also remove the object from this list
- // that's why we start from the end
- this->RemoveObject(gameobj);
- }
+ KX_GameObject* obj;
- numobj= m_delayReleaseObjects->GetCount();
- for (i = numobj-1;i>=0;i--)
+ while ((numobj = m_euthanasyobjects->GetCount()) > 0)
{
- KX_GameObject* gameobj = (KX_GameObject*)m_delayReleaseObjects->GetValue(i);
- // This list is not for object removal, but just object release
- gameobj->Release();
+ // remove the object from this list to make sure we will not hit it again
+ obj = (KX_GameObject*)m_euthanasyobjects->GetValue(numobj-1);
+ m_euthanasyobjects->Remove(numobj-1);
+ obj->Release();
+ RemoveObject(obj);
}
- // empty the list as we have removed all references
- m_delayReleaseObjects->Resize(0);
}
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index 0cfef8b7bd1..128f8d23135 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -108,11 +108,6 @@ protected:
* LogicEndFrame() via a call to RemoveObject().
*/
CListValue* m_euthanasyobjects;
- /**
- * The list of objects that couldn't be released during logic update.
- * for example, AddObject actuator sometimes releases an object that was cached from previous frame
- */
- CListValue* m_delayReleaseObjects;
CListValue* m_objectlist;
CListValue* m_parentlist; // all 'root' parents
@@ -331,8 +326,6 @@ public:
void RemoveObject(CValue* gameobj);
void DelayedRemoveObject(CValue* gameobj);
- void DelayedReleaseObject(CValue* gameobj);
-
int NewRemoveObject(CValue* gameobj);
void ReplaceMesh(CValue* gameobj,
void* meshobj);
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 15eb354ee79..07a880c950b 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -83,17 +83,19 @@ CValue* KX_SoundActuator::GetReplica()
{
KX_SoundActuator* replica = new KX_SoundActuator(*this);
replica->ProcessReplica();
+ return replica;
+};
+
+void KX_SoundActuator::ProcessReplica()
+{
+ SCA_IActuator::ProcessReplica();
if (m_soundObject)
{
SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
- replica->setSoundObject(soundobj);
+ setSoundObject(soundobj);
m_soundScene->AddObject(soundobj);
}
-
- return replica;
-};
-
-
+}
bool KX_SoundActuator::Update(double curtime, bool frame)
{
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h
index ad58087dc57..a7491355667 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.h
+++ b/source/gameengine/Ketsji/KX_SoundActuator.h
@@ -75,6 +75,7 @@ public:
virtual bool Update(double curtime, bool frame);
CValue* GetReplica();
+ void ProcessReplica();
/* -------------------------------------------------------------------- */
/* Python interface --------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 48d4cf59a2b..8ae5fae8fa3 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -100,7 +100,7 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (m_sensors.insert(touchsensor).second)
+ if (m_sensors.AddBack(touchsensor))
// the sensor was effectively inserted, register it
touchsensor->RegisterSumo(this);
}
@@ -108,7 +108,7 @@ void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- if (m_sensors.erase(touchsensor))
+ if (touchsensor->Delink())
// the sensor was effectively removed, unregister it
touchsensor->UnregisterSumo(this);
}
@@ -117,12 +117,10 @@ void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
void KX_TouchEventManager::EndFrame()
{
- set<SCA_ISensor*>::iterator it;
- for ( it = m_sensors.begin();
- !(it==m_sensors.end());it++)
+ SG_DList::iterator<KX_TouchSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
{
- ((KX_TouchSensor*)*it)->EndFrame();
-
+ (*it)->EndFrame();
}
}
@@ -130,12 +128,11 @@ void KX_TouchEventManager::EndFrame()
void KX_TouchEventManager::NextFrame()
{
- if (m_sensors.size() > 0)
+ if (!m_sensors.Empty())
{
- set<SCA_ISensor*>::iterator it;
-
- for (it = m_sensors.begin();!(it==m_sensors.end());++it)
- static_cast<KX_TouchSensor*>(*it)->SynchronizeTransform();
+ SG_DList::iterator<KX_TouchSensor> it(m_sensors);
+ for (it.begin();!it.end();++it)
+ (*it)->SynchronizeTransform();
for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit)
{
@@ -161,7 +158,7 @@ void KX_TouchEventManager::NextFrame()
m_newCollisions.clear();
- for (it = m_sensors.begin();!(it==m_sensors.end());++it)
- (*it)->Activate(m_logicmgr,NULL);
+ for (it.begin();!it.end();++it)
+ (*it)->Activate(m_logicmgr);
}
}
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index f000c16041a..2c02d949c63 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -66,10 +66,10 @@ void KX_TouchSensor::UnregisterToManager()
{
// before unregistering the sensor, make sure we release all references
EndFrame();
- m_eventmgr->RemoveSensor(this);
+ SCA_ISensor::UnregisterToManager();
}
-bool KX_TouchSensor::Evaluate(CValue* event)
+bool KX_TouchSensor::Evaluate()
{
bool result = false;
bool reset = m_reset && m_level;
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index 056b5701937..9c9c6bf5816 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -86,7 +86,7 @@ public:
virtual CValue* GetReplica();
virtual void ProcessReplica();
virtual void SynchronizeTransform();
- virtual bool Evaluate(CValue* event);
+ virtual bool Evaluate();
virtual void Init();
virtual void ReParent(SCA_IObject* parent);
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 672b9e739ba..800da83dc3d 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -83,6 +83,10 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
// if so, store the initial local rotation
// this is needed to revert the effect of the parent inverse node (TBC)
m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+ // use registration mechanism rather than AddRef, it creates zombie objects
+ m_parentobj->RegisterActuator(this);
+ // GetParent did AddRef, undo here
+ m_parentobj->Release();
}
}
}
@@ -189,7 +193,7 @@ KX_TrackToActuator::~KX_TrackToActuator()
if (m_object)
m_object->UnregisterActuator(this);
if (m_parentobj)
- m_parentobj->Release();
+ m_parentobj->UnregisterActuator(this);
} /* end of destructor */
void KX_TrackToActuator::ProcessReplica()
@@ -198,7 +202,7 @@ void KX_TrackToActuator::ProcessReplica()
if (m_object)
m_object->RegisterActuator(this);
if (m_parentobj)
- m_parentobj->AddRef();
+ m_parentobj->RegisterActuator(this);
SCA_IActuator::ProcessReplica();
}
@@ -211,6 +215,11 @@ bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj)
m_object = NULL;
return true;
}
+ if (clientobj == m_parentobj)
+ {
+ m_parentobj = NULL;
+ return true;
+ }
return false;
}
@@ -227,9 +236,9 @@ void KX_TrackToActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
void **h_parobj = (*obj_map)[m_parentobj];
if (h_parobj) {
if (m_parentobj)
- m_parentobj->Release();
+ m_parentobj->UnregisterActuator(this);
m_parentobj= (KX_GameObject*)(*h_parobj);
- m_parentobj->AddRef();
+ m_parentobj->RegisterActuator(this);
}
}
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index 6563d0446eb..4b0ad083473 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -62,8 +62,8 @@ PyTypeObject KX_VertexProxy::Type = {
PyParentObject KX_VertexProxy::Parents[] = {
&KX_VertexProxy::Type,
- &SCA_IObject::Type,
&CValue::Type,
+ &PyObjectPlus::Type,
NULL
};
@@ -162,11 +162,11 @@ KX_VertexProxy::py_getattro(PyObject *attr)
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
- py_getattro_up(SCA_IObject);
+ py_getattro_up(CValue);
}
PyObject* KX_VertexProxy::py_getattro_dict() {
- py_getattro_dict_up(SCA_IObject);
+ py_getattro_dict_up(CValue);
}
int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
@@ -322,7 +322,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
}
}
- return SCA_IObject::py_setattro(attr, pyvalue);
+ return CValue::py_setattro(attr, pyvalue);
}
KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
@@ -343,8 +343,8 @@ CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) {
STR_String sVertexName="vertex";
const STR_String & KX_VertexProxy::GetText() {return sVertexName;};
double KX_VertexProxy::GetNumber() { return -1;}
-STR_String KX_VertexProxy::GetName() { return sVertexName;}
-void KX_VertexProxy::SetName(STR_String) { };
+STR_String& KX_VertexProxy::GetName() { return sVertexName;}
+void KX_VertexProxy::SetName(const char *) { };
CValue* KX_VertexProxy::GetReplica() { return NULL;}
// stuff for python integration
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h
index 81dd0d222a7..42db5fbc322 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.h
+++ b/source/gameengine/Ketsji/KX_VertexProxy.h
@@ -31,7 +31,7 @@
#include "SCA_IObject.h"
-class KX_VertexProxy : public SCA_IObject
+class KX_VertexProxy : public CValue
{
Py_Header;
protected:
@@ -47,8 +47,8 @@ public:
CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
const STR_String & GetText();
double GetNumber();
- STR_String GetName();
- void SetName(STR_String name); // Set the name of the value
+ STR_String& GetName();
+ void SetName(const char *name); // Set the name of the value
CValue* GetReplica();