7#ifndef JPH_DEBUG_RENDERER
8 #error This file should only be included when JPH_DEBUG_RENDERER is defined
11#ifndef JPH_DEBUG_RENDERER_EXPORT
13 #define JPH_DEBUG_RENDERER_EXPORT JPH_EXPORT
73 void DrawCoordinateSystem(
RMat44Arg inTransform,
float inSize = 1.0f);
82 template <
class VERTEX_ARRAY>
83 void DrawWirePolygon(
RMat44Arg inTransform,
const VERTEX_ARRAY &inVertices,
ColorArg inColor,
float inArrowSize = 0.0f) {
for (
typename VERTEX_ARRAY::size_type i = 0; i < inVertices.size(); ++i) DrawArrow(inTransform * inVertices[i], inTransform * inVertices[(i + 1) % inVertices.size()], inColor, inArrowSize); }
86 void DrawWireSphere(
RVec3Arg inCenter,
float inRadius,
ColorArg inColor,
int inLevel = 3);
116 void DrawCapsule(
RMat44Arg inMatrix,
float inHalfHeightOfCylinder,
float inRadius,
ColorArg inColor,
ECastShadow inCastShadow = ECastShadow::On,
EDrawMode inDrawMode = EDrawMode::Solid);
141 void DrawSwingConeLimits(
RMat44Arg inMatrix,
float inSwingYHalfAngle,
float inSwingZHalfAngle,
float inEdgeLength,
ColorArg inColor,
ECastShadow inCastShadow = ECastShadow::On,
EDrawMode inDrawMode = EDrawMode::Solid);
153 void DrawSwingPyramidLimits(
RMat44Arg inMatrix,
float inMinSwingYAngle,
float inMaxSwingYAngle,
float inMinSwingZAngle,
float inMaxSwingZAngle,
float inEdgeLength,
ColorArg inColor,
ECastShadow inCastShadow = ECastShadow::On,
EDrawMode inDrawMode = EDrawMode::Solid);
210 Geometry(
const Batch &inBatch,
const AABox &inBounds) : mBounds(inBounds) { mLODs.push_back({ inBatch, FLT_MAX }); }
220 for (
const LOD &lod : mLODs)
221 if (dist_sq <= inLODScaleSq *
Square(lod.mDistance))
238 static AABox sCalculateBounds(
const Vertex *inVertices,
int inVertexCount);
270 void DrawGeometry(
RMat44Arg inModelMatrix,
ColorArg inModelColor,
const GeometryRef &inGeometry,
ECullMode inCullMode = ECullMode::CullBackFace,
ECastShadow inCastShadow = ECastShadow::On,
EDrawMode inDrawMode = EDrawMode::Solid) {
DrawGeometry(inModelMatrix, inGeometry->mBounds.Transformed(inModelMatrix), max(max(inModelMatrix.
GetAxisX().
LengthSq(), inModelMatrix.
GetAxisY().
LengthSq()), inModelMatrix.
GetAxisZ().
LengthSq()), inModelColor, inGeometry, inCullMode, inCastShadow, inDrawMode); }
287 void Create8thSphereRecursive(
Array<uint32> &ioIndices,
Array<Vertex> &ioVertices,
Vec3Arg inDir1,
uint32 &ioIdx1,
Vec3Arg inDir2,
uint32 &ioIdx2,
Vec3Arg inDir3,
uint32 &ioIdx3,
const Float2 &inUV,
SupportFunction inGetSupport,
int inLevel);
291 Geometry * CreateSwingLimitGeometry(
int inNumSegments,
const Vec3 *inVertices);
302 struct SwingConeLimits
304 bool operator == (
const SwingConeLimits &inRHS)
const
306 return mSwingYHalfAngle == inRHS.mSwingYHalfAngle
307 && mSwingZHalfAngle == inRHS.mSwingZHalfAngle;
310 float mSwingYHalfAngle;
311 float mSwingZHalfAngle;
314 JPH_MAKE_HASH_STRUCT(SwingConeLimits, SwingConeLimitsHasher, t.mSwingYHalfAngle, t.mSwingZHalfAngle)
316 using SwingConeBatches =
UnorderedMap<SwingConeLimits, GeometryRef, SwingConeLimitsHasher>;
317 SwingConeBatches mSwingConeLimits;
318 SwingConeBatches mPrevSwingConeLimits;
320 struct SwingPyramidLimits
322 bool operator == (
const SwingPyramidLimits &inRHS)
const
324 return mMinSwingYAngle == inRHS.mMinSwingYAngle
325 && mMaxSwingYAngle == inRHS.mMaxSwingYAngle
326 && mMinSwingZAngle == inRHS.mMinSwingZAngle
327 && mMaxSwingZAngle == inRHS.mMaxSwingZAngle;
330 float mMinSwingYAngle;
331 float mMaxSwingYAngle;
332 float mMinSwingZAngle;
333 float mMaxSwingZAngle;
336 JPH_MAKE_HASH_STRUCT(SwingPyramidLimits, SwingPyramidLimitsHasher, t.mMinSwingYAngle, t.mMaxSwingYAngle, t.mMinSwingZAngle, t.mMaxSwingZAngle)
338 using SwingPyramidBatches =
UnorderedMap<SwingPyramidLimits, GeometryRef, SwingPyramidLimitsHasher>;
339 SwingPyramidBatches mSwingPyramidLimits;
340 SwingPyramidBatches mPrevSwingPyramidLimits;
343 PieBatces mPieLimits;
344 PieBatces mPrevPieLimits;
#define JPH_NAMESPACE_END
Definition: Core.h:378
std::uint32_t uint32
Definition: Core.h:455
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_DEBUG_RENDERER_EXPORT
Definition: DebugRenderer.h:13
#define JPH_MAKE_HASH_STRUCT(type, name,...)
Definition: HashCombine.h:76
JPH_INLINE constexpr T Square(T inV)
Square a value.
Definition: Math.h:52
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:31
std::unordered_map< Key, T, Hash, KeyEqual, STLAllocator< pair< const Key, T > > > UnorderedMap
Definition: UnorderedMap.h:13
Axis aligned box.
Definition: AABox.h:16
float GetSqDistanceTo(Vec3Arg inPoint) const
Get the squared distance between inPoint and this box (will be 0 if in Point is inside the box)
Definition: AABox.h:294
bool empty() const
Returns true if there are no elements in the array.
Definition: Array.h:312
size_type size() const
Returns amount of elements in the array.
Definition: Array.h:318
Class that holds an RGBA color with 8-bits per component.
Definition: Color.h:16
static const Color sWhite
Definition: Color.h:67
A geometry primitive containing triangle batches for various lods.
Definition: DebugRenderer.h:204
AABox mBounds
Bounding box that encapsulates all LODs.
Definition: DebugRenderer.h:231
const LOD & GetLOD(Vec3Arg inCameraPosition, const AABox &inWorldSpaceBounds, float inLODScaleSq) const
Definition: DebugRenderer.h:217
Array< LOD > mLODs
All level of details for this mesh.
Definition: DebugRenderer.h:228
JPH_OVERRIDE_NEW_DELETE Geometry(const AABox &inBounds)
Constructor.
Definition: DebugRenderer.h:209
Geometry(const Batch &inBatch, const AABox &inBounds)
Definition: DebugRenderer.h:210
A single level of detail.
Definition: DebugRenderer.h:196
Batch mTriangleBatch
Definition: DebugRenderer.h:198
float mDistance
Definition: DebugRenderer.h:199
A single triangle.
Definition: DebugRenderer.h:182
Vertex format used by the triangle renderer.
Definition: DebugRenderer.h:172
Float3 mPosition
Definition: DebugRenderer.h:174
Float2 mUV
Definition: DebugRenderer.h:176
Color mColor
Definition: DebugRenderer.h:177
Float3 mNormal
Definition: DebugRenderer.h:175
Definition: DebugRenderer.h:47
virtual void DrawText3D(RVec3Arg inPosition, const string_view &inString, ColorArg inColor=Color::sWhite, float inHeight=0.5f)=0
Draw text.
ECullMode
Determines which polygons are culled.
Definition: DebugRenderer.h:254
virtual Batch CreateTriangleBatch(const Vertex *inVertices, int inVertexCount, const uint32 *inIndices, int inIndexCount)=0
virtual Batch CreateTriangleBatch(const Triangle *inTriangles, int inTriangleCount)=0
Create a batch of triangles that can be drawn efficiently.
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
ECastShadow
Enum that determines if a shadow should be cast or not.
Definition: DebugRenderer.h:91
static DebugRenderer * sInstance
Singleton instance.
Definition: DebugRenderer.h:168
Batch CreateTriangleBatch(const Array< Triangle > &inTriangles)
Definition: DebugRenderer.h:243
EDrawMode
Determines how triangles are drawn.
Definition: DebugRenderer.h:98
Batch CreateTriangleBatch(const Array< Vertex > &inVertices, const Array< uint32 > &inIndices)
Definition: DebugRenderer.h:244
void DrawGeometry(RMat44Arg inModelMatrix, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode=ECullMode::CullBackFace, ECastShadow inCastShadow=ECastShadow::On, EDrawMode inDrawMode=EDrawMode::Solid)
Definition: DebugRenderer.h:270
void DrawWirePolygon(RMat44Arg inTransform, const VERTEX_ARRAY &inVertices, ColorArg inColor, float inArrowSize=0.0f)
Draw a wireframe polygon.
Definition: DebugRenderer.h:83
virtual void DrawLine(RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor)=0
Draw line.
function< Vec3(Vec3Arg inDirection)> SupportFunction
Create a primitive for a convex shape using its support function.
Definition: DebugRenderer.h:248
virtual void DrawTriangle(RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor, ECastShadow inCastShadow=ECastShadow::Off)=0
Draw a single back face culled triangle.
Class that holds 2 floats, used as a storage class mainly.
Definition: Float2.h:11
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition: Float3.h:13
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
JPH_INLINE Vec3 GetAxisY() const
Definition: Mat44.h:148
JPH_INLINE Vec3 GetAxisZ() const
Definition: Mat44.h:150
JPH_INLINE Vec3 GetAxisX() const
Access to the columns.
Definition: Mat44.h:146
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Oriented box.
Definition: OrientedBox.h:18
Definition: Reference.h:35
JPH_INLINE float LengthSq() const
Squared length of vector.
Definition: Vec3.inl:661