Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
TriangleSplitter.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11
14{
15public:
17 TriangleSplitter(const VertexList &inVertices, const IndexedTriangleList &inTriangles);
18
20 virtual ~TriangleSplitter() = default;
21
22 struct Stats
23 {
24 const char * mSplitterName = nullptr;
25 int mLeafSize = 0;
26 };
27
29 virtual void GetStats(Stats &outStats) const = 0;
30
32 struct Range
33 {
35 Range() = default;
36 Range(uint inBegin, uint inEnd) : mBegin(inBegin), mEnd(inEnd) { }
37
39 uint Count() const
40 {
41 return mEnd - mBegin;
42 }
43
47 };
48
51 {
52 return Range(0, (uint)mSortedTriangleIdx.size());
53 }
54
60 virtual bool Split(const Range &inTriangles, Range &outLeft, Range &outRight) = 0;
61
63 const VertexList & GetVertices() const
64 {
65 return mVertices;
66 }
67
69 const IndexedTriangle & GetTriangle(uint inIdx) const
70 {
71 return mTriangles[mSortedTriangleIdx[inIdx]];
72 }
73
74protected:
76 bool SplitInternal(const Range &inTriangles, uint inDimension, float inSplit, Range &outLeft, Range &outRight);
77
82};
83
#define JPH_EXPORT
Definition: Core.h:236
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
Triangle with 32-bit indices and material index.
Definition: IndexedTriangle.h:73
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
A class that splits a triangle list into two parts for building a tree.
Definition: TriangleSplitter.h:14
Array< Float3 > mCentroids
Unsorted centroids of triangles.
Definition: TriangleSplitter.h:80
virtual ~TriangleSplitter()=default
Virtual destructor.
const VertexList & GetVertices() const
Get the list of vertices.
Definition: TriangleSplitter.h:63
const VertexList & mVertices
Vertices of the indexed triangles.
Definition: TriangleSplitter.h:78
virtual void GetStats(Stats &outStats) const =0
Get stats of splitter.
virtual bool Split(const Range &inTriangles, Range &outLeft, Range &outRight)=0
const IndexedTriangleList & mTriangles
Unsorted triangles.
Definition: TriangleSplitter.h:79
Array< uint > mSortedTriangleIdx
Indices to sort triangles.
Definition: TriangleSplitter.h:81
const IndexedTriangle & GetTriangle(uint inIdx) const
Get triangle by index.
Definition: TriangleSplitter.h:69
Range GetInitialRange() const
Range of triangles to start with.
Definition: TriangleSplitter.h:50
Helper struct to indicate triangle range before and after the split.
Definition: TriangleSplitter.h:33
uint mEnd
Definition: TriangleSplitter.h:46
Range(uint inBegin, uint inEnd)
Definition: TriangleSplitter.h:36
uint Count() const
Get number of triangles in range.
Definition: TriangleSplitter.h:39
uint mBegin
Start and end index (end = 1 beyond end)
Definition: TriangleSplitter.h:45
Range()=default
Constructor.
Definition: TriangleSplitter.h:23