#pragma once #include #include #include "Shape.h" #include namespace J3ML::Geometry { class Polygon : public Shape { public: std::vector vertices; /// Quickly returns an arbitrary point inside this AABB. Used in GJK intersection test. Vector3 AnyPointFast() const; AABB MinimalEnclosingAABB() const; int NumVertices() const; Vector3 Vertex(int vertexIndex) const; Vector3 ExtremePoint(const Vector3 &direction, float &projectionDistance) const; Vector3 ExtremePoint(const Vector3 &direction) const; void ProjectToAxis(const Vector3 &direction, float &outMin, float &outMax) const; bool Intersects(const Capsule &capsule) const; bool Intersects(const Line &line) const; bool Intersects(const Ray &ray) const; bool Intersects(const LineSegment &lineSegment) const; bool Intersects(const Plane &plane) const; bool Intersects(const AABB &aabb) const; bool Intersects(const OBB &obb) const; bool Intersects(const Triangle &triangle, float polygonThickness = 1e-3f) const; bool Intersects(const Polygon &polygon, float polygonThickness = 1e-3f) const; bool Intersects(const Frustum &frustum) const; bool Intersects(const Polyhedron &polyhedron) const; bool Intersects(const Sphere &sphere) const; std::vector Triangulate() const; /// Tests if this polygon is planar. /** A polygon is planar if all its vertices lie on the same plane. @note Almost all functions in this class require that the polygon is planar. While you can store vertices of non-planar polygons in this class, they are better avoided. Read the member function documentation carefully to avoid calling for non-planar polygons any functions which assume planarity. @see IsConvex(), IsSimple(), IsNull(), IsFinite(), IsDegenerate(). */ bool IsPlanar(float epsilonSq = 1e-4f) const; Vector2 MapTo2D(int i) const; Vector2 MapTo2D(const Vector3 &point) const; Vector3 BasisU() const; Vector3 BasisV() const; Plane PlaneCCW() const; bool Contains(const Polygon &worldSpacePolygon, float polygonThickness) const; bool Contains(const Vector3 &worldSpacePoint, float polygonThicknessSq = 1e-2f) const; bool Contains(const LineSegment &worldSpaceLineSegment, float polygonThickness) const; bool Contains(const Triangle &worldSpaceTriangle, float polygonThickness) const; LineSegment Edge(int i) const; bool ConvexIntersects(const AABB &aabb) const; bool ConvexIntersects(const OBB &obb) const; bool ConvexIntersects(const Frustum &frustum) const; Vector3 MapFrom2D(const Vector2 &point) const; bool Intersects2D(const LineSegment &segment) const; Vector3 ClosestPoint(const LineSegment &lineSegment) const; Vector3 ClosestPoint(const LineSegment &lineSegment, Vector3 *lineSegmentPt) const; Vector3 ClosestPoint(const Vector3 &point) const; protected: }; }