| 7 | #include "Engine/Core/Log.h" |
| 8 | |
| 9 | void CSG::Mesh::Build(Brush* parentBrush) |
| 10 | { |
| 11 | struct EdgeIntersection |
| 12 | { |
| 13 | int32 EdgeIndex; |
| 14 | int32 PlaneIndices[2]; |
| 15 | |
| 16 | EdgeIntersection() |
| 17 | { |
| 18 | EdgeIndex = INVALID_INDEX; |
| 19 | } |
| 20 | |
| 21 | EdgeIntersection(int32 edgeIndex, int32 planeIndexA, int32 planeIndexB) |
| 22 | { |
| 23 | EdgeIndex = edgeIndex; |
| 24 | PlaneIndices[0] = planeIndexA; |
| 25 | PlaneIndices[1] = planeIndexB; |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | struct PointIntersection |
| 30 | { |
| 31 | // TODO: optimize this shit? |
| 32 | int32 VertexIndex; |
| 33 | Array<EdgeIntersection> Edges; |
| 34 | Array<int32> PlaneIndices; |
| 35 | |
| 36 | PointIntersection() |
| 37 | { |
| 38 | VertexIndex = INVALID_INDEX; |
| 39 | } |
| 40 | |
| 41 | PointIntersection(int32 vertexIndex, const Array<int32>& planes) |
| 42 | { |
| 43 | VertexIndex = vertexIndex; |
| 44 | PlaneIndices = planes; |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | // Clear |
| 49 | _bounds.Clear(); |
| 50 | _surfaces.Clear(); |
| 51 | _polygons.Clear(); |
| 52 | _edges.Clear(); |
| 53 | _vertices.Clear(); |
| 54 | _brushesMeta.Clear(); |
| 55 | |
| 56 | // Get brush planes |
| 57 | if (parentBrush == nullptr) |
| 58 | return; |
| 59 | auto mode = parentBrush->GetBrushMode(); |
| 60 | parentBrush->GetSurfaces(_surfaces); |
| 61 | int32 surfacesCount = _surfaces.Count(); |
| 62 | if (surfacesCount > 250) |
| 63 | { |
| 64 | LOG(Error, "CSG brush has too many planes: {0}. Cannot process it!", surfacesCount); |
| 65 | return; |
| 66 | } |
nothing calls this directly
no test coverage detected