Skip to content

Commit 3804cfe

Browse files
committed
Refactor debug property flags and editor options
Introduces new, more granular debug property flags (DebugMatrix, DebugRuntime, DebugUID) in PropertyFlags and updates their usage throughout the codebase. Splits editor debug options into EditorDebugFlags and PropertiesDisplayFlags, with corresponding getter methods and UI logic. Updates ImGui property visibility logic and refines property registration for improved debug property control. Also changes some warning logs to info logs in SoundComponent and AnimationComponent.
1 parent 2cdeb0b commit 3804cfe

11 files changed

Lines changed: 89 additions & 69 deletions

File tree

‎Editor.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</Object>
4141
</Property>
4242
<Property type="EnumFlagsU32" name="m_consoleOptions.m_levels" value="Warning|Error"/>
43-
<Property type="EnumFlagsU64" name="m_debugFlags" value=""/>
43+
<Property type="EnumFlagsU64" name="m_editorDebugFlags" value=""/>
44+
<Property type="EnumFlagsU64" name="m_propertiesDisplayFlags" value=""/>
4445
</Object>
4546
</Root>

‎src/core/GameObject/GameObject.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace vg::core
3131
registerPropertyEnumBitfield(GameObject, Tag, m_tags, "Tags");
3232
setPropertyDescription(GameObject, m_tags, "GameObjects can use Tags to categorize object (e.g., Player, Ennemy ...)")
3333

34-
registerPropertyEnumBitfieldEx(GameObject, UpdateFlags, m_update, "Update", PropertyFlags::Transient /* | PropertyFlags::Debug*/);
34+
registerPropertyEnumBitfieldEx(GameObject, UpdateFlags, m_update, "Update", PropertyFlags::Transient | PropertyFlags::DebugRuntime);
3535

3636
registerPropertyObjectPtrVector(GameObject, m_components, "Components");
3737
registerPropertyObjectPtrVectorEx(GameObject, m_children, "Children", PropertyFlags::Hidden);

‎src/core/IProperty.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace vg::core
8181
HasRange = 0x0000000000000010, // Property has [min..max] range
8282
SingleLine = 0x0000000000000020, // This property and the following ones will be displayed on the same line to save space
8383
Radio = 0x0000000000000040, // Part of a radio button group
84-
Debug = 0x0000000000000080, // A misc debug property that is hidden by default
84+
Debug = 0x0000000000000080, // A misc debug property that is hidden by default (use 'DebugXXX' categories instead whenever possible)
8585
Bitfield = 0x0000000000000100, // Value displayed as hex, enum as flags
8686
Resource = 0x0000000000000200, // Property is a Resource
8787
Transient = 0x0000000000000400, // Property is not saved nor loaded
@@ -94,8 +94,9 @@ namespace vg::core
9494
EulerAngle = 0x0000000000020000, // Edited value is Euler angle
9595
AlphabeticalOrder = 0x0000000000040000, // Sort multiple values in alphabetical order (e.g., enums)
9696
Alias = 0x0000000000080000, // Property can alias another property of the same class. Other property must be the same type and same size or larger (e.g. can be a float2 aliasing a float3 but not the other way around)
97-
Runtime = 0x0000000000100000, // Property is a tuntime flag that is usually hidden
98-
UID = 0x0000000000200000 // Property is an UID that is usually hidden
97+
DebugRuntime = 0x0000000000100000, // Property is a debug runtime flag that is usually hidden
98+
DebugUID = 0x0000000000200000, // Property is an debug UID that is usually hidden
99+
DebugMatrix = 0x0000000000400000 // Property is a debug matrix that is usually hidden
99100
);
100101

