Skip to content

Commit d5516d3

Browse files
committed
restoring validFace function
1 parent 559fdd1 commit d5516d3

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

‎kernels/subdiv/half_edge.h‎

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -307,27 +307,42 @@ namespace embree
307307
}
308308

309309
private:
310-
__forceinline bool validRing(const BufferView<Vec3fa>* vertices) const
310+
311+
/*! Tests if this is a valid face topology. If vertices are
312+
* provided these are also tested to have valid floating point
313+
* numbers. */
314+
__forceinline bool validFace(const BufferView<Vec3fa>* vertices, size_t& N) const
315+
{
316+
if (vertices) {
317+
const Vec3fa v = vertices[getStartVertexIndex()];
318+
if (!isvalid(v)) return false;
319+
}
320+
size_t n = 1;
321+
for (const HalfEdge* p = next(); p!=this; p=p->next(), n++) {
322+
if (vertices) {
323+
const Vec3fa v = vertices[p->getStartVertexIndex()];
324+
if (!isvalid(v)) return false;
325+
}
326+
}
327+
if (n < 2) return false;
328+
N += n-2;
329+
return n >= 3 && n <= MAX_PATCH_VALENCE;
330+
}
331+
332+
/*! Tests if this is a valid ring topology. If vertices are
333+
* provided these are also tested to have valid floating point
334+
* numbers. */
335+
__forceinline bool validRing(const BufferView<Vec3fa>* vertices) const
311336
{
312337
size_t faceValence = 0;
313338
size_t edgeValence = 0;
314339

315340
const HalfEdge* p = this;
316341
do
317342
{
318-
size_t n = 0;
319-
const HalfEdge* q = p;
320-
do
321-
{
322-
if (vertices && !isvalid((*vertices)[q->getStartVertexIndex()]))
323-
return false;
324-
n++;
325-
q = q->next();
326-
} while (q != p);
327-
328-
if (n < 3 || n > MAX_PATCH_VALENCE)
343+
/* calculate bounds of current face */
344+
if (!p->validFace(vertices,edgeValence))
329345
return false;
330-
edgeValence += n-2;
331346

332347
faceValence++;
333348
p = p->prev();
@@ -344,14 +359,10 @@ namespace embree
344359
while (p->hasOpposite())
345360
p = p->opposite()->next();
346361
}
347-
348-
/* stop early for degenerated topology */
349-
if (faceValence > MAX_RING_FACE_VALENCE || edgeValence > MAX_RING_EDGE_VALENCE)
350-
return false;
351-
352-
} while (p != this);
353-
354-
return true;
362+
363+
} while (p != this);
364+
365+
return faceValence <= MAX_RING_FACE_VALENCE && edgeValence <= MAX_RING_EDGE_VALENCE;
355366
}
356367

357368
private:

0 commit comments

Comments
 (0)