mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Flatten each upserted draped line's positions once in the Cesium draw port
patchLines flattened a draped line's positions twice per upsert, once to decide whether it could patch and once to apply it; it now flattens them once and uses the result for both.
This commit is contained in:
1 parent
10dcab837b
commit
c145c63b4f
1 file changed
+9
-4
@@ -1442,9 +1442,9 @@ export function createCesiumDraw({
|
|||||||
* the set's pending one (or drawn alone); one that moves is built anew
|
* the set's pending one (or drawn alone); one that moves is built anew
|
||||||
* at once, which needs Cesium's terrain heights loaded.
|
* at once, which needs Cesium's terrain heights loaded.
|
||||||
*/
|
*/
|
||||||
function drapedPatchable(record, was, item) {
|
function drapedPatchable(record, was, flat) {
|
||||||
if (was.ground?.isDestroyed() || was.batch?.isDestroyed()) return false;
|
if (was.ground?.isDestroyed() || was.batch?.isDestroyed()) return false;
|
||||||
if (!samePositions(flatPositions(item.positions), was.positions))
|
if (!samePositions(flat, was.positions))
|
||||||
return groundSyncs() && typeof record.host?.add === 'function';
|
return groundSyncs() && typeof record.host?.add === 'function';
|
||||||
if (was.solo) return true;
|
if (was.solo) return true;
|
||||||
return was.ground.ready || record.pending?.includes(was.ground);
|
return was.ground.ready || record.pending?.includes(was.ground);
|
||||||
@@ -1462,12 +1462,17 @@ export function createCesiumDraw({
|
|||||||
function patchLines(record, list) {
|
function patchLines(record, list) {
|
||||||
const parts = record.lineParts;
|
const parts = record.lineParts;
|
||||||
if (record.kind !== 'lines' || !parts) return false;
|
if (record.kind !== 'lines' || !parts) return false;
|
||||||
|
// Each draped line's positions, flattened once for both passes.
|
||||||
|
const flats = new Map();
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
const was = parts.get(item.id);
|
const was = parts.get(item.id);
|
||||||
if (!was || was.look !== lineLook(item)) return false;
|
if (!was || was.look !== lineLook(item)) return false;
|
||||||
if (was.deep !== undefined && record.deepLines?.isDestroyed())
|
if (was.deep !== undefined && record.deepLines?.isDestroyed())
|
||||||
return false;
|
return false;
|
||||||
if (was.clampTo && !drapedPatchable(record, was, item)) return false;
|
if (!was.clampTo) continue;
|
||||||
|
const flat = flatPositions(item.positions);
|
||||||
|
if (!drapedPatchable(record, was, flat)) return false;
|
||||||
|
flats.set(item.id, flat);
|
||||||
}
|
}
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
const was = parts.get(item.id);
|
const was = parts.get(item.id);
|
||||||
@@ -1499,7 +1504,7 @@ export function createCesiumDraw({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
was.id.meta = item.meta;
|
was.id.meta = item.meta;
|
||||||
const flat = flatPositions(item.positions);
|
const flat = flats.get(item.id);
|
||||||
if (!samePositions(flat, was.positions)) {
|
if (!samePositions(flat, was.positions)) {
|
||||||
moveDraped(record, was, item, flat);
|
moveDraped(record, was, item, flat);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in new issue
Block a user