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:
authorCampbell Barton <ideasman42@gmail.com>2009-04-05 18:01:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-05 18:01:49 +0400
commit033a63f8580227582a9695ebdd78ac0b4322e867 (patch)
tree61517f343a2908f894d54c46269baa5c54338135 /source/gameengine/Ketsji/KX_GameObject.cpp
parent7d4dc4f0f5d34d91703b2219323ef4a3db28a572 (diff)
BGE Bugfixes (mostly in the py api)
KX_PolygonMaterial and KX_BlenderMaterial - Added a print function (would raise a python error on printing) * Crashes * KX_GameObject SetParent - Disallowed setting a parent to its self, caused a recursion crash. KX_MeshProxy "materials" attribute was segfaulting because of my recent change - I was wrong, you do need to check material types (no idea why since they are both PyObject * at the base) KX_VisibilityActuator - Wasn't initialized with PyType_Ready() making it crash on access (own fault) * Crashes because of missing NULL checks * KX_PolygonMaterial's "gl_texture" attribute wasnt checking for a valid m_tface KX_GameObject - added checks for GetPhysicsController() KX_RayCast::RayTest - didnt check for a valid physics_environment KX_SceneActuator's getCamera python function wasnt checking if there was a camera.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 6f4aa2bc71a..a788b12b121 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -73,6 +73,8 @@ typedef unsigned long uint_ptr;
#include "KX_SG_NodeRelationships.h"
+static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0);
+
KX_GameObject::KX_GameObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
@@ -943,7 +945,7 @@ const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
}
-static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0);
+
const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
{
// check on valid node in case a python controller holds a reference to a deleted object
@@ -964,7 +966,8 @@ void KX_GameObject::Resume(void)
{
if (m_suspended) {
SCA_IObject::Resume();
- GetPhysicsController()->RestoreDynamics();
+ if(GetPhysicsController())
+ GetPhysicsController()->RestoreDynamics();
m_suspended = false;
}
@@ -975,7 +978,8 @@ void KX_GameObject::Suspend()
if ((!m_ignore_activity_culling)
&& (!m_suspended)) {
SCA_IObject::Suspend();
- GetPhysicsController()->SuspendDynamics();
+ if(GetPhysicsController())
+ GetPhysicsController()->SuspendDynamics();
m_suspended = true;
}
}
@@ -1717,7 +1721,7 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args)
PyObject* KX_GameObject::PyGetMass(PyObject* self)
{
ShowDeprecationWarning("getMass()", "the mass property");
- return PyFloat_FromDouble(GetPhysicsController()->GetMass());
+ return PyFloat_FromDouble((GetPhysicsController() != NULL) ? GetPhysicsController()->GetMass() : 0.0f);
}
@@ -1725,14 +1729,24 @@ PyObject* KX_GameObject::PyGetMass(PyObject* self)
PyObject* KX_GameObject::PyGetReactionForce(PyObject* self)
{
// only can get the velocity if we have a physics object connected to us...
- return PyObjectFrom(GetPhysicsController()->getReactionForce());
+
+ // XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce
+ /*
+ if (GetPhysicsController())
+ return PyObjectFrom(GetPhysicsController()->getReactionForce());
+ return PyObjectFrom(dummy_point);
+ */
+
+ return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f);
+
}
PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self)
{
- GetPhysicsController()->setRigidBody(true);
+ if(GetPhysicsController())
+ GetPhysicsController()->setRigidBody(true);
Py_RETURN_NONE;
}
@@ -1741,7 +1755,8 @@ PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self)
PyObject* KX_GameObject::PyDisableRigidBody(PyObject* self)
{
- GetPhysicsController()->setRigidBody(false);
+ if(GetPhysicsController())
+ GetPhysicsController()->setRigidBody(false);
Py_RETURN_NONE;
}
@@ -1763,6 +1778,10 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value)
PyErr_SetString(PyExc_TypeError, "expected a KX_GameObject type");
return NULL;
}
+ if (self==value) {
+ PyErr_SetString(PyExc_ValueError, "cannot set the object to be its own parent!");
+ return NULL;
+ }
// The object we want to set as parent
CValue *m_ob = (CValue*)value;