Browse Source

load mesh data and structure meshes

server-collision
FatBoy-DOTC 10 months ago
parent
commit
94e16bdf3d
  1. 9
      src/engine/CollisionEngine/Mesh.java
  2. 1
      src/engine/gameManager/BuildingManager.java

9
src/engine/CollisionEngine/Mesh.java

@ -1,5 +1,7 @@
package engine.CollisionEngine; package engine.CollisionEngine;
import engine.objects.Building;
import java.awt.geom.Line2D; import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
@ -11,6 +13,7 @@ public class Mesh {
public Rectangle2D boundsRect; public Rectangle2D boundsRect;
public float maxY; public float maxY;
public float minY; public float minY;
public Building parentBuilding;
public boolean BoundsCollides(Line2D line){ public boolean BoundsCollides(Line2D line){
for(Line2D side : BoundingLines) for(Line2D side : BoundingLines)
@ -23,7 +26,11 @@ public class Mesh {
public boolean MeshCollides(Line2D line, float charHeight, float charY){ public boolean MeshCollides(Line2D line, float charHeight, float charY){
//check if movement path intersects this mesh //check if movement path intersects this mesh
if(!this.BoundsCollides(line) && !boundsRect.contains(line.getP1()) && !boundsRect.contains(line.getP2())) if(boundsRect == null){
return false;
}
if(!line.intersects(boundsRect) && !boundsRect.contains(line.getP1()) && !boundsRect.contains(line.getP2()))
return false; return false;

1
src/engine/gameManager/BuildingManager.java

@ -996,6 +996,7 @@ public enum BuildingManager {
return; //no data for this mesh return; //no data for this mesh
Mesh generatedMesh = new Mesh(); Mesh generatedMesh = new Mesh();
generatedMesh.parentBuilding = building;
generatedMesh.maxY = building.loc.y + mesh_heights.get(mesh).x; generatedMesh.maxY = building.loc.y + mesh_heights.get(mesh).x;
generatedMesh.minY = building.loc.y + mesh_heights.get(mesh).y; generatedMesh.minY = building.loc.y + mesh_heights.get(mesh).y;
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(mesh); ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(mesh);

Loading…
Cancel
Save