diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-08 21:40:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-08 21:40:09 +0400 |
commit | 1ee970e03bb6395ed0c0e884826a8e08b91e97bf (patch) | |
tree | eff183ebf356ad08d615b504e4170a5812b7fd19 | |
parent | db33320df7f4db6480a15502baecaafefc1be63d (diff) |
small bge edits
- Only try and remove light objects from the light list.
- Only loop over mesh verts once when getting the bounding box
- dont return None from python attribute localInertia when theres no physics objects. better return a vector still.
- add names to send message PyArg_ParseTuple functions.
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 18 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 2 |
4 files changed, 14 insertions, 12 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3c77f122758..50a660e77c9 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1120,6 +1120,7 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size) BoundBox *bb; MT_Point3 min, max; float mloc[3], msize[3]; + float radius=0.0f, vert_radius, *co; int a; if(me->bb==0) me->bb= (struct BoundBox *)MEM_callocN(sizeof(BoundBox), "boundbox"); @@ -1132,7 +1133,15 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size) mvert= me->mvert; for(a=0; a<me->totvert; a++, mvert++) { - DO_MINMAX(mvert->co, min, max); + co= mvert->co; + + /* bounds */ + DO_MINMAX(co, min, max); + + /* radius */ + vert_radius= co[0]*co[0] + co[1]*co[1] + co[2]*co[2]; + if (vert_radius > radius) + radius= vert_radius; } if(me->totvert) { @@ -1158,13 +1167,6 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size) bb->vec[0][2]=bb->vec[3][2]=bb->vec[4][2]=bb->vec[7][2]= loc[2]-size[2]; bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= loc[2]+size[2]; - float radius = 0; - for (a=0, mvert = me->mvert; a < me->totvert; a++, mvert++) - { - float vert_radius = MT_Vector3(mvert->co).length2(); - if (vert_radius > radius) - radius = vert_radius; - } return sqrt(radius); } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5085b52adda..13e839d9d2e 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1325,7 +1325,7 @@ PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB { return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia()); } - Py_RETURN_NONE; + return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); } PyObject* KX_GameObject::pyattr_get_orientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) @@ -2349,7 +2349,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, char* to = ""; const STR_String& from = GetName(); - if (!PyArg_ParseTuple(args, "s|sss", &subject, &body, &to)) + if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to)) return NULL; KX_GetActiveScene()->GetNetworkScene()->SendMessage(to, from, subject, body); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 57c84050397..8302855577d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -184,7 +184,7 @@ static PyObject* gPySendMessage(PyObject*, PyObject* args) char* to = ""; char* from = ""; - if (!PyArg_ParseTuple(args, "s|sss", &subject, &body, &to, &from)) + if (!PyArg_ParseTuple(args, "s|sss:sendMessage", &subject, &body, &to, &from)) return NULL; gp_KetsjiScene->GetNetworkScene()->SendMessage(to, from, subject, body); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 7eed1cc387b..0bd7d7270e1 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -956,7 +956,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) newobj->RemoveMeshes(); ret = 1; - if (m_lightlist->RemoveValue(newobj)) // TODO - use newobj->IsLight() test when its merged in from apricot. - Campbell + if (newobj->IsLight() && m_lightlist->RemoveValue(newobj)) ret = newobj->Release(); if (m_objectlist->RemoveValue(newobj)) ret = newobj->Release(); |