Refactor CalculateDotProduct draft
authorMiko Mynttinen <mikokm@gmail.com>
Mon, 08 Aug 2016 13:06:46 -0700
changeset 398887 747bb960a7b9c175d04086332893dcda77102a67
parent 398886 0bc26cdc42c30be87e6c66d9a4e6414524625089
child 398888 78469d5aacb0ae9204cea56f43ed0027ce2d5325
push id25668
push userbmo:mikokm@gmail.com
push dateTue, 09 Aug 2016 23:22:28 +0000
milestone51.0a1
Refactor CalculateDotProduct MozReview-Commit-ID: D6ELJUM4JFd
gfx/layers/BSPTree.cpp
--- a/gfx/layers/BSPTree.cpp
+++ b/gfx/layers/BSPTree.cpp
@@ -58,27 +58,28 @@ BSPTree::CalculateDotProduct(const gfx::
   const float epsilon = 0.05f;
 
   const gfx::Point3D& normal = aFirst.GetNormal();
   const gfx::Point3D& planePoint = aFirst[0];
 
   nsTArray<float> dotProducts;
 
   for (const gfx::Point3D& point : aSecond.GetPoints()) {
-    const float dot = (point - planePoint).DotProduct(normal);
-    dotProducts.AppendElement(dot);
+    float dot = (point - planePoint).DotProduct(normal);
 
     if (dot > epsilon) {
       aPos++;
     } else if (dot < -epsilon) {
       aNeg++;
     } else {
       // The point is within the thick plane.
-      dotProducts[dotProducts.Length() - 1] = 0.0f;
+      dot = 0.0f;
     }
+
+    dotProducts.AppendElement(dot);
   }
 
   return dotProducts;
 }
 
 void
 BSPTree::BuildTree(UniquePtr<BSPTreeNode>& aRoot,
                    std::deque<gfx::Polygon3D>& aPolygons)