// This is called if the selection changes, so that the local list of selected instances can be updated
void RadiantSelectionSystem::onSelectedChanged(scene::Instance& instance, const Selectable& selectable) {
	// Cache the selection state
	bool isSelected = selectable.isSelected();

	_countPrimitive += (isSelected) ? +1 : -1;
	_selectionChangedCallbacks(selectable); // legacy

	_selectionInfo.totalCount += (isSelected) ? +1 : -1;

	if (Instance_getBrush(instance) != NULL) {
		_selectionInfo.brushCount += (isSelected) ? +1 : -1;
	}
	else {
		_selectionInfo.entityCount += (isSelected) ? +1 : -1;
	}

	// If the selectable is selected, add it to the local selection list, otherwise remove it
	if (isSelected) {
		_selection.append(instance);
	}
	else {
		_selection.erase(instance);
	}

	// Notify observers, FALSE = primitive selection change
	notifyObservers(instance, false);

	// Check if the number of selected primitives in the list matches the value of the selection counter
	ASSERT_MESSAGE(_selection.size() == _countPrimitive, "selection-tracking error");

	// Schedule an idle callback
	requestIdleCallback();

	_requestWorkZoneRecalculation = true;
}
Example #2
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;
  }
Example #3
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_functor(*brush);
     }
   }
   return true;
 }
Example #4
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;
}
Example #5
0
	void visit(scene::Instance& instance) const {
		BrushInstance* brushInstance = Instance_getBrush(instance);
		if (brushInstance != NULL) {
			_vector.push_back(&brushInstance->getBrush());
		}
	}