Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
DebugRendererSimple.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#ifndef JPH_DEBUG_RENDERER
8 #error This file should only be included when JPH_DEBUG_RENDERER is defined
9#endif // !JPH_DEBUG_RENDERER
10
12
14
38{
39public:
41
44
47 void SetCameraPos(RVec3Arg inCameraPos)
48 {
49 mCameraPos = inCameraPos;
50 mCameraPosSet = true;
51 }
52
54 virtual void DrawTriangle(RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor, ECastShadow inCastShadow) override
55 {
56 DrawLine(inV1, inV2, inColor);
57 DrawLine(inV2, inV3, inColor);
58 DrawLine(inV3, inV1, inColor);
59 }
60
61protected:
63 virtual Batch CreateTriangleBatch(const Triangle *inTriangles, int inTriangleCount) override;
64 virtual Batch CreateTriangleBatch(const Vertex *inVertices, int inVertexCount, const uint32 *inIndices, int inIndexCount) override;
65 virtual void DrawGeometry(RMat44Arg inModelMatrix, const AABox &inWorldSpaceBounds, float inLODScaleSq, ColorArg inModelColor, const GeometryRef &inGeometry, ECullMode inCullMode, ECastShadow inCastShadow, EDrawMode inDrawMode) override;
66
67private:
69 class BatchImpl : public RefTargetVirtual
70 {
71 public:
73
74 virtual void AddRef() override { ++mRefCount; }
75 virtual void Release() override { if (--mRefCount == 0) delete this; }
76
77 Array<Triangle> mTriangles;
78
79 private:
80 atomic<uint32> mRefCount = 0;
81 };
82
84 RVec3 mCameraPos;
85 bool mCameraPosSet = false;
86};
87
#define JPH_NAMESPACE_END
Definition Core.h:379
std::uint32_t uint32
Definition Core.h:456
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_DEBUG_RENDERER_EXPORT
Definition DebugRenderer.h:13
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
Axis aligned box.
Definition AABox.h:16
Definition Array.h:36
Class that holds an RGBA color with 8-bits per component.
Definition Color.h:16
Definition DebugRenderer.h:47
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
virtual void DrawLine(RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor)=0
Draw line.
Definition DebugRendererSimple.h:38
void SetCameraPos(RVec3Arg inCameraPos)
Definition DebugRendererSimple.h:47
virtual void DrawTriangle(RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor, ECastShadow inCastShadow) override
Fallback implementation that uses DrawLine to draw a triangle (override this if you have a version th...
Definition DebugRendererSimple.h:54
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
Pure virtual version of RefTarget.
Definition Reference.h:88
A simple triangle and its material.
Definition Triangle.h:11
Definition Vec3.h:17