debug view of entity colliders

This commit is contained in:
austin 2025-05-22 14:21:28 -04:00
parent 4e4367f915
commit 93a4d16427
3 changed files with 83 additions and 1 deletions

View File

@ -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

View File

@ -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)){

View File

@ -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();
}
}