Returns the number of triangles in a surface.
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based).
Returns triangle count (integer, 0 or more) or 0 on error.
3D Graphics
Parameters & Returns
Parameters
meshInt
surfaceInt
Returns
Int
Quick Summary
Returns the number of triangles in a surface.
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based).
Returns triangle count (integer, 0 or more) or 0 on error.
Technical Exegesis...
Returns the number of triangles in a surface. Takes mesh (surface-based mesh entity), surface (surface handle, 0-based). Returns triangle count (integer, 0 or more) or 0 on error. Validates mesh exists, type is ENTITY_MESH, is surface-based, and surface index valid. Returns surface->indices.size() / 3 as integer (each triangle = 3 indices). Returns 0 if: invalid handle, not a mesh, not surface-based, invalid surface index.
This function queries triangle count from index array size.
Returns the number of triangles in a surface. Takes mesh (surface-based mesh entity), surface (surface handle, 0-based). Returns triangle count (integer, 0 or more) or 0 on error. Validates mesh exists, type is ENTITY_MESH, is surface-based, and surface index valid. Returns surface->indices.size() / 3 as integer (each triangle = 3 indices). Returns 0 if: invalid handle, not a mesh, not surface-based, invalid surface index.
This function queries triangle count from index array size. Triangle count = indices.size() / 3 because each triangle uses 3 consecutive indices (v0, v1, v2). Empty surface (0 triangles) valid but not renderable. Return value 0 ambiguous (could be valid empty surface or error) - check mesh/surface validity separately if needed. Use cases: (1) Triangle iteration (For i=0 To b3dCountTriangles(mesh, surf)-1), (2) Performance metrics (triangle budget checking), (3) Validation before b3dTriangleVertex calls, (4) Debug info (Print "Rendering " + b3dCountTriangles(mesh, surf) + " triangles"). Triangle indices 0-based: valid triangle indices range from 0 to (count-1). Triangle count changes: increments with b3dAddTriangle, decrements with b3dDeleteTriangle. Minimum renderable: surface needs at least 1 triangle (3 vertices) for visibility. Maximum triangles: no hard limit, constrained by memory and index buffer size (practical limit ~millions). Index buffer size = triangle count x 3 x sizeof(uint32) = triCount x 12 bytes. Alternative: track triangle count manually if adding/removing sequentially. Fast operation - simple array size division. Common pattern: For i=0 To b3dCountTriangles(mesh, surf)-1, v0=b3dTriangleVertex(mesh, surf, i, 0), v1=b3dTriangleVertex(mesh, surf, i, 1), v2=b3dTriangleVertex(mesh, surf, i, 2), process triangle. Triangle count independent between surfaces - each surface has own index array. Rendering performance: GPU draws all triangles in surface per draw call, more triangles = slower rendering (typical budget 10k-100k per surface for 60fps).