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

Primitive for GJK algorithm. More...

#include <types.hpp>

Public Member Functions

bool append (const glm::vec3 &candidatePoint, const glm::vec3 &supportA, const glm::vec3 &supportB)
 Adds a new point to the simplex.
void reorder (const std::vector< uint8_t > reorderedIndices)
 Replaces the current simplex with points from a new list (which will usually have as many or fewer points).
std::pair< bool, glm::vec3 > evaluate ()
 Tries to find a 3-simplex that encloses the origin.

Public Attributes

std::array< glm::vec3, 4 > mPoints
 Points representing the simplex, derived by finding the Minksowski difference of support points on two convex shapes.
std::array< glm::vec3, 4 > mPointsSupportA
 The point on the LHS of the Minkowski difference, where each index corresponds to a point on mPoints.
std::array< glm::vec3, 4 > mPointsSupportB
 The point on the RHS of the Minkowski difference, where each index corresponds to a point on mPoints.
uint8_t mNPoints { 0 }
 The number of points in this simplex.

Private Member Functions

std::pair< bool, glm::vec3 > doSimplex4 ()
glm::vec3 doSimplex3 ()
glm::vec3 doSimplex2 ()

Detailed Description

Primitive for GJK algorithm.

Stores up to 4 points which should enclose the origin in the Minkowski different of two shapes (if those shapes intersect).

Member Function Documentation

◆ append()

bool ToyMaker::Simplex::append ( const glm::vec3 & candidatePoint,
const glm::vec3 & supportA,
const glm::vec3 & supportB )
inline

Adds a new point to the simplex.

Return values
falseA duplicate was found, and this point could not be added
trueAppended new point successfully

◆ evaluate()

std::pair< bool, glm::vec3 > Simplex::evaluate ( )

Tries to find a 3-simplex that encloses the origin.

Implementation of the simplex evaluation/simplification test in GJK, an algorithm for determining whether 2 convex shapes intersect. When they do intersect, this simplex forms a tetrahedron containing point (0, 0, 0).

Returns
Whether this simplex forms a tetrahedron enclosing (0, 0, 0), and a search direction to use in the next support function call

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