From 530ae2985bc2e60b18153831254beb6d6cb4fcf0 Mon Sep 17 00:00:00 2001 From: Cort Date: Thu, 24 Aug 2023 09:29:32 +0800 Subject: [PATCH] Improve performance for multiple nested compounds --- public/arena.html | 2 +- public/builder.html | 2 +- public/index.html | 2 +- public/js/worlds/World_Base.js | 10 ++++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/public/arena.html b/public/arena.html index 5360f19..f78c87f 100644 --- a/public/arena.html +++ b/public/arena.html @@ -96,7 +96,7 @@ - + diff --git a/public/builder.html b/public/builder.html index 2e6d5be..4e696b1 100644 --- a/public/builder.html +++ b/public/builder.html @@ -86,7 +86,7 @@ - + diff --git a/public/index.html b/public/index.html index 6cabfde..e634ac4 100755 --- a/public/index.html +++ b/public/index.html @@ -187,7 +187,7 @@ - + diff --git a/public/js/worlds/World_Base.js b/public/js/worlds/World_Base.js index e9fc8ec..c72925f 100644 --- a/public/js/worlds/World_Base.js +++ b/public/js/worlds/World_Base.js @@ -503,7 +503,13 @@ var World_Base = function() { } // Compute all world matrices in order - self.computeAllWorldMatrices(scene.meshes); + let parentlessMeshes = []; + for (let mesh of scene.meshes) { + if (mesh.parent == null) { + parentlessMeshes.push(mesh); + } + } + self.computeAllWorldMatrices(parentlessMeshes); // Remove designated parents, keeping transform self.removeParents(self.parentsToRemove); @@ -532,7 +538,7 @@ var World_Base = function() { this.computeAllWorldMatrices = function(meshes) { for (let mesh of meshes) { mesh.computeWorldMatrix(true); - let childMeshes = mesh.getChildMeshes(); + let childMeshes = mesh.getChildren(); if (childMeshes.length > 0) { self.computeAllWorldMatrices(childMeshes); }