![]() |
CRM64Pro GDK v0.15.0
A free cross-platform game development kit built on top of SDL 3.0
|
Physics interface class. More...
Physics interface class.
Classes | |
| struct | AABB |
| Axis-aligned bounding box using half-open bounds [min, max). More... | |
Public Types | |
| typedef bool(* | TileSolidCallback) (const SceneLayerTile *pTileLayer, Sint32 iCellX, Sint32 iCellY, Uint32 iCellValue, void *pUserData) |
| Callback used by tile-layer sweep/ground checks to decide if one tile is solid. | |
Public Member Functions | |
| bool | overlapsSprite (Sprite *pS1, float fX1, float fY1, Sprite *pS2, float fX2, float fY2, const SDL_FRect *pOverlap=nullptr, ePhysicsCollisionMode eMode=PCM_PIXEL) |
| Check overlap between two sprites. | |
| bool | overlapsSprite (Sprite *pS1, float fX1, float fY1, const SDL_FRect &rect, const SDL_FRect *pOverlap=nullptr, ePhysicsCollisionMode eMode=PCM_PIXEL) |
| Check overlap between a sprite and a rectangle. | |
| bool | overlapsSprite (Sprite *pS1, float fX1, float fY1, float fPX, float fPY, ePhysicsCollisionMode eMode=PCM_PIXEL) |
| Check overlap between a sprite and a point. | |
| bool | resolve (SDL_FRect &subject, const SDL_FRect &obstacle) |
| Resolve overlap between two rectangular areas. | |
| bool | sweepAABBOnLayerTile (const SDL_FRect &rectStart, float fDX, float fDY, SceneLayerTile *pSceneLayer, SDL_FRect *pRectResolved, bool *pHitX=nullptr, bool *pHitY=nullptr, bool *pGrounded=nullptr, TileSolidCallback fnSolid=nullptr, void *pUserData=nullptr) |
| Sweep an AABB on a tile layer and resolve collisions (axis separated: X then Y). | |
| bool | isGroundedOnLayerTile (const SDL_FRect &rect, SceneLayerTile *pSceneLayer, float fProbeDistance=1.0f, TileSolidCallback fnSolid=nullptr, void *pUserData=nullptr) |
| Ground probe helper against a tile layer. | |
| bool | info (Sint32 iMode=0) override |
| Request Physics Interface information. | |
Static Public Member Functions | |
| static bool | integrateVelocity (float &fV, float fA, float fDT) |
| Integrate velocity using explicit Euler: v = v + a * dt. | |
| static bool | applyLinearDamping (float &fV, float fDamping, float fDT) |
| Apply linear damping to velocity: v *= max(0, 1 - damping * dt). | |
| static bool | clampVelocity (float &fV, float fMaxV) |
| Clamp a velocity value within a maximum magnitude. | |
| static bool | isValidAABB (const AABB &aabb) |
| Validate if an AABB contains finite values and non-inverted bounds. | |
| static bool | containsPoint (const AABB &aabb, float px, float py) |
| Test if a point is inside an AABB using half-open bounds [min, max). | |
| static bool | overlapsAABB (const AABB &aabb1, const AABB &aabb2, SDL_FRect *pOverlap=nullptr) |
| Test if two AABBs overlap using half-open bounds [min, max). | |
| static bool | overlapsObjectAABB (const SceneObject *pObjA, const SceneObject *pObjB, SDL_FRect *pOverlap=nullptr) |
| Fast object-object broad phase using cached object AABBs. | |
| static bool | containsObjectPoint (const SceneObject *pObj, float fPX, float fPY) |
| Precise point-in-object check using object shape geometry. | |
| static bool | overlapsObject (const SceneObject *pObjA, const SceneObject *pObjB, ePhysicsCollisionMode eMode=PCM_SHAPE, SDL_FRect *pOverlap=nullptr) |
| Object-object overlap with selectable narrow phase. | |
| static bool | overlapsObjectTrigger (const SceneObject *pOwnerObj, const SceneShapeData &triggerLocalShape, const SceneObject *pOther, ePhysicsCollisionMode eMode=PCM_SHAPE, SDL_FRect *pOverlap=nullptr) |
| Trigger-local-shape versus object overlap. | |
| static bool | matchTypeHash (Uint32 iObjectTypeHash, const vector< Uint32 > &vIncludeHashes, const vector< Uint32 > &vExcludeHashes) |
| Fast hash filter helper for trigger/object-type matching. | |
| typedef bool(* CRM64Pro::Physics::TileSolidCallback) (const SceneLayerTile *pTileLayer, Sint32 iCellX, Sint32 iCellY, Uint32 iCellValue, void *pUserData) |
Callback used by tile-layer sweep/ground checks to decide if one tile is solid.
| pTileLayer | Tile layer being queried. |
| iCellX | Tile cell X. |
| iCellY | Tile cell Y. |
| iCellValue | Tile GID/value at the queried cell (0 for out-of-bounds). |
| pUserData | User payload passed through helper call. |
|
static |
Integrate velocity using explicit Euler: v = v + a * dt.
| fV | Reference to velocity. |
| fA | Acceleration. |
| fDT | Delta time in seconds (must be >= 0). |
|
static |
Apply linear damping to velocity: v *= max(0, 1 - damping * dt).
| fV | Reference to velocity. |
| fDamping | Damping factor in 1/seconds (must be >= 0). |
| fDT | Delta time in seconds (must be >= 0). |
|
static |
Clamp a velocity value within a maximum magnitude.
| fV | Reference to the velocity value to be clamped. |
| fMaxV | The maximum allowed velocity. |
|
static |
|
static |
|
static |
Test if two AABBs overlap using half-open bounds [min, max).
| aabb1 | First AABB. |
| aabb2 | Second AABB. |
| pOverlap | Optional output pointer. When overlap exists, receives intersection rectangle in world space. |
|
static |
Fast object-object broad phase using cached object AABBs.
| pObjA | First object. |
| pObjB | Second object. |
| pOverlap | Optional output pointer. When overlap exists, receives intersection rectangle in world space. |
|
static |
Precise point-in-object check using object shape geometry.
| pObj | Object to test. |
| fPX | Point X coordinate in world space. |
| fPY | Point Y coordinate in world space. |
|
static |
Object-object overlap with selectable narrow phase.
PCM_AABB uses only cached AABB overlap. PCM_SHAPE uses precise per-point shape checks inside the overlap region. PCM_PIXEL currently falls back to PCM_SHAPE when no sprite alpha source is available.
| pObjA | First object. |
| pObjB | Second object. |
| eMode | Overlap mode. |
| pOverlap | Optional output pointer. Receives AABB intersection when broad-phase overlap exists. |
|
static |
Trigger-local-shape versus object overlap.
The trigger shape is defined in owner-local coordinates and transformed to world space using owner transform.
| pOwnerObj | Owner object that defines trigger transform space. |
| triggerLocalShape | Trigger shape in owner-local coordinates. |
| pOther | Object tested against trigger shape. |
| eMode | Overlap mode. |
| pOverlap | Optional output pointer. Receives trigger/object AABB overlap rectangle when broad-phase overlap exists. |
|
static |
Fast hash filter helper for trigger/object-type matching.
| iObjectTypeHash | 32-bit type hash for tested object. |
| vIncludeHashes | Include filter hashes. Empty means include all. |
| vExcludeHashes | Exclude filter hashes. Matching any excludes the object. |
| bool CRM64Pro::Physics::overlapsSprite | ( | Sprite * | pS1, |
| float | fX1, | ||
| float | fY1, | ||
| Sprite * | pS2, | ||
| float | fX2, | ||
| float | fY2, | ||
| const SDL_FRect * | pOverlap = nullptr, | ||
| ePhysicsCollisionMode | eMode = PCM_PIXEL ) |
Check overlap between two sprites.
| pS1 | Pointer to the first Sprite. |
| fX1 | X position of the first sprite. |
| fY1 | Y position of the first sprite. |
| pS2 | Pointer to the second Sprite. |
| fX2 | X position of the second sprite. |
| fY2 | Y position of the second sprite. |
| pOverlap | Optional pointer to a precomputed intersection rectangle to speed up math. |
| eMode | Overlap mode. PCM_AABB performs rectangle overlap only, PCM_PIXEL performs pixel-perfect overlap, PCM_SHAPE is not supported for sprites in this version. |
| bool CRM64Pro::Physics::overlapsSprite | ( | Sprite * | pS1, |
| float | fX1, | ||
| float | fY1, | ||
| const SDL_FRect & | rect, | ||
| const SDL_FRect * | pOverlap = nullptr, | ||
| ePhysicsCollisionMode | eMode = PCM_PIXEL ) |
Check overlap between a sprite and a rectangle.
| pS1 | Pointer to the Sprite. |
| fX1 | X position of the sprite. |
| fY1 | Y position of the sprite. |
| rect | Reference to the SDL_FRect defining the overlap area. |
| pOverlap | Optional pointer to a precomputed intersection rectangle to speed up math. |
| eMode | Overlap mode. PCM_AABB performs rectangle overlap only, PCM_PIXEL performs pixel-perfect overlap, PCM_SHAPE is not supported for sprites in this version. |
| bool CRM64Pro::Physics::overlapsSprite | ( | Sprite * | pS1, |
| float | fX1, | ||
| float | fY1, | ||
| float | fPX, | ||
| float | fPY, | ||
| ePhysicsCollisionMode | eMode = PCM_PIXEL ) |
Check overlap between a sprite and a point.
| pS1 | Pointer to the Sprite. |
| fX1 | X position of the sprite. |
| fY1 | Y position of the sprite. |
| fPX | X coordinate of the point. |
| fPY | Y coordinate of the point. |
| eMode | Overlap mode. PCM_AABB performs sprite bounds test only, PCM_PIXEL performs pixel test, PCM_SHAPE is not supported for sprites in this version. |
| bool CRM64Pro::Physics::resolve | ( | SDL_FRect & | subject, |
| const SDL_FRect & | obstacle ) |
Resolve overlap between two rectangular areas.
| subject | Reference to the subject rectangle (to be moved). |
| obstacle | Reference to the static obstacle rectangle. |
| bool CRM64Pro::Physics::sweepAABBOnLayerTile | ( | const SDL_FRect & | rectStart, |
| float | fDX, | ||
| float | fDY, | ||
| SceneLayerTile * | pSceneLayer, | ||
| SDL_FRect * | pRectResolved, | ||
| bool * | pHitX = nullptr, | ||
| bool * | pHitY = nullptr, | ||
| bool * | pGrounded = nullptr, | ||
| TileSolidCallback | fnSolid = nullptr, | ||
| void * | pUserData = nullptr ) |
Sweep an AABB on a tile layer and resolve collisions (axis separated: X then Y).
| rectStart | Initial world-space rectangle. |
| fDX | Desired movement on X axis in world units. |
| fDY | Desired movement on Y axis in world units. |
| pSceneLayer | Tile layer used as collision map. |
| pRectResolved | Output resolved rectangle after collision response. |
| pHitX | Optional output flag set to true when X movement is blocked. |
| pHitY | Optional output flag set to true when Y movement is blocked. |
| pGrounded | Optional output flag set when downward movement collides with ground. |
| fnSolid | Optional solidity callback (default: any non-zero tile is solid, out-of-bounds sides/bottom are solid, above top is non-solid). |
| pUserData | User payload passed to fnSolid. |
| bool CRM64Pro::Physics::isGroundedOnLayerTile | ( | const SDL_FRect & | rect, |
| SceneLayerTile * | pSceneLayer, | ||
| float | fProbeDistance = 1.0f, | ||
| TileSolidCallback | fnSolid = nullptr, | ||
| void * | pUserData = nullptr ) |
Ground probe helper against a tile layer.
| rect | Object/world rectangle. |
| pSceneLayer | Tile layer used as collision map. |
| fProbeDistance | Thickness of the feet probe strip in world units below rect bottom. Typical values: 0.5 to 4.0. |
| fnSolid | Optional solidity callback (same semantics as sweepAABBOnTileLayer()). |
| pUserData | User payload passed to fnSolid. |