Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
PolyhedronSubmergedVolumeCalculator Class Reference

#include <PolyhedronSubmergedVolumeCalculator.h>

Classes

class  Point
 A helper class that contains cached information about a polyhedron vertex. More...
 

Public Member Functions

 PolyhedronSubmergedVolumeCalculator (const Mat44 &inTransform, const Vec3 *inPoints, int inPointStride, int inNumPoints, const Plane &inSurface, Point *ioBuffer, RVec3 inBaseOffset)
 
bool AreAllAbove () const
 Check if all points are above the surface. Should be used as early out.
 
bool AreAllBelow () const
 Check if all points are below the surface. Should be used as early out.
 
int GetReferencePointIdx () const
 Get the lowest point of the polyhedron. Used to form the 4th vertex to make a tetrahedron out of a polyhedron face.
 
void AddFace (int inIdx1, int inIdx2, int inIdx3)
 Add a polyhedron face. Supply the indices of the points that form the face (in counter clockwise order).
 
void GetResult (float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy) const
 Call after all faces have been added. Returns the submerged volume and the center of buoyancy for the submerged volume.
 

Detailed Description

This class calculates the intersection between a fluid surface and a polyhedron and returns the submerged volume and its center of buoyancy Construct this class and then one by one add all faces of the polyhedron using the AddFace function. After all faces have been added the result can be gotten through GetResult.

Constructor & Destructor Documentation

◆ PolyhedronSubmergedVolumeCalculator()

PolyhedronSubmergedVolumeCalculator::PolyhedronSubmergedVolumeCalculator ( const Mat44 inTransform,
const Vec3 inPoints,
int  inPointStride,
int  inNumPoints,
const Plane inSurface,
Point ioBuffer,
RVec3  inBaseOffset 
)
inline

Constructor

Parameters
inTransformTransform to transform all incoming points with
inPointsArray of points that are part of the polyhedron
inPointStrideAmount of bytes between each point (should usually be sizeof(Vec3))
inNumPointsThe amount of points
inSurfaceThe plane that forms the fluid surface (normal should point up)
ioBufferA temporary buffer of Point's that should have inNumPoints entries and should stay alive while this class is alive
inBaseOffsetThe offset to transform inTransform to world space (in double precision mode this can be used to shift the whole operation closer to the origin). Only used for debug drawing.

Member Function Documentation

◆ AddFace()

void PolyhedronSubmergedVolumeCalculator::AddFace ( int  inIdx1,
int  inIdx2,
int  inIdx3 
)
inline

Add a polyhedron face. Supply the indices of the points that form the face (in counter clockwise order).

◆ AreAllAbove()

bool PolyhedronSubmergedVolumeCalculator::AreAllAbove ( ) const
inline

Check if all points are above the surface. Should be used as early out.

◆ AreAllBelow()

bool PolyhedronSubmergedVolumeCalculator::AreAllBelow ( ) const
inline

Check if all points are below the surface. Should be used as early out.

◆ GetReferencePointIdx()

int PolyhedronSubmergedVolumeCalculator::GetReferencePointIdx ( ) const
inline

Get the lowest point of the polyhedron. Used to form the 4th vertex to make a tetrahedron out of a polyhedron face.

◆ GetResult()

void PolyhedronSubmergedVolumeCalculator::GetResult ( float &  outSubmergedVolume,
Vec3 outCenterOfBuoyancy 
) const
inline

Call after all faces have been added. Returns the submerged volume and the center of buoyancy for the submerged volume.


The documentation for this class was generated from the following file: