#ifndef WORLD_PHYSICS_H #define WORLD_PHYSICS_H /* * Simple game physics: * gravity, terrain contact, oriented-box collisions (separating axes) * per collider pair, walkable slopes, step-up for characters, * stepping over low things (slowing down for them), pushing by * weight/strength (walking only shoves light things aside), and friction. * Nothing comes to rest on people: it slides off them, and whatever hits * them adds to their knock (momentum), which may stagger or floor them. */ #include "world/object.h" #include "world/terrain.h" /* Something low and narrow enough to step over: its height (0 = not that). */ float Physics_lowObstacle(const Object *o); /* Solid enough to stand on and won't break (heavy or fixed, a flat top; not a bottle or a table). */ bool Physics_standsOn(const struct Object *o); /* How wide the top of o is to stand on, the narrow way (m; a log: about its diameter). */ float Physics_footing(const Object *o); /* Is o something low that who steps over (no collision with the body)? */ bool Physics_stepsOver(const Object *who, const Object *o); /* Do collider ia of a and collider ib of b overlap? */ bool Physics_overlap(const Object *a, int ia, const Object *b, int ib); /* How deep a and b are in each other (deepest collider pair; 0 = apart). */ float Physics_penetration(const Object *a, const Object *b); /* Advances one dynamic object and resolves its contacts. */ void Physics_step(Object *obj, Object *const *objects, int count, const Terrain *terrain, float dt); /* Where things are (the world's cell grid), so a step only looks at what's near; NULL: everything. */ struct Grid; void Physics_useGrid(struct Grid *grid); #endif /* WORLD_PHYSICS_H */