Skip to content

Commit 8c42037

Browse files
committed
clusterizer: Remove redundant radius computation
Now that computeBoundingSphere is correct, we no longer need the adjustment to the radius to ensure all spheres are covered. Note that the resulting radius is subject to some floating-point errors, so we can't necessarily replace the removed code with assertions, as the containment of the spheres is true only with some floating point tolerance.
1 parent 201fc56 commit 8c42037

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/clusterizer.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,23 +1009,10 @@ meshopt_Bounds meshopt_computeSphereBounds(const float* positions, size_t count,
10091009
float psphere[4] = {};
10101010
computeBoundingSphere(psphere, positions, count, positions_stride, radii ? radii : &rzero, radii ? radii_stride : 0);
10111011

1012-
float pradius = 0;
1013-
1014-
for (size_t i = 0; i < count; ++i)
1015-
{
1016-
const float* position = positions + i * (positions_stride / sizeof(float));
1017-
float radius = radii ? radii[i * (radii_stride / sizeof(float))] : 0;
1018-
1019-
float dx = position[0] - psphere[0], dy = position[1] - psphere[1], dz = position[2] - psphere[2];
1020-
float distance = sqrtf(dx * dx + dy * dy + dz * dz) + radius;
1021-
1022-
pradius = pradius < distance ? distance : pradius;
1023-
}
1024-
10251012
bounds.center[0] = psphere[0];
10261013
bounds.center[1] = psphere[1];
10271014
bounds.center[2] = psphere[2];
1028-
bounds.radius = pradius;
1015+
bounds.radius = psphere[3];
10291016

10301017
return bounds;
10311018
}

0 commit comments

Comments
 (0)