svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22875:22935
authorCampbell Barton <ideasman42@gmail.com>
Tue, 1 Sep 2009 18:49:33 +0000 (18:49 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 1 Sep 2009 18:49:33 +0000 (18:49 +0000)
Note, missing r22897, schlaile
source/blender/src/hddaudio.c

1  2 
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_PolyProxy.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Rasterizer/RAS_MaterialBucket.h
source/gameengine/Rasterizer/RAS_Polygon.h

index eeff39ab9b10fbb20d7ee186abb9e63475620efd,bfafce1dd40776d29b8aa4fada1ee6a50ba9d6f0..8193aa8c37bca1097b49ffa1cee11ca8d8ae4aea
@@@ -87,8 -87,10 +87,8 @@@ static MT_Matrix3x3 dummy_orientation 
  
  KX_GameObject::KX_GameObject(
        void* sgReplicationInfo,
 -      SG_Callbacks callbacks,
 -      PyTypeObject* T
 -) : 
 -      SCA_IObject(T),
 +      SG_Callbacks callbacks)
 +      : SCA_IObject(),
        m_bDyna(false),
        m_layer(0),
        m_pBlenderObject(NULL),
@@@ -464,7 -466,7 +464,7 @@@ void KX_GameObject::AddMeshUser(
        double* fl = GetOpenGLMatrixPtr()->getPointer();
  
        SG_QList::iterator<RAS_MeshSlot> mit(m_meshSlots);
 -      RAS_MeshSlot* ms;
 +//    RAS_MeshSlot* ms;
        for(mit.begin(); !mit.end(); ++mit)
        {
                (*mit)->m_OpenGLMatrix = fl;
@@@ -981,17 -983,7 +981,17 @@@ void KX_GameObject::NodeSetLocalOrienta
        GetSGNode()->SetLocalOrientation(rot);
  }
  
 +void KX_GameObject::NodeSetGlobalOrientation(const MT_Matrix3x3& rot)
 +{
 +      // check on valid node in case a python controller holds a reference to a deleted object
 +      if (!GetSGNode())
 +              return;
  
 +      if (GetSGNode()->GetSGParent())
 +              GetSGNode()->SetLocalOrientation(GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
 +      else
 +              GetSGNode()->SetLocalOrientation(rot);
 +}
  
  void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
  {
@@@ -1070,13 -1062,7 +1070,13 @@@ const MT_Matrix3x3& KX_GameObject::Node
        return GetSGNode()->GetWorldOrientation();
  }
  
 -
 +const MT_Matrix3x3& KX_GameObject::NodeGetLocalOrientation() const
 +{
 +      // check on valid node in case a python controller holds a reference to a deleted object
 +      if (!GetSGNode())
 +              return dummy_orientation;
 +      return GetSGNode()->GetLocalOrientation();
 +}
  
  const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
  {
        return GetSGNode()->GetWorldScaling();
  }
  
 +const MT_Vector3& KX_GameObject::NodeGetLocalScaling() const
 +{
 +      // check on valid node in case a python controller holds a reference to a deleted object
 +      if (!GetSGNode())
 +              return dummy_scaling;
  
 +      return GetSGNode()->GetLocalScale();
 +}
  
  const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
  {
                return dummy_point;
  }
  
 +const MT_Point3& KX_GameObject::NodeGetLocalPosition() const
 +{
 +      // check on valid node in case a python controller holds a reference to a deleted object
 +      if (GetSGNode())
 +              return GetSGNode()->GetLocalPosition();
 +      else
 +              return dummy_point;
 +}
 +
 +
  /* Suspend/ resume: for the dynamic behaviour, there is a simple
   * method. For the residual motion, there is not. I wonder what the
   * correct solution is for Sumo. Remove from the motion-update tree?
@@@ -1182,181 -1151,6 +1182,181 @@@ CListValue* KX_GameObject::GetChildrenR
        return list;
  }
  
 +#ifdef USE_MATHUTILS
 +
 +/* These require an SGNode */
 +#define MATHUTILS_VEC_CB_POS_LOCAL 1
 +#define MATHUTILS_VEC_CB_POS_GLOBAL 2
 +#define MATHUTILS_VEC_CB_SCALE_LOCAL 3
 +#define MATHUTILS_VEC_CB_SCALE_GLOBAL 4
 +#define MATHUTILS_VEC_CB_INERTIA_LOCAL 5
 +
 +static int mathutils_kxgameob_vector_cb_index= -1; /* index for our callbacks */
 +
 +static int mathutils_kxgameob_generic_check(PyObject *self_v)
 +{
 +      KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 +      if(self==NULL)
 +              return 0;
 +      
 +      return 1;
 +}
 +
 +static int mathutils_kxgameob_vector_get(PyObject *self_v, int subtype, float *vec_from)
 +{
 +      KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 +      if(self==NULL)
 +              return 0;
 +      
 +      switch(subtype) {
 +              case MATHUTILS_VEC_CB_POS_LOCAL:
 +                      self->NodeGetLocalPosition().getValue(vec_from);
 +                      break;
 +              case MATHUTILS_VEC_CB_POS_GLOBAL:
 +                      self->NodeGetWorldPosition().getValue(vec_from);
 +                      break;
 +              case MATHUTILS_VEC_CB_SCALE_LOCAL:
 +                      self->NodeGetLocalScaling().getValue(vec_from);
 +                      break;
 +              case MATHUTILS_VEC_CB_SCALE_GLOBAL:
 +                      self->NodeGetWorldScaling().getValue(vec_from);
 +                      break;
 +              case MATHUTILS_VEC_CB_INERTIA_LOCAL:
 +                      if(!self->GetPhysicsController()) return 0;
 +                      self->GetPhysicsController()->GetLocalInertia().getValue(vec_from);
 +                      break;
 +      }
 +      
 +      return 1;
 +}
 +
 +static int mathutils_kxgameob_vector_set(PyObject *self_v, int subtype, float *vec_to)
 +{
 +      KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 +      if(self==NULL)
 +              return 0;
 +      
 +      switch(subtype) {
 +              case MATHUTILS_VEC_CB_POS_LOCAL:
 +                      self->NodeSetLocalPosition(MT_Point3(vec_to));
 +                      self->NodeUpdateGS(0.f);
 +                      break;
 +              case MATHUTILS_VEC_CB_POS_GLOBAL:
 +                      self->NodeSetWorldPosition(MT_Point3(vec_to));
 +                      self->NodeUpdateGS(0.f);
 +                      break;
 +              case MATHUTILS_VEC_CB_SCALE_LOCAL:
 +                      self->NodeSetLocalScale(MT_Point3(vec_to));
 +                      self->NodeUpdateGS(0.f);
 +                      break;
 +              case MATHUTILS_VEC_CB_SCALE_GLOBAL:
 +                      break;
 +              case MATHUTILS_VEC_CB_INERTIA_LOCAL:
 +                      /* read only */
 +                      break;
 +      }
 +      
 +      return 1;
 +}
 +
 +static int mathutils_kxgameob_vector_get_index(PyObject *self_v, int subtype, float *vec_from, int index)
 +{
 +      float f[4];
 +      /* lazy, avoid repeteing the case statement */
 +      if(!mathutils_kxgameob_vector_get(self_v, subtype, f))
 +              return 0;
 +      
 +      vec_from[index]= f[index];
 +      return 1;
 +}
 +
 +static int mathutils_kxgameob_vector_set_index(PyObject *self_v, int subtype, float *vec_to, int index)
 +{
 +      float f= vec_to[index];
 +      
 +      /* lazy, avoid repeteing the case statement */
 +      if(!mathutils_kxgameob_vector_get(self_v, subtype, vec_to))
 +              return 0;
 +      
 +      vec_to[index]= f;
 +      mathutils_kxgameob_vector_set(self_v, subtype, vec_to);
 +      
 +      return 1;
 +}
 +
 +Mathutils_Callback mathutils_kxgameob_vector_cb = {
 +      mathutils_kxgameob_generic_check,
 +      mathutils_kxgameob_vector_get,
 +      mathutils_kxgameob_vector_set,
 +      mathutils_kxgameob_vector_get_index,
 +      mathutils_kxgameob_vector_set_index
 +};
 +
 +/* Matrix */
 +#define MATHUTILS_MAT_CB_ORI_LOCAL 1
 +#define MATHUTILS_MAT_CB_ORI_GLOBAL 2
 +
 +static int mathutils_kxgameob_matrix_cb_index= -1; /* index for our callbacks */
 +
 +static int mathutils_kxgameob_matrix_get(PyObject *self_v, int subtype, float *mat_from)
 +{
 +      KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 +      if(self==NULL)
 +              return 0;
 +      
 +      switch(subtype) {
 +              case MATHUTILS_MAT_CB_ORI_LOCAL:
 +                      self->NodeGetLocalOrientation().getValue3x3(mat_from);
 +                      break;
 +              case MATHUTILS_MAT_CB_ORI_GLOBAL:
 +                      self->NodeGetWorldOrientation().getValue3x3(mat_from);
 +                      break;
 +      }
 +      
 +      return 1;
 +}
 +
 +
 +static int mathutils_kxgameob_matrix_set(PyObject *self_v, int subtype, float *mat_to)
 +{
 +      KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 +      if(self==NULL)
 +              return 0;
 +      
 +      MT_Matrix3x3 mat3x3;
 +      switch(subtype) {
 +              case MATHUTILS_MAT_CB_ORI_LOCAL:
 +                      mat3x3.setValue3x3(mat_to);
 +                      self->NodeSetLocalOrientation(mat3x3);
 +                      self->NodeUpdateGS(0.f);
 +                      break;
 +              case MATHUTILS_MAT_CB_ORI_GLOBAL:
 +                      mat3x3.setValue3x3(mat_to);
 +                      self->NodeSetLocalOrientation(mat3x3);
 +                      self->NodeUpdateGS(0.f);
 +                      break;
 +      }
 +      
 +      return 1;
 +}
 +
 +Mathutils_Callback mathutils_kxgameob_matrix_cb = {
 +      mathutils_kxgameob_generic_check,
 +      mathutils_kxgameob_matrix_get,
 +      mathutils_kxgameob_matrix_set,
 +      NULL,
 +      NULL
 +};
 +
 +
 +void KX_GameObject_Mathutils_Callback_Init(void)
 +{
 +      // register mathutils callbacks, ok to run more then once.
 +      mathutils_kxgameob_vector_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_vector_cb);
 +      mathutils_kxgameob_matrix_cb_index= Mathutils_RegisterCallback(&mathutils_kxgameob_matrix_cb);
 +}
 +
 +#endif // USE_MATHUTILS
  
  /* ------- python stuff ---------------------------------------------------*/
  
@@@ -1383,8 -1177,8 +1383,8 @@@ PyMethodDef KX_GameObject::Methods[] = 
        {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS},
        {"setOcclusion",(PyCFunction) KX_GameObject::sPySetOcclusion, METH_VARARGS},
        {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS},
 -      {"getChildren", (PyCFunction)KX_GameObject::sPyGetChildren,METH_NOARGS},
 -      {"getChildrenRecursive", (PyCFunction)KX_GameObject::sPyGetChildrenRecursive,METH_NOARGS},
 +
 +
        {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS},
        {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS},
        {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_VARARGS},
        KX_PYMETHODTABLE(KX_GameObject, sendMessage),
        
        // dict style access for props
 -      {"has_key",(PyCFunction) KX_GameObject::sPyhas_key, METH_O},
        {"get",(PyCFunction) KX_GameObject::sPyget, METH_VARARGS},
        
 -      // deprecated
 -      {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS},
 -      {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O},
 -      {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O},
 -      {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS},
 -      {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O},
 -      {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS},
 -      {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_O},
 -      {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_NOARGS},
 -      {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_NOARGS},
 -      {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_NOARGS},
 -      {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS},
        {NULL,NULL} //Sentinel
  };
  
