depreciate filled

This commit is contained in:
TreetopFlyer 2021-07-05 21:36:52 -04:00
parent 32c436f40a
commit 6225a1af13
2 changed files with 15 additions and 16 deletions

View File

@ -25,7 +25,7 @@ import { Region, Kernel } from "./region.js";
let r = Region.Create(); let r = Region.Create();
let filler = (x, y, z)=> let filler = (x, y, z)=>
{ {
r.filled.push(Region.I(x, y, z)); r.voxels[Region.I(x, y, z)] = true;
}; };
filler(1, 1, 1); filler(1, 1, 1);
Kernel.Loop(Kernel.Corners, [1, 1, 1], filler); Kernel.Loop(Kernel.Corners, [1, 1, 1], filler);

View File

@ -36,7 +36,7 @@ export const Region =
{ {
Create() Create()
{ {
return {filled:[]}; return {voxels:[]};
}, },
I(inX, inY, inZ) I(inX, inY, inZ)
{ {
@ -53,23 +53,22 @@ export const Region =
Surface(inRegion) Surface(inRegion)
{ {
let surface = []; let surface = [];
inRegion.filled.forEach(inIndex => inRegion.voxels.forEach((inValue, inIndex) =>
{
if(inValue)
{ {
let coords = Region.XYZ(inIndex); let coords = Region.XYZ(inIndex);
Kernel.Loop(Kernel.Corners, coords, (inX, inY, inZ)=> Kernel.Loop(Kernel.Corners, coords, (inX, inY, inZ)=>
{ {
let index = Region.I(inX, inY, inZ); let kernel = Region.I(inX, inY, inZ);
if(inRegion.filled[index] === undefined) if(!inRegion.voxels[kernel])
{ {
console.log(inX, inY, inZ, "surface"); console.log(coords, "surface");
surface.push(inIndex); surface.push(inIndex);
return true; return true;
} }
else
{
console.log(inX, inY, inZ, "filled");
}
}); });
}
}); });
return surface; return surface;
} }