diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-10 00:06:36 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-10 00:06:36 +0400 |
commit | 83e9f32382810437bf113fee3b5c32881d7e67ec (patch) | |
tree | 60d1a6aef4accf267053a521a6d21ad117d64eee /source/gameengine/Ketsji | |
parent | f6502a67f203dbd57446f5b10cbdd82a4610e84c (diff) |
BGE: Committing patch #32422 "Debug properties for added objects" by HG1.
This patch allows debug properties from objects added to the scene at runtime to be displayed under the Debug Properties in the overhead display.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 37 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 23 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.h | 1 |
4 files changed, 34 insertions, 28 deletions
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 1061e9fd571..360a337f852 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -129,8 +129,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_keyboarddevice(NULL), m_mousedevice(NULL), - m_propertiesPresent(false), - m_bInitialized(false), m_activecam(0), m_bFixedTime(false), @@ -515,7 +513,7 @@ void KX_KetsjiEngine::EndFrame() // Show profiling info m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true); - if (m_show_framerate || m_show_profile || (m_show_debug_properties && m_propertiesPresent)) + if (m_show_framerate || m_show_profile || (m_show_debug_properties)) { RenderDebugProperties(); } @@ -1389,7 +1387,6 @@ void KX_KetsjiEngine::AddScene(KX_Scene* scene) { m_scenes.push_back(scene); PostProcessScene(scene); - SceneListsChanged(); } @@ -1533,7 +1530,7 @@ void KX_KetsjiEngine::RenderDebugProperties() ycoord += title_y_top_margin; /* Property display*/ - if (m_show_debug_properties && m_propertiesPresent) { + if (m_show_debug_properties) { /* Title for debugging("Debug properties") */ m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, @@ -1548,18 +1545,22 @@ void KX_KetsjiEngine::RenderDebugProperties() // Add the title indent afterwards ycoord += title_y_bottom_margin; + /* Calculate amount of properties that can displayed. */ + unsigned propsAct = 0; + unsigned propsMax = (m_canvas->GetHeight() - ycoord) / const_ysize; + KX_SceneList::iterator sceneit; for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) { KX_Scene* scene = *sceneit; /* the 'normal' debug props */ vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); - for (vector<SCA_DebugProp*>::iterator it = debugproplist.begin(); - !(it==debugproplist.end());it++) + for (unsigned i=0; i < debugproplist.size() && propsAct < propsMax; i++) { - CValue *propobj = (*it)->m_obj; + CValue *propobj = debugproplist[i]->m_obj; STR_String objname = propobj->GetName(); - STR_String propname = (*it)->m_name; + STR_String propname = debugproplist[i]->m_name; + propsAct++; if (propname == "__state__") { // reserve name for object state KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj); @@ -1943,24 +1944,6 @@ void KX_KetsjiEngine::ProcessScheduledScenes(void) ReplaceScheduledScenes(); RemoveScheduledScenes(); AddScheduledScenes(); - - // Notify - SceneListsChanged(); - } -} - - - -void KX_KetsjiEngine::SceneListsChanged(void) -{ - m_propertiesPresent = false; - KX_SceneList::iterator sceneit = m_scenes.begin(); - while ((sceneit != m_scenes.end()) && (!m_propertiesPresent)) - { - KX_Scene* scene = *sceneit; - vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); - m_propertiesPresent = !debugproplist.empty(); - sceneit++; } } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 4e69c7d35f7..4dd8ea10e62 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -437,7 +437,6 @@ protected: /** * This method is invoked when the scene lists have changed. */ - void SceneListsChanged(void); void RemoveScheduledScenes(void); void AddScheduledScenes(void); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 13fb168221d..c12fda8912e 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -59,6 +59,7 @@ #include "SCA_JoystickManager.h" #include "KX_PyMath.h" #include "RAS_MeshObject.h" +#include "SCA_IScene.h" #include "RAS_IRasterizer.h" #include "RAS_BucketManager.h" @@ -73,6 +74,7 @@ #include "SG_Tree.h" #include "DNA_group_types.h" #include "DNA_scene_types.h" +#include "DNA_property_types.h" #include "KX_SG_NodeRelationships.h" @@ -438,6 +440,21 @@ void KX_Scene::EnableZBufferClearing(bool isclearingZbuffer) m_isclearingZbuffer = isclearingZbuffer; } +void KX_Scene::AddObjectDebugProperties(class KX_GameObject* gameobj) +{ + Object* blenderobject = gameobj->GetBlenderObject(); + bProperty* prop = (bProperty*)blenderobject->prop.first; + + while(prop) { + if (prop->flag & PROP_DEBUG) + AddDebugProperty(gameobj,STR_String(prop->name)); + prop = prop->next; + } + + if (blenderobject->scaflag & OB_DEBUGSTATE) + AddDebugProperty(gameobj,STR_String("__state__")); +} + void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj) { KX_GameObject* orgobj = (KX_GameObject*)gameobj; @@ -561,6 +578,8 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal // SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks. void KX_Scene::ReplicateLogic(KX_GameObject* newobj) { + /* add properties to debug list, for added objects and DupliGroups */ + AddObjectDebugProperties(newobj); // also relink the controller to sensors/actuators SCA_ControllerList& controllers = newobj->GetControllers(); //SCA_SensorList& sensors = newobj->GetSensors(); @@ -972,6 +991,9 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) int ret; KX_GameObject* newobj = (KX_GameObject*) gameobj; + /* remove property to debug list */ + RemoveObjectDebugProperties(newobj); + /* Invalidate the python reference, since the object may exist in script lists * its possible that it wont be automatically invalidated, so do it manually here, * @@ -1911,6 +1933,7 @@ bool KX_Scene::MergeScene(KX_Scene *other) { KX_GameObject* gameobj = (KX_GameObject*)other->GetObjectList()->GetValue(i); MergeScene_GameObject(gameobj, this, other); + AddObjectDebugProperties(gameobj); // add properties to debug list for LibLoad objects gameobj->UpdateBuckets(false); /* only for active objects */ } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 7c3ea946044..edaa0663b22 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -324,6 +324,7 @@ public: return (m_groupGameObjects.empty() || m_groupGameObjects.find(gameobj) != m_groupGameObjects.end()); } + void AddObjectDebugProperties(class KX_GameObject* gameobj); SCA_IObject* AddReplicaObject(CValue* gameobj, CValue* locationobj, int lifespan=0); |