22 #ifndef BLADERUNNER_OBSTACLES_H 23 #define BLADERUNNER_OBSTACLES_H 25 #include "bladerunner/rect_float.h" 26 #include "bladerunner/vector.h" 30 class BladeRunnerEngine;
31 class SaveFileReadStream;
32 class SaveFileWriteStream;
35 static const int kVertexCount = 150;
36 static const int kPolygonCount = 50;
37 static const int kPolygonVertexCount = 160;
38 static const int kMaxPathSize = 500;
56 Vector2 vertices[kPolygonVertexCount];
57 VertexType vertexType[kPolygonVertexCount];
59 Polygon() : isPresent(
false), verticeCount(0), vertexType()
66 Polygon *_polygonsBackup;
72 static bool lineLineIntersection(LineSegment a, LineSegment b,
Vector2 *intersectionPoint);
73 static bool linePolygonIntersection(LineSegment lineA, VertexType lineAType, Polygon *polyB,
Vector2 *intersectionPoint,
int *intersectionIndex,
int pathLengthSinceLastIntersection);
75 bool mergePolygons(Polygon &polyA, Polygon &PolyB);
83 void add(
float x0,
float z0,
float x1,
float z1) { add(
RectFloat(x0, z0, x1, z1)); }
84 int findEmptyPolygon()
const;
85 static float getLength(
float x0,
float z0,
float x1,
float z1);
88 bool findIntersectionNearest(
int polygonIndex,
Vector2 from,
Vector2 to,
89 int *outVertexIndex,
float *outDistance,
Vector2 *out)
const;
90 bool findIntersectionFarthest(
int polygonIndex,
Vector2 from,
Vector2 to,
91 int *outVertexIndex,
float *outDistance,
Vector2 *out)
const;
94 bool findPolygonVerticeByXZ(
int *polygonIndex,
int *verticeIndex,
int *verticeCount,
float x,
float z)
const;
95 bool findPolygonVerticeByXZWithinTolerance(
float x,
float z,
int *polygonIndex,
int *verticeIndex,
int startSearchFromPolygonIdx)
const;
98 int buildNegativePath(
int polyIndex,
int vertStartIndex,
Vector2 startPos,
int vertEndIndex,
Vector2 endPos,
Vector2 *path,
int pathCapacity,
bool *pathBlocked);
99 int buildPositivePath(
int polyIndex,
int vertStartIndex,
Vector2 startPos,
int vertEndIndex,
Vector2 endPos,
Vector2 *path,
int pathCapacity,
bool *pathBlocked);
101 bool verticesCanIntersect(
int lineType0,
int lineType1,
float x0,
float y0,
float x1,
float y1)
const;
102 bool findFarthestAvailablePathVertex(
Vector2 *path,
int pathSize,
Vector3 start,
Vector3 *next)
const;
Definition: savefile.h:88
Definition: obstacles.h:34
Definition: savefile.h:113
Definition: rect_float.h:32
Definition: bladerunner.h:113