Returns entity's parent handle (0 if no parent).
Takes entity (child entity handle).
Returns parent handle as Int (entity handle of parent, 0 if no parent or invalid entity).
3D Graphics
Parameters & Returns
Parameters
entityInt
Returns
Int
Quick Summary
Returns entity's parent handle (0 if no parent).
Takes entity (child entity handle).
Returns parent handle as Int (entity handle of parent, 0 if no parent or invalid entity).
Technical Exegesis...
Returns entity's parent handle (0 if no parent). Takes entity (child entity handle). Returns parent handle as Int (entity handle of parent, 0 if no parent or invalid entity). Validates entity exists and has parent (it->second.parent!=nullptr), returns parent->handle (parent entity's handle), returns 0 if entity doesn't exist or has no parent. Query function for hierarchy relationships.
This function queries parent relationship.
Returns entity's parent handle (0 if no parent). Takes entity (child entity handle). Returns parent handle as Int (entity handle of parent, 0 if no parent or invalid entity). Validates entity exists and has parent (it->second.parent!=nullptr), returns parent->handle (parent entity's handle), returns 0 if entity doesn't exist or has no parent. Query function for hierarchy relationships.
This function queries parent relationship. Return values: returns parent entity handle (integer, same handle type used in other entity functions), returns 0 if entity has no parent (root-level entity, never parented or detached via b3dSetParent(child, 0)), returns 0 if entity handle invalid (entity doesn't exist in g_entities map). Parent pointer: internally entities store parent as pointer (entity.parent = Entity3D*), function returns parent->handle (parent entity's handle integer), 0 represents nullptr/no parent (sentinel value). Use cases: (1) Hierarchy traversal (walk up parent chain to root), (2) Validation (check if entity parented before operations), (3) Debugging (inspect scene graph structure), (4) Save/load systems (serialize hierarchy relationships), (5) Unparenting (if b3dGetParent(entity)!=0, has parent). Common pattern: parent = b3dGetParent(child), while parent != 0: parent = b3dGetParent(parent) to traverse to root, or if b3dGetParent(entity) == 0: entity is root-level. Typical usage: check parent before hierarchy operations, traverse hierarchy for scene graph visualization, verify parenting after b3dSetParent calls. Root entities: entities created without parents (b3dLoadMesh, b3dCreatePivot, etc.) have parent=nullptr, b3dGetParent returns 0 for root entities. Detached entities: entities detached via b3dSetParent(entity, 0) become root entities (parent=nullptr), subsequent b3dGetParent returns 0. Hierarchy depth: repeatedly call b3dGetParent to find hierarchy depth: depth=0, p=entity, while b3dGetParent(p)!=0: depth++, p=b3dGetParent(p). Performance: O(1) lookup (hash map find, pointer dereference, handle return), fast query. Validation: returns 0 for invalid handles (no error message), safe to call on any integer (won't crash on invalid handles). Related: b3dSetParent establishes parent-child relationships, UpdateEntityWorldMatrix uses parent chain for matrix calculation, entity hierarchy system for grouped transforms.