Jolt Physics
A multi core friendly Game Physics Engine
|
#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. More... | |
using | GeometryRef = Ref< Geometry > |
Handle for a lodded triangle batch. More... | |
using | SupportFunction = function< Vec3(Vec3Arg inDirection)> |
Create a primitive for a convex shape using its support function. More... | |
Public Member Functions | |
JPH_OVERRIDE_NEW_DELETE | DebugRenderer () |
Constructor. More... | |
virtual | ~DebugRenderer () |
void | NextFrame () |
Call once after frame is complete. Releases unused dynamically generated geometry assets. More... | |
virtual void | DrawLine (RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor)=0 |
Draw line. More... | |
void | DrawWireBox (const AABox &inBox, ColorArg inColor) |
Draw wireframe box. More... | |
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. More... | |
void | DrawArrow (RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor, float inSize) |
Draw an arrow. More... | |
void | DrawCoordinateSystem (RMat44Arg inTransform, float inSize=1.0f) |
Draw coordinate system (3 arrows, x = red, y = green, z = blue) More... | |
void | DrawPlane (RVec3Arg inPoint, Vec3Arg inNormal, ColorArg inColor, float inSize) |
Draw a plane through inPoint with normal inNormal. More... | |
void | DrawWireTriangle (RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor) |
Draw wireframe triangle. More... | |
template<class VERTEX_ARRAY > | |
void | DrawWirePolygon (RMat44Arg inTransform, const VERTEX_ARRAY &inVertices, ColorArg inColor, float inArrowSize=0.0f) |
Draw a wireframe polygon. More... | |
void | DrawWireSphere (RVec3Arg inCenter, float inRadius, ColorArg inColor, int inLevel=3) |
Draw wireframe sphere. More... | |
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. More... | |
void | DrawBox (const AABox &inBox, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
Draw a box. More... | |
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. More... | |
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 | DrawSwingConeLimits (RMat44Arg inMatrix, float inSwingYHalfAngle, float inSwingZHalfAngle, float inEdgeLength, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid) |
void | DrawSwingPyramidLimits (RMat44Arg inMatrix, float inMinSwingYAngle, float inMaxSwingYAngle, float inMinSwingZAngle, float inMaxSwingZAngle, 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. More... | |
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. More... | |
Public Member Functions inherited from NonCopyable | |
NonCopyable ()=default | |
NonCopyable (const NonCopyable &)=delete | |
void | operator= (const NonCopyable &)=delete |
Static Public Member Functions | |
static AABox | sCalculateBounds (const Vertex *inVertices, int inVertexCount) |
Calculate bounding box for a batch of triangles. More... | |
Static Public Attributes | |
static DebugRenderer * | sInstance = nullptr |
Singleton instance. More... | |
Protected Member Functions | |
void | Initialize () |
Initialize the system, must be called from the constructor of the DebugRenderer implementation. More... | |
Simple triangle renderer for debugging purposes.
Inherit from this class to provide your own implementation.
Implement the following virtual functions:
Make sure you call Initialize() from the constructor of your implementation.
The CreateTriangleBatch is used to prepare a batch of triangles to be drawn by a single DrawGeometry call, which means that Jolt can render a complex scene much more efficiently than when each triangle in that scene would have been drawn through DrawTriangle.
Note that an implementation that implements CreateTriangleBatch and DrawGeometry is provided by DebugRendererSimple which can be used to start quickly.
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, and DebugRendererSimple.
|
pure virtual |
Implemented in DebugRendererRecorder, and DebugRendererSimple.
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, and DebugRendererSimple.
|
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 | determines 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 | determines 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::DrawSwingConeLimits | ( | RMat44Arg | inMatrix, |
float | inSwingYHalfAngle, | ||
float | inSwingZHalfAngle, | ||
float | inEdgeLength, | ||
ColorArg | inColor, | ||
ECastShadow | inCastShadow = ECastShadow::On , |
||
EDrawMode | inDrawMode = EDrawMode::Solid |
||
) |
Draws cone 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 | determines if this geometry should cast a shadow or not. |
inDrawMode | determines if we draw the geometry solid or in wireframe. |
void DebugRenderer::DrawSwingPyramidLimits | ( | RMat44Arg | inMatrix, |
float | inMinSwingYAngle, | ||
float | inMaxSwingYAngle, | ||
float | inMinSwingZAngle, | ||
float | inMaxSwingZAngle, | ||
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 |
inMinSwingYAngle | See SwingTwistConstraintPart |
inMaxSwingYAngle | See SwingTwistConstraintPart |
inMinSwingZAngle | See SwingTwistConstraintPart |
inMaxSwingZAngle | See SwingTwistConstraintPart |
inEdgeLength | Size of the edge of the cone shape |
inColor | Color to use for drawing the cone. |
inCastShadow | determines 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, and DebugRendererSimple.
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.
void DebugRenderer::NextFrame | ( | ) |
Call once after frame is complete. Releases unused dynamically generated geometry assets.
Calculate bounding box for a batch of triangles.
|
static |
Singleton instance.