Gama C Library
Gama C API Documentation
Loading...
Searching...
No Matches
physics.h File Reference
#include "body.h"
#include "body_list.h"
#include "collision.h"
#include "gapi.h"
#include "position.h"
#include "system.h"
#include <math.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 body in the system by integrating its position and velocity over time.
void gm_body_update_dt (gmBody *body, double dt)
 Updates a single body by integrating its position and velocity over time.
void gm_body_update (gmBody *body)
 Updates a single body by integrating its position and velocity over time.
gmCollisiongm_collision_detect (gmBody *, gmBody *)
 Detects collision between two bodies.
void gm_system_update_dt (gmSystem *sys, double unit, double dt)
 Updates the physics system with collision detection at specified time intervals.
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 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.

Function Documentation

◆ gm_body_update()

void gm_body_update ( gmBody * body)

Updates a single body by integrating its position and velocity over time.

Parameters
bodyPointer to the body to update.

◆ gm_body_update_dt()

void gm_body_update_dt ( gmBody * body,
double dt )

Updates a single body by integrating its position and velocity over time.

Parameters
bodyPointer to the body to update.
dtThe time step for the update.

◆ gm_collision_detect()

gmCollision * gm_collision_detect ( gmBody * a,
gmBody * b )

Detects collision between two bodies.

Parameters
aPointer to the first body.
bPointer to the second body.
Returns
A pointer to a gmCollision structure if collision occurs, NULL otherwise.

◆ gm_collision_penetration()

double gm_collision_penetration ( gmBody * a,
gmBody * b )

Calculates the penetration depth for a collision between two bodies.

Parameters
aPointer to the first body.
bPointer to the second body.
Returns
The penetration depth between the bodies.

◆ gm_collision_penetration_normals()

double gm_collision_penetration_normals ( gmBody * a,
gmBody * b,
double * normal_x,
double * normal_y )

Calculates the penetration depth and normal vector for a collision between two bodies.

Parameters
aPointer to the first body.
bPointer to the second body.
normal_xPointer to store the x component of the collision normal (can be NULL).
normal_yPointer to store the y component of the collision normal (can be NULL).
Returns
The penetration depth between the bodies.

◆ gm_collision_resolve()

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.

Parameters
collisionPointer to the collision to resolve.
collPointer to the collision to resolve.

◆ gm_system_get_collision()

int gm_system_get_collision ( gmCollision * collision,
gmSystem * sys,
gmBody * a,
gmBody * b )

Gets the collision information for two specific bodies in a system.

Parameters
collisionPointer to the collision where to copy the result, or NULL.
sysPointer to the system to search in.
aPointer to the first body.
bPointer to the second body.
Returns
1 if it found a collision else 0.

◆ gm_system_update_body_dt()

void gm_system_update_body_dt ( gmSystem * sys,
gmBody * body,
double dt )

Updates a single body in the system by integrating its position and velocity over time.

Parameters
sysPointer to the system containing the body (can be NULL).
bodyPointer to the body to update.
dtThe time step for the update.

◆ gm_system_update_dt()

void gm_system_update_dt ( gmSystem * sys,
double unit,
double dt )

Updates the physics system with collision detection at specified time intervals.

Parameters
sysPointer to the system to update.
unitThe time unit for sub-step calculations.
dtThe total time step to simulate.

Variable Documentation

◆ gm_system_frame_time

double gm_system_frame_time = 0.001

Default time step for physics system frame updates.