Files

36 lines
1.2 KiB
C
Raw Permalink Normal View History

2023-09-26 19:40:16 +02:00
#ifndef _PIUMA_PHYSICS_COLLISION_H_
#define _PIUMA_PHYSICS_COLLISION_H_
#include "world.h"
struct phy_body_pair
{
phy_body *body_a;
phy_body *body_b;
};
struct phy_collision
{
phy_body *body_a;
phy_body *body_b;
f32 depth;
v3 furthest_point_a;
v3 furthest_point_b;
v3 best_separation_direction;
};
// Generates possibile collision pairs and saves it in the memory pointed by pair_list, up to a maximum of max_pairs. The number of possible collisions is returned in num_pairs (might be >= max_pairs).
void phy_collisions_broadphase(phy_world *world, phy_body_pair *pair_list, u32 max_pairs, u32 *num_pairs);
// Generates list of collisions and saves it in the memory pointed by collision_list, up to a maximum of max_pairs. The number of collisions is returned in num_collisions (might be >= max_collisions).
// Uses pair_list (with size num_pairs) as a list of possible collisions (computed with a faster algorithm).
void phy_collisions_detection(phy_world *world, phy_body_pair *pair_list, u32 num_pairs, phy_collision *collision_list, u32 max_collisions, u32 *num_collisions);
// Modifies world state based on collision_list
void phy_collisions_resolution(phy_world *world, phy_collision *collision_list, u32 num_collisions);
#endif