Пример #1
0
SelectionOperation* SelectionPlugin::createDeselection()
{
	// If there is a current selection, and the user pressed the mouse,
	// then we need to unselect everything that is currently selected.

	SelectionOperation* selection = CreateSelectionOperation("Deselection");
	selection->setPreviousSelections( selections->getSelections() );

	return selection;
}
Пример #2
0
SelectionOperation* CreateEntitySelectionOperation(const EntityPtr& entity)
{
	SelectionManager* selections = GetPlugin<SelectionPlugin>()->getSelectionManager();
	if( !selections ) return nullptr;

	SelectionOperation* selection = CreateSelectionOperation("Entity selection");
	selection->selections.addEntity(entity);
	selection->setPreviousSelections( selections->getSelections() );

	return selection;
}
Пример #3
0
SelectionOperation* SelectionPlugin::processDragSelection(const MouseButtonEvent& event)
{
	SceneDocument* sceneDocument = (SceneDocument*) editor->getDocument();
	Scene* scene = sceneDocument->scene.get();
	
	RenderView* view = sceneDocument->sceneWindow->getView();
	Camera* camera = sceneDocument->sceneWindow->getCamera().get();

	Overlay* overlay = selections->dragRectangle->getComponent<Overlay>().get();
	const Vector3& pos = overlay->getOffset();
	const Vector3& size = overlay->getSize();

	Frustum pickVolume = camera->getVolume(pos.x, pos.x+size.x, pos.y, pos.y+size.y);

	RayQueryList list;
	scene->doRayVolumeQuery(pickVolume, list);

	sceneDocument->editorScene->entities.remove(selections->dragRectangle);
	selections->dragRectangle.reset();

	if( list.empty() )
	{
		SelectionOperation* selection = createDeselection();
		return selection;
	}

#if 0
	// If we are in additive mode, don't create a new selection.
	if( selected && additiveMode )
		selection = selected;
#endif

	// If there is no current selection, create a new one.
	SelectionOperation* selection = CreateSelectionOperation("Drag Selection");
	selection->setPreviousSelections( selections->getSelections() );

	SelectionCollection& selections = selection->selections;

	for( size_t i = 0; i < list.size(); i++ )
	{
		// Add the picked selection to the selection collection.
		selections.addEntity( list[i].entity );
	}

#if 0
	if( selected && !additiveMode )
		selection->previous = selected->selections;
#endif

	return selection;
}
Пример #4
0
SelectionOperation* SelectionPlugin::processSelection(const MouseButtonEvent& event)
{
	SelectionOperation* selection = nullptr;

	EntityPtr entity;
	
	if( !getPickEntity(event.x, event.y, entity) )
	{
		selection = createDeselection();
		return selection;
	}
	
	selection = CreateSelectionOperation("Selection");
	selection->selections.addEntity(entity);
	selection->setPreviousSelections( selections->getSelections() );

	return selection;
}