macro compression

This commit is contained in:
John Alanbrook 2024-03-20 14:32:35 -05:00
parent 7e6fc1ffbe
commit 23afa7b266
5 changed files with 240 additions and 447 deletions

View file

@ -477,7 +477,7 @@ component.edge2d = Object.copy(collider2d, {
}
if (this.hollow) {
var hpoints = inflate_cpv(spoints, spoints.length, this.hollowt);
var hpoints = vector.inflate(spoints, this.hollowt);
if (hpoints.length === spoints.length) return spoints;
var arr1 = hpoints.filter(function(x,i) { return i % 2 === 0; });
var arr2 = hpoints.filter(function(x,i) { return i % 2 !== 0; });

View file

@ -70,7 +70,7 @@ function use(file)
var c = io.slurp(file);
var script = `(function() { ${c} })();`;
use.files[file] = os.eval_env(file,global,script);
use.files[file] = os.eval_env(file,script,global);
return use.files[file];
}
@ -90,7 +90,7 @@ function eval_env(script, env, file)
file ??= "SCRIPT";
console.spam(`eval ${file}`);
script = `(function() { ${script}; }).call(this);\n`;
return os.eval_env(file,env,script);
return os.eval_env(file,script,env);
}
global.check_registers = function(obj)
@ -147,8 +147,7 @@ global.mixin("scripts/render.js");
global.mixin("scripts/debug.js");
var frame_t = profile.secs(profile.now());
var updateMS = 1/60;
var physMS = 1/60;
var phys_step = 1/60;
var sim = {
mode: "play",
@ -185,10 +184,10 @@ function process()
physlag += dt;
while (physlag > physMS) {
physlag -= physMS;
prosperon.phys2d_step(physMS*timescale);
prosperon.physupdate(physMS*timescale);
while (physlag > phys_step) {
physlag -= phys_step;
prosperon.phys2d_step(phys_step*timescale);
prosperon.physupdate(phys_step*timescale);
}
prosperon.window_render();

View file

@ -287,9 +287,8 @@ float phys2d_circle_moi(struct phys2d_circle *c) {
return cpMomentForCircle(m, 0, cpCircleShapeGetRadius(c->shape.shape), cpCircleShapeGetOffset(c->shape.shape));
}
void phys2d_circledel(struct phys2d_circle *c) {
phys2d_shape_del(&c->shape);
}
void phys2d_circledel(struct phys2d_circle *c) { phys2d_shape_del(&c->shape); }
void circle2d_free(circle2d *c) { phys2d_circledel(c); }
void phys2d_dbgdrawcpcirc(cpShape *c) {
HMM_Vec2 pos = mat_t_pos(t_go2world(shape2go(c)), (HMM_Vec2)cpCircleShapeGetOffset(c));

View file

@ -47,6 +47,8 @@ struct phys2d_circle {
struct phys2d_shape shape;
};
typedef struct phys2d_circle circle2d;
/* A convex polygon; defined as the convex hull around the given set of points */
struct phys2d_poly {
HMM_Vec2 *points;
@ -66,6 +68,7 @@ struct phys2d_edge {
struct phys2d_circle *Make2DCircle(gameobject *go);
void phys2d_circledel(struct phys2d_circle *c);
void circle2d_free(circle2d *c);
void phys2d_applycircle(struct phys2d_circle *circle);
void phys2d_dbgdrawcircle(struct phys2d_circle *circle);
float phys2d_circle_moi(struct phys2d_circle *c);

File diff suppressed because it is too large Load diff