void RadiantSelectionSystem::testSelectScene(SelectablesList& targetList, SelectionTest& test, const View& view, SelectionSystem::EMode mode, SelectionSystem::EComponentMode componentMode) { // The (temporary) storage pool SelectionPool selector; SelectionPool sel2; switch(mode) { case eEntity: { // Instantiate a walker class which is specialised for selecting entities EntitySelector entityTester(selector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, entityTester); for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i) { targetList.push_back(i->second); } } break; case ePrimitive: { // Do we have a camera view (filled rendering?) if (view.fill() || !GlobalXYWnd().higherEntitySelectionPriority()) { // Test for any visible elements (primitives, entities), but don't select child primitives AnySelector anyTester(selector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, anyTester); } else { // We have an orthoview, here, select entities first // First, obtain all the selectable entities EntitySelector entityTester(selector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, entityTester); // Now retrieve all the selectable primitives PrimitiveSelector primitiveTester(sel2, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, primitiveTester); } // Add the first selection crop to the target vector for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i) { targetList.push_back(i->second); } // Add the secondary crop to the vector (if it has any entries) for (SelectionPool::iterator i = sel2.begin(); i != sel2.end(); ++i) { // Check for duplicates SelectablesList::iterator j; for (j = targetList.begin(); j != targetList.end(); ++j) { if (*j == i->second) break; } // Insert if not yet in the list if (j == targetList.end()) { targetList.push_back(i->second); } } } break; case eGroupPart: { // Retrieve all the selectable primitives of group nodes GroupChildPrimitiveSelector primitiveTester(selector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, primitiveTester); // Add the selection crop to the target vector for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i) { targetList.push_back(i->second); } } break; case eComponent: { ComponentSelector selectionTester(selector, test, componentMode); foreachSelected(selectionTester); for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i) { targetList.push_back(i->second); } } break; } // switch }
void DragManipulator::testSelect(const render::View& view, const Matrix4& pivot2world) { SelectionPool selector; SelectionVolume test(view); if (GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive) { // Find all entities BooleanSelector entitySelector; EntitySelector selectionTester(entitySelector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, selectionTester); if (entitySelector.isSelected()) { // Found a selectable entity selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable); _selected = false; } else { // Find all primitives that are selectable BooleanSelector primitiveSelector; PrimitiveSelector primitiveTester(primitiveSelector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, primitiveTester); if (primitiveSelector.isSelected()) { // Found a selectable primitive selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable); _selected = false; } else { // Entities and worldspawn primitives failed, so check for group children too // Find all group child primitives that are selectable BooleanSelector childPrimitiveSelector; GroupChildPrimitiveSelector childPrimitiveTester(childPrimitiveSelector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, childPrimitiveTester); if (childPrimitiveSelector.isSelected()) { // Found a selectable group child primitive selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable); _selected = false; } else { // all direct hits failed, check for drag-selectable faces _selected = Scene_forEachPlaneSelectable_selectPlanes(selector, test); } } } } else if (GlobalSelectionSystem().Mode() == SelectionSystem::eGroupPart) { // Find all primitives that are selectable BooleanSelector booleanSelector; GroupChildPrimitiveSelector childPrimitiveTester(booleanSelector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, childPrimitiveTester); if (booleanSelector.isSelected()) { // Found a selectable primitive selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable); _selected = false; } else { // Check for selectable faces _selected = Scene_forEachPlaneSelectable_selectPlanes(selector, test); } } // Check for entities that can be selected else if (GlobalSelectionSystem().Mode() == SelectionSystem::eEntity) { // Create a boolean selection pool (can have exactly one selectable or none) BooleanSelector booleanSelector; // Find the visible entities EntitySelector selectionTester(booleanSelector, test); GlobalSceneGraph().foreachVisibleNodeInVolume(view, selectionTester); // Check, if an entity could be found if (booleanSelector.isSelected()) { selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable); _selected = false; } } else { BestSelector bestSelector; ComponentSelector selectionTester(bestSelector, test, GlobalSelectionSystem().ComponentMode()); GlobalSelectionSystem().foreachSelected(selectionTester); for (std::list<Selectable*>::iterator i = bestSelector.best().begin(); i != bestSelector.best().end(); ++i) { // greebo: Disabled this, it caused the currently selected patch vertices being deselected. if (registry::getValue<bool>(RKEY_TRANSIENT_COMPONENT_SELECTION)) { if (!(*i)->isSelected()) { GlobalSelectionSystem().setSelectedAllComponents(false); } } _selected = false; selector.addSelectable(SelectionIntersection(0, 0), (*i)); _dragSelectable.setSelected(true); } } for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i) { i->second->setSelected(true); } }