Phases correctly detached

This commit is contained in:
Luis Fernando Molina committed 2019-05-22 11:22:16 +02:00
1 parent 8cd8c75752
commit 3c46d3ec91
2 files changed
+26 -11

No files matched your search

+11 -11
View File
@@ -142,21 +142,22 @@ function newStrategyPart () {
function detachingPhysics () {
if (thisObject.isOnFocus !== true) { return }
if (thisObject.payload.chainParent === undefined) { return }
if (thisObject.payload.parentNode === undefined) { return }
let THRESHOLD = 1.15
if (thisObject.payload.chainParent !== undefined) {
let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2))
if (previousDistance !== undefined) {
if (distanceToChainParent / previousDistance > THRESHOLD) {
canvas.strategySpace.workspace.detachNode(thisObject.payload.node)
} else {
if (distanceToChainParent / previousDistance > 1) {
console.log(distanceToChainParent / previousDistance)
}
let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2))
if (previousDistance !== undefined) {
if (distanceToChainParent / previousDistance > THRESHOLD) {
canvas.strategySpace.workspace.detachNode(thisObject.payload.node)
} else {
if (distanceToChainParent / previousDistance > 1) {
console.log(distanceToChainParent / previousDistance)
}
}
previousDistance = distanceToChainParent
}
previousDistance = distanceToChainParent
}
function highlightPhisycs () {
@@ -464,4 +465,3 @@ function newStrategyPart () {
}
}
}
+15
View File
@@ -93,6 +93,21 @@ function newWorkspace () {
}
}
break
case 'Phase': {
let payload = node.payload
for (let i = 0; i < payload.parentNode.phases.length; i++) {
let phase = payload.parentNode.phases[i]
if (phase.id === node.id) {
for (let j = i + 1; j < payload.parentNode.phases.length; j++) {
let phaseNode = payload.parentNode.phases[j]
phaseNode.payload.parentNode = undefined
}
payload.parentNode.phases.splice(i, payload.parentNode.phases.length)
}
}
}
break
default:
}