Code: Select all
// Convert body local to world coordinates
static inline cpVect
cpBodyLocal2World(cpBody *body, cpVect v)
{
return cpvadd(body->p, cpvrotate(v, body->rot));
}
// Convert world to body local coordinates
static inline cpVect
cpBodyWorld2Local(cpBody *body, cpVect v)
{
return cpvunrotate(cpvsub(v, body->p), body->rot);
}
Code: Select all
// Returns the minimum distance of the polygon to the axis.
static inline cpFloat
cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d)
{
cpVect *verts = poly->tVerts;
cpFloat min = cpvdot(n, verts[0]);
int i;
for(i=1; i<poly->numVerts; i++)
min = cpfmin(min, cpvdot(n, verts[i]));
return min - d;
}
// Returns true if the polygon contains the vertex.
static inline int
cpPolyShapeContainsVert(cpPolyShape *poly, cpVect v)
{
cpPolyShapeAxis *axes = poly->tAxes;
int i;
for(i=0; i<poly->numVerts; i++){
cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d;
if(dist > 0.0f) return 0;
}
return 1;
}
Or maybe this is by design to discourage pointers?
Just thought I'd bring this up since i run into it pretty often