Desig Space Performance Improvement by calculating node proximity only when needed.

This commit is contained in:
Luis Fernando Molina committed 2021-02-25 11:20:53 +01:00
1 parent 463ac96bcb
commit d5ce013d23
2 files changed
+15 -1

No files matched your search

@@ -20,6 +20,7 @@ function newFloatingLayer() {
let thisObject = {
isProximityPhysicsNeeded: false,
addFloatingObject: addFloatingObject,
removeFloatingObject: removeFloatingObject,
getFloatingObject: getFloatingObject,
@@ -283,12 +284,21 @@ function newFloatingLayer() {
*/
try {
thisObject.isProximityPhysicsNeeded = false // this might be turned on bu the visiblePhysics downstream if needed.
makeVisible()
makeInvisible()
visiblePhysics()
enginePhysics()
proximityPhysics()
if (thisObject.isProximityPhysicsNeeded === true) {
/*
This is an expensive calculation, so we are going to do it only when we need to.
*/
proximityPhysics()
}
function visiblePhysics() {
for (let i = 0; i < visibleFloatingObjects.length; i++) {
let floatingObject = visibleFloatingObjects[i]
@@ -444,6 +444,8 @@ function newUiObject() {
if (rightDragging !== true) { return }
if (thisObject.payload.chainParent !== undefined) { return }
UI.projects.superalgos.spaces.floatingSpace.floatingLayer.isProximityPhysicsNeeded = true
let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects
let compatibleTypes
@@ -586,6 +588,8 @@ function newUiObject() {
if (rightDragging !== true) { return }
if (thisObject.payload.referenceParent !== undefined) { return }
UI.projects.superalgos.spaces.floatingSpace.floatingLayer.isProximityPhysicsNeeded = true
let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects
let compatibleTypes