RigsofRods
Soft-body Physics Simulation
Functions
DynamicCollisions.cpp File Reference
#include "DynamicCollisions.h"
#include "Application.h"
#include "Actor.h"
#include "SimData.h"
#include "CartesianToTriangleTransform.h"
#include "Collisions.h"
#include "GameContext.h"
#include "PointColDetector.h"
#include "Triangle.h"
+ Include dependency graph for DynamicCollisions.cpp:

Go to the source code of this file.

Functions

static bool BackfaceCollisionTest (const float distance, const Vector3 &normal, const node_t &surface_point, const std::vector< int > &neighbour_node_ids, const node_t nodes[])
 Determine on which side of a triangle an occuring collision takes place. More...
 
static bool InsideTriangleTest (const CartesianToTriangleTransform::TriangleCoord &local, const float margin)
 Test if a point given in triangle local coordinates lies within the triangle itself. More...
 
void ResolveCollisionForces (const float penetration_depth, node_t &hitnode, node_t &na, node_t &nb, node_t &no, const float alpha, const float beta, const float gamma, const Vector3 &normal, const float dt, const bool remote, ground_model_t &submesh_ground_model)
 Calculate collision forces and apply them to the collision node and the three vertex nodes of the collision triangle. More...
 

Function Documentation

◆ BackfaceCollisionTest()

static bool BackfaceCollisionTest ( const float  distance,
const Vector3 &  normal,
const node_t surface_point,
const std::vector< int > &  neighbour_node_ids,
const node_t  nodes[] 
)
static

Determine on which side of a triangle an occuring collision takes place.

The frontface of the triangle is the side towards which the surface normal is pointing. The backface is the opposite side.

Note
This implementation is a heuristic, not an accurate calculation.
Parameters
distanceSigned shortest distance from collision point to triangle plane.
normalSurface normal of the triangle.
surface_pointArbitrary point within the triangle plane.
neighbour_node_idsIndices of neighbouring nodes connected to the colliding node.
nodes

Definition at line 49 of file DynamicCollisions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InsideTriangleTest()

static bool InsideTriangleTest ( const CartesianToTriangleTransform::TriangleCoord local,
const float  margin 
)
static

Test if a point given in triangle local coordinates lies within the triangle itself.

A point (within in the triangle plane) is located inside the triangle if its barycentric coordinates \(\alpha, \beta, \gamma\) are all positive. The margin additionally defines the maximum distance from the triangle plane within which a three-dimensional point is still considered to be close enough to be inside the triangle.

Parameters
localPoint in triangle local coordinates.
marginRange within which a point is considered to be close enough to the triangle plane.

Definition at line 88 of file DynamicCollisions.cpp.

+ Here is the caller graph for this function:

◆ ResolveCollisionForces()

void ResolveCollisionForces ( const float  penetration_depth,
node_t hitnode,
node_t na,
node_t nb,
node_t no,
const float  alpha,
const float  beta,
const float  gamma,
const Vector3 &  normal,
const float  dt,
const bool  remote,
ground_model_t submesh_ground_model 
)

Calculate collision forces and apply them to the collision node and the three vertex nodes of the collision triangle.

Definition at line 97 of file DynamicCollisions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: