From fc3208632636430fe08bcf4795ad964c6a96ea22 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 4 Aug 2015 13:33:06 -0400
Subject: [PATCH] fixed bounding box calc

---
 js/cells/DMACell.js       |  2 +-
 js/lattice/LatticeBase.js | 21 +++++++--------------
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js
index d0169cc0..1c5e78a6 100644
--- a/js/cells/DMACell.js
+++ b/js/cells/DMACell.js
@@ -102,7 +102,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
             return null;
         }
         if (!this.superCell) return this.getIndex();
-        return this.superCell.getAbsoluteIndex().add(this.superCell.applyRotation(this.getIndex()));
+        return this.superCell.getAbsoluteIndex().add(this.superCell.applyRotation(this.getIndex()).round());
     };
 
     DMACell.prototype.getPosition = function(){
diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js
index 88ce0c20..e045e8ba 100644
--- a/js/lattice/LatticeBase.js
+++ b/js/lattice/LatticeBase.js
@@ -204,20 +204,13 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             this._loopCells(this.sparseCells, function(cell, x, y, z){
                 if (cell){
                     var material = cell.getMaterial();
-                    if (material.dimensions){
-                        var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(material.dimensions.clone()).round());
-                        dimMax.max(subCellRange);
-                        dimMin.min(subCellRange);
-                    } else if (cell.length){//gik
-                        var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(new THREE.Vector3(cell.length, 0, 0)).round());
-                        var padding = cell.applyRotation(new THREE.Vector3(0,1,1)).round();
-                        _.each(padding, function(element, key){
-                            if (element == -1) padding[key] = 1;
-                        });
-                        subCellRange.add(padding);
-                        dimMax.max(subCellRange);
-                        dimMin.min(subCellRange);
-                    }
+                    var dimensions = material.dimensions;
+                    if (dimensions) dimensions.clone();
+                    else dimensions = new THREE.Vector3(cell.length, 1, 1);
+                    dimensions.sub(new THREE.Vector3(1,1,1));
+                    var subCellRange = (new THREE.Vector3(x, y, z)).add(cell.applyRotation(dimensions).round().add(new THREE.Vector3(1,1,1)));
+                    dimMax.max(subCellRange);
+                    dimMin.min(subCellRange);
                 }
             });
             return {max:dimMax, min:dimMin};
-- 
GitLab