diff options
author | hwc487 | 2012-06-28 11:44:15 -0700 |
---|---|---|
committer | hwc487 | 2012-06-28 11:44:15 -0700 |
commit | 22cbc9644b79df60b3f6336f9563debd47fb3ea1 (patch) | |
tree | f32687a920a039e0f048fab74627e0dc4ad6a8f1 /js/lib/drawing | |
parent | 2ebf3e3ea24d0d580575dfa13d31588dac1de445 (diff) | |
download | ninja-22cbc9644b79df60b3f6336f9563debd47fb3ea1.tar.gz |
Added capability to split a mesh into multiiple parts to avoid buffer overflow situations.
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-x | js/lib/drawing/world.js | 21 |
1 files changed, 14 insertions, 7 deletions
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) { | |||
442 | if (prims.length != materialNodes.length) | 442 | if (prims.length != materialNodes.length) |
443 | throw new Error("inconsistent material and primitive counts"); | 443 | throw new Error("inconsistent material and primitive counts"); |
444 | var nPrims = prims.length; | 444 | var nPrims = prims.length; |
445 | var iPrim = 0; | ||
445 | var ctrTrNode; | 446 | var ctrTrNode; |
446 | if (nPrims > 0) | 447 | if (nPrims > 0) |
447 | { | 448 | { |
@@ -459,8 +460,12 @@ World.prototype.updateObject = function (obj) { | |||
459 | ); | 460 | ); |
460 | ctrTrNode.meshes = []; | 461 | ctrTrNode.meshes = []; |
461 | 462 | ||
462 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); | ||
463 | ctrTrNode.attachMaterial(materialNodes[0]); | 463 | ctrTrNode.attachMaterial(materialNodes[0]); |
464 | while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0])) | ||
465 | { | ||
466 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); | ||
467 | iPrim++; | ||
468 | } | ||
464 | } | 469 | } |
465 | 470 | ||
466 | // delete all of the child nodes | 471 | // delete all of the child nodes |
@@ -481,16 +486,18 @@ World.prototype.updateObject = function (obj) { | |||
481 | } | 486 | } |
482 | ctrTrNode.children = []; | 487 | ctrTrNode.children = []; |
483 | 488 | ||
484 | for (var i = 1; i < nPrims; i++) | 489 | while (iPrim < nPrims) |
485 | { | 490 | { |
486 | // get the next primitive | ||
487 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); | 491 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); |
488 | ctrTrNode.insertAsChild(childTrNode); | 492 | ctrTrNode.insertAsChild(childTrNode); |
493 | var matNode = materialNodes[iPrim]; | ||
494 | childTrNode.attachMaterial(matNode); | ||
489 | 495 | ||
490 | // attach the instanced box goe | 496 | while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode)) |
491 | var prim = prims[i]; | 497 | { |
492 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); | 498 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); |
493 | childTrNode.attachMaterial(materialNodes[i]); | 499 | iPrim++; |
500 | } | ||
494 | } | 501 | } |
495 | 502 | ||
496 | // send a notification that the tree has changed | 503 | // send a notification that the tree has changed |