Tests if entity is visible in camera frustum (1=visible, 0=culled).
Takes entity (entity handle to test), camera (camera entity handle).
Returns 1 if entity is inside camera frustum (visible), 0 if outside frustum (culled) or invalid handles.
3D Graphics
Parameters & Returns
Parameters
entityInt
cameraInt
Returns
Int
Quick Summary
Tests if entity is visible in camera frustum (1=visible, 0=culled).
Takes entity (entity handle to test), camera (camera entity handle).
Returns 1 if entity is inside camera frustum (visible), 0 if outside frustum (culled) or invalid handles.
Technical Exegesis...
Tests if entity is visible in camera frustum (1=visible, 0=culled). Takes entity (entity handle to test), camera (camera entity handle). Returns 1 if entity is inside camera frustum (visible), 0 if outside frustum (culled) or invalid handles. Validates both entities exist and camera is ENTITY_CAMERA type, allocates Camera3D if null, extracts 6 frustum planes from view-projection matrix, tests entity position/bounds against planes.
This function performs frustum culling.
Tests if entity is visible in camera frustum (1=visible, 0=culled). Takes entity (entity handle to test), camera (camera entity handle). Returns 1 if entity is inside camera frustum (visible), 0 if outside frustum (culled) or invalid handles. Validates both entities exist and camera is ENTITY_CAMERA type, allocates Camera3D if null, extracts 6 frustum planes from view-projection matrix, tests entity position/bounds against planes.
This function performs frustum culling. Frustum definition: view frustum = 6-sided pyramid defined by camera's view and projection matrices (6 planes: left, right, top, bottom, near, far), objects inside frustum are visible, objects outside any plane are culled. Plane extraction: combines view and projection matrices into view-projection matrix, extracts 6 planes using Gribb-Hartmann method (left = vp[3]+vp[0], right = vp[3]-vp[0], etc.), normalizes all planes for accurate distance testing. Point entities: camera, light, pivot entities tested as single point (world position), tests point against all 6 planes (point inside = visible), faster than AABB test (no bounding box). Mesh/billboard entities: uses AABB bounding box (collisionBoxMin/Max), transforms AABB to world space (apply scale and position, rotation ignored for axis-aligned box), tests positive vertex (furthest corner in plane normal direction), if positive vertex outside any plane then entire AABB culled. Use cases: (1) Visibility checks (skip AI updates for off-screen enemies), (2) LOD selection (only process visible entities), (3) Culling (skip rendering invisible objects, engine does this automatically), (4) Debug visualization (show which entities are visible), (5) Gameplay logic (trigger events when entity enters/leaves view). Common pattern: if b3dEntityInView(entity, camera) then update AI. Typical usage: check visibility before expensive operations (pathfinding, physics, complex AI), engine automatically culls invisible entities during rendering. Projection mode handling: if camera projMode=0 (disabled), returns 0 (nothing visible), perspective and orthographic both supported. Viewport handling: frustum computed from camera viewport dimensions (viewportWidth/Height if > 0, else g_3D_resolutionWidth/Height). Performance: O(1) frustum test (extract 6 planes, test 6 planes against point or AABB, no iteration), very fast (suitable for every frame), much faster than pixel-perfect occlusion queries. False positives: AABB test may return visible for objects partially in frustum but not actually rendered (conservative culling, bounding box visible but mesh outside), acceptable trade-off for performance. Camera allocation: if camera->camera==nullptr, allocates new Camera3D. Related: b3dCameraProject projects positions to screen, b3dCameraFOV/Range define frustum shape, b3dEntityBox sets collision bounds for frustum test.