Пример #1
0
void
BSPTree::BuildDrawOrder(const UniquePtr<BSPTreeNode>& aNode,
                        nsTArray<LayerPolygon>& aLayers) const
{
  const gfx::Point3D& normal = aNode->First().GetNormal();

  UniquePtr<BSPTreeNode> *front = &aNode->front;
  UniquePtr<BSPTreeNode> *back = &aNode->back;

  // Since the goal is to return the draw order from back to front, we reverse
  // the traversal order if the current polygon is facing towards the camera.
  const bool reverseOrder = normal.z > 0.0f;

  if (reverseOrder) {
    std::swap(front, back);
  }

  if (*front) {
    BuildDrawOrder(*front, aLayers);
  }

  for (LayerPolygon& layer : aNode->layers) {
    MOZ_ASSERT(layer.geometry);

    if (layer.geometry->GetPoints().Length() >= 3) {
      aLayers.AppendElement(Move(layer));
    }
  }

  if (*back) {
    BuildDrawOrder(*back, aLayers);
  }
}
Пример #2
0
void
BSPTree::BuildDrawOrder(const UniquePtr<BSPTreeNode>& aNode,
                        nsTArray<gfx::Polygon3D>& aPolygons) const
{
  const gfx::Point3D& normal = aNode->First().GetNormal();

  UniquePtr<BSPTreeNode> *front = &aNode->front;
  UniquePtr<BSPTreeNode> *back = &aNode->back;

  // Since the goal is to return the draw order from back to front, we reverse
  // the traversal order if the current polygon is facing towards the camera.
  const bool reverseOrder = normal.z > 0.0f;

  if (reverseOrder) {
    std::swap(front, back);
  }

  if (*front) {
    BuildDrawOrder(*front, aPolygons);
  }

  for (gfx::Polygon3D& polygon : aNode->polygons) {
    aPolygons.AppendElement(std::move(polygon));
  }

  if (*back) {
    BuildDrawOrder(*back, aPolygons);
  }
}