Returns triangle index of pick hit point from last pick operation (-1 if sphere/box pick or no hit).
Takes no parameters.
Returns triangle index (Int) from g_lastPickResult.triangleIndex, or -1 if not polygon pick.
3D Graphics
Parameters & Returns
Parameters
This function takes no parameters.
Returns
Int
Quick Summary
Returns triangle index of pick hit point from last pick operation (-1 if sphere/box pick or no hit).
Takes no parameters.
Returns triangle index (Int) from g_lastPickResult.triangleIndex, or -1 if not polygon pick.
Technical Exegesis...
Returns triangle index of pick hit point from last pick operation (-1 if sphere/box pick or no hit). Takes no parameters. Returns triangle index (Int) from g_lastPickResult.triangleIndex, or -1 if not polygon pick. Reads result from last b3dCameraPick, b3dEntityPick, or b3dLinePick call with pickMode=2 (polygon). Triangle index in mesh index buffer.
This function retrieves hit triangle.
Returns triangle index of pick hit point from last pick operation (-1 if sphere/box pick or no hit). Takes no parameters. Returns triangle index (Int) from g_lastPickResult.triangleIndex, or -1 if not polygon pick. Reads result from last b3dCameraPick, b3dEntityPick, or b3dLinePick call with pickMode=2 (polygon). Triangle index in mesh index buffer.
This function retrieves hit triangle. Pick sequence: (1) Call b3dCameraPick/EntityPick/LinePick to perform ray-cast, (2) Call b3dPickedTriangle to get triangle index (only valid for polygon picks). Triangle index: index into mesh triangle list (not vertex index), for pickMode=2 (polygon) identifies which triangle was hit, for pickMode=0 (sphere) or pickMode=1 (box) returns -1 (no specific triangle). Index calculation: triangleIndex = i / 3 where i is index buffer position (3 indices per triangle), range [0, triangleCount-1]. Use cases: (1) Texture lookups (get UV coordinates of hit triangle for decal placement), (2) Material queries (identify which material/surface type hit), (3) Per-triangle data (retrieve custom data stored per triangle), (4) Debug visualization (highlight hit triangle in mesh), (5) Mesh editing (modify hit triangle in editor). Common pattern: if b3dPickedEntity() > 0 and b3dPickedTriangle() >= 0 then triIdx=b3dPickedTriangle(), look up triangle data. Typical usage: use for polygon picks (pickMode=2) when triangle-level precision needed, -1 for sphere/box picks (coarse collision). Triangle data access: use index to look up vertex indices (mesh.indices[triIdx*3+0/1/2]), then vertex data (positions, normals, UVs). No hit or non-polygon: returns -1 if no entity picked, pickMode != 2, or sphere/box pick. Result storage: g_lastPickResult.triangleIndex populated by polygon pick functions only. Performance: O(1) read (simple global variable access, instant). Related: b3dPickedSurface retrieves surface/material index, b3dPickedEntity checks if hit occurred, b3dEntityPickMode sets pick mode (0=sphere, 1=box, 2=polygon), b3dCameraPick/EntityPick/LinePick perform picking.