Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 56 additions & 13 deletions Mods/Editor/Src/Components/DebugChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,36 @@ void Editor::DrawDebugChannels(bool p_HasFocus) {

ImGui::Checkbox("Draw Gizmos", &m_DrawGizmos);

ImGui::Indent();

ImGui::BeginDisabled(!m_DrawGizmos);

if (ImGui::Checkbox("Draw All Gizmos", &m_DrawAllGizmos)) {
for (auto& [s_DebugChannel, s_IsVisible] : m_DebugChannelToState) {
s_IsVisible = m_DrawAllGizmos;
}
}

ImGui::Checkbox("Draw Gizmos For Selected Entity Only", &m_DrawGizmosForSelectedEntityOnly);

ImGui::EndDisabled();

ImGui::Unindent();

ImGui::Separator();

ImGui::Checkbox("Draw Shapes", &m_DrawShapes);

ImGui::Indent();

ImGui::BeginDisabled(!m_DrawShapes);

ImGui::Checkbox("Draw Shapes For Selected Entity Only", &m_DrawShapesForSelectedEntityOnly);

ImGui::EndDisabled();

ImGui::Unindent();

for (const auto& pair : m_DebugChannels) {
const std::string s_Header = fmt::format(
"{} ({})",
Expand Down Expand Up @@ -357,7 +377,26 @@ void Editor::DrawDebugChannels(bool p_HasFocus) {
}

void Editor::DrawDebugEntities(IRenderer* p_Renderer) {
if (!m_DrawGizmos && !m_DrawShapes) {
if (!m_DrawGizmos && !m_DrawShapes && !m_DrawGizmosForSelectedEntityOnly && !m_DrawShapesForSelectedEntityOnly) {
return;
}

if ((m_DrawGizmosForSelectedEntityOnly || m_DrawShapesForSelectedEntityOnly) && !m_DrawGizmos && !m_DrawShapes) {
auto it = m_EntityRefToDebugEntities.find(m_SelectedEntity);

if (it == m_EntityRefToDebugEntities.end()) {
return;
}

for (const auto& s_DebugEntity : it->second) {
if (s_DebugEntity->m_HasGizmo) {
DrawGizmo(static_cast<GizmoEntity&>(*s_DebugEntity), p_Renderer);
}
else {
DrawShapes(*s_DebugEntity, p_Renderer);
}
}

return;
}

Expand Down Expand Up @@ -393,16 +432,18 @@ void Editor::DrawDebugEntities(IRenderer* p_Renderer) {
}

void Editor::DrawGizmo(GizmoEntity& p_GizmoEntity, IRenderer* p_Renderer) {
if (!m_DrawGizmos) {
if (!m_DrawGizmos && !m_DrawGizmosForSelectedEntityOnly) {
return;
}

if (!m_DebugChannelToState[p_GizmoEntity.m_DebugChannel]) {
return;
}
if (m_DrawGizmos) {
if (!m_DebugChannelToState[p_GizmoEntity.m_DebugChannel]) {
return;
}

if (!m_DebugChannelToTypeNameToState[p_GizmoEntity.m_DebugChannel][p_GizmoEntity.m_TypeName]) {
return;
if (!m_DebugChannelToTypeNameToState[p_GizmoEntity.m_DebugChannel][p_GizmoEntity.m_TypeName]) {
return;
}
}

if (p_GizmoEntity.m_DebugChannel == EDebugChannel::DEBUGCHANNEL_PARTITIONING &&
Expand Down Expand Up @@ -481,16 +522,18 @@ void Editor::DrawGizmo(GizmoEntity& p_GizmoEntity, IRenderer* p_Renderer) {
}

void Editor::DrawShapes(const DebugEntity& p_DebugEntity, IRenderer* p_Renderer) {
if (!m_DrawShapes) {
if (!m_DrawShapes && !m_DrawShapesForSelectedEntityOnly) {
return;
}

if (!m_DebugChannelToState[p_DebugEntity.m_DebugChannel]) {
return;
}
if (m_DrawShapes) {
if (!m_DebugChannelToState[p_DebugEntity.m_DebugChannel]) {
return;
}

if (!m_DebugChannelToTypeNameToState[p_DebugEntity.m_DebugChannel][p_DebugEntity.m_TypeName]) {
return;
if (!m_DebugChannelToTypeNameToState[p_DebugEntity.m_DebugChannel][p_DebugEntity.m_TypeName]) {
return;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Mods/Editor/Src/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,8 @@ DEFINE_PLUGIN_DETOUR(Editor, void, OnClearScene, ZEntitySceneContext* th, bool p
m_GlobalOutfitKit = {};

m_SelectedGizmoEntity = nullptr;
m_DrawGizmosForSelectedEntityOnly = false;
m_DrawShapesForSelectedEntityOnly = false;

m_EntityRefToDebugEntities.clear();

Expand Down
2 changes: 2 additions & 0 deletions Mods/Editor/Src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ class Editor : public IPluginInterface {
bool m_DrawAllGizmos = false;
bool m_DrawShapes = false;
GizmoEntity* m_SelectedGizmoEntity = nullptr;
bool m_DrawGizmosForSelectedEntityOnly = false;
bool m_DrawShapesForSelectedEntityOnly = false;

bool m_DrawCoverInvalidOnNPCErrors = true;
bool m_DrawHeroGuidesSolid = false;
Expand Down