|
Gama C Library
Gama C API Documentation
|
#include "_math.h"#include "body.h"#include "body_list.h"#include "collision.h"#include "gapi.h"#include "position.h"#include "system.h"Go to the source code of this file.
Functions | |
| void | gm_collision_resolve (gmCollision *collision) |
| Resolves a collision between two bodies by applying appropriate forces and corrections. | |
| void | gm_system_update_body_dt (gmSystem *sys, gmBody *body, double dt) |
| Updates a single physics body's position and velocity based on applied accelerations and damping. | |
| void | gm_body_update_dt (gmBody *body, double dt) |
| Updates a single physics body's position and velocity using a specified time step, without considering a global physics system. | |
| void | gm_body_update (gmBody *body) |
| Updates a single physics body's position and velocity using the engine's global delta time (gm_dt()), without considering a global physics system. | |
| gmCollision * | gm_collision_detect (gmBody *, gmBody *) |
| Detects a collision between two physics bodies. | |
| void | gm_system_update_dt (gmSystem *sys, double unit, double dt) |
| Updates a physics system over a given total time step, performing sub-steps for stable collision detection and resolution. | |
| int | gm_system_get_collision (gmCollision *collision, gmSystem *sys, gmBody *a, gmBody *b) |
| Gets the collision information for two specific bodies in a system. | |
| double | gm_collision_penetration_normals (gmBody *a, gmBody *b, double *normal_x, double *normal_y) |
| Calculates the penetration depth and optionally the normal vector for a collision between two bodies. | |
| double | gm_collision_penetration (gmBody *a, gmBody *b) |
| Calculates the penetration depth for a collision between two bodies. | |
Variables | |
| double | gm_system_frame_time = 0.001 |
| Default time step for physics system frame updates. | |
| void gm_body_update | ( | gmBody * | body | ) |
Updates a single physics body's position and velocity using the engine's global delta time (gm_dt()), without considering a global physics system.
| body | Pointer to the body to update. |
| void gm_body_update_dt | ( | gmBody * | body, |
| double | dt ) |
Updates a single physics body's position and velocity using a specified time step, without considering a global physics system.
| body | Pointer to the body to update. |
| dt | The time step for the update. |
| gmCollision * gm_collision_detect | ( | gmBody * | a, |
| gmBody * | b ) |
Detects a collision between two physics bodies.
| a | Pointer to the first body. |
| b | Pointer to the second body. |
Detects a collision between two physics bodies.
This function dispatches to specific collision tests (e.g., AABB vs AABB, Circle vs Circle, Circle vs AABB) based on the collider_type of the input bodies.
| a | Pointer to the first body. |
| b | Pointer to the second body. |
Calculates the penetration depth for a collision between two bodies.
This function is a simplified version of gm_collision_penetration_normals that only returns the depth and does not calculate the normal vector.
| a | Pointer to the first body. |
| b | Pointer to the second body. |
| double gm_collision_penetration_normals | ( | gmBody * | a, |
| gmBody * | b, | ||
| double * | normal_x, | ||
| double * | normal_y ) |
Calculates the penetration depth and optionally the normal vector for a collision between two bodies.
This function handles collision between various collider types (Circle-Circle, Rect-Rect, Circle-Rect). It determines how much the bodies overlap and the direction of the separation.
| a | Pointer to the first body. |
| b | Pointer to the second body. |
| normal_x | Pointer to store the x component of the collision normal (can be NULL if not needed). The normal points from body a to body b. |
| normal_y | Pointer to store the y component of the collision normal (can be NULL if not needed). The normal points from body a to body b. |
| void gm_collision_resolve | ( | gmCollision * | coll | ) |
Resolves a collision between two bodies by applying appropriate forces and corrections.
Resolves a collision by adjusting positions and velocities of colliding bodies.
| collision | Pointer to the collision to resolve. |
| coll | Pointer to the collision to resolve. |
| int gm_system_get_collision | ( | gmCollision * | collision, |
| gmSystem * | sys, | ||
| gmBody * | a, | ||
| gmBody * | b ) |
Gets the collision information for two specific bodies in a system.
This function searches the system's active collisions to find one involving the two specified bodies.
| collision | Pointer to a gmCollision struct where the found collision data will be copied. Can be NULL if only checking for existence. |
| sys | Pointer to the system to search in. |
| a | Pointer to the first body. |
| b | Pointer to the second body. |
Updates a single physics body's position and velocity based on applied accelerations and damping.
This function integrates the body's motion over a given time step. It accounts for the body's own acceleration and any system-wide acceleration and damping.
| sys | Pointer to the physics system the body belongs to (can be NULL if no system-wide effects are desired). |
| body | Pointer to the body to update. |
| dt | The time step (delta time) for the update. |
| void gm_system_update_dt | ( | gmSystem * | sys, |
| double | unit, | ||
| double | dt ) |
Updates a physics system over a given total time step, performing sub-steps for stable collision detection and resolution.
This is the main update function for a physics system. It integrates the motion of all bodies, detects new collisions, resolves them, and manages the lifecycle of collision objects.
| sys | Pointer to the system to update. |
| unit | The duration of each sub-step for physics integration. |
| dt | The total time duration to simulate in this update. |
| double gm_system_frame_time = 0.001 |
Default time step for physics system frame updates.
This value determines the granularity of physics calculations per frame. A smaller value leads to more accurate (and potentially slower) simulations.