ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ToyMaker::Polytope Class Reference

Primitive for EPA algorithm. More...

#include <types.hpp>

Classes

struct  Face
 Stores the indices of a single face of this polytope. More...

Public Member Functions

 Polytope (const Simplex &simplex)
 Creates a polytope object out of a simplex.
glm::vec3 getNextSearch () const
 Returns the next search direction for a point to add to the polytope.
std::size_t getNumFaces () const
std::size_t getNumPoints () const
glm::vec3 getClosestPoint () const
 Returns the closest point to the origin on the triangle face closest to the origin.
glm::vec3 getClosestTriangleNormal () const
 Returns the direction to the closest point on the polytope's surface from the origin.
AreaTriangle getClosestTriangle () const
 Returns the closest polytope triangle.
AreaTriangle getClosestTriangleSupportA () const
 Gets the points of shape A that were responsible for generating the closest triangle of the polytope.
AreaTriangle getClosestTriangleSupportB () const
 Gets the points of shape B that were responsible for generating the closest triangle of the polytope.
bool append (const glm::vec3 &newPoint, const glm::vec3 &supportA, const glm::vec3 &supportB)
 Appends a new point, replacing the topmost triangle in the polygon with 3 more triangles including the new point.

Private Member Functions

 Polytope ()
glm::vec3 getTriangleCross (const Face &face) const
glm::vec3 getTriangleNorm (const Face &face) const

Private Attributes

std::priority_queue< Face, std::vector< Face >, std::function< bool(const Face &, const Face &)> > mFaces
 The list of triangle faces representing this polytope.
std::vector< glm::vec3 > mPoints {}
 List of points representing this polytope.
std::vector< glm::vec3 > mPointsSupportA {}
 List of points representing support point A, where each point corresponds to the polytope point it generated in mPoints at the same index.
std::vector< glm::vec3 > mPointsSupportB {}
 List of points representing support point B, where each point corresponds to the polytope point it generated in mPoints at the same index.

Detailed Description

Primitive for EPA algorithm.

Represents a polygonal shape contained within the Minkowski difference of two intersecting shapes. Stores polytope faces in order of their proximity to the origin.

Constructor & Destructor Documentation

◆ Polytope() [1/2]

Polytope::Polytope ( )
private

Initializes an empty polytope

◆ Polytope() [2/2]

Polytope::Polytope ( const Simplex & simplex)

Creates a polytope object out of a simplex.

Simplex must be a tetrahedron enclosing the origin – creation will fail otherwise.

Member Function Documentation

◆ append()

bool Polytope::append ( const glm::vec3 & newPoint,
const glm::vec3 & supportA,
const glm::vec3 & supportB )

Appends a new point, replacing the topmost triangle in the polygon with 3 more triangles including the new point.

Parameters
newPointThe new point to add to the polytope
supportAThe term on the LHS of the Minkowski difference that created newPoint
supportBThe term on the RHS of the Minkowski difference that created newPoint
Return values
falseNew point is not beyond current closest point in latest search direction.
trueSuccessfully appended triangles including new point to the list.

◆ getClosestTriangle()

AreaTriangle Polytope::getClosestTriangle ( ) const

Returns the closest polytope triangle.

This is useful when we want to find the barycentric coordinates of this triangle to derive contact points for a pair of intersecting shapes.

◆ getClosestTriangleNormal()

glm::vec3 Polytope::getClosestTriangleNormal ( ) const

Returns the direction to the closest point on the polytope's surface from the origin.

Directly represents the contact normal between two objects.

◆ getNumFaces()

std::size_t ToyMaker::Polytope::getNumFaces ( ) const
inline

Returns the number of faces that this polytope is comprised of


The documentation for this class was generated from the following files:
  • ToyMaker_Main/include/toymaker/engine/spatial_query/types.hpp
  • ToyMaker_Main/src/spatial_query/types.cpp