MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / checkSphereInFrustum

Method checkSphereInFrustum

Source/Graphics/camera.cpp:639–654  ·  view source on GitHub ↗

Check if a sphere is visible

Source from the content-addressed store, hash-verified

637
638// Check if a sphere is visible
639int Camera::checkSphereInFrustum(vec3 where, float radius) const {
640 int sphere_in_frustum = 2;
641 for (auto frustumPlane : frustumPlanes) {
642 float d =
643 frustumPlane[0] * where.x() +
644 frustumPlane[1] * where.y() +
645 frustumPlane[2] * where.z() +
646 frustumPlane[3];
647 if (d <= -radius) {
648 return 0; // Sphere is entirely outside one of the frustum planes
649 } else if (d < radius) {
650 sphere_in_frustum = 1; // Sphere is intersecting a frustum plane
651 }
652 }
653 return sphere_in_frustum;
654}
655
656#if defined(USE_SSE)
657static __m128 simd_dot_product(__m128 x1, __m128 y1, __m128 z1, __m128 x2, __m128 y2, __m128 z2) {

Callers 6

PreDrawCameraMethod · 0.80
DrawMethod · 0.80
DrawBillboardFunction · 0.80
DrawMethod · 0.80
PreDrawCameraMethod · 0.80
DrawMethod · 0.80

Calls 3

xMethod · 0.45
yMethod · 0.45
zMethod · 0.45

Tested by

no test coverage detected