System info & network
This commit is contained in:
28
code/physics/body.cpp
Normal file
28
code/physics/body.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "body.h"
|
||||
#include "../lib/geometry.h"
|
||||
#include <assert.h>
|
||||
|
||||
Box phy_aabb_from_body(phy_body *body)
|
||||
{
|
||||
Box aabb;
|
||||
switch(body->shape)
|
||||
{
|
||||
case PHY_SHAPE_SPHERE: {
|
||||
aabb.min = body->position - body->sphere.radius * v3{1,1,1};
|
||||
aabb.max = body->position + body->sphere.radius * v3{1,1,1};
|
||||
} break;
|
||||
case PHY_SHAPE_BOX: {
|
||||
v3 box[8]; build_cube_vertices(box);
|
||||
m3 rotoscale = M3(rotation_v3(body->rotation) * scale_v3(body->box.dimensions));
|
||||
for(u32 i = 0; i < 8; i++)
|
||||
box[i] = body->position + rotoscale * box[i];
|
||||
|
||||
aabb = box_from_point_cloud(box, 8);
|
||||
} break;
|
||||
case PHY_SHAPE_MESH: {
|
||||
assert(false && "Yet to be implemented");
|
||||
} break;
|
||||
default: { assert(false && "Unknown shape"); }
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
Reference in New Issue
Block a user