Exemplo n.º 1
0
  bool pre(const scene::Path& path, scene::Instance& instance) const
  {
    if(path.top().get().visible())
    {
      BrushInstance* brush = Instance_getBrush(instance);
      if(brush != 0)
      {
        m_test.BeginMesh(brush->localToWorld());

        for(Brush::const_iterator i = brush->getBrush().begin(); i != brush->getBrush().end(); ++i)
        {
          Face_getClosest(*(*i), m_test, m_bestIntersection, m_closestFace);
        }
      }
      else
      {
        SelectionTestable* selectionTestable = Instance_getSelectionTestable(instance);
        if(selectionTestable)
        {
          bool occluded;
          OccludeSelector selector(m_bestIntersection, occluded);
          selectionTestable->testSelect(selector, m_test);
          if(occluded)
          {
            m_closestFace = 0;
          }
        }
      }
    }
    return true;
  }
Exemplo n.º 2
0
bool ClosestTexturableFinder::pre (const scene::Path& path, scene::Instance& instance) const
{
	// Check if the node is filtered
	if (path.top().get().visible()) {
		// Test the instance for a brush
		BrushInstance* brush = Instance_getBrush(instance);

		if (brush != NULL) {
			// Construct the selectiontest
			_selectionTest.BeginMesh(brush->localToWorld());

			// Cycle through all the faces
			for (Brush::const_iterator i = brush->getBrush().begin(); i != brush->getBrush().end(); i++) {
				// Test the face for selection
				SelectionIntersection intersection;
				(*i)->testSelect(_selectionTest, intersection);

				// Any intersection found / is it better than the previous one?
				if (intersection.valid() && SelectionIntersection_closer(intersection, _bestIntersection)) {
					// Yes, store this as new best intersection
					_bestIntersection = intersection;

					// Save the face and the parent brush
					_texturable.face = (*i);
					_texturable.brush = &brush->getBrush();
				}
			}
		} else {
			// No brush, test for a patch
			SelectionTestable* selectionTestable = Instance_getSelectionTestable(instance);

			if (selectionTestable != NULL) {
				bool occluded;
				OccludeSelector selector(_bestIntersection, occluded);
				selectionTestable->testSelect(selector, _selectionTest);

				if (occluded) {
					_texturable = Texturable();
				}
			}
		}
	}

	return true;
}
Exemplo n.º 3
0
	void visit(scene::Instance& instance) const {
		BrushInstance* brushInstance = Instance_getBrush(instance);
		if (brushInstance != NULL) {
			_vector.push_back(&brushInstance->getBrush());
		}
	}
Exemplo n.º 4
0
 void operator()(BrushInstance& brush) const
 {
   brush.forEachFaceInstance(m_visitor);
 }