feat(physics): added physics_world_query

This commit is contained in:
Sara 2023-11-24 23:23:27 +01:00
parent 73cd7c5f96
commit 67b138741b
2 changed files with 10 additions and 0 deletions

View file

@ -29,6 +29,13 @@ void physics_world_remove_entity(PhysicsEntity entity) {
ASSERT_RETURN(0,, "Physics entity with data at %p is not registered in physics world", entity.data);
}
PhysicsEntity physics_world_query(PhysicsQuery query) {
list_foreach(PhysicsEntity*, entity, &_world_bodies) {
if(overlap_check(query, *entity))
return *entity;
}
}
static inline
void _internal_physics_narrow_collision() {
size_t half_end = _world_bodies.len/2;

View file

@ -2,6 +2,7 @@
#define _fencer_physics_world_h
#include "physics_entity.h"
#include "collision.h"
extern void physics_world_init();
extern void physics_world_clean();
@ -9,6 +10,8 @@ extern void physics_world_clean();
extern void physics_world_add_entity(PhysicsEntity entity);
extern void physics_world_remove_entity(PhysicsEntity entity);
extern PhysicsEntity physics_world_query(PhysicsQuery query);
extern void physics_world_tick();
#endif // !_fencer_physics_world_h