Skip to content

Commit

Permalink
Report empty scene problem before using bvhNode[0].
Browse files Browse the repository at this point in the history
  • Loading branch information
jbikker committed Jan 9, 2025
1 parent 7ee7e01 commit 5346e17
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tiny_bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -1382,11 +1382,11 @@ void BVH::PrepareBuild( const bvhvec4slice& vertices, const uint32_t* indices, c
else FATAL_ERROR_IF( !rebuildable, "BVH::Build( .. ), bvh not rebuildable." );
verts = vertices, idxCount = triCount = primCount;
// prepare fragments
FATAL_ERROR_IF( vertices.count == 0, "BVH::PrepareBuild( .. ), empty vertex slice." );
BVHNode& root = bvhNode[0];
root.leftFirst = 0, root.triCount = triCount, root.aabbMin = bvhvec3( BVH_FAR ), root.aabbMax = bvhvec3( -BVH_FAR );
if (!indices)
{
FATAL_ERROR_IF( vertices.count == 0, "BVH::PrepareBuild( .. ), primCount == 0." );
FATAL_ERROR_IF( prims != 0, "BVH::PrepareBuild( .. ), indices == 0." );
// building a BVH over triangles specified as three 16-byte vertices each.
for (uint32_t i = 0; i < triCount; i++)
Expand All @@ -1401,7 +1401,6 @@ void BVH::PrepareBuild( const bvhvec4slice& vertices, const uint32_t* indices, c
}
else
{
FATAL_ERROR_IF( vertices.count == 0, "BVH::PrepareBuild( .. ), empty vertex slice." );
FATAL_ERROR_IF( prims == 0, "BVH::PrepareBuild( .. ), prims == 0." );
// building a BVH over triangles consisting of vertices indexed by 'indices'.
for (uint32_t i = 0; i < triCount; i++)
Expand Down

0 comments on commit 5346e17

Please sign in to comment.