101102
vg_enum_class(vg::core, PropertyLayoutElement, u8,

‎src/core/Instance/Instance.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace vg::core
4141
registerPropertyEnumBitfield(Instance, InstanceFlags, m_flags, "Instance Flags");
4242
setPropertyDescription(Instance, m_flags, "Instance flags that are serialized");
4343

44-
registerPropertyEnumBitfieldEx(Instance, InstanceRuntimeFlags, m_runtimeFlags, "Runtime flags", PropertyFlags::Runtime | PropertyFlags::Transient);
44+
registerPropertyEnumBitfieldEx(Instance, InstanceRuntimeFlags, m_runtimeFlags, "Runtime flags", PropertyFlags::DebugRuntime | PropertyFlags::Transient);
4545
setPropertyDescription(Instance, m_runtimeFlags, "Instance flags that are only runtime");
4646

4747
registerPropertyEx(Instance, m_color, "Color", PropertyFlags::Color);
@@ -50,7 +50,7 @@ namespace vg::core
5050
registerPropertyEx(Instance, m_local, "Local", PropertyFlags::Flatten);
5151
setPropertyDescription(Instance, m_local, "Local transform");
5252

53-
registerPropertyEx(Instance, m_global, "Global", PropertyFlags::Flatten | PropertyFlags::Debug | PropertyFlags::Transient);
53+
registerPropertyEx(Instance, m_global, "Global", PropertyFlags::Flatten | PropertyFlags::DebugMatrix | PropertyFlags::Transient);
5454
setPropertyDescription(Instance, m_global, "Global transform");
5555

5656
return true;

‎src/core/Object/Object.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ namespace vg::core
2929
registerPropertyEx(Object, m_name, "Name", PropertyFlags::Hidden);
3030
setPropertyDescription(Object, m_name, "User-friendly name");
3131

32-
registerPropertyEx(Object, m_uid, "Object UID", PropertyFlags::UID | PropertyFlags::Hexadecimal | PropertyFlags::ReadOnly);
32+
registerPropertyEx(Object, m_uid, "Object UID", PropertyFlags::DebugUID | PropertyFlags::Hexadecimal | PropertyFlags::ReadOnly);
3333
setPropertyDescription(Object, m_uid, "Object unique ID");
3434

3535
// TODO: display only if != 0?
36-
registerPropertyEx(Object, m_originalUID, "Source UID", PropertyFlags::UID | PropertyFlags::Hexadecimal | PropertyFlags::ReadOnly);
36+
registerPropertyEx(Object, m_originalUID, "Source UID", PropertyFlags::DebugUID | PropertyFlags::Hexadecimal | PropertyFlags::ReadOnly);
3737
setPropertyDescription(Object, m_originalUID, "Source object's unique ID");
3838
setPropertyHiddenCallback(Object, m_originalUID, IsOriginalUIDHidden);
3939

4040
registerPropertyEnumBitfieldEx(Object, ObjectFlags, m_objectFlags, "Object Flags", PropertyFlags::Debug);
4141
setPropertyDescription(Object, m_objectFlags, "Object flags that are serialized");
4242

43-
registerPropertyEnumBitfieldEx(Object, ObjectRuntimeFlags, m_objectRuntimeFlags, "Runtime flags", PropertyFlags::Runtime | PropertyFlags::Transient);
43+
registerPropertyEnumBitfieldEx(Object, ObjectRuntimeFlags, m_objectRuntimeFlags, "Runtime flags", PropertyFlags::DebugRuntime | PropertyFlags::Transient);
4444
setPropertyDescription(Object, m_objectRuntimeFlags, "Object flags that are only runtime");
4545

4646
return true;

‎src/editor/ImGui/Extensions/ImGuiExtensions.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ namespace ImGui
350350
//--------------------------------------------------------------------------------------
351351
string getObjectLabel(const string & _label, const void * _object)
352352
{
353-
return fmt::sprintf("%s###%s%p", _label.c_str(), _label.c_str(), _object);
353+
return fmt::sprintf("%s###%s%p", _label, _label, _object);
354354
}
355355

356356
//--------------------------------------------------------------------------------------
357357
string getObjectLabel(const string & _label, const string & _subLabel, const void * _object)
358358
{
359-
return fmt::sprintf("%s###%s_%p", _label.c_str(), _subLabel.c_str(), _object);
359+
return fmt::sprintf("%s###%s_%p", _label, _subLabel, _object);
360360
}
361361

362362
//--------------------------------------------------------------------------------------

‎src/editor/ImGui/Window/ImGuiWindow.cpp‎

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -855,10 +855,6 @@ namespace vg::editor
855855
if (!classDesc)
856856
return false;
857857

858-
// debug only
859-
if (EditorOptions::get()->IsDebugPropertyVisible())
860-
ImGui::Text("Parent = 0x%016llX (%s)", _object->GetParent(), _object->GetClassName());
861-
862858
if (_objectContext.m_treeNodes.size() > 0)
863859
{
864860
auto & nodeInfo = _objectContext.m_treeNodes[_objectContext.m_treeNodes.size() - 1];
@@ -941,13 +937,16 @@ namespace vg::editor
941937

942938
bool visible = !hidden;
943939

944-
if (asBool(PropertyFlags::Debug & flags) && !EditorOptions::get()->IsDebugPropertyVisible())
940+
if (asBool(PropertyFlags::DebugMatrix & flags) && !EditorOptions::get()->IsDebugMatrixPropertyVisible())
941+
visible = false;
942+
943+
if (asBool(PropertyFlags::DebugRuntime & flags) && !EditorOptions::get()->IsDebugRuntimePropertyVisible())
945944
visible = false;
946945

947-
if (asBool(PropertyFlags::Runtime & flags) && !EditorOptions::get()->IsRuntimeFlagsPropertyVisible())
946+
if (asBool(PropertyFlags::DebugUID & flags) && !EditorOptions::get()->IsDebugUIDPropertyVisible())
948947
visible = false;
949948

950-
if (asBool(PropertyFlags::UID & flags) && !EditorOptions::get()->IsUIDPropertyVisible())
949+
if (asBool(PropertyFlags::Debug & flags) && !EditorOptions::get()->IsMiscDebugPropertyVisible())
951950
visible = false;
952951

953952
return visible;
@@ -2959,17 +2958,17 @@ namespace vg::editor
29592958
float prevRot[3] = { rotation[0], rotation[1], rotation[2] };
29602959
float prevScale[3] = { scale[0], scale[1], scale[2] };
29612960

2962-
edited |= CustomDragFloat3(interactionType, getPropertyLabel("T").c_str(), (float *)&translation, getDragSpeedFloat(_object, _prop) * 90.0f/8.0f, -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
2961+
edited |= CustomDragFloat3(interactionType, getObjectLabel("","T", pFloat4x4).c_str(), (float *)&translation, getDragSpeedFloat(_object, _prop) * 90.0f/8.0f, -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
29632962
itemActive = ImGui::IsItemActive() || InteractionType::Single == interactionType;
29642963
itemAfterEdit = ImGui::IsItemDeactivatedAfterEdit() || InteractionType::Single == interactionType;
29652964
drawPropertyLabel(_propContext, TLabel.c_str(), "Represents the translation part of the matrix");
29662965

2967-
edited |= CustomDragFloat3(interactionType, getPropertyLabel("R").c_str(), (float *)&rotation, getDragSpeedFloat(_object, _prop) * 90.0f / 8.0f, -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
2966+
edited |= CustomDragFloat3(interactionType, getObjectLabel("","R", pFloat4x4).c_str(), (float *)&rotation, getDragSpeedFloat(_object, _prop) * 90.0f / 8.0f, -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
29682967
itemActive |= ImGui::IsItemActive() || InteractionType::Single == interactionType;
29692968
itemAfterEdit |= ImGui::IsItemDeactivatedAfterEdit() || InteractionType::Single == interactionType;
29702969
drawPropertyLabel(_propContext, RLabel.c_str(), "Represents the rotation part of the matrix");
29712970

2972-
edited |= CustomDragFloat3(interactionType, getPropertyLabel("S").c_str(), (float *)&scale, getDragSpeedFloat(_object, _prop) * 90.0f / 8.0f, 0.01f, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
2971+
edited |= CustomDragFloat3(interactionType, getObjectLabel("","S", pFloat4x4).c_str(), (float *)&scale, getDragSpeedFloat(_object, _prop) * 90.0f / 8.0f, 0.01f, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
29732972
itemActive |= ImGui::IsItemActive() || InteractionType::Single == interactionType;
29742973
itemAfterEdit |= ImGui::IsItemDeactivatedAfterEdit() || InteractionType::Single == interactionType;
29752974
drawPropertyLabel(_propContext, SLabel.c_str(), "Represents the scale part of the matrix");
@@ -3047,31 +3046,34 @@ namespace vg::editor
30473046
if (EditingState::Unknown == editingState)
30483047
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType, itemActive, itemAfterEdit);
30493048

3050-
if (ImGui::TreeNode(getObjectLabel("(float4x4) " + (string)displayName, _propContext.m_originalProp).c_str()))
3049+
if (EditorOptions::get()->IsDebugMatrixPropertyVisible())
30513050
{
3052-
ImGui::Spacing();
3053-
3054-
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("I").c_str(), (float *)&temp[0], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3055-
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3056-
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3057-
drawPropertyLabel(_propContext, LabelI.c_str(), "Represents the x-axis in the transformed space");
3058-
3059-
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("J").c_str(), (float *)&temp[4], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3060-
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3061-
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3062-
drawPropertyLabel(_propContext, LabelJ.c_str(), "Represents the y-axis in the transformed space");
3063-
3064-
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("K").c_str(), (float *)&temp[8], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3065-
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3066-
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3067-
drawPropertyLabel(_propContext, LabelK.c_str(), "Represents the z-axis in the transformed space");
3068-
3069-
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("T").c_str(), (float *)&temp[12], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3070-
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3071-
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3072-
drawPropertyLabel(_propContext, LabelT.c_str(), "Represents the translation component");
3073-
3074-
ImGui::TreePop();
3051+
if (ImGui::TreeNode(getObjectLabel("(float4x4) " + (string)displayName, _propContext.m_originalProp).c_str()))
3052+
{
3053+
ImGui::Spacing();
3054+
3055+
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("I").c_str(), (float *)&temp[0], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3056+
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3057+
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3058+
drawPropertyLabel(_propContext, LabelI.c_str(), "Represents the x-axis in the transformed space");
3059+
3060+
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("J").c_str(), (float *)&temp[4], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3061+
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3062+
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3063+
drawPropertyLabel(_propContext, LabelJ.c_str(), "Represents the y-axis in the transformed space");
3064+
3065+
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("K").c_str(), (float *)&temp[8], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3066+
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3067+
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3068+
drawPropertyLabel(_propContext, LabelK.c_str(), "Represents the z-axis in the transformed space");
3069+
3070+
edited |= ImGui::CustomDragFloat4(interactionType, getPropertyLabel("T").c_str(), (float *)&temp[12], getDragSpeedFloat(_object, _prop), -style::range::maxFloat, style::range::maxFloat, g_editFloatFormat) && !_propContext.m_readOnly;
3071+
if (EditingState::Unknown == editingState || InteractionType::Single == interactionType)
3072+
editingState = undoRedoBeforeEdit<float4x4>(edited, _propContext, _object, _prop, (float *)&temp[0], pFloat, interactionType);
3073+
drawPropertyLabel(_propContext, LabelT.c_str(), "Represents the translation component");
3074+
3075+
ImGui::TreePop();
3076+
}
30753077
}
30763078

30773079
if (_propContext.m_readOnly)

‎src/editor/Options/EditorOptions.cpp‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ namespace vg::editor
4848

4949
registerPropertyGroupBegin(EditorOptions, "Debug");
5050
{
51-
registerPropertyEnumBitfield(EditorOptions, EditorDebugFlags, m_debugFlags, "Flags");
52-
setPropertyDescription(EditorOptions, m_debugFlags, "Enable some editor debug features");
51+
registerPropertyEnumBitfield(EditorOptions, EditorDebugFlags, m_editorDebugFlags, "Editor");
52+
setPropertyDescription(EditorOptions, m_editorDebugFlags, "Enable some editor debug features");
53+
54+
registerPropertyEnumBitfield(EditorOptions, PropertiesDisplayFlags, m_propertiesDisplayFlags, "Properties");
55+
setPropertyDescription(EditorOptions, m_propertiesDisplayFlags, "Enable display of debug properties");
5356
}
5457
registerPropertyGroupEnd(EditorOptions);
5558

@@ -59,37 +62,43 @@ namespace vg::editor
5962
//--------------------------------------------------------------------------------------
6063
bool EditorOptions::IsDebugCulling() const
6164
{
62-
return core::asBool(EditorDebugFlags::Culling & m_debugFlags);
65+
return core::asBool(EditorDebugFlags::Culling & m_editorDebugFlags);
6366
}
6467

6568
//--------------------------------------------------------------------------------------
6669
bool EditorOptions::IsDebugInspector() const
6770
{
68-
return core::asBool(EditorDebugFlags::Inspector & m_debugFlags);
71+
return core::asBool(EditorDebugFlags::Inspector & m_editorDebugFlags);
6972
}
7073

7174
//--------------------------------------------------------------------------------------
7275
bool EditorOptions::IsDebugPicking() const
7376
{
74-
return core::asBool(EditorDebugFlags::Picking & m_debugFlags);
77+
return core::asBool(EditorDebugFlags::Picking & m_editorDebugFlags);
78+
}
79+
80+
//--------------------------------------------------------------------------------------
81+
bool EditorOptions::IsDebugMatrixPropertyVisible() const
82+
{
83+
return core::asBool(PropertiesDisplayFlags::Matrix & m_propertiesDisplayFlags);
7584
}
7685

7786
//--------------------------------------------------------------------------------------
78-
bool EditorOptions::IsDebugPropertyVisible() const
87+
bool EditorOptions::IsDebugRuntimePropertyVisible() const
7988
{
80-
return core::asBool(EditorDebugFlags::DebugProperties & m_debugFlags);
89+
return core::asBool(PropertiesDisplayFlags::Runtime & m_propertiesDisplayFlags);
8190
}
8291

8392
//--------------------------------------------------------------------------------------
84-
bool EditorOptions::IsRuntimeFlagsPropertyVisible() const
93+
bool EditorOptions::IsDebugUIDPropertyVisible() const
8594
{
86-
return core::asBool(EditorDebugFlags::RuntimeFlags & m_debugFlags);
95+
return core::asBool(PropertiesDisplayFlags::UID & m_propertiesDisplayFlags);
8796
}
8897

8998
//--------------------------------------------------------------------------------------
90-
bool EditorOptions::IsUIDPropertyVisible() const
99+
bool EditorOptions::IsMiscDebugPropertyVisible() const
91100
{
92-
return core::asBool(EditorDebugFlags::UID & m_debugFlags);
101+
return core::asBool(PropertiesDisplayFlags::Misc & m_propertiesDisplayFlags);
93102
}
94103

95104
//--------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)