Ray-casts from arbitrary origin/direction (returns picked entity handle, 0=no hit).
Takes x/y/z (ray origin position), dx/dy/dz (ray offset/distance, NOT normalized direction), radius (unused parameter).
Returns picked entity handle (Int), or 0 if no hit.
3D Graphics
Parameters & Returns
Parameters
xDouble
yDouble
zDouble
dxDouble
dyDouble
dzDouble
radiusDouble
Returns
Int
Quick Summary
Ray-casts from arbitrary origin/direction (returns picked entity handle, 0=no hit).
Takes x/y/z (ray origin position), dx/dy/dz (ray offset/distance, NOT normalized direction), radius (unused parameter).
Returns picked entity handle (Int), or 0 if no hit.
Technical Exegesis...
Ray-casts from arbitrary origin/direction (returns picked entity handle, 0=no hit). Takes x/y/z (ray origin position), dx/dy/dz (ray offset/distance, NOT normalized direction), radius (unused parameter). Returns picked entity handle (Int), or 0 if no hit. Resets g_lastPickResult, calculates ray direction and length from origin+offset, tests ray against all mesh entities within ray length respecting pickMode, returns closest hit entity handle. Custom ray-cast for arbitrary picking scenarios.
Ray-casts from arbitrary origin/direction (returns picked entity handle, 0=no hit). Takes x/y/z (ray origin position), dx/dy/dz (ray offset/distance, NOT normalized direction), radius (unused parameter). Returns picked entity handle (Int), or 0 if no hit. Resets g_lastPickResult, calculates ray direction and length from origin+offset, tests ray against all mesh entities within ray length respecting pickMode, returns closest hit entity handle. Custom ray-cast for arbitrary picking scenarios.
This function performs arbitrary ray picking. Ray construction: origin=(x,y,z), end=(x+dx, y+dy, z+dz), direction=normalized(end-origin), max distance=length(dx,dy,dz). Offset interpretation: dx/dy/dz are offsets from origin (NOT unit direction), allows specifying ray as origin+offset instead of origin+direction*distance, ray length automatically calculated from offset magnitude. Pick modes: pickMode=0 (PICK_SPHERE) uses ray-sphere intersection with entity collisionRadius, pickMode=1 (PICK_BOX) uses ray-OBB intersection with entity collisionBoxMin/Max, pickMode=2 (PICK_POLYGON) uses ray-triangle intersection for exact mesh picking (CPU for < 1000 tris, GPU for complex). Closest hit: finds closest intersection along ray (smallest t value within ray length), stores full result in g_lastPickResult (retrieve with b3dPickedEntity/X/Y/Z/NX/NY/NZ/Triangle/Surface/Time). Use cases: (1) Custom ray-casts (arbitrary origin/direction), (2) Projectile paths (ray from spawn point in velocity direction), (3) Physics queries (ray-cast for ground detection), (4) Editor tools (ray from arbitrary position), (5) Reflection rays (bounce ray from surface). Common pattern: b3dLinePick(startX, startY, startZ, dirX*100, dirY*100, dirZ*100, 0), entity=b3dPickedEntity(). Typical usage: call with start position and direction*distance for custom ray-casts, useful when not picking from entity or camera. Radius parameter: currently unused (reserved for future cylinder-cast or sphere-cast, currently performs ray-cast only). Result storage: stores hit position (b3dPickedX/Y/Z), surface normal (b3dPickedNX/NY/NZ), triangle index (b3dPickedTriangle), surface index (b3dPickedSurface), distance (b3dPickedTime). Performance: O(N*T) where N=entity count, T=triangles per entity (CPU), O(N) for GPU picking, suitable for real-time use. Pick mode filtering: only tests entities with non-zero pickMode (set by b3dEntityPickMode). GPU acceleration: meshes with > 1000 triangles use GPU compute shader for picking. Related: b3dCameraPick picks from camera screen coords, b3dEntityPick picks from entity forward direction, b3dPickedEntity/X/Y/Z/NX/NY/NZ retrieve results, b3dEntityPickMode sets pickability.