synched with trunk at revision 32129
[blender.git] / source / gameengine / Ketsji / KX_GameObject.cpp
index e5fb78daceb3b93444543335368458113cf51e56..e955c344f0ab84c0b03f9b144f47f6dcdcb3d9c4 100644 (file)
@@ -34,7 +34,7 @@ typedef unsigned __int64 uint_ptr;
 typedef unsigned long uint_ptr;
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(FREE_WINDOWS)
 // This warning tells us about truncation of __long__ stl-generated names.
 // It can occasionally cause DevStudio to have internal compiler warnings.
 #pragma warning( disable : 4786 )     
@@ -67,6 +67,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 */
 
@@ -101,6 +102,7 @@ KX_GameObject::KX_GameObject(
        m_pGraphicController(NULL),
        m_xray(false),
        m_pHitObject(NULL),
+       m_pObstacleSimulation(NULL),
        m_isDeformable(false)
 #ifndef DISABLE_PYTHON
        , m_attr_dict(NULL)
@@ -148,6 +150,12 @@ KX_GameObject::~KX_GameObject()
        {
                delete m_pGraphicController;
        }
+
+       if (m_pObstacleSimulation)
+       {
+               m_pObstacleSimulation->DestroyObstacleForObj(this);
+       }
+
 #ifndef DISABLE_PYTHON
        if (m_attr_dict) {
                PyDict_Clear(m_attr_dict); /* incase of circular refs or other weired cases */
@@ -348,6 +356,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);
+       }
+
 #ifndef DISABLE_PYTHON
        if(m_attr_dict)
                m_attr_dict= PyDict_Copy(m_attr_dict);
@@ -846,7 +862,7 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
        {       
                case 0: //x axis
                        ori.setValue(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
-                       if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot?
+                       if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector parallel to the pivot?
                                ori.setValue(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
                        if (fac == 1.0) {
                                x = vect;
@@ -1329,7 +1345,8 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
                        self->NodeUpdateGS(0.f);
                        break;
                case MATHUTILS_VEC_CB_SCALE_GLOBAL:
-                       break;
+                       PyErr_SetString(PyExc_AttributeError, "KX_GameObject.worldScale is read-only");
+                       return 0;
                case MATHUTILS_VEC_CB_INERTIA_LOCAL:
                        /* read only */
                        break;
@@ -1355,12 +1372,9 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
 
 static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index)
 {
-       float f[4];
        /* lazy, avoid repeteing the case statement */
        if(!mathutils_kxgameob_vector_get(bmo, subtype))
                return 0;
-       
-       bmo->data[index]= f[index];
        return 1;
 }
 
@@ -1373,9 +1387,7 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype,
                return 0;
        
        bmo->data[index]= f;
-       mathutils_kxgameob_vector_set(bmo, subtype);
-       
-       return 1;
+       return mathutils_kxgameob_vector_set(bmo, subtype);
 }
 
 Mathutils_Callback mathutils_kxgameob_vector_cb = {
@@ -1742,6 +1754,8 @@ PySequenceMethods KX_GameObject::Sequence = {
        NULL,           /* sq_ass_item */
        NULL,           /* sq_ass_slice */
        (objobjproc)Seq_Contains,       /* sq_contains */
+       (binaryfunc) NULL, /* sq_inplace_concat */
+       (ssizeargfunc) NULL, /* sq_inplace_repeat */
 };
 
 PyTypeObject KX_GameObject::Type = {
@@ -2736,7 +2750,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
        KX_RayCast::Callback<KX_GameObject> callback(this,spc);
        KX_RayCast::RayTest(pe, fromPoint, toPoint, callback);
 
-    if (m_pHitObject)
+       if (m_pHitObject)
                return m_pHitObject->GetProxy();
        
        Py_RETURN_NONE;