scale
This commit is contained in:
@@ -37,7 +37,6 @@ void set_cat_mask(int cat, unsigned int mask) { category_masks[cat] = mask; }
|
||||
|
||||
cpTransform m3_to_cpt(HMM_Mat3 m)
|
||||
{
|
||||
|
||||
cpTransform t;
|
||||
t.a = m.Columns[0].x;
|
||||
t.b = m.Columns[0].y;
|
||||
@@ -306,7 +305,8 @@ void phys2d_applypoly(struct phys2d_poly *poly) {
|
||||
assert(sizeof(poly->points[0]) == sizeof(cpVect));
|
||||
struct gameobject *go = poly->shape.go;
|
||||
// cpTransform T = m3_to_cpt(transform2d2mat(poly->t));
|
||||
cpPolyShapeSetVerts(poly->shape.shape, arrlen(poly->points), (cpVect*)poly->points, cpTransformIdentity);
|
||||
cpTransform T = m3_to_cpt(transform2d2mat(poly->shape.go->t));
|
||||
cpPolyShapeSetVerts(poly->shape.shape, arrlen(poly->points), (cpVect*)poly->points, T);
|
||||
cpPolyShapeSetRadius(poly->shape.shape, poly->radius);
|
||||
cpSpaceReindexShapesForBody(space, cpShapeGetBody(poly->shape.shape));
|
||||
}
|
||||
@@ -320,7 +320,7 @@ void phys2d_dbgdrawpoly(struct phys2d_poly *poly) {
|
||||
HMM_Vec2 points[n+1];
|
||||
HMM_Mat3 rt = t_go2world(shape2go(poly->shape.shape));
|
||||
for (int i = 0; i < n; i++)
|
||||
points[i] = mat_t_pos(rt, (HMM_Vec2)cpPolyShapeGetVert(poly->shape.shape, i));
|
||||
points[i] = (HMM_Vec2)cpPolyShapeGetVert(poly->shape.shape, i);
|
||||
|
||||
points[n] = points[0];
|
||||
|
||||
|
||||
@@ -129,17 +129,17 @@ static void velocityFn(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt
|
||||
return;
|
||||
}
|
||||
|
||||
cpFloat d = isnan(go->damping) ? damping : d;
|
||||
cpFloat d = isfinite(go->damping) ? go->damping : damping;
|
||||
cpVect g = gravity;
|
||||
if (isfinite(go->gravity.x) && isfinite(go->gravity.y))
|
||||
g = go->gravity.cp;
|
||||
|
||||
cpBodyUpdateVelocity(body,g,d,dt*go->timescale);
|
||||
|
||||
if (!isinf(go->maxvelocity))
|
||||
if (isfinite(go->maxvelocity))
|
||||
cpBodySetVelocity(body, cpvclamp(cpBodyGetVelocity(body), go->maxvelocity));
|
||||
|
||||
if (!isinf(go->maxangularvelocity)) {
|
||||
if (isfinite(go->maxangularvelocity)) {
|
||||
float av = cpBodyGetAngularVelocity(body);
|
||||
if (fabs(av) > go->maxangularvelocity)
|
||||
cpBodySetAngularVelocity(body, copysignf(go->maxangularvelocity, av));
|
||||
|
||||
@@ -1354,6 +1354,18 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
||||
case 214:
|
||||
ret = int2js(go_count());
|
||||
break;
|
||||
case 215:
|
||||
ret = vec2js(js2sprite(argv[1])->t.scale);
|
||||
break;
|
||||
case 216:
|
||||
js2sprite(argv[1])->t.scale = js2vec2(argv[2]);
|
||||
break;
|
||||
case 217:
|
||||
ret = num2js(js2sprite(argv[1])->t.angle);
|
||||
break;
|
||||
case 218:
|
||||
js2sprite(argv[1])->t.angle = js2number(argv[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (str)
|
||||
|
||||
Reference in New Issue
Block a user