From f4bd6c2e6c49044780bea4d443f8a988c156b342 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Tue, 25 Aug 2015 16:03:40 +0200 Subject: [PATCH] safeguard stepquality --- dist/vis.js | 3 ++- lib/network/modules/PhysicsEngine.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/vis.js b/dist/vis.js index c2328643..96fa5ca0 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -33432,6 +33432,7 @@ return /******/ (function(modules) { // webpackBootstrap var nodeIds = Object.keys(this.previousStates); var nodes = this.body.nodes; var velocities = this.physicsBody.velocities; + this.referenceState = {}; for (var i = 0; i < nodeIds.length; i++) { var nodeId = nodeIds[i]; @@ -33465,7 +33466,7 @@ return /******/ (function(modules) { // webpackBootstrap var posThreshold = 0.3; for (var nodeId in this.referenceState) { - if (this.referenceState.hasOwnProperty(nodeId)) { + if (this.referenceState.hasOwnProperty(nodeId) && nodes[nodeId] !== undefined) { dx = nodes[nodeId].x - reference[nodeId].positions.x; dy = nodes[nodeId].y - reference[nodeId].positions.y; diff --git a/lib/network/modules/PhysicsEngine.js b/lib/network/modules/PhysicsEngine.js index 8b3e9184..c1a2c3fe 100644 --- a/lib/network/modules/PhysicsEngine.js +++ b/lib/network/modules/PhysicsEngine.js @@ -417,6 +417,7 @@ class PhysicsEngine { var nodeIds = Object.keys(this.previousStates); var nodes = this.body.nodes; var velocities = this.physicsBody.velocities; + this.referenceState = {}; for (let i = 0; i < nodeIds.length; i++) { let nodeId = nodeIds[i]; @@ -447,7 +448,7 @@ class PhysicsEngine { let posThreshold = 0.3; for (let nodeId in this.referenceState) { - if (this.referenceState.hasOwnProperty(nodeId)) { + if (this.referenceState.hasOwnProperty(nodeId) && nodes[nodeId] !== undefined) { dx = nodes[nodeId].x - reference[nodeId].positions.x; dy = nodes[nodeId].y - reference[nodeId].positions.y;