Tests if dest_entity is visible from src_entity (1=visible, 0=occluded, ray-cast line-of-sight).
Takes src_entity (source entity handle), dest_entity (destination entity handle), radius (multi-ray radius, 0=single center ray).
Returns 1 if dest visible from src (no occlusion), 0 if occluded or invalid entities.
3D Graphics
Parameters & Returns
Parameters
src_entityInt
dest_entityInt
radiusDouble
Returns
Int
Quick Summary
Tests if dest_entity is visible from src_entity (1=visible, 0=occluded, ray-cast line-of-sight).
Takes src_entity (source entity handle), dest_entity (destination entity handle), radius (multi-ray radius, 0=single center ray).
Returns 1 if dest visible from src (no occlusion), 0 if occluded or invalid entities.
Technical Exegesis...
Tests if dest_entity is visible from src_entity (1=visible, 0=occluded, ray-cast line-of-sight). Takes src_entity (source entity handle), dest_entity (destination entity handle), radius (multi-ray radius, 0=single center ray). Returns 1 if dest visible from src (no occlusion), 0 if occluded or invalid entities. Validates both entities exist, calculates direction and distance from src to dest, casts ray(s) between entities, returns 0 if any occluding entity found closer than dest, 1 if line-of-sight clear.
Tests if dest_entity is visible from src_entity (1=visible, 0=occluded, ray-cast line-of-sight). Takes src_entity (source entity handle), dest_entity (destination entity handle), radius (multi-ray radius, 0=single center ray). Returns 1 if dest visible from src (no occlusion), 0 if occluded or invalid entities. Validates both entities exist, calculates direction and distance from src to dest, casts ray(s) between entities, returns 0 if any occluding entity found closer than dest, 1 if line-of-sight clear. AI vision and occlusion testing.
This function performs line-of-sight testing. Ray construction: origin=src position, direction=normalized(dest position - src position), max distance=distance between entities. Radius modes: radius <= 0 uses single center ray (simple line-of-sight, fast), radius > 0 uses multiple rays in cone (TODO: currently only implements single ray, multi-ray for thick occlusion checking). Occlusion testing: casts ray from src to dest, tests against all other mesh entities (skips src and dest), if any entity intersects ray before reaching dest then occluded (returns 0), if no intersections or all beyond dest then visible (returns 1). Pick mode filtering: respects entity pickMode (0=sphere, 1=box, 2=polygon for occlusion tests), only tests entities with non-zero pickMode. Use cases: (1) AI vision (can NPC see player?), (2) Stealth detection (is player hidden behind cover?), (3) Line-of-sight checks (can turret see target?), (4) Alert triggers (enemy spots player when visible), (5) Cover system (is position behind cover from enemy?). Common pattern: if b3dEntityVisible(enemy, player, 0) then alert enemy. Typical usage: call every frame for AI vision checks, call when checking stealth detection, call for turret targeting. Same position handling: if entities at same position (distance < 0.0001) returns 1 (visible, no occlusion possible). Occlusion threshold: uses t > 0.001 to avoid self-intersection artifacts (tiny offset from ray origin), only counts hits closer than dest distance (t < closestT). Performance: O(N*T) where N=entity count, T=triangles per entity (CPU), O(N) for GPU picking, suitable for real-time AI (check once per second or on events, not every frame for many entities). GPU acceleration: meshes with > 1000 triangles use GPU compute shader for ray-triangle tests. Entity exclusion: skips both src and dest entities (only tests potential occluders), prevents false occlusion from source or target. Related: b3dEntityDistance calculates distance between entities (use for range checks before visibility), b3dEntityPick performs similar ray-cast (but returns picked entity), b3dEntityPickMode sets entity pickability for occlusion.