From 22cbc9644b79df60b3f6336f9563debd47fb3ea1 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 28 Jun 2012 11:44:15 -0700 Subject: Added capability to split a mesh into multiiple parts to avoid buffer overflow situations. --- js/lib/drawing/world.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'js/lib/drawing') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 8068284e..39f97134 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -442,6 +442,7 @@ World.prototype.updateObject = function (obj) { if (prims.length != materialNodes.length) throw new Error("inconsistent material and primitive counts"); var nPrims = prims.length; + var iPrim = 0; var ctrTrNode; if (nPrims > 0) { @@ -459,8 +460,12 @@ World.prototype.updateObject = function (obj) { ); ctrTrNode.meshes = []; - ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); ctrTrNode.attachMaterial(materialNodes[0]); + while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0])) + { + ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); + iPrim++; + } } // delete all of the child nodes @@ -481,16 +486,18 @@ World.prototype.updateObject = function (obj) { } ctrTrNode.children = []; - for (var i = 1; i < nPrims; i++) + while (iPrim < nPrims) { - // get the next primitive childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); ctrTrNode.insertAsChild(childTrNode); + var matNode = materialNodes[iPrim]; + childTrNode.attachMaterial(matNode); - // attach the instanced box goe - var prim = prims[i]; - childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); - childTrNode.attachMaterial(materialNodes[i]); + while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode)) + { + childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); + iPrim++; + } } // send a notification that the tree has changed -- cgit v1.2.3