コード例 #1
0
ファイル: brushmanip.cpp プロジェクト: ChunHungLiu/GtkRadiant
  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;
  }
コード例 #2
0
ファイル: Texturable.cpp プロジェクト: chrisglass/ufoai
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;
}
コード例 #3
0
		// The visitor function
		bool pre (const scene::Path& path, scene::Instance& instance) const
		{
			// Check if the node is filtered
			if (path.top().get().visible()) {
				SelectionTestable* selectionTestable = Instance_getSelectionTestable(instance);

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

					if (occluded) {
						_instance = &instance;
					}
				}
			}

			return true;
		}