speedup shadow clipping with progressive shadow generation
This commit is contained in:
parent
e761079c78
commit
0eb42ef03a
1 changed files with 15 additions and 2 deletions
|
|
@ -946,13 +946,26 @@ class OpPocket extends CamOp {
|
|||
return slice;
|
||||
}
|
||||
let shadows = {};
|
||||
function genShadows(zs) {
|
||||
let lastShadow, lastZ;
|
||||
for (let z of zs) {
|
||||
if (shadows[z]) continue;
|
||||
let shadow = CAM.shadowAt(widget, z, lastZ);
|
||||
lastZ = z;
|
||||
if (lastShadow) {
|
||||
shadow = POLY.union([...shadow, ...lastShadow], undefined, true);
|
||||
}
|
||||
lastShadow = shadow;
|
||||
shadows[z] = shadow;
|
||||
}
|
||||
}
|
||||
function clearZ(polys, z, down) {
|
||||
let zs = down ? base.util.lerp(zTop, z, down) : [ z ];
|
||||
let nested = POLY.nest(polys);
|
||||
for (let poly of nested) {
|
||||
genShadows(zs);
|
||||
for (let z of zs) {
|
||||
let shadow = shadows[z] || CAM.shadowAt(widget, z);
|
||||
shadows[z] = shadow;
|
||||
let shadow = shadows[z];
|
||||
let clip = [];
|
||||
POLY.subtract([poly], shadow, clip);
|
||||
let slice = newSliceOut(z);
|
||||
|
|
|
|||
Loading…
Reference in a new issue