22 #include "precompiled.h"
39 for(
size_t i = 0; i < 8; ++i)
43 m_Vertices[i][2] = bounds[(i & 4) ? 1 : 0][2];
111 std::vector<SliceOpNewVertexInfo>
nvInfo;
134 for(idx = 0; idx < sliceOp.
nvInfo.size(); ++idx)
136 if ((sliceOp.
nvInfo[idx].edgeIdx1 == edgeIdx1 && sliceOp.
nvInfo[idx].edgeIdx2 == edgeIdx2) ||
137 (sliceOp.
nvInfo[idx].edgeIdx1 == edgeIdx2 && sliceOp.
nvInfo[idx].edgeIdx2 == edgeIdx1))
141 if (idx >= sliceOp.
nvInfo.size())
148 float inv = 1.0 / (sliceOp.
ovInfo[edgeIdx1].planeDist - sliceOp.
ovInfo[edgeIdx2].planeDist);
159 sliceOp.
nvInfo.push_back(nvi);
189 return sliceOp.
nvInfo[idx].resIdx;
237 for(
size_t i = 0; i <
m_Faces.size(); ++i)
244 currentFaceStartIdx =
m_Faces[i];
245 resultFaceStartIdx = result.
m_Faces.size();
278 if (curIdx == currentFaceStartIdx)
281 if (result.
m_Faces.size() > resultFaceStartIdx)
294 if (sliceOp.
nvInfo.size())
307 idx = sliceOp.
nvInfo[0].neighbIdx2;
313 if (idx >= sliceOp.
nvInfo.size())
316 if (sliceOp.
nvInfo[idx].neighbIdx1 == prev)
320 sliceOp.
nvInfo[idx].neighbIdx1 = sliceOp.
nvInfo[idx].neighbIdx2;
335 idx = sliceOp.
nvInfo[idx].neighbIdx1;
359 const CBrush* prev =
this;
372 prev->
Slice(frustum[i], *next);
393 size_t faceStartIdx = 0;
394 while (faceStartIdx <
m_Faces.size())
397 std::vector<size_t> singleFace;
398 singleFace.push_back(
m_Faces[faceStartIdx]);
401 size_t j = faceStartIdx + 1;
404 singleFace.push_back(
m_Faces[j]);
411 singleFace.push_back(
m_Faces[j]);
412 out.push_back(singleFace);
414 faceStartIdx = j + 1;
void GetFaces(std::vector< std::vector< size_t > > &out) const
Writes a vector of the faces in this brush to out.
void Intersect(const CFrustum &frustum, CBrush &result) const
Intersect: Intersect the brush with the given frustum.
size_t neighbIdx1
Index into SliceOpInfo.nvInfo; hold the indices of this new vertex's direct neighbours in the slicing...
static void out(const wchar_t *fmt,...)
std::vector< CVector3D > GetVertices() const
Returns a copy of the vertices in this brush.
size_t thisFaceNewVertexIdx
Indices into nvInfo; during the execution of the slicing algorithm, holds the previously inserted new...
static const size_t NO_VERTEX
std::vector< SliceOpNewVertexInfo > nvInfo
Holds information about newly inserted vertices during a slice operation.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
float planeDist
Signed distance from this vertex to the slicing plane.
Class CBrush: Represents a convex object, supports some CSG operations.
Holds information about what happens to a single vertex in a brush during a slicing operation...
float DistanceToPlane(const CVector3D &point) const
size_t resIdx
Index of this vertex in the resulting brush (or NO_VERTEX if cut away)
size_t edgeIdx1
Indices of adjacent edge vertices in original brush.
static size_t SliceNewVertex(SliceOpInfo &sliceInfo, size_t v1, size_t v2)
Creates a new vertex between the given two vertices (indexed into the original brush).
Holds support information during a CBrush/CPlane slicing operation.
void Slice(const CPlane &plane, CBrush &result) const
Slice: Cut the object along the given plane, resulting in a smaller (or even empty) brush representin...
Vertices m_Vertices
Collection of unique vertices that make up this shape.
FaceIndices m_Faces
Holds the face definitions of this brush.
void Bounds(CBoundingBoxAligned &result) const
Bounds: Calculate the axis-aligned bounding box for this brush.
size_t GetNumPlanes() const
std::vector< SliceOpVertexInfo > ovInfo
Holds information about what happens to each vertex in the original brush after the slice operation...
size_t resIdx
Index of newly introduced vertex in resulting brush.
Holds information about a newly introduced vertex on an edge in a brush as the result of a slicing op...