synched with trunk at revision 36569
[blender.git] / source / gameengine / Ketsji / KX_GameObject.cpp
index bd59949..d4ef462 100644 (file)
@@ -73,6 +73,7 @@ typedef unsigned long uint_ptr;
 #include "SCA_ISensor.h"
 #include "SCA_IController.h"
 #include "NG_NetworkScene.h" //Needed for sendMessage()
+#include "KX_ObstacleSimulation.h"
 
 #include "PyObjectPlus.h" /* python stuff */
 
@@ -107,7 +108,8 @@ KX_GameObject::KX_GameObject(
        m_pGraphicController(NULL),
        m_xray(false),
        m_pHitObject(NULL),
-       m_isDeformable(false)
+       m_isDeformable(false),
+       m_pObstacleSimulation(NULL)
 #ifdef WITH_PYTHON
        , m_attr_dict(NULL)
 #endif
@@ -154,9 +156,15 @@ KX_GameObject::~KX_GameObject()
        {
                delete m_pGraphicController;
        }
+
+       if (m_pObstacleSimulation)
+       {
+               m_pObstacleSimulation->DestroyObstacleForObj(this);
+       }
+
 #ifdef WITH_PYTHON
        if (m_attr_dict) {
-               PyDict_Clear(m_attr_dict); /* incase of circular refs or other weired cases */
+               PyDict_Clear(m_attr_dict); /* incase of circular refs or other weird cases */
                /* Py_CLEAR: Py_DECREF's and NULL's */
                Py_CLEAR(m_attr_dict);
        }
@@ -355,6 +363,14 @@ void KX_GameObject::ProcessReplica()
        m_pClient_info->m_gameobject = this;
        m_state = 0;
 
+       KX_Scene* scene = KX_GetActiveScene();
+       KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation();
+       struct Object* blenderobject = GetBlenderObject();
+       if (obssimulation && (blenderobject->gameflag & OB_HASOBSTACLE))
+       {
+               obssimulation->AddObstacleForObj(this);
+       }
+
 #ifdef WITH_PYTHON
        if(m_attr_dict)
                m_attr_dict= PyDict_Copy(m_attr_dict);
@@ -1224,7 +1240,7 @@ CListValue* KX_GameObject::GetChildrenRecursive()
 /* ---------------------------------------------------------------------
  * Some stuff taken from the header
  * --------------------------------------------------------------------- */
-void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter)
+void KX_GameObject::Relink(CTR_Map<CTR_HashedPtr, void*> *map_parameter)
 {
        // we will relink the sensors and actuators that use object references
        // if the object is part of the replicated hierarchy, use the new
@@ -1368,7 +1384,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
 static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index)
 {
        /* lazy, avoid repeteing the case statement */
-       if(!mathutils_kxgameob_vector_get(bmo, subtype))
+       if(mathutils_kxgameob_vector_get(bmo, subtype) == -1)
                return -1;
        return 0;
 }
@@ -1378,7 +1394,7 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype,
        float f= bmo->data[index];
        
        /* lazy, avoid repeteing the case statement */
-       if(!mathutils_kxgameob_vector_get(bmo, subtype))
+       if(mathutils_kxgameob_vector_get(bmo, subtype) == -1)
                return -1;
        
        bmo->data[index]= f;