From dfe1b9b7a727d5d4cf998a89153aad9f3f6fde55 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 15 Jul 2014 17:52:01 -0700 Subject: Fix T40146: BGE Compound parent crash --- source/gameengine/Ketsji/KX_KetsjiEngine.h | 1 + source/gameengine/Physics/Bullet/CMakeLists.txt | 1 + source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 13 +++++++++++-- source/gameengine/Physics/Bullet/SConscript | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 45d594e21dc..2bc5bad6daf 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -223,6 +223,7 @@ public: PyObject* GetPyProfileDict(); #endif void SetSceneConverter(KX_ISceneConverter* sceneconverter); + KX_ISceneConverter* GetSceneConverter() { return m_sceneconverter; } void SetAnimRecordMode(bool animation_record, int startFrame); RAS_IRasterizer* GetRasterizer() { return m_rasterizer; } diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index 87d851016dd..fbaa7bb59ba 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -29,6 +29,7 @@ remove_strict_flags() set(INC . ../common + ../../Converter ../../Expressions ../../GameLogic ../../Ketsji diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index f34311d70a0..3e0b99eb7e2 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -42,6 +42,7 @@ subject to the following restrictions: #include "PHY_Pro.h" #include "KX_GameObject.h" #include "KX_PythonInit.h" // for KX_RasterizerDrawDebugLine +#include "KX_BlenderSceneConverter.h" #include "RAS_MeshObject.h" #include "RAS_Polygon.h" #include "RAS_TexVert.h" @@ -3044,9 +3045,17 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject CcdConstructionInfo ci; class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo(); - KX_GameObject *parent = gameobj->GetParent(); - if (parent) + // get Root Parent of blenderobject + Object *blenderparent = blenderobject->parent; + while (blenderparent && blenderparent->parent) { + blenderparent = blenderparent->parent; + } + + KX_GameObject *parent = NULL; + if (blenderparent) { + KX_BlenderSceneConverter *converter = (KX_BlenderSceneConverter*)KX_GetActiveEngine()->GetSceneConverter(); + parent = converter->FindGameObject(blenderparent); isbulletdyna = false; isbulletsoftbody = false; shapeprops->m_mass = 0.f; diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index 2700997ccd4..2a8249b9558 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -39,6 +39,7 @@ incs = [ '#source/blender/blenkernel', '#source/blender/blenlib', '#source/blender/makesdna', + '#source/gameengine/Converter', '#source/gameengine/Expressions', '#source/gameengine/GameLogic', '#source/gameengine/Ketsji', -- cgit v1.2.3