From f8cbeb4cc699764ec8950245b67913e8a3b62f59 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 3 Jan 2024 19:33:34 -0600 Subject: [PATCH] debug dev command for collision --- src/engine/collision/Mesh.java | 2 ++ src/engine/devcmd/cmds/RegionCmd.java | 13 +++++++++++-- src/engine/gameManager/BuildingManager.java | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/engine/collision/Mesh.java b/src/engine/collision/Mesh.java index e0be17b4..f0a8868d 100644 --- a/src/engine/collision/Mesh.java +++ b/src/engine/collision/Mesh.java @@ -2,11 +2,13 @@ package engine.collision; import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; import java.util.ArrayList; public class Mesh { public ArrayList triangles; public ArrayList BoundingLines; + public Rectangle2D boundsRect; public float meshHeight; public boolean BoundsCollides(Line2D line){ diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 7ba118eb..664f97eb 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -10,10 +10,12 @@ package engine.devcmd.cmds; import engine.Enum; +import engine.collision.Mesh; import engine.devcmd.AbstractDevCmd; import engine.gameManager.BuildingManager; import engine.objects.*; +import java.awt.geom.Point2D; import java.lang.reflect.Field; public class RegionCmd extends AbstractDevCmd { @@ -37,7 +39,6 @@ public class RegionCmd extends AbstractDevCmd { Regions region = ((AbstractCharacter)target).region; if (region == null) { this.throwbackInfo(pc, "No Region Found."); - return; } if(region != null) { @@ -48,7 +49,15 @@ public class RegionCmd extends AbstractDevCmd { output += "is Outside: " + region.isOutside(); this.throwbackInfo(pc, output); } - + if(building != null){ + for(Mesh mesh : building.buildingMeshes){ + if(mesh.boundsRect.contains(new Point2D.Float(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z))){ + this.throwbackInfo(pc, "Inside Mesh Bounds"); + return; + } + } + this.throwbackInfo(pc, "Outside Mesh Bounds"); + } } @Override diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index d0700f36..51674173 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -1031,6 +1031,9 @@ public enum BuildingManager { tri.sides.add(new Line2D.Float(p3,p1)); generatedMesh.triangles.add(tri); } + if(BuildingManager.mesh_bounding_boxes.containsKey(mesh)){ + generatedMesh.boundsRect = BuildingManager.mesh_bounding_boxes.get(mesh); + } building.buildingMeshes.add(generatedMesh); } }