// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Check a spherical bound against a virtual view // Not compiled or tested in-world // Setup: Use a spare owned prim. Set local camera-space CENTER,+X forward, radius and view parameters. Touch for private calculations. // Stop / restore: Disable/remove. No camera or object settings are changed. // Notes: A conservative sphere-frustum test; it does not check occlusion or actual rendering. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Transform planning only. vector CENTER=<10.0,-4.0,2.0>; float RADIUS=1.0; float FOV=60.0; float ASPECT=1.7777778; float NEAR=0.1; float FAR=30.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(RADIUS<0.0||FOV<=1.0||FOV>=170.0||ASPECT<=0.0||NEAR<=0.0||FAR<=NEAR) { llOwnerSay("Invalid view."); return; } float v=llTan(FOV*DEG_TO_RAD*0.5); float h=v*ASPECT; integer visible=TRUE; if(CENTER.x+RADIUSFAR)visible=FALSE; if(CENTER.x*h-llFabs(CENTER.y)< -RADIUS*llSqrt(1.0+h*h))visible=FALSE; if(CENTER.x*v-llFabs(CENTER.z)< -RADIUS*llSqrt(1.0+v*v))visible=FALSE; llOwnerSay("Potentially visible="+(string)visible); } }