[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16724] trunk/blender/source: BGE patch: add Debug button next to object state.
Campbell Barton
ideasman42 at gmail.com
Thu Sep 25 19:06:02 CEST 2008
thanks for this feature, was using a custom script to debug states.
Heres the way it was displaying them, not sure if its a lot better or
Im just used to it. but its very good when having problems with states
jittering which I think would be hard to read if the numbers were
changing very fast.
Dont think you could do this without 2 lines of text though.
http://imagebin.org/27315
On Fri, Sep 26, 2008 at 2:19 AM, Benoit Bolsee <benoit.bolsee at online.be> wrote:
> Revision: 16724
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16724
> Author: ben2610
> Date: 2008-09-25 18:19:07 +0200 (Thu, 25 Sep 2008)
>
> Log Message:
> -----------
> BGE patch: add Debug button next to object state. The object state mask will be printed at runtime with the debug info as a comma separated list of state numbers (1..30) for each active state bit. The reserved property name __state__ is used for that purpose (users should not create a property with that name).
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/makesdna/DNA_object_types.h
> trunk/blender/source/blender/src/buttons_logic.c
> trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp
> trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
>
> Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_object_types.h 2008-09-25 16:13:17 UTC (rev 16723)
> +++ trunk/blender/source/blender/makesdna/DNA_object_types.h 2008-09-25 16:19:07 UTC (rev 16724)
> @@ -469,6 +469,7 @@
> #define OB_SHOWCONT 2048
> #define OB_SETSTBIT 4096
> #define OB_INITSTBIT 8192
> +#define OB_DEBUGSTATE 16384
>
> /* ob->restrictflag */
> #define OB_RESTRICT_VIEW 1
>
> Modified: trunk/blender/source/blender/src/buttons_logic.c
> ===================================================================
> --- trunk/blender/source/blender/src/buttons_logic.c 2008-09-25 16:13:17 UTC (rev 16723)
> +++ trunk/blender/source/blender/src/buttons_logic.c 2008-09-25 16:19:07 UTC (rev 16724)
> @@ -3366,24 +3366,25 @@
>
> /* first show the state */
> uiBlockSetEmboss(block, UI_EMBOSSP);
> - uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 40, 19, "Object state menu: store and retrieve initial state");
> + uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, 19, "Object state menu: store and retrieve initial state");
> uiBlockSetEmboss(block, UI_EMBOSS);
> if (!ob->state)
> ob->state = 1;
> for (offset=0; offset<15; offset+=5) {
> uiBlockBeginAlign(block);
> for (stbit=0; stbit<5; stbit++) {
> - but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+35+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
> + but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
> uiButSetFunc(but, check_state_mask, but, &(ob->state));
> }
> for (stbit=0; stbit<5; stbit++) {
> - but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+35+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
> + but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
> uiButSetFunc(but, check_state_mask, but, &(ob->state));
> }
> }
> uiBlockBeginAlign(block);
> - uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+235), yco-10, 25, 19, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
> - uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+260), yco-10, 25, 19, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
> + uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+226), yco-10, 22, 19, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
> + uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+248), yco-10, 22, 19, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
> + uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D",(short)(xco+270), yco-10, 15, 19, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
> uiBlockEndAlign(block);
>
> yco-=35;
>
> Modified: trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp 2008-09-25 16:13:17 UTC (rev 16723)
> +++ trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp 2008-09-25 16:19:07 UTC (rev 16724)
> @@ -132,6 +132,10 @@
>
> prop = prop->next;
> }
> -
> -
> + // check if state needs to be debugged
> + if (object->scaflag & OB_DEBUGSTATE)
> + {
> + // reserve name for object state
> + scene->AddDebugProperty(gameobj,STR_String("__state__"));
> + }
> }
>
> Modified: trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2008-09-25 16:13:17 UTC (rev 16723)
> +++ trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2008-09-25 16:19:07 UTC (rev 16724)
> @@ -1243,19 +1243,49 @@
> CValue* propobj = (*it)->m_obj;
> STR_String objname = propobj->GetName();
> STR_String propname = (*it)->m_name;
> - CValue* propval = propobj->GetProperty(propname);
> - if (propval)
> + if (propname == "__state__")
> {
> - STR_String text = propval->GetText();
> - debugtxt = objname + "." + propname + " = " + text;
> + // reserve name for object state
> + KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj);
> + unsigned int state = gameobj->GetState();
> + debugtxt = objname + "." + propname + " = ";
> + bool first = true;
> + for (int statenum=1;state;state >>= 1, statenum++)
> + {
> + if (state & 1)
> + {
> + if (!first)
> + {
> + debugtxt += ",";
> + }
> + debugtxt += STR_String(statenum);
> + first = false;
> + }
> + }
> m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
> - debugtxt.Ptr(),
> - xcoord,
> - ycoord,
> - m_canvas->GetWidth(),
> - m_canvas->GetHeight());
> + debugtxt.Ptr(),
> + xcoord,
> + ycoord,
> + m_canvas->GetWidth(),
> + m_canvas->GetHeight());
> ycoord += 14;
> }
> + else
> + {
> + CValue* propval = propobj->GetProperty(propname);
> + if (propval)
> + {
> + STR_String text = propval->GetText();
> + debugtxt = objname + "." + propname + " = " + text;
> + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
> + debugtxt.Ptr(),
> + xcoord,
> + ycoord,
> + m_canvas->GetWidth(),
> + m_canvas->GetHeight());
> + ycoord += 14;
> + }
> + }
> }
> }
> }
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
--
- Campbell
More information about the Bf-committers
mailing list