@@@ -1502,10 -1309,17 +1502,10 @@@ PyObject* KX_GameObject::PyReinstancePh
        Py_RETURN_FALSE;
  }
  
 -
 -PyObject* KX_GameObject::PyGetPosition()
 -{
 -      ShowDeprecationWarning("getPosition()", "the position property");
 -      return PyObjectFrom(NodeGetWorldPosition());
 -}
 -
  static PyObject *Map_GetItem(PyObject *self_v, PyObject *item)
  {
        KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 -      const char *attr_str= PyString_AsString(item);
 +      const char *attr_str= _PyUnicode_AsString(item);
        CValue* resultattr;
        PyObject* pyconvert;
        
  static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
  {
        KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v);
 -      const char *attr_str= PyString_AsString(key);
 +      const char *attr_str= _PyUnicode_AsString(key);
        if(attr_str==NULL)
                PyErr_Clear();
        
                int set= 0;
                
                /* as CValue */
 -              if(attr_str && BGE_PROXY_CHECK_TYPE(val)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
 +              if(attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
                {
                        CValue* vallie = self->ConvertPythonToValue(val, ""); /* error unused */
                        
@@@ -1633,7 -1447,7 +1633,7 @@@ static int Seq_Contains(PyObject *self_
                return -1;
        }
        
 -      if(PyString_Check(value) && self->GetProperty(PyString_AsString(value)))
 +      if(PyUnicode_Check(value) && self->GetProperty(_PyUnicode_AsString(value)))
                return 1;
        
        if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value))
@@@ -1661,37 -1475,50 +1661,37 @@@ PySequenceMethods KX_GameObject::Sequen
  };
  
  PyTypeObject KX_GameObject::Type = {
 -#if (PY_VERSION_HEX >= 0x02060000)
        PyVarObject_HEAD_INIT(NULL, 0)
 -#else
 -      /* python 2.5 and below */
 -      PyObject_HEAD_INIT( NULL )  /* required py macro */
 -      0,                          /* ob_size */
 -#endif
 -              "KX_GameObject",
 -              sizeof(PyObjectPlus_Proxy),
 -              0,
 -              py_base_dealloc,
 -              0,
 -              0,
 -              0,
 -              0,
 -              py_base_repr,
 -              0,
 -              &Sequence,
 -              &Mapping,
 -              0,0,0,
 -              py_base_getattro,
 -              py_base_setattro,
 -              0,
 -              Py_TPFLAGS_DEFAULT,
 -              0,0,0,0,0,0,0,
 -              Methods
 -};
 -
 -
 -
 -
 -
 -
 -PyParentObject KX_GameObject::Parents[] = {
 -      &KX_GameObject::Type,
 -              &SCA_IObject::Type,
 -              &CValue::Type,
 -              NULL
 +      "KX_GameObject",
 +      sizeof(PyObjectPlus_Proxy),
 +      0,
 +      py_base_dealloc,
 +      0,
 +      0,
 +      0,
 +      0,
 +      py_base_repr,
 +      0,
 +      &Sequence,
 +      &Mapping,
 +      0,0,0,
 +      NULL,
 +      NULL,
 +      0,
 +      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 +      0,0,0,0,0,0,0,
 +      Methods,
 +      0,
 +      0,
 +      &SCA_IObject::Type,
 +      0,0,0,0,0,0,
 +      py_base_new
  };
  
  PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 -      return PyString_FromString(self->GetName().ReadPtr());
 +      return PyUnicode_FromString(self->GetName().ReadPtr());
  }
  
  PyObject* KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@@ -1797,12 -1624,8 +1797,12 @@@ int KX_GameObject::pyattr_set_visible(v
  
  PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        return PyObjectFrom(self->NodeGetWorldPosition());
 +#endif
  }
  
  int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
  
  PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS  
 +      return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL);
 +#else 
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 -      if (self->GetSGNode())
 -              return PyObjectFrom(self->GetSGNode()->GetLocalPosition());
 -      else
 -              return PyObjectFrom(dummy_point);
 +      return PyObjectFrom(self->NodeGetLocalPosition());
 +#endif
  }
  
  int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
  
  PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        if (self->GetPhysicsController())
 -      {
                return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia());
 -      }
        return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
 +#endif
  }
  
  PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        return PyObjectFrom(self->NodeGetWorldOrientation());
 +#endif
  }
  
  int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
        if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, "))
                return PY_SET_ATTR_FAIL;
  
 -      if (self->GetSGNode() && self->GetSGNode()->GetSGParent()) {
 -              self->NodeSetLocalOrientation(self->GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
 -      }
 -      else {
 -              self->NodeSetLocalOrientation(rot);
 -      }
 +      self->NodeSetGlobalOrientation(rot);
        
        self->NodeUpdateGS(0.f);
        return PY_SET_ATTR_SUCCESS;
  
  PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 -      if (self->GetSGNode())
 -              return PyObjectFrom(self->GetSGNode()->GetLocalOrientation());
 -      else
 -              return PyObjectFrom(dummy_orientation);
 +      return PyObjectFrom(self->NodeGetLocalOrientation());
 +#endif
  }
  
  int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
  
  PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        return PyObjectFrom(self->NodeGetWorldScaling());
 +#endif
  }
  
  PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
  {
 +#ifdef USE_MATHUTILS
 +      return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL);
 +#else
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 -      if (self->GetSGNode())
 -              return PyObjectFrom(self->GetSGNode()->GetLocalScale());
 -      else
 -              return PyObjectFrom(dummy_scaling);
 +      return PyObjectFrom(self->NodeGetLocalScaling());
 +#endif
  }
  
  int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@@ -1964,13 -1779,13 +1964,13 @@@ PyObject* KX_GameObject::pyattr_get_sta
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        int state = 0;
        state |= self->GetState();
 -      return PyInt_FromLong(state);
 +      return PyLong_FromSsize_t(state);
  }
  
  int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
  {
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
 -      int state_i = PyInt_AsLong(value);
 +      int state_i = PyLong_AsSsize_t(value);
        unsigned int state = 0;
        
        if (state_i == -1 && PyErr_Occurred()) {
@@@ -2041,6 -1856,128 +2041,6 @@@ PyObject* KX_GameObject::pyattr_get_att
        return self->m_attr_dict;
  }
  
 -/* We need these because the macros have a return in them */
 -PyObject* KX_GameObject::py_getattro__internal(PyObject *attr)
 -{
 -      py_getattro_up(SCA_IObject);
 -}
 -
 -int KX_GameObject::py_setattro__internal(PyObject *attr, PyObject *value)     // py_setattro method
 -{
 -      py_setattro_up(SCA_IObject);
 -}
 -
 -
 -PyObject* KX_GameObject::py_getattro(PyObject *attr)
 -{
 -      PyObject *object= py_getattro__internal(attr);
 -      
 -      if (object==NULL && m_attr_dict)
 -      {
 -              /* backup the exception incase the attr doesnt exist in the dict either */
 -              PyObject *err_type, *err_value, *err_tb;
 -              PyErr_Fetch(&err_type, &err_value, &err_tb);
 -              
 -              object= PyDict_GetItem(m_attr_dict, attr);
 -              if (object) {
 -                      Py_INCREF(object);
 -                      
 -                      PyErr_Clear();
 -                      Py_XDECREF( err_type );
 -                      Py_XDECREF( err_value );
 -                      Py_XDECREF( err_tb );
 -              }
 -              else {
 -                      PyErr_Restore(err_type, err_value, err_tb); /* use the error from the parent function */
 -              }
 -      }
 -      return object;
 -}
 -
 -PyObject* KX_GameObject::py_getattro_dict() {
 -      //py_getattro_dict_up(SCA_IObject);
 -      PyObject *dict= py_getattr_dict(SCA_IObject::py_getattro_dict(), Type.tp_dict);
 -      if(dict==NULL)
 -              return NULL;
 -      
 -      /* normally just return this but KX_GameObject has some more items */
 -
 -      
 -      /* Not super fast getting as a list then making into dict keys but its only for dir() */
 -      PyObject *list= ConvertKeysToPython();
 -      if(list)
 -      {
 -              int i;
 -              for(i=0; i<PyList_Size(list); i++)
 -                      PyDict_SetItem(dict, PyList_GET_ITEM(list, i), Py_None);
 -      }
 -      else
 -              PyErr_Clear();
 -      
 -      Py_DECREF(list);
 -      
 -      /* Add m_attr_dict if we have it */
 -      if(m_attr_dict)
 -              PyDict_Update(dict, m_attr_dict);
 -      
 -      return dict;
 -}
 -
 -int KX_GameObject::py_setattro(PyObject *attr, PyObject *value)       // py_setattro method
 -{
 -      int ret= py_setattro__internal(attr, value);
 -      
 -      if (ret==PY_SET_ATTR_SUCCESS) {
 -              /* remove attribute in our own dict to avoid double ups */
 -              /* NOTE: Annoying that we also do this for setting builtin attributes like mass and visibility :/ */
 -              if (m_attr_dict) {
 -                      if (PyDict_DelItem(m_attr_dict, attr) != 0)
 -                              PyErr_Clear();
 -              }
 -      }
 -      
 -      if (ret==PY_SET_ATTR_COERCE_FAIL) {
 -              /* CValue attribute exists, remove CValue and add PyDict value */
 -              RemoveProperty(PyString_AsString(attr));
 -              ret= PY_SET_ATTR_MISSING;
 -      }
 -      
 -      if (ret==PY_SET_ATTR_MISSING) {
 -              /* Lazy initialization */
 -              if (m_attr_dict==NULL)
 -                      m_attr_dict = PyDict_New();
 -              
 -              if (PyDict_SetItem(m_attr_dict, attr, value)==0) {
 -                      PyErr_Clear();
 -                      ret= PY_SET_ATTR_SUCCESS;
 -              }
 -              else {
 -                      PyErr_Format(PyExc_AttributeError, "gameOb.myAttr = value: KX_GameObject, failed assigning value to internal dictionary");
 -                      ret= PY_SET_ATTR_FAIL;
 -              }
 -      }
 -      
 -      return ret;     
 -}
 -
 -
 -int   KX_GameObject::py_delattro(PyObject *attr)
 -{
 -      ShowDeprecationWarning("del ob.attr", "del ob['attr'] for user defined properties");
 -      
 -      char *attr_str= PyString_AsString(attr); 
 -      
 -      if (RemoveProperty(attr_str)) // XXX - should call CValues instead but its only 2 lines here
 -              return PY_SET_ATTR_SUCCESS;
 -      
 -      if (m_attr_dict && (PyDict_DelItem(m_attr_dict, attr) == 0))
 -              return PY_SET_ATTR_SUCCESS;
 -      
 -      PyErr_Format(PyExc_AttributeError, "del gameOb.myAttr: KX_GameObject, attribute \"%s\" dosnt exist", attr_str);
 -      return PY_SET_ATTR_MISSING;
 -}
 -
 -
  PyObject* KX_GameObject::PyApplyForce(PyObject* args)
  {
        int local = 0;
@@@ -2181,6 -2118,41 +2181,6 @@@ PyObject* KX_GameObject::PySetOcclusion
        Py_RETURN_NONE;
  }
  
 -PyObject* KX_GameObject::PyGetVisible()
 -{
 -      ShowDeprecationWarning("getVisible()", "the visible property");
 -      return PyInt_FromLong(m_bVisible);      
 -}
 -
 -PyObject* KX_GameObject::PyGetState()
 -{
 -      ShowDeprecationWarning("getState()", "the state property");
 -      int state = 0;
 -      state |= GetState();
 -      return PyInt_FromLong(state);
 -}
 -
 -PyObject* KX_GameObject::PySetState(PyObject* value)
 -{
 -      ShowDeprecationWarning("setState()", "the state property");
 -      int state_i = PyInt_AsLong(value);
 -      unsigned int state = 0;
 -      
 -      if (state_i == -1 && PyErr_Occurred()) {
 -              PyErr_SetString(PyExc_TypeError, "expected an int bit field");
 -              return NULL;
 -      }
 -      
 -      state |= state_i;
 -      if ((state & ((1<<30)-1)) == 0) {
 -              PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)");
 -              return NULL;
 -      }
 -      SetState(state);
 -      
 -      Py_RETURN_NONE;
 -}
 -
  PyObject* KX_GameObject::PyGetVelocity(PyObject* args)
  {
        // only can get the velocity if we have a physics object connected to us...
        }
  }
  
 -
 -
 -PyObject* KX_GameObject::PyGetMass()
 -{
 -      ShowDeprecationWarning("getMass()", "the mass property");
 -      return PyFloat_FromDouble((GetPhysicsController() != NULL) ? GetPhysicsController()->GetMass() : 0.0f);
 -}
 -
  PyObject* KX_GameObject::PyGetReactionForce()
  {
        // only can get the velocity if we have a physics object connected to us...
@@@ -2235,6 -2215,18 +2235,6 @@@ PyObject* KX_GameObject::PyDisableRigid
  }
  
  
 -
 -PyObject* KX_GameObject::PyGetParent()
 -{
 -      ShowDeprecationWarning("getParent()", "the parent property");
 -      KX_GameObject* parent = this->GetParent();
 -      if (parent) {
 -              parent->Release(); /* self->GetParent() AddRef's */
 -              return parent->GetProxy();
 -      }
 -      Py_RETURN_NONE;
 -}
 -
  PyObject* KX_GameObject::PySetParent(PyObject* args)
  {
        KX_Scene *scene = KX_GetActiveScene();
@@@ -2260,6 -2252,41 +2260,6 @@@ PyObject* KX_GameObject::PyRemoveParent
        Py_RETURN_NONE;
  }
  
 -PyObject* KX_GameObject::PyGetChildren()
 -{
 -      ShowDeprecationWarning("getChildren()", "the children property");
 -      
 -      return GetChildren()->NewProxy(true);
 -}
 -
 -PyObject* KX_GameObject::PyGetChildrenRecursive()
 -{
 -      ShowDeprecationWarning("getChildrenRecursive()", "the childrenRecursive property");
 -      
 -      return GetChildrenRecursive()->NewProxy(true);
 -}
 -
 -PyObject* KX_GameObject::PyGetMesh(PyObject* args)
 -{
 -      ShowDeprecationWarning("getMesh()", "the meshes property (now a list of meshes)");
 -      
 -      int mesh = 0;
 -
 -      if (!PyArg_ParseTuple(args, "|i:getMesh", &mesh))
 -              return NULL; // python sets a simple error
 -      
 -      if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0)
 -      {
 -              KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]);
 -              return meshproxy->NewProxy(true); // XXX Todo Python own.
 -      }
 -      
 -      Py_RETURN_NONE;
 -}
 -
 -
 -
 -
  
  PyObject* KX_GameObject::PySetCollisionMargin(PyObject* value)
  {
@@@ -2323,6 -2350,29 +2323,6 @@@ PyObject* KX_GameObject::PyRestoreDynam
  }
  
  
 -
 -PyObject* KX_GameObject::PyGetOrientation() //keywords
 -{
 -      ShowDeprecationWarning("getOrientation()", "the orientation property");
 -      return PyObjectFrom(NodeGetWorldOrientation());
 -}
 -
 -
 -
 -PyObject* KX_GameObject::PySetOrientation(PyObject* value)
 -{
 -      ShowDeprecationWarning("setOrientation()", "the orientation property");
 -      MT_Matrix3x3 rot;
 -      
 -      /* if value is not a sequence PyOrientationTo makes an error */
 -      if (!PyOrientationTo(value, rot, "gameOb.setOrientation(sequence): KX_GameObject, "))
 -              return NULL;
 -
 -      NodeSetLocalOrientation(rot);
 -      NodeUpdateGS(0.f);
 -      Py_RETURN_NONE;
 -}
 -
  PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* args)
  {
        PyObject* pyvect;
@@@ -2355,6 -2405,33 +2355,6 @@@ PyObject* KX_GameObject::PyGetAxisVect(
        return NULL;
  }
  
 -PyObject* KX_GameObject::PySetPosition(PyObject* value)
 -{
 -      ShowDeprecationWarning("setPosition()", "the localPosition property");
 -      MT_Point3 pos;
 -      if (PyVecTo(value, pos))
 -      {
 -              NodeSetLocalPosition(pos);
 -              NodeUpdateGS(0.f);
 -              Py_RETURN_NONE;
 -      }
 -
 -      return NULL;
 -}
 -
 -PyObject* KX_GameObject::PySetWorldPosition(PyObject* value)
 -{
 -      ShowDeprecationWarning("setWorldPosition()", "the worldPosition property");
 -      MT_Point3 pos;
 -      if (PyVecTo(value, pos))
 -      {
 -              NodeSetWorldPosition(pos);
 -              NodeUpdateGS(0.f);
 -              Py_RETURN_NONE;
 -      }
 -
 -      return NULL;
 -}
  
  PyObject* KX_GameObject::PyGetPhysicsId()
  {
        {
                physid= (uint_ptr)ctrl->GetUserData();
        }
 -      return PyInt_FromLong((long)physid);
 +      return PyLong_FromSsize_t((long)physid);
  }
  
  PyObject* KX_GameObject::PyGetPropertyNames()
@@@ -2716,7 -2793,7 +2716,7 @@@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObjec
        char* to = (char *)"";
        const STR_String& from = GetName();
  
-       if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to))
+       if (!PyArg_ParseTuple(args, "s|ss:sendMessage", &subject, &body, &to))
                return NULL;
        
        scene->GetNetworkScene()->SendMessage(to, from, subject, body);
