MCPcopy Create free account
hub / github.com/crownengine/crown / add_points

Function add_points

src/core/math/sphere.cpp:57–80  ·  view source on GitHub ↗

Reference: https://web.archive.org/web/20170808221957/https://sharif.edu/~zarrabi/papers/cccg-06/meb.pdf

Source from the content-addressed store, hash-verified

55 // Reference:
56 // https://web.archive.org/web/20170808221957/https://sharif.edu/~zarrabi/papers/cccg-06/meb.pdf
57 void add_points(Sphere &s, u32 num, u32 stride, const void *points)
58 {
59 const char *pts = (char *)points;
60
61 if (CE_UNLIKELY(num == 0))
62 return;
63
64 s.c = *(Vector3 *)pts;
65 s.r = 0.0f;
66 pts += stride;
67
68 for (u32 i = 1; i < num; ++i, pts += stride) {
69 const Vector3 &p = *(Vector3 *)pts;
70
71 if (!sphere::contains_point(s, p)) {
72 const f32 dist = distance(p, s.c);
73 const f32 delta = 0.5f * (dist - s.r);
74 const f32 alpha = delta / dist;
75
76 s.c += alpha * (p - s.c);
77 s.r += delta + FLOAT_EPSILON * 10.0f;
78 }
79 }
80 }
81
82} // namespace sphere
83

Callers 2

test_sphereFunction · 0.85
sphereFunction · 0.85

Calls 1

distanceFunction · 0.85

Tested by 1

test_sphereFunction · 0.68