From 641d59527d842b5adc626a38677365cb9d943840 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 4 Jun 2012 15:12:49 -0700 Subject: Fixed RDGE render tree when PI changes causes node changes. --- js/lib/drawing/world.js | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'js') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 3c93b2b7..228c0d94 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -437,15 +437,15 @@ World.prototype.getGeomRoot = function() { World.prototype.updateObject = function (obj) { if (!this._useWebGL) return; - var prims = obj.getPrimitiveArray(); + var prims = obj.getPrimitiveArray(); var materialNodes = obj.getMaterialNodeArray(); - if (prims.length != materialNodes.length) - throw new Error("inconsistent material and primitive counts"); - var nPrims = prims.length; - var ctrTrNode; - if (nPrims > 0) + if (prims.length != materialNodes.length) + throw new Error("inconsistent material and primitive counts"); + var nPrims = prims.length; + var ctrTrNode; + if (nPrims > 0) { - ctrTrNode = obj.getTransformNode(); + ctrTrNode = obj.getTransformNode(); if (ctrTrNode == null) { ctrTrNode = RDGE.createTransformNode("objRootNode_" + this._nodeCounter++); this._rootNode.insertAsChild( ctrTrNode ); @@ -459,42 +459,42 @@ World.prototype.updateObject = function (obj) { ); ctrTrNode.meshes = []; - ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); - ctrTrNode.attachMaterial(materialNodes[0]); - } + ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); + ctrTrNode.attachMaterial(materialNodes[0]); + } + // delete all of the child nodes + var i; + var childTrNode; var children = ctrTrNode.children; - for (var i = 1; i < nPrims; i++) + for (i=0; i= i) { - childTrNode = children[i-1].transformNode; - - childTrNode.meshes.forEach( - function(thisMesh) - { - RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name); - } - ); - childTrNode.meshes = []; - } - else - { - childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); - ctrTrNode.insertAsChild(childTrNode); - } + childTrNode = children[i].transformNode; + childTrNode.meshes.forEach( + function(thisMesh) + { + RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name); + } + ); + childTrNode.meshes = []; + children[i] = null; + } + ctrTrNode.children = []; - // attach the instanced box goe - childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); - childTrNode.attachMaterial(materialNodes[i]); - } + for (var i = 1; i < nPrims; i++) + { + // get the next primitive + var prim = prims[i]; + childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); + ctrTrNode.insertAsChild(childTrNode); + + // attach the instanced box goe + childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); + childTrNode.attachMaterial(materialNodes[i]); + } - // send a notification that the tree has changed - this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); + // send a notification that the tree has changed + this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); }; World.prototype.addObject = function( obj ) -- cgit v1.2.3