Jolt Physics
A multi core friendly Game Physics Engine
|
Simple triangle renderer for debugging purposes. More...
#include <DebugRenderer.h>
Classes | |
class | Geometry |
A geometry primitive containing triangle batches for various lods. More... | |
class | LOD |
A single level of detail. More... | |
class | Triangle |
A single triangle. More... | |
class | Vertex |
Vertex format used by the triangle renderer. More... | |
Public Types | |
enum class | ECastShadow { On , Off } |
Enum that determines if a shadow should be cast or not. More... | |
enum class | EDrawMode { Solid , Wireframe } |
Determines how triangles are drawn. More... | |
enum class | ECullMode { CullBackFace , CullFrontFace , Off } |
Determines which polygons are culled. More... | |
using | Batch = Ref<RefTargetVirtual> |
Handle for a batch of triangles. | |
using | GeometryRef = Ref<Geometry> |
Handle for a lodded triangle batch. | |
using | SupportFunction = function<Vec3 (Vec3Arg inDirection)> |
Create a primitive for a convex shape using its support function. | |
Public Member Functions | |
JPH_OVERRIDE_NEW_DELETE | DebugRenderer () |
Constructor. | |
virtual | ~DebugRenderer () |
virtual void | DrawLine (RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor)=0 |
Draw line. | |
void | DrawWireBox (const AABox &inBox, ColorArg inColor) |
Draw wireframe box. | |
void | DrawWireBox (const OrientedBox &inBox, ColorArg inColor) |
void | DrawWireBox (RMat44Arg inMatrix, const AABox &inBox, ColorArg inColor) |
void | DrawMarker (RVec3Arg inPosition, ColorArg inColor, float inSize) |
Draw a marker on a position. | |
void | DrawArrow (RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor, float inSize) |
Draw an arrow. | |
void | DrawCoordinateSystem (RMat44Arg inTransform, float inSize=1.0f) |
Draw coordinate system (3 arrows, x = red, y = green, z = blue) | |
void | DrawPlane (RVec3Arg inPoint, Vec3Arg inNormal, ColorArg inColor, float inSize) |
Draw a plane through inPoint with normal inNormal. | |
void | DrawWireTriangle (RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor) |
Draw wireframe triangle. | |
template<class VERTEX_ARRAY > | |
void | DrawWirePolygon (RMat44Arg inTransform, const VERTEX_ARRAY &inVertices, ColorArg inColor, float inArrowSize=0.0f) |
Draw a wireframe polygon. | |
void | DrawWireSphere (RVec3Arg inCenter, float inRadius, ColorArg inColor, int inLevel=3) |
Draw wireframe sphere. | |
void | DrawWireUnitSphere (RMat44Arg inMatrix, ColorArg inColor, int inLevel=3) |
virtual void | DrawTriangle (RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::Off)=0 |
Draw a single back face culled triangle. | |
void | DrawBox (const AABox &inBox, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
Draw a box. | |
void | DrawBox (RMat44Arg inMatrix, const AABox &inBox, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawSphere (RVec3Arg inCenter, float inRadius, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
Draw a sphere. | |
void | DrawUnitSphere (RMat44Arg inMatrix, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawCapsule (RMat44Arg inMatrix, float inHalfHeightOfCylinder, float inRadius, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawCylinder (RMat44Arg inMatrix, float inHalfHeight, float inRadius, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawOpenCone (RVec3Arg inTop, Vec3Arg inAxis, Vec3Arg inPerpendicular, float inHalfAngle, float inLength, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawSwingLimits (RMat44Arg inMatrix, float inSwingYHalfAngle, float inSwingZHalfAngle, float inEdgeLength, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawPie (RVec3Arg inCenter, float inRadius, Vec3Arg inNormal, Vec3Arg inAxis, float inMinAngle, float inMaxAngle, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
virtual Batch | CreateTriangleBatch (const Triangle *inTriangles, int inTriangleCount)=0 |
Create a batch of triangles that can be drawn efficiently. | |
virtual Batch | CreateTriangleBatch (const Vertex *inVertices, int inVertexCount, const uint32 *inIndices, int inIndexCount)=0 |
Batch | CreateTriangleBatch (const Array< Triangle > &inTriangles) |
Batch | CreateTriangleBatch (const Array< Vertex > &inVertices, const Array< uint32 > &inIndices) |
Batch | CreateTriangleBatch (const VertexList &inVertices, const IndexedTriangleNoMaterialList &inTriangles) |
Batch | CreateTriangleBatchForConvex (SupportFunction inGetSupport, int inLevel, AABox *outBounds=nullptr) |
GeometryRef | CreateTriangleGeometryForConvex (SupportFunction inGetSupport) |
virtual void | DrawGeometry (RMat44Arg inModelMatrix, const AABox &inWorldSpaceBounds, float inLODScaleSq, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode=ECullMode::CullBackFace, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid)=0 |
void | DrawGeometry (RMat44Arg inModelMatrix, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode=ECullMode::CullBackFace, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
virtual void | DrawText3D (RVec3Arg inPosition, const string_view &inString, ColorArg inColor=Color::sWhite, float inHeight=0.5f)=0 |
Draw text. | |
Static Public Member Functions | |
static AABox | sCalculateBounds (const Vertex *inVertices, int inVertexCount) |
Calculate bounding box for a batch of triangles. | |
Static Public Attributes | |
static DebugRenderer * | sInstance = nullptr |
Singleton instance. | |
Protected Member Functions | |
void | Initialize () |
Initialize the system, must be called from the constructor of the DebugRenderer implementation. | |
Simple triangle renderer for debugging purposes.
using DebugRenderer::Batch = Ref<RefTargetVirtual> |
Handle for a batch of triangles.
using DebugRenderer::GeometryRef = Ref<Geometry> |
Handle for a lodded triangle batch.
using DebugRenderer::SupportFunction = function<Vec3 (Vec3Arg inDirection)> |
Create a primitive for a convex shape using its support function.
|
strong |
|
strong |
|
strong |
DebugRenderer::DebugRenderer | ( | ) |
Constructor.
|
virtual |
|
inline |
|
pure virtual |
Create a batch of triangles that can be drawn efficiently.
Implemented in DebugRendererRecorder.
|
pure virtual |
Implemented in DebugRendererRecorder.
DebugRenderer::Batch DebugRenderer::CreateTriangleBatch | ( | const VertexList & | inVertices, |
const IndexedTriangleNoMaterialList & | inTriangles ) |
DebugRenderer::Batch DebugRenderer::CreateTriangleBatchForConvex | ( | SupportFunction | inGetSupport, |
int | inLevel, | ||
AABox * | outBounds = nullptr ) |
DebugRenderer::GeometryRef DebugRenderer::CreateTriangleGeometryForConvex | ( | SupportFunction | inGetSupport | ) |
Draw an arrow.
void DebugRenderer::DrawBox | ( | const AABox & | inBox, |
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a box.
void DebugRenderer::DrawBox | ( | RMat44Arg | inMatrix, |
const AABox & | inBox, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
void DebugRenderer::DrawCapsule | ( | RMat44Arg | inMatrix, |
float | inHalfHeightOfCylinder, | ||
float | inRadius, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a capsule with one half sphere at (0, -inHalfHeightOfCylinder, 0) and the other half sphere at (0, inHalfHeightOfCylinder, 0) and radius inRadius. The capsule will be transformed by inMatrix.
void DebugRenderer::DrawCoordinateSystem | ( | RMat44Arg | inTransform, |
float | inSize = 1.0f ) |
Draw coordinate system (3 arrows, x = red, y = green, z = blue)
void DebugRenderer::DrawCylinder | ( | RMat44Arg | inMatrix, |
float | inHalfHeight, | ||
float | inRadius, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a cylinder with top (0, inHalfHeight, 0) and bottom (0, -inHalfHeight, 0) and radius inRadius. The cylinder will be transformed by inMatrix
|
inline |
|
pure virtual |
Draw some geometry
inModelMatrix | is the matrix that transforms the geometry to world space. |
inWorldSpaceBounds | is the bounding box of the geometry after transforming it into world space. |
inLODScaleSq | is the squared scale of the model matrix, it is multiplied with the LOD distances in inGeometry to calculate the real LOD distance (so a number > 1 will force a higher LOD). |
inModelColor | is the color with which to multiply the vertex colors in inGeometry. |
inGeometry | The geometry to draw. |
inCullMode | determines which polygons are culled. |
inCastShadow | determines if this geometry should cast a shadow or not. |
inDrawMode | determines if we draw the geometry solid or in wireframe. |
Implemented in DebugRendererRecorder.
|
pure virtual |
Draw line.
Implemented in DebugRendererRecorder.
Draw a marker on a position.
void DebugRenderer::DrawOpenCone | ( | RVec3Arg | inTop, |
Vec3Arg | inAxis, | ||
Vec3Arg | inPerpendicular, | ||
float | inHalfAngle, | ||
float | inLength, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a bottomless cone.
inTop | Top of cone, center of base is at inTop + inAxis. |
inAxis | Height and direction of cone |
inPerpendicular | Perpendicular vector to inAxis. |
inHalfAngle | Specifies the cone angle in radians (angle measured between inAxis and cone surface). |
inLength | The length of the cone. |
inColor | Color to use for drawing the cone. |
inCastShadow | determins if this geometry should cast a shadow or not. |
inDrawMode | determines if we draw the geometry solid or in wireframe. |
void DebugRenderer::DrawPie | ( | RVec3Arg | inCenter, |
float | inRadius, | ||
Vec3Arg | inNormal, | ||
Vec3Arg | inAxis, | ||
float | inMinAngle, | ||
float | inMaxAngle, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a pie (part of a circle).
inCenter | The center of the circle. |
inRadius | Radius of the circle. |
inNormal | The plane normal in which the pie resides. |
inAxis | The axis that defines an angle of 0 radians. |
inMinAngle | The pie will be drawn between [inMinAngle, inMaxAngle] (in radians). |
inMaxAngle | The pie will be drawn between [inMinAngle, inMaxAngle] (in radians). |
inColor | Color to use for drawing the pie. |
inCastShadow | determins if this geometry should cast a shadow or not. |
inDrawMode | determines if we draw the geometry solid or in wireframe. |
void DebugRenderer::DrawPlane | ( | RVec3Arg | inPoint, |
Vec3Arg | inNormal, | ||
ColorArg | inColor, | ||
float | inSize ) |
Draw a plane through inPoint with normal inNormal.
void DebugRenderer::DrawSphere | ( | RVec3Arg | inCenter, |
float | inRadius, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draw a sphere.
void DebugRenderer::DrawSwingLimits | ( | RMat44Arg | inMatrix, |
float | inSwingYHalfAngle, | ||
float | inSwingZHalfAngle, | ||
float | inEdgeLength, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
Draws rotation limits as used by the SwingTwistConstraintPart.
inMatrix | Matrix that transforms from constraint space to world space |
inSwingYHalfAngle | See SwingTwistConstraintPart |
inSwingZHalfAngle | See SwingTwistConstraintPart |
inEdgeLength | Size of the edge of the cone shape |
inColor | Color to use for drawing the cone. |
inCastShadow | determins if this geometry should cast a shadow or not. |
inDrawMode | determines if we draw the geometry solid or in wireframe. |
|
pure virtual |
Draw text.
Implemented in DebugRendererRecorder.
|
pure virtual |
Draw a single back face culled triangle.
Implemented in DebugRendererRecorder.
void DebugRenderer::DrawUnitSphere | ( | RMat44Arg | inMatrix, |
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On, | ||
EDrawMode | inDrawMode = EDrawMode::Solid ) |
void DebugRenderer::DrawWireBox | ( | const OrientedBox & | inBox, |
ColorArg | inColor ) |
|
inline |
Draw a wireframe polygon.
void DebugRenderer::DrawWireSphere | ( | RVec3Arg | inCenter, |
float | inRadius, | ||
ColorArg | inColor, | ||
int | inLevel = 3 ) |
Draw wireframe sphere.
void DebugRenderer::DrawWireTriangle | ( | RVec3Arg | inV1, |
RVec3Arg | inV2, | ||
RVec3Arg | inV3, | ||
ColorArg | inColor ) |
Draw wireframe triangle.
|
protected |
Initialize the system, must be called from the constructor of the DebugRenderer implementation.
Calculate bounding box for a batch of triangles.
|
static |
Singleton instance.