|
Untitled Game engine no.5
1.0
|
#include <Physics.hpp>
Public Types | |
| enum | CollisionType { D2, D3 } |
Static Public Member Functions | |
| static std::vector< CollisionPoint > | Raycast (const Scene &scene, glm::vec3 pos, glm::vec3 dir, float maxDistance=FLT_MAX) |
| static CollisionPoint | RaycastClosest (const Scene &scene, glm::vec3 pos, glm::vec3 dir, float maxDistance=FLT_MAX) |
| static CollisionPoint | GJK_EPA (const Shape &colliderA, const Shape &colliderB, CollisionType type=D3) |
| Combination Gilbert-Johnson-Keerthi Expanding-Polytope-Algorithm TODO: (not fully memory optimized) | |
| static CollisionPoint | EPA2 (Simplex &simplex, const Shape &shapeA, const Shape &shapeB) |
| Expanding Polytope Algorithm Implementation Calculates the separation normal from a colliding GJK simplex. Assumes that the input simplex contains a collision. More... | |
| static bool | GJK (const Shape &colliderA, const Shape &colliderB, Simplex &simplex, CollisionType type) |
| Gilbert-Johnson-Keerthi collision detection algorithm https://blog.winter.dev/2020/gjk-algorithm/ improved from. More... | |
| static bool | NextSimplex (Simplex &simplex, glm::vec3 &direction, CollisionType type) |
| static bool | Line (Simplex &simplex, glm::vec3 &direction) |
| static bool | Triangle (Simplex &simplex, glm::vec3 &direction) |
| static bool | Tetrahedron (Simplex &simplex, glm::vec3 &direction) |
| static void | Update (Scene &scene) |
| static void | simulateSystem (Scene &scene, float dt) |
| Simulate the scene elements by a delta t Partially Implements Extended Position Based Dynamics. More... | |
| static CollisionPoint | processJoint (const Ref< Joint > &joint, const Ref< PhysicsEntity > &pe1, const Ref< PhysicsEntity > &pe2) |
| static void | processJoints (const std::vector< Ref< Joint >> &joints, float h) |
| static void | processCollisions (std::vector< Ref< PhysicsEntity >> &elements, float h, CollisionType type=D3) |
| Generate collision data and solve it. More... | |
| static void | applyManifold (CollisionPoint cp, Ref< PhysicsEntity > &e1, Ref< PhysicsEntity > &e2, float h) |
| static std::vector< Ref< Joint > > | CollectJoints (const Scene &scene) |
| static std::vector< Ref< PhysicsEntity > > | CollectBodiesAndParticles (Scene &scene) |
| static std::vector< Ref< PhysicsEntity > > | Collect2DElements (Scene &scene) |
| static Support | furthestDiff (const Shape &shapeA, const Shape &shapeB, const glm::vec3 &norm, Support &support) |
| static void | Barycentric (const glm::vec3 &p, const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c, float &u, float &v, float &w) |
XPBD GJK EPA style physics engine (enjoy :) ).
Enumeration for indexing 3D or 2D physics interactions.
|
inlinestatic |
Process delta x and delta q data from joints or collisions.
| cp | delta data |
| e1 | physics entity 1 |
| e2 | physics entitiy 2 |
| h | delta t |
|
inlinestatic |
Calculate barycentric coordinates.
lovingly adapted from https://gamedev.stackexchange.com/questions/23743/whats-the-most-efficient-way-to-find-barycentric-coordinates
Inputs are the collision point the face vertexes and the outputs are the triangle coordinates (u, v, w).
| p | |
| a | |
| b | |
| c | |
| u | |
| v | |
| w |
|
inlinestatic |
Generate a list of 2D PhysicsEntity from the scene.
| scene | reference |
|
inlinestatic |
Generate a list of PhysicsEntity from the scene.
| scene | reference |
|
inlinestatic |
Expanding Polytope Algorithm Implementation Calculates the separation normal from a colliding GJK simplex. Assumes that the input simplex contains a collision.
lovingly adapted from https://github.com/kevinmoran/GJK/blob/master/GJK.h
| simplex | output from running GJK |
| shapeA | shape definition for object A |
| shapeB | shape definition for object B |
|
inlinestatic |
Find the difference vector between the two furthest vertex points in the two shapes along the normal.
| shapeA | |
| shapeB | |
| norm | |
| support | storage for the support points |
|
inlinestatic |
Gilbert-Johnson-Keerthi collision detection algorithm https://blog.winter.dev/2020/gjk-algorithm/ improved from.
| colliderA | shape definition for object A |
| colliderB | shape definition for object B |
| simplex | storage for simplex data |
|
inlinestatic |
Generate collision data and solve it.
Using GKJ and EPA produce collision normals and then solve them using XPBD.
| elements | list of physics elements |
| h | delta t |
| type | type of collisions to produce (for 2D the physics are not calculated) |
|
inlinestatic |
Process a Joint structure using physics entity data.
| joint | |
| pe1 | |
| pe2 |
|
inlinestatic |
Generate Joint collision interactions.
| joints | list of joints |
| h | delta t |
|
inlinestatic |
Unimplemented raycasting function. TODO: Implement and test
| scene | |
| pos | |
| dir | |
| maxDistance |
|
inlinestatic |
Another unimplemented Raycasting function. TODO: Implement and test
| scene | |
| pos | |
| dir | |
| maxDistance |
|
inlinestatic |
Simulate the scene elements by a delta t Partially Implements Extended Position Based Dynamics.
Collects PhysicsEntities from the scene. Calculates their interactions. Produces delta values. And updates the corresponding scene components.
| scene | scene reference |
| dt | time delta |
|
inlinestatic |
Update the physics parameters of the scene.
| scene |
1.8.17