|
@@ -17,6 +17,7 @@
|
|
#include <Jolt/Core/Reference.h>
|
|
#include <Jolt/Core/Reference.h>
|
|
#include <Jolt/Core/HashCombine.h>
|
|
#include <Jolt/Core/HashCombine.h>
|
|
#include <Jolt/Core/UnorderedMap.h>
|
|
#include <Jolt/Core/UnorderedMap.h>
|
|
|
|
+#include <Jolt/Core/NonCopyable.h>
|
|
#include <Jolt/Math/Float2.h>
|
|
#include <Jolt/Math/Float2.h>
|
|
#include <Jolt/Geometry/IndexedTriangle.h>
|
|
#include <Jolt/Geometry/IndexedTriangle.h>
|
|
#include <Jolt/Geometry/AABox.h>
|
|
#include <Jolt/Geometry/AABox.h>
|
|
@@ -26,7 +27,23 @@ JPH_NAMESPACE_BEGIN
|
|
class OrientedBox;
|
|
class OrientedBox;
|
|
|
|
|
|
/// Simple triangle renderer for debugging purposes.
|
|
/// Simple triangle renderer for debugging purposes.
|
|
-class JPH_DEBUG_RENDERER_EXPORT DebugRenderer
|
|
|
|
|
|
+///
|
|
|
|
+/// Inherit from this class to provide your own implementation.
|
|
|
|
+///
|
|
|
|
+/// Implement the following virtual functions:
|
|
|
|
+/// - DrawLine
|
|
|
|
+/// - DrawTriangle
|
|
|
|
+/// - DrawText3D
|
|
|
|
+/// - CreateTriangleBatch
|
|
|
|
+/// - DrawGeometry
|
|
|
|
+///
|
|
|
|
+/// 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.
|
|
|
|
+class JPH_DEBUG_RENDERER_EXPORT DebugRenderer : public NonCopyable
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
JPH_OVERRIDE_NEW_DELETE
|
|
JPH_OVERRIDE_NEW_DELETE
|
|
@@ -192,6 +209,21 @@ public:
|
|
Geometry(const AABox &inBounds) : mBounds(inBounds) { }
|
|
Geometry(const AABox &inBounds) : mBounds(inBounds) { }
|
|
Geometry(const Batch &inBatch, const AABox &inBounds) : mBounds(inBounds) { mLODs.push_back({ inBatch, FLT_MAX }); }
|
|
Geometry(const Batch &inBatch, const AABox &inBounds) : mBounds(inBounds) { mLODs.push_back({ inBatch, FLT_MAX }); }
|
|
|
|
|
|
|
|
+ /// Determine which LOD to render
|
|
|
|
+ /// @param inCameraPosition Current position of the camera
|
|
|
|
+ /// @param inWorldSpaceBounds World space bounds for this geometry (transform mBounds by model space matrix)
|
|
|
|
+ /// @param 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).
|
|
|
|
+ /// @return The selected LOD.
|
|
|
|
+ const LOD & GetLOD(Vec3Arg inCameraPosition, const AABox &inWorldSpaceBounds, float inLODScaleSq) const
|
|
|
|
+ {
|
|
|
|
+ float dist_sq = inWorldSpaceBounds.GetSqDistanceTo(inCameraPosition);
|
|
|
|
+ for (const LOD &lod : mLODs)
|
|
|
|
+ if (dist_sq <= inLODScaleSq * Square(lod.mDistance))
|
|
|
|
+ return lod;
|
|
|
|
+
|
|
|
|
+ return mLODs.back();
|
|
|
|
+ }
|
|
|
|
+
|
|
/// All level of details for this mesh
|
|
/// All level of details for this mesh
|
|
Array<LOD> mLODs;
|
|
Array<LOD> mLODs;
|
|
|
|
|