From 93a4d16427902f7c85f6b963862d411b1f8b1906 Mon Sep 17 00:00:00 2001 From: austin Date: Thu, 22 May 2025 14:21:28 -0400 Subject: [PATCH] debug view of entity colliders --- docs/src/progress/renderertodo.md | 1 + .../menu/debug/entity/ImGuiEntityMacros.java | 2 +- .../entity/tabs/ImGuiEntityPhysicsTab.java | 81 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index c6a4cd0c..28f7bdce 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1933,6 +1933,7 @@ Geom-only collidables on server (05/22/2025) Block colliders leveraging spaces Scene view debug window +Debug view of entity colliders diff --git a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java index d72bd3b5..7214a909 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityMacros.java @@ -200,7 +200,7 @@ public class ImGuiEntityMacros { if(ServerPlayerViewDirTree.hasTree(detailViewEntity) && ImGui.checkbox("Server View Dir", showServerViewDirTab)){ showServerViewDirTab = !showServerViewDirTab; } - if(PhysicsEntityUtils.getDBody(detailViewEntity) != null && ImGui.checkbox("Physics", showPhysicsTab)){ + if((PhysicsEntityUtils.getDBody(detailViewEntity) != null || PhysicsEntityUtils.getDGeom(detailViewEntity) != null) && ImGui.checkbox("Physics", showPhysicsTab)){ showPhysicsTab = !showPhysicsTab; } if(HitboxCollectionState.hasHitboxState(detailViewEntity) && ImGui.checkbox("Hitbox State", showHitboxTab)){ diff --git a/src/main/java/electrosphere/client/ui/menu/debug/entity/tabs/ImGuiEntityPhysicsTab.java b/src/main/java/electrosphere/client/ui/menu/debug/entity/tabs/ImGuiEntityPhysicsTab.java index 1ae95176..7ba2b7c9 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/entity/tabs/ImGuiEntityPhysicsTab.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/entity/tabs/ImGuiEntityPhysicsTab.java @@ -1,6 +1,8 @@ package electrosphere.client.ui.menu.debug.entity.tabs; import org.ode4j.ode.DBody; +import org.ode4j.ode.DGeom; +import org.ode4j.ode.DSpace; import electrosphere.client.ui.components.imgui.CollidableEditBlock; import electrosphere.collision.PhysicsEntityUtils; @@ -89,6 +91,85 @@ public class ImGuiEntityPhysicsTab { CollidableEditBlock.drawCollidableEdit(physicsBody, template); } } + + if(PhysicsEntityUtils.getDGeom(detailViewEntity) != null){ + DGeom collider = PhysicsEntityUtils.getDGeom(detailViewEntity); + if(collider != null){ + if(collider instanceof DSpace space){ + int i = 0; + for(DGeom child : space.getGeoms()){ + ImGui.text("Child " + i); + ImGui.indent(); + ImGui.text("Position: " + child.getPosition()); + ImGui.text("Rotation: " + child.getQuaternion()); + ImGui.text("Offset Position: " + child.getOffsetPosition()); + ImGui.unindent(); + i++; + } + } else { + ImGui.text("Position: " + collider.getPosition()); + ImGui.text("Rotation: " + collider.getQuaternion()); + ImGui.text("Offset Position: " + collider.getOffsetPosition()); + } + } + //synchronized data + if( + Globals.clientState.clientSceneWrapper.getScene().getEntityFromId(detailViewEntity.getId()) != null && + Globals.clientState.clientSceneWrapper.mapClientToServerId(detailViewEntity.getId()) != -1 + ){ + //detailViewEntity is a client entity + //get server entity + int serverIdForClientEntity = Globals.clientState.clientSceneWrapper.mapClientToServerId(detailViewEntity.getId()); + Entity serverEntity = EntityLookupUtils.getEntityById(serverIdForClientEntity); + DGeom serverCollider = PhysicsEntityUtils.getDGeom(serverEntity); + if(serverCollider != null){ + ImGui.newLine(); + ImGui.text("Linked server entity:"); + if(serverCollider instanceof DSpace space){ + int i = 0; + for(DGeom child : space.getGeoms()){ + ImGui.text("Child " + i); + ImGui.indent(); + ImGui.text("Position: " + child.getPosition()); + ImGui.text("Rotation: " + child.getQuaternion()); + ImGui.text("Offset Position: " + child.getOffsetPosition()); + ImGui.unindent(); + i++; + } + } else { + ImGui.text("Position: " + serverCollider.getPosition()); + ImGui.text("Rotation: " + serverCollider.getQuaternion()); + ImGui.text("Offset Position: " + serverCollider.getOffsetPosition()); + } + } + } else if(Globals.clientState.clientSceneWrapper.containsServerId(detailViewEntity.getId())){ + //detailViewEntity is a server entity + //get client entity + int clientId = Globals.clientState.clientSceneWrapper.mapServerToClientId(detailViewEntity.getId()); + Entity clientEntity = Globals.clientState.clientSceneWrapper.getScene().getEntityFromId(clientId); + DGeom clientCollider = PhysicsEntityUtils.getDGeom(clientEntity); + if(clientCollider != null){ + ImGui.newLine(); + ImGui.text("Linked client entity:"); + if(clientCollider instanceof DSpace space){ + int i = 0; + for(DGeom child : space.getGeoms()){ + ImGui.text("Child " + i); + ImGui.indent(); + ImGui.text("Position: " + child.getPosition()); + ImGui.text("Rotation: " + child.getQuaternion()); + ImGui.text("Offset Position: " + child.getOffsetPosition()); + ImGui.unindent(); + i++; + } + } else { + ImGui.text("Position: " + clientCollider.getPosition()); + ImGui.text("Rotation: " + clientCollider.getQuaternion()); + ImGui.text("Offset Position: " + clientCollider.getOffsetPosition()); + } + } + } + } ImGui.unindent(); } }