From f5200abf61e731d95f1bcc33e3617242aca21278 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 7 Nov 2023 19:18:46 -0600 Subject: [PATCH] shape --- src/engine/devcmd/cmds/RegionCmd.java | 28 ++++++++++--- src/engine/gameManager/BuildingManager.java | 45 ++------------------- src/engine/objects/Building.java | 3 ++ src/engine/objects/Zone.java | 2 +- 4 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 3a9b8a09..786c493a 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -14,8 +14,11 @@ import engine.devcmd.AbstractDevCmd; import engine.gameManager.BuildingManager; import engine.gameManager.ZoneManager; import engine.math.Vector3f; +import engine.math.Vector3fImmutable; import engine.objects.*; +import java.awt.*; +import java.awt.geom.Area; import java.lang.reflect.Field; public class RegionCmd extends AbstractDevCmd { @@ -52,13 +55,26 @@ public class RegionCmd extends AbstractDevCmd { output += "NavMesh Data" + newline; this.throwbackInfo(pc, output); } - Zone zone = ZoneManager.findSmallestZone(((AbstractCharacter) target).loc); - if(zone != null) { - output += "zone: " + zone.zoneName + newline; - output += "on navmesh: " + zone.navMesh.contains(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z) + newline; - }else { - output += "zone: null" + newline; + //Zone zone = ZoneManager.findSmallestZone(((AbstractCharacter) target).loc); + //if(zone != null) { + // output += "zone: " + zone.zoneName + newline; + // output += "on navmesh: " + zone.navMesh.contains(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z) + newline; + //}else { + // output += "zone: null" + newline; + //} + if( building != null){ + boolean pointBlocked = false; + for(Area area : building.meshes){ + Vector3fImmutable pos = ((AbstractCharacter)target).loc; + if(area.contains(new Point((int) pos.x, (int) pos.z))){ + pointBlocked = true; + } + } + output += "pointBlocked: " + pointBlocked; } + + + this.throwbackInfo(pc, output); } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index c842506c..9f5e219f 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -984,52 +984,13 @@ public enum BuildingManager { return; } - Area footprint = new Area(new Rectangle((int) building.loc.x, (int) building.loc.z, (int) (building.getBounds().getHalfExtents().x * 2), (int) (building.getBounds().getHalfExtents().y * 2))); - building.parentZone.navMesh.subtract(footprint); - for (ArrayList meshEntry : convexHullList) { Polygon poly = new Polygon(); - for(Vector2f vect : meshEntry){ - Vector3fImmutable rotationPoint = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x + building.loc.x,0,vect.y + building.loc.z),building.loc,building.getRot().getRotation()); + for (Vector2f vect : meshEntry) { + Vector3fImmutable rotationPoint = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x + building.loc.x, 0, vect.y + building.loc.z), building.loc, building.getRot().getRotation()); poly.addPoint((int) rotationPoint.x, (int) rotationPoint.z); } - footprint.subtract(new Area(poly)); - //Path2D.Float stencilPath = new Path2D.Float(); - - // Add building offset and rotation to vertices - - //for (Vector2f vertex : meshEntry) { - // vertex.addLocal(building.getLoc().x, building.getLoc().z); - // Vector3fImmutable rotatedPoint = new Vector3fImmutable(vertex.x, 0, vertex.y); - // rotatedPoint = Vector3fImmutable.rotateAroundPoint(building.getLoc(), rotatedPoint, building.getBounds().getQuaternion().angleY); - // vertex.set(rotatedPoint.x, rotatedPoint.z); - //} - - // Move to start of path - - //stencilPath.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); - - // Draw path - - //for (int i = 1; i < meshEntry.size(); i++) - // stencilPath.lineTo(meshEntry.get(i).x, meshEntry.get(i).y); - - // enclose the path - - //stencilPath.closePath(); - - // subtract stencil from zone navmesh - - //Area stencilArea = new Area(stencilPath); - //AffineTransform at = new AffineTransform(); - //at.createTransformedShape(new Polygon()); - //building.parentZone.navMesh.subtract(stencilArea.createTransformedArea(at)); + building.meshes.add(new Area(poly)); } - building.parentZone.navMesh.add(footprint); - - //add in all the regions to the navMesh - - //for (Regions region : building.getBounds().getRegions()) - // building.parentZone.navMesh.add(region.getArea()); } } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index ea9fcfd7..ccb901b7 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -34,6 +34,7 @@ import engine.net.client.msg.UpdateObjectMsg; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.Area; import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; @@ -99,6 +100,8 @@ public class Building extends AbstractWorldObject { private ConcurrentHashMap condemned; private ArrayList children = null; + public ArrayList meshes; + /** * ResultSet Constructor */ diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 93e52d05..24ba8266 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -184,7 +184,7 @@ public class Zone extends AbstractWorldObject { ZoneManager.populateZoneCollections(this); - this.createNavMesh(); + //this.createNavMesh(); }