polygon MOI
This commit is contained in:
parent
4510543aaf
commit
b6788e25b1
|
@ -365,7 +365,13 @@ struct phys2d_poly *Make2DPoly(int go)
|
|||
|
||||
float phys2d_poly_moi(struct phys2d_poly *poly, float m)
|
||||
{
|
||||
return cpMomentForPoly(m, arrlen(poly->points), poly->points, cpvzero, poly->radius);
|
||||
float moi = cpMomentForPoly(m, arrlen(poly->points), poly->points, cpvzero, poly->radius);
|
||||
if (moi <= 0) {
|
||||
YughError("Polygon MOI is negative. Returning one;");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return moi;
|
||||
}
|
||||
|
||||
void phys2d_polydel(struct phys2d_poly *poly)
|
||||
|
|
|
@ -117,6 +117,11 @@ void gameobject_apply(struct gameobject *go)
|
|||
cpBodyEachShape(go->body, go_shape_apply, go);
|
||||
if (go->bodytype == CP_BODY_TYPE_DYNAMIC)
|
||||
cpBodySetMass(go->body, go->mass);
|
||||
|
||||
if (cpBodyGetMoment(go->body) <= 0.f) {
|
||||
YughError("Moment for object %d is zero. Setting to one.", go2id(go));
|
||||
cpBodySetMoment(go->body, 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
static void gameobject_setpickcolor(struct gameobject *go)
|
||||
|
|
Loading…
Reference in a new issue