diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-11 22:29:19 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-11 22:29:19 +0400 |
commit | 8997e5ae0676382b7f2afb59d04819f4c926a330 (patch) | |
tree | ef80b7987945cb6b71d320c48b764399707412d5 /source/gameengine | |
parent | 1a8dcbcb4fe9686c641167fca3b880803859c5c4 (diff) |
BGE: Fix for issue #32606 "Raycasts are locked to the scene of calling object" reported by Josiah Lane (solarlune). The raycasting functions were using the active scene instead of the object's scene.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 18 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 63854c6aebd..3a60ccc85e9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1400,6 +1400,14 @@ CListValue* KX_GameObject::GetChildrenRecursive() return list; } +KX_Scene* KX_GameObject::GetScene() +{ + SG_Node* node = this->GetSGNode(); + KX_Scene* scene = static_cast<KX_Scene*>(node->GetSGClientInfo()); + + return scene; +} + /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ @@ -1754,8 +1762,7 @@ PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) PyObject *KX_GameObject::PyEndObject() { - SG_Node* node = this->GetSGNode(); - KX_Scene* scene = static_cast<KX_Scene*>(node->GetSGClientInfo()); + KX_Scene* scene = GetScene(); scene->DelayedRemoveObject(this); @@ -2003,8 +2010,7 @@ PyObject *KX_GameObject::pyattr_get_group_members(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject *self = static_cast<KX_GameObject*>(self_v); - SG_Node *node = self->GetSGNode(); - KX_Scene *scene = static_cast<KX_Scene *>(node->GetSGClientInfo()); + KX_Scene *scene = self->GetScene(); if (scene) { return scene->GetProxy(); } @@ -3056,7 +3062,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, if (dist != 0.0f) toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); - PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) @@ -3202,7 +3208,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, return none_tuple_3(); } - PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 253b5e26ebe..86c712ea017 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -923,6 +923,8 @@ public: CListValue* GetChildren(); CListValue* GetChildrenRecursive(); + KX_Scene* GetScene(); + #ifdef WITH_PYTHON /** * \section Python interface functions. |