62 lines
678 B
C
62 lines
678 B
C
|
|
#ifndef _PIUMA_PHYSICS_OBJECT_H_
|
||
|
|
#define _PIUMA_PHYSICS_OBJECT_H_
|
||
|
|
|
||
|
|
#include "../lib/math.h"
|
||
|
|
#include "../lib/geometry.h"
|
||
|
|
|
||
|
|
enum phy_shape_type
|
||
|
|
{
|
||
|
|
PHY_SHAPE_SPHERE,
|
||
|
|
PHY_SHAPE_BOX,
|
||
|
|
PHY_SHAPE_MESH,
|
||
|
|
|
||
|
|
PHY_SHAPE_COUNT
|
||
|
|
};
|
||
|
|
|
||
|
|
struct phy_sphere
|
||
|
|
{
|
||
|
|
f32 radius;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct phy_box
|
||
|
|
{
|
||
|
|
v3 dimensions;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct phy_mesh
|
||
|
|
{
|
||
|
|
// TODO
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
struct phy_body
|
||
|
|
{
|
||
|
|
v3 position;
|
||
|
|
v3 rotation;
|
||
|
|
|
||
|
|
f32 mass;
|
||
|
|
v3 center_of_mass;
|
||
|
|
f32 gravity_multiplier;
|
||
|
|
f32 friction;
|
||
|
|
f32 bounciness;
|
||
|
|
|
||
|
|
// Dynamics
|
||
|
|
v3 velocity;
|
||
|
|
v3 angular_velocity;
|
||
|
|
|
||
|
|
// Collision
|
||
|
|
phy_shape_type shape;
|
||
|
|
union
|
||
|
|
{
|
||
|
|
phy_sphere sphere;
|
||
|
|
phy_box box;
|
||
|
|
phy_mesh mesh;
|
||
|
|
};
|
||
|
|
Box aabb;
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
Box phy_aabb_from_body(phy_body *body);
|
||
|
|
|
||
|
|
#endif
|