@@@ -2737,8 -2814,8 +2737,8 @@@ PyObject* KX_GameObject::Pyget(PyObjec
                return NULL;
        
        
 -      if(PyString_Check(key)) {
 -              CValue *item = GetProperty(PyString_AsString(key));
 +      if(PyUnicode_Check(key)) {
 +              CValue *item = GetProperty(_PyUnicode_AsString(key));
                if (item) {
                        ret = item->ConvertValueToPython();
                        if(ret)
        return def;
  }
  
 -/* Matches python dict.has_key() */
 -PyObject* KX_GameObject::Pyhas_key(PyObject* value)
 -{
 -      // the ONLY error case is invalid data, this is checked by the macro'd static function
 -      // that calls this one. but make sure Seq_Contains doesnt add extra errors later on.
 -      return PyBool_FromLong(Seq_Contains((PyObject *)this, value));
 -}
 -
  /* --------------------------------------------------------------------- 
   * Some stuff taken from the header
   * --------------------------------------------------------------------- */
@@@ -2799,13 -2884,13 +2799,13 @@@ bool ConvertPythonToGameObject(PyObjec
                }
        }
        
 -      if (PyString_Check(value)) {
 -              *object = (KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( PyString_AsString(value) ));
 +      if (PyUnicode_Check(value)) {
 +              *object = (KX_GameObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( _PyUnicode_AsString(value) ));
                
                if (*object) {
                        return true;
                } else {
 -                      PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, PyString_AsString(value));
 +                      PyErr_Format(PyExc_ValueError, "%s, requested name \"%s\" did not match any KX_GameObject in this scene", error_prefix, _PyUnicode_AsString(value));
                        return false;
                }
        }
index eae1894428ccbb556b6cd00045e3919d9d2a6cac,66457f46deb5e81fb2f23dcc0a0f6ad232dbd8fc..af8e0510a112f09cbbe0a918c7b1ad31ad8c1977
  #include "KX_PyMath.h"
  
  PyTypeObject KX_PolyProxy::Type = {
 -#if (PY_VERSION_HEX >= 0x02060000)
        PyVarObject_HEAD_INIT(NULL, 0)
 -#else
 -      /* python 2.5 and below */
 -      PyObject_HEAD_INIT( NULL )  /* required py macro */
 -      0,                          /* ob_size */
 -#endif
        "KX_PolyProxy",
        sizeof(PyObjectPlus_Proxy),
        0,
        0,
        0,
        py_base_repr,
 -      0,0,0,0,0,0,
 -      py_base_getattro,
 -      py_base_setattro,
        0,0,0,0,0,0,0,0,0,
 -      Methods
 -};
 -
 -PyParentObject KX_PolyProxy::Parents[] = {
 -      &KX_PolyProxy::Type,
 +      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 +      0,0,0,0,0,0,0,
 +      Methods,
 +      0,
 +      0,
        &CValue::Type,
 -      &PyObjectPlus::Type,
 -      NULL
 +      0,0,0,0,0,0,
 +      py_base_new
  };
  
  PyMethodDef KX_PolyProxy::Methods[] = {
@@@ -89,17 -98,16 +89,17 @@@ PyAttributeDef KX_PolyProxy::Attributes
        { NULL }        //Sentinel
  };
  
 +#if 0
  PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
  {
 -      char *attr_str= PyString_AsString(attr);
 +      char *attr_str= _PyUnicode_AsString(attr);
        if (!strcmp(attr_str, "matname"))
        {
 -              return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
 +              return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
        }
        if (!strcmp(attr_str, "texture"))
        {
 -              return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
 +              return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
        }
        if (!strcmp(attr_str, "material"))
        {
                                // found it
                                break;
                }
 -              return PyInt_FromLong(matid);
 +              return PyLong_FromSsize_t(matid);
        }
        if (!strcmp(attr_str, "v1"))
        {
-               return PyLong_FromSsize_t(m_polygon->GetVertexOffset(0));
 -              return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
++              return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
        }
        if (!strcmp(attr_str, "v2"))
        {
-               return PyLong_FromSsize_t(m_polygon->GetVertexOffset(1));
 -              return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
++              return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
        }
        if (!strcmp(attr_str, "v3"))
        {
-               return PyLong_FromSsize_t(m_polygon->GetVertexOffset(2));
 -              return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
++              return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
        }
        if (!strcmp(attr_str, "v4"))
        {
-               return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
 -              return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
++              return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
        }
        if (!strcmp(attr_str, "visible"))
        {
 -              return PyInt_FromLong(m_polygon->IsVisible());
 +              return PyLong_FromSsize_t(m_polygon->IsVisible());
        }
        if (!strcmp(attr_str, "collide"))
        {
 -              return PyInt_FromLong(m_polygon->IsCollider());
 +              return PyLong_FromSsize_t(m_polygon->IsCollider());
        }
 -      py_getattro_up(CValue);
 -}
 -
 -PyObject* KX_PolyProxy::py_getattro_dict() {
 -      py_getattro_dict_up(CValue);
 +      // py_getattro_up(CValue); // XXX -- todo, make all these attributes
  }
 +#endif
  
  KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
  :     m_polygon(polygon),
@@@ -193,37 -204,37 +193,37 @@@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy
                        // found it
                        break;
        }
 -      return PyInt_FromLong(matid);
 +      return PyLong_FromSsize_t(matid);
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
  "getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
  {
 -      return PyInt_FromLong(m_polygon->VertexCount());
 +      return PyLong_FromSsize_t(m_polygon->VertexCount());
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
  "isVisible() : returns whether the polygon is visible or not\n")
  {
 -      return PyInt_FromLong(m_polygon->IsVisible());
 +      return PyLong_FromSsize_t(m_polygon->IsVisible());
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
  "isCollider() : returns whether the polygon is receives collision or not\n")
  {
 -      return PyInt_FromLong(m_polygon->IsCollider());
 +      return PyLong_FromSsize_t(m_polygon->IsCollider());
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
  "getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
  {
 -      return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
 +      return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
  "getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
  {
 -      return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
 +      return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
  }
  
  KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
        }
        if (index < m_polygon->VertexCount())
        {
-               return PyLong_FromSsize_t(m_polygon->GetVertexOffset(index));
 -              return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, index));
