fix stock box lines (failing from over-aggressive memory management)

This commit is contained in:
Stewart Allen 2020-11-29 00:16:37 -05:00
commit 2ba8741956
2 changed files with 11 additions and 4 deletions

View file

@ -10,10 +10,10 @@
emissive = 0x101010, emissive = 0x101010,
metalness = 0, metalness = 0,
roughness = 0.3, roughness = 0.3,
newMat = createPhongMaterial, newMat = createPhongMaterial;
freeMem = true;
let stacks = {}, let stacks = {},
freeMem = true,
tallest = 0, tallest = 0,
min = 0, min = 0,
max = 0, max = 0,
@ -26,6 +26,11 @@
UI = API.ui; UI = API.ui;
} }
function setFreeMem(bool) {
freeMem = bool;
return this;
}
function clear() { function clear() {
if (!API) { if (!API) {
init(); init();
@ -278,7 +283,8 @@
remove, remove,
getStack, getStack,
getRange, getRange,
setRange setRange,
setFreeMem
}; };
})(); })();

View file

@ -398,7 +398,7 @@
const {x, y, z} = stock; const {x, y, z} = stock;
if (x && y && z && !STACKS.getStack('bounds')) { if (x && y && z && !STACKS.getStack('bounds')) {
const render = new KIRI.Render().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa }); const render = new KIRI.Render().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa });
const stack = STACKS.create('bounds', SPACE.platform.world); const stack = STACKS.setFreeMem(false).create('bounds', SPACE.platform.world);
stack.add(render.addPolys([ stack.add(render.addPolys([
newPolygon().centerRectangle({x:csox, y:csoy, z:0}, x, y), newPolygon().centerRectangle({x:csox, y:csoy, z:0}, x, y),
newPolygon().centerRectangle({x:csox, y:csoy, z}, x, y) newPolygon().centerRectangle({x:csox, y:csoy, z}, x, y)
@ -411,6 +411,7 @@
newPoint(csox - hx, csoy - hy, 0), newPoint(csox - hx, csoy - hy, sz), newPoint(csox - hx, csoy - hy, 0), newPoint(csox - hx, csoy - hy, sz),
newPoint(csox - hx, csoy + hy, 0), newPoint(csox - hx, csoy + hy, sz), newPoint(csox - hx, csoy + hy, 0), newPoint(csox - hx, csoy + hy, sz),
], { thin: true })); ], { thin: true }));
STACKS.setFreeMem(true);
} }
API.platform.update_top_z(delta); API.platform.update_top_z(delta);