![]() |
CRM64Pro GDK v0.19.0
A free cross-platform game development kit built on top of SDL 3.0
|
Object layer containing game objects with spatial partitioning.
Each SceneLayerObject manages a collection of SceneObject instances with efficient spatial queries via an internal grid. Supports render/update flags and deferred destruction.
Classes | |
| struct | CRM64Pro::SceneShapeData |
| Shape geometry data for a SceneObject. More... | |
| struct | CRM64Pro::SceneObjectTrigger |
| Object trigger zone definition. More... | |
| struct | CRM64Pro::SceneTriggerEvent |
| Trigger event payload. More... | |
| class | CRM64Pro::ISceneObjectFactory |
| Factory interface for creating game objects from Tiled type strings. More... | |
| class | CRM64Pro::SceneObject |
| Base class for all Scene game objects. More... | |
| class | CRM64Pro::SceneLayerObject |
| Object layer containing game objects with spatial partitioning. More... | |
Functions | |
| CRM64PRO_API void | CRM64Pro::SceneShapeData::calculateAABB (float fObjX, float fObjY, float fObjWidth, float fObjHeight) |
| Recalculate AABB from object position and dimensions. | |
| CRM64PRO_API void | CRM64Pro::SceneObjectTrigger::addIncludeType (const string &sType) |
| Add one type identifier to the include filter. | |
| CRM64PRO_API void | CRM64Pro::SceneObjectTrigger::addExcludeType (const string &sType) |
| Add one type identifier to the exclude filter. | |
| CRM64Pro::SceneObject::SceneObject () | |
| Default constructor. | |
| virtual | CRM64Pro::SceneObject::~SceneObject () |
| Virtual destructor for proper cleanup of derived classes. | |
| virtual void | CRM64Pro::SceneObject::initialize () |
| Called after TMX import populates all fields. | |
| virtual void | CRM64Pro::SceneObject::update (Scene *pScene, SceneLayerContext &rContext) |
| Called each frame when layer has UPDATE enabled. | |
| virtual void | CRM64Pro::SceneObject::render (Scene *pScene, SceneLayerContext &rContext) |
| Called each frame when layer has RENDER enabled and object is visible. | |
| void | CRM64Pro::SceneObject::setPosition (float fNewX, float fNewY) |
| Set object position and update spatial grid. | |
| bool | CRM64Pro::SceneObject::setSize (float fNewWidth, float fNewHeight) |
| Set object size and update cached bounds. | |
| void | CRM64Pro::SceneObject::setVisible (bool bNewVisible) |
| Set object visibility. | |
| float | CRM64Pro::SceneObject::getX () const |
| Get the object X position. | |
| float | CRM64Pro::SceneObject::getY () const |
| Get the object Y position. | |
| float | CRM64Pro::SceneObject::getWidth () const |
| Get the object width. | |
| float | CRM64Pro::SceneObject::getHeight () const |
| Get the object height. | |
| float | CRM64Pro::SceneObject::getRotationDeg () const |
| Get the object rotation. | |
| bool | CRM64Pro::SceneObject::isVisible () const |
| Check if the object is visible. | |
| Sint32 | CRM64Pro::SceneObject::getID () const |
| Get the object ID. | |
| const string & | CRM64Pro::SceneObject::getType () const |
| Get the type identifier. | |
| const string & | CRM64Pro::SceneObject::getName () const |
| Get the object name. | |
| const SceneShapeData & | CRM64Pro::SceneObject::getShape () const |
| Get the object shape data. | |
| bool | CRM64Pro::SceneObject::isPendingDestruction () const |
| Check if the object is pending destruction. | |
| bool | CRM64Pro::SceneObject::addTrigger (const SceneObjectTrigger &rTrigger) |
| Add a trigger zone to this object. | |
| bool | CRM64Pro::SceneObject::updateTrigger (const SceneObjectTrigger &rTrigger) |
| Update an existing trigger by name. | |
| bool | CRM64Pro::SceneObject::removeTrigger (const string &sName) |
| Remove a trigger by name. | |
| void | CRM64Pro::SceneObject::clearTriggers () |
| Remove all triggers. | |
| bool | CRM64Pro::SceneObject::setTriggerEnabled (const string &sName, bool bEnabled) |
| Enable or disable a trigger. | |
| bool | CRM64Pro::SceneObject::getTrigger (const string &sName, SceneObjectTrigger *pOut) const |
| Get a trigger definition by name. | |
| Sint32 | CRM64Pro::SceneObject::getTriggerCount () const |
| Get number of triggers assigned to this object. | |
| void | CRM64Pro::SceneObject::setOnTriggerEvent (TriggerEventCallback fnCallback) |
| Set trigger event callback. | |
| bool | CRM64Pro::SceneObject::hasProperty (const string &sKey) const |
| Check if a custom property exists. | |
| string | CRM64Pro::SceneObject::getPropertyString (const string &sKey, const string &sDefault="") const |
| Get a string custom property. | |
| Sint32 | CRM64Pro::SceneObject::getPropertyInt (const string &sKey, Sint32 iDefault=0) const |
| Get an integer custom property. | |
| bool | CRM64Pro::SceneObject::getPropertyBool (const string &sKey, bool bDefault=false) const |
| Get a boolean custom property. | |
| float | CRM64Pro::SceneObject::getPropertyFloat (const string &sKey, float fDefault=0.0f) const |
| Get a floating-point custom property. | |
| void | CRM64Pro::SceneObject::recalculateBounds () |
| Recalculate cached AABB after shape or dimension changes. | |
| bool | CRM64Pro::SceneObject::containsPoint (float fX, float fY) const |
| Test if a point is inside this object's shape. | |
| bool | CRM64Pro::SceneObject::overlapsObject (const SceneObject *pOther, SDL_FRect *pOverlap=nullptr) const |
| Test if this object's AABB overlaps another object's AABB. | |
| eSceneLayerType | CRM64Pro::SceneLayerObject::getType () const override |
| Get the layer type. | |
| Sint32 | CRM64Pro::SceneLayerObject::update (Scene *pEngine, SceneLayerContext &rContext) override |
| Update object layer logic. | |
| Sint32 | CRM64Pro::SceneLayerObject::render (Scene *pEngine, SceneLayerContext &rContext) override |
| Render object layer content. | |
| Sint32 | CRM64Pro::SceneLayerObject::addObject (SceneObject *pObj) |
| Add an object to this layer. | |
| bool | CRM64Pro::SceneLayerObject::closeObject (Sint32 id) |
| Destroy an object by its ID. | |
| bool | CRM64Pro::SceneLayerObject::setSpatialGridCellSize (Sint32 iSize) |
| Set the spatial grid cell size. | |
| bool | CRM64Pro::SceneLayerObject::setSize (float fWidth, float fHeight) |
| Set the logical size of the layer (in pixels). | |
| void | CRM64Pro::SceneLayerObject::setRenderOrderMode (eSceneObjectRenderOrder eMode) |
| Set object rendering order policy. | |
| eSceneObjectRenderOrder | CRM64Pro::SceneLayerObject::getRenderOrderMode () const |
| Get object rendering order policy. | |
| void | CRM64Pro::SceneLayerObject::queryRegion (float fX, float fY, float fW, float fH, vector< SceneObject * > &vResults) |
| Query objects whose AABB overlaps a region. | |
| SceneObject * | CRM64Pro::SceneLayerObject::getObjectByID (Sint32 idObject) |
| Get object by Tiled ID. | |
| Sint32 | CRM64Pro::SceneLayerObject::getObjectCount () |
| Get number of objects in this layer. | |
| SceneObject * | CRM64Pro::SceneLayerObject::findFirstByType (const string &sType) |
| Find first object matching an exact type string. | |
| SceneObject * | CRM64Pro::SceneLayerObject::findFirstByName (const string &sName) |
| Find first object matching an exact name string. | |
| void | CRM64Pro::SceneLayerObject::findAllByType (const string &sType, vector< SceneObject * > &vResults) |
| Find all objects matching an exact type string. | |
| void | CRM64Pro::SceneLayerObject::findAllByName (const string &sName, vector< SceneObject * > &vResults) |
| Find all objects matching an exact name string. | |
| void | CRM64Pro::SceneLayerObject::setOnTriggerEvent (SceneObject::TriggerEventCallback fnCallback) |
| Set a layer-wide trigger event callback. | |
| float | CRM64Pro::SceneLayerObject::getTotalWidth () const override |
| Get layer total width in pixels. | |
| float | CRM64Pro::SceneLayerObject::getTotalHeight () const override |
| Get layer total height in pixels. | |
| void | CRM64Pro::Scene::setObjectFactory (ISceneObjectFactory *pFactory) |
| Set the object factory for creating game objects from Tiled types. | |
| ISceneObjectFactory * | CRM64Pro::Scene::getObjectFactory () const |
| Get the current object factory. | |
| bool | CRM64Pro::Scene::isObjectLayer (Sint32 iLayer) const |
| Check if a layer is an object layer. | |
| void CRM64Pro::SceneShapeData::calculateAABB | ( | float | fObjX, |
| float | fObjY, | ||
| float | fObjWidth, | ||
| float | fObjHeight ) |
Recalculate AABB from object position and dimensions.
For polygons/polylines, calculates bounds from vertices. For other shapes, uses position and width/height.
| fObjX | Object X position in world space. |
| fObjY | Object Y position in world space. |
| fObjWidth | Object width (ignored for polygon/polyline). |
| fObjHeight | Object height (ignored for polygon/polyline). |
| void CRM64Pro::SceneObjectTrigger::addIncludeType | ( | const string & | sType | ) |
Add one type identifier to the include filter.
Type is hashed internally exactly as provided. Empty strings are ignored.
| sType | The type string to include. |
| void CRM64Pro::SceneObjectTrigger::addExcludeType | ( | const string & | sType | ) |
Add one type identifier to the exclude filter.
Type is hashed internally exactly as provided. Empty strings are ignored.
| sType | The type string to exclude. |
|
virtual |
Called after TMX import populates all fields.
Override to parse properties, create sprites, initialize game state. Base implementation does nothing.
|
virtual |
Called each frame when layer has UPDATE enabled.
Override to implement game logic, movement, AI, etc. Base implementation does nothing.
| pScene | Pointer to the Scene instance. |
| rContext | Layer context structure containing update state. |
|
virtual |
Called each frame when layer has RENDER enabled and object is visible.
Override to implement custom rendering. Base implementation renders the tile if gid is non-zero; otherwise does nothing.
| pScene | Pointer to the Scene instance. |
| rContext | Layer context structure containing render state. |
| void CRM64Pro::SceneObject::setPosition | ( | float | fNewX, |
| float | fNewY ) |
Set object position and update spatial grid.
Always use this method to move objects - direct modification of coordinates will desynchronize the object from the spatial grid.
| fNewX | New X position in world pixels. |
| fNewY | New Y position in world pixels. |
| bool CRM64Pro::SceneObject::setSize | ( | float | fNewWidth, |
| float | fNewHeight ) |
Set object size and update cached bounds.
| fNewWidth | New width in pixels. |
| fNewHeight | New height in pixels. |
| void CRM64Pro::SceneObject::setVisible | ( | bool | bNewVisible | ) |
Set object visibility.
| bNewVisible | true to render, false to hide. |
| float CRM64Pro::SceneObject::getX | ( | ) | const |
Get the object X position.
| float CRM64Pro::SceneObject::getY | ( | ) | const |
Get the object Y position.
| float CRM64Pro::SceneObject::getWidth | ( | ) | const |
Get the object width.
| float CRM64Pro::SceneObject::getHeight | ( | ) | const |
Get the object height.
| float CRM64Pro::SceneObject::getRotationDeg | ( | ) | const |
Get the object rotation.
| bool CRM64Pro::SceneObject::isVisible | ( | ) | const |
Check if the object is visible.
| Sint32 CRM64Pro::SceneObject::getID | ( | ) | const |
Get the object ID.
| const string & CRM64Pro::SceneObject::getType | ( | ) | const |
Get the type identifier.
| const string & CRM64Pro::SceneObject::getName | ( | ) | const |
Get the object name.
| const SceneShapeData & CRM64Pro::SceneObject::getShape | ( | ) | const |
Get the object shape data.
| bool CRM64Pro::SceneObject::isPendingDestruction | ( | ) | const |
Check if the object is pending destruction.
| bool CRM64Pro::SceneObject::addTrigger | ( | const SceneObjectTrigger & | rTrigger | ) |
Add a trigger zone to this object.
| rTrigger | Trigger definition. |
| bool CRM64Pro::SceneObject::updateTrigger | ( | const SceneObjectTrigger & | rTrigger | ) |
Update an existing trigger by name.
| rTrigger | Trigger definition. sName selects the trigger to update. |
| bool CRM64Pro::SceneObject::removeTrigger | ( | const string & | sName | ) |
Remove a trigger by name.
| sName | Trigger name. |
| bool CRM64Pro::SceneObject::setTriggerEnabled | ( | const string & | sName, |
| bool | bEnabled ) |
Enable or disable a trigger.
| sName | Trigger name. |
| bEnabled | New enabled state. |
| bool CRM64Pro::SceneObject::getTrigger | ( | const string & | sName, |
| SceneObjectTrigger * | pOut ) const |
Get a trigger definition by name.
| sName | Trigger name. |
| pOut | Destination structure. |
| Sint32 CRM64Pro::SceneObject::getTriggerCount | ( | ) | const |
Get number of triggers assigned to this object.
| void CRM64Pro::SceneObject::setOnTriggerEvent | ( | TriggerEventCallback | fnCallback | ) |
Set trigger event callback.
Object-level callback for this specific SceneObject instance. Called before layer/global trigger callbacks (dispatch order: object -> layer -> global).
| fnCallback | Callback function, or an empty callback to clear. |
| bool CRM64Pro::SceneObject::hasProperty | ( | const string & | sKey | ) | const |
Check if a custom property exists.
| sKey | Property key. |
| string CRM64Pro::SceneObject::getPropertyString | ( | const string & | sKey, |
| const string & | sDefault = "" ) const |
Get a string custom property.
| sKey | Property key. |
| sDefault | Value returned when the property does not exist. |
| Sint32 CRM64Pro::SceneObject::getPropertyInt | ( | const string & | sKey, |
| Sint32 | iDefault = 0 ) const |
Get an integer custom property.
| sKey | Property key. |
| iDefault | Value returned when the property does not exist. |
| bool CRM64Pro::SceneObject::getPropertyBool | ( | const string & | sKey, |
| bool | bDefault = false ) const |
Get a boolean custom property.
| sKey | Property key. |
| bDefault | Value returned when the property does not exist. |
| float CRM64Pro::SceneObject::getPropertyFloat | ( | const string & | sKey, |
| float | fDefault = 0.0f ) const |
Get a floating-point custom property.
| sKey | Property key. |
| fDefault | Value returned when the property does not exist. |
| void CRM64Pro::SceneObject::recalculateBounds | ( | ) |
Recalculate cached AABB after shape or dimension changes.
Call this if you modify shape.points directly.
| bool CRM64Pro::SceneObject::containsPoint | ( | float | fX, |
| float | fY ) const |
Test if a point is inside this object's shape.
Uses precise shape geometry (not just AABB).
| fX | Point X coordinate in world space. |
| fY | Point Y coordinate in world space. |
| bool CRM64Pro::SceneObject::overlapsObject | ( | const SceneObject * | pOther, |
| SDL_FRect * | pOverlap = nullptr ) const |
Test if this object's AABB overlaps another object's AABB.
Fast broad-phase overlap test using cached AABBs.
| pOther | Pointer to other object. |
| pOverlap | Optional pointer to a SDL_FRect filled with the intersection area if overlap occurs. |
|
overridevirtual |
|
overrideprotectedvirtual |
Update object layer logic.
| pEngine | Pointer to the Scene instance. |
| rContext | Layer context structure containing update state. |
Implements CRM64Pro::SceneLayer.
|
overrideprotectedvirtual |
Render object layer content.
| pEngine | Pointer to the Scene instance. |
| rContext | Layer context structure containing render state. |
Implements CRM64Pro::SceneLayer.
| Sint32 CRM64Pro::SceneLayerObject::addObject | ( | SceneObject * | pObj | ) |
Add an object to this layer.
The object is queued for addition at the next synchronization point (usually end of update loop) to ensure thread-safety and prevent iterator invalidation. The layer takes ownership of the object and will release its memory upon destruction or closeObject(). Runtime-created objects are assigned a unique ID starting from 16384 to avoid collisions with Tiled IDs.
| pObj | Object to add (must not be nullptr). |
| bool CRM64Pro::SceneLayerObject::closeObject | ( | Sint32 | id | ) |
Destroy an object by its ID.
The object is marked for removal and its memory will be safely released at the end of the frame. This method is thread-safe and safe to call during logic updates or from worker threads.
| id | Object ID to destroy. |
| bool CRM64Pro::SceneLayerObject::setSpatialGridCellSize | ( | Sint32 | iSize | ) |
Set the spatial grid cell size.
Warning: This will clear the grid structure! Only use during initialization/loading.
| iSize | New cell size in pixels. |
| bool CRM64Pro::SceneLayerObject::setSize | ( | float | fWidth, |
| float | fHeight ) |
Set the logical size of the layer (in pixels).
| fWidth | Total width in pixels. |
| fHeight | Total height in pixels. |
| void CRM64Pro::SceneLayerObject::setRenderOrderMode | ( | eSceneObjectRenderOrder | eMode | ) |
Set object rendering order policy.
| eMode | Draw order mode. See ::eSceneObjectRenderOrder. |
| eSceneObjectRenderOrder CRM64Pro::SceneLayerObject::getRenderOrderMode | ( | ) | const |
Get object rendering order policy.
| void CRM64Pro::SceneLayerObject::queryRegion | ( | float | fX, |
| float | fY, | ||
| float | fW, | ||
| float | fH, | ||
| vector< SceneObject * > & | vResults ) |
Query objects whose AABB overlaps a region.
Efficient spatial query using internal grid.
| fX | Region X position in world pixels. |
| fY | Region Y position in world pixels. |
| fW | Region width in pixels. |
| fH | Region height in pixels. |
| vResults | Output vector filled with unique objects overlapping region. |
| SceneObject * CRM64Pro::SceneLayerObject::getObjectByID | ( | Sint32 | idObject | ) |
Get object by Tiled ID.
| idObject | Object ID to find. |
| Sint32 CRM64Pro::SceneLayerObject::getObjectCount | ( | ) |
Get number of objects in this layer.
| SceneObject * CRM64Pro::SceneLayerObject::findFirstByType | ( | const string & | sType | ) |
Find first object matching an exact type string.
Exact case-sensitive match against the stored type string. Pending-destruction objects are ignored.
| sType | Exact type string to match. |
| SceneObject * CRM64Pro::SceneLayerObject::findFirstByName | ( | const string & | sName | ) |
Find first object matching an exact name string.
Exact case-sensitive match against the stored object name. Pending-destruction objects are ignored.
| sName | Exact object name to match. |
| void CRM64Pro::SceneLayerObject::findAllByType | ( | const string & | sType, |
| vector< SceneObject * > & | vResults ) |
Find all objects matching an exact type string.
Exact case-sensitive match against the stored type string. Pending-destruction objects are ignored.
| sType | Exact type string to match. |
| vResults | Output vector receiving matches (cleared by this method). |
| void CRM64Pro::SceneLayerObject::findAllByName | ( | const string & | sName, |
| vector< SceneObject * > & | vResults ) |
Find all objects matching an exact name string.
Exact case-sensitive match against the stored object name. Pending-destruction objects are ignored.
| sName | Exact object name to match. |
| vResults | Output vector receiving matches (cleared by this method). |
| void CRM64Pro::SceneLayerObject::setOnTriggerEvent | ( | SceneObject::TriggerEventCallback | fnCallback | ) |
Set a layer-wide trigger event callback.
Layer-level callback for all trigger events generated in this SceneLayerObject. Called after object callback and before Scene global callback (dispatch order: object -> layer -> global).
| fnCallback | Callback function, or an empty callback to clear. |
|
overridevirtual |
Get layer total width in pixels.
Reimplemented from CRM64Pro::SceneLayer.
|
overridevirtual |
Get layer total height in pixels.
Reimplemented from CRM64Pro::SceneLayer.
| void CRM64Pro::Scene::setObjectFactory | ( | ISceneObjectFactory * | pFactory | ) |
Set the object factory for creating game objects from Tiled types.
The factory is called during TMX import when objects with a "type" attribute are encountered. If no factory is set, or if the factory returns nullptr, a generic SceneObject is created.
| pFactory | Borrowed user-provided factory implementing ISceneObjectFactory, or nullptr to clear it. CRM64Pro does not take ownership. The pointer must remain valid until this Scene is closed or the factory is replaced or cleared. |
| ISceneObjectFactory * CRM64Pro::Scene::getObjectFactory | ( | ) | const |
Get the current object factory.
| bool CRM64Pro::Scene::isObjectLayer | ( | Sint32 | iLayer | ) | const |
Check if a layer is an object layer.
| iLayer | Layer index (1-based). |