++              return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, index));
        }
 -      return PyInt_FromLong(0);
 +      return PyLong_FromSsize_t(0);
  }
  
  KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,
index 12562e345838f80761b1997f0b7988402765fc35,7f84b06cc3cc82ad898b93e9afa42ef1ba80bb1f..df8dc3560ac208b50acdb63f4546feb65f642790
@@@ -1073,7 -1073,7 +1073,7 @@@ void            CcdPhysicsController::ApplyTorque
                                //workaround for incompatibility between 'DYNAMIC' game object, and angular factor
                                //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque
                                const btVector3& angFac = body->getAngularFactor();
-                               btVector3 tmpFac(0,0,1);
+                               btVector3 tmpFac(1,1,1);
                                body->setAngularFactor(tmpFac);
                                body->applyTorque(torque);
                                body->setAngularFactor(angFac);
@@@ -1829,6 -1829,8 +1829,6 @@@ bool CcdShapeConstructionInfo::UpdateMe
                        }
  
                        for(mf= mface, i=0; i < numpolys; mf++, i++) {
 -                              unsigned int *fv = &mf->v1;
 -
                                if(mf->v4) {
                                        fv_pt= quad_verts;
                                        *poly_index_pt++ = *poly_index_pt++ = index[i];
index 207763392b2ad54eecc6b4c32cce2445d8399cee,49837652483d5fea0a06bbbf6ecb0524e0dacc45..dc9abbfbddfa633bbf4f3b0524e6e174c4ab1172
@@@ -79,8 -79,11 +79,11 @@@ class RAS_DisplayArra
  public:
        vector<RAS_TexVert> m_vertex;
        vector<unsigned short> m_index;
+       /* LINE currently isnt used */
        enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type;
        //RAS_MeshSlot *m_origSlot;
+       
+       /* Number of RAS_MeshSlot using this array */
        int m_users;
  
        enum { BUCKET_MAX_INDEX = 65535 };
@@@ -169,13 -172,6 +172,13 @@@ public
        bool IsCulled() { return m_bCulled; }
  #endif
        void SetCulled(bool culled) { m_bCulled = culled; }
 +      
 +      
 +#ifdef WITH_CXX_GUARDEDALLOC
 +public:
 +      void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshSlot"); }
 +      void operator delete( void *mem ) { MEM_freeN(mem); }
 +#endif
  };
  
  /* Used by RAS_MeshObject, to point to it's slots in a bucket */
@@@ -186,13 -182,6 +189,13 @@@ public
        RAS_MeshSlot *m_baseslot;
        class RAS_MaterialBucket *m_bucket;
        GEN_Map<GEN_HashedPtr,RAS_MeshSlot*> m_slots;
 +
 +
 +#ifdef WITH_CXX_GUARDEDALLOC
 +public:
 +      void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshMaterial"); }
 +      void operator delete( void *mem ) { MEM_freeN(mem); }
 +#endif
  };
  
  /* Contains a list of display arrays with the same material,
@@@ -246,12 -235,6 +249,12 @@@ private
        RAS_IPolyMaterial*                      m_material;
        SG_DList                                        m_activeMeshSlotsHead;  // only those which must be rendered
        
 +
 +#ifdef WITH_CXX_GUARDEDALLOC
 +public:
 +      void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MaterialBucket"); }
 +      void operator delete( void *mem ) { MEM_freeN(mem); }
 +#endif
  };
  
  #endif //__RAS_MATERIAL_BUCKET
index a5b777380261acd71447f016349bb0bec77c8d2e,188390f1c6bcd3b4e4a7f1e6b7183f7fb49c1e9e..bd8cfe0be28654c430f3af27350d6c9d1be469a9
  #include <vector>
  using namespace std;
  
 +#ifdef WITH_CXX_GUARDEDALLOC
 +#include "MEM_guardedalloc.h"
 +#endif
 +
  /* polygon flags */
  
  class RAS_Polygon
@@@ -72,6 -68,7 +72,7 @@@ public
  
        void                            SetVertexOffset(int i, unsigned short offset);
        int                                     GetVertexOffset(int i);
+       int                                     GetVertexOffsetAbs(RAS_MeshObject *mesh, int i); /* accounts for quad and tri arrays, slower, for python */
        
        // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
        // - Not used yet!
  
        RAS_MaterialBucket*     GetMaterial();
        RAS_DisplayArray*       GetDisplayArray();
 +      
 +#ifdef WITH_CXX_GUARDEDALLOC
 +public:
 +      void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Polygon"); }
 +      void operator delete( void *mem ) { MEM_freeN(mem); }
 +#endif
  };
  
  #endif