Пример #1
0
  void show(bool show)
  {
    if(show && !shown())
    {
      Pointfile_Parse(*this);
	    GenerateDisplayList();
      SceneChangeNotify();
    }
    else if(!show && shown())
    {
	    glDeleteLists (m_displaylist, 1);
	    m_displaylist = 0;
      SceneChangeNotify();
    }
  }
Пример #2
0
void mergeSelectedBrushes(const cmd::ArgumentList& args)
{
	// Get the current selection
	BrushPtrVector brushes = selection::algorithm::getSelectedBrushes();

	if (brushes.empty()) {
		rMessage() << _("CSG Merge: No brushes selected.") << std::endl;
		wxutil::Messagebox::ShowError(_("CSG Merge: No brushes selected."));
		return;
	}

	if (brushes.size() < 2) {
		rMessage() << "CSG Merge: At least two brushes have to be selected.\n";
		wxutil::Messagebox::ShowError("CSG Merge: At least two brushes have to be selected.");
		return;
	}

	rMessage() << "CSG Merge: Merging " << brushes.size() << " brushes." << std::endl;

	UndoableCommand undo("mergeSelectedBrushes");

	// Take the last selected node as reference for layers and parent
	scene::INodePtr merged = GlobalSelectionSystem().ultimateSelected();

	scene::INodePtr parent = merged->getParent();
	assert(parent != NULL);

	// Create a new BrushNode
	scene::INodePtr node = GlobalBrushCreator().createBrush();

	// Insert the newly created brush into the (same) parent entity
	parent->addChildNode(node);

	// Move the new brush to the same layers as the merged one
	node->assignToLayers(merged->getLayers());

	// Get the contained brush
	Brush* brush = Node_getBrush(node);

	// Attempt to merge the selected brushes into the new one
	if (!Brush_merge(*brush, brushes, true))
	{
		rWarning() << "CSG Merge: Failed - result would not be convex." << std::endl;
		return;
	}

	ASSERT_MESSAGE(!brush->empty(), "brush left with no faces after merge");

	// Remove the original brushes
	for (BrushPtrVector::iterator i = brushes.begin(); i != brushes.end(); ++i)
	{
		scene::removeNodeFromParent(*i);
	}

	// Select the new brush
	Node_setSelected(node, true);

	rMessage() << "CSG Merge: Succeeded." << std::endl;
	SceneChangeNotify();
}
Пример #3
0
	/**
	 * Performs selection operation on the global scenegraph.
	 * If delete_bounds_src is true, then the objects which were
	 * used as source for the selection aabbs will be deleted.
	 */
	static void DoSelection(bool deleteBoundsSrc = true) {
		if (GlobalSelectionSystem().Mode() != SelectionSystem::ePrimitive) {
			// Wrong selection mode
			return;
		}

		// we may not need all AABBs since not all selected objects have to be brushes
		const std::size_t max = GlobalSelectionSystem().countSelected();
		AABB* aabbs = new AABB[max];
            
		CollectSelectedBrushesBounds collector(aabbs, max);
		GlobalSelectionSystem().foreachSelected(collector);

		std::size_t count = collector.getCount();

		// nothing usable in selection
		if (!count) {
			delete[] aabbs;
			return;
		}
      
		// delete selected objects?
		if (deleteBoundsSrc) {
			UndoableCommand undo("deleteSelected");
			selection::algorithm::deleteSelection();
		}

		// Instantiate a "self" object SelectByBounds and use it as visitor
		SelectByBounds<TSelectionPolicy> walker(aabbs, count);
		Node_traverseSubgraph(GlobalSceneGraph().root(), walker);
		
		SceneChangeNotify();
		delete[] aabbs;
	}
Пример #4
0
void FaceInstance_pasteTexture(FaceInstance& faceInstance)
{
  faceInstance.getFace().SetTexdef(g_faceTextureClipboard.m_projection);
  faceInstance.getFace().SetShader(TextureBrowser_GetSelectedShader(g_TextureBrowser));
  faceInstance.getFace().SetFlags(g_faceTextureClipboard.m_flags);
  SceneChangeNotify();
}
void RadiantSelectionSystem::cancelMove() {

    // Unselect any currently selected manipulators to be sure
    _manipulator->setSelected(false);

    // Tell all the scene objects to revert their transformations
    RevertTransformForSelected walker;
    Node_traverseSubgraph(GlobalSceneGraph().root(), walker);

    _pivotMoving = false;
    pivotChanged();

    // greebo: Deselect all faces if we are in brush and drag mode
    if (Mode() == ePrimitive && ManipulatorMode() == eDrag)
    {
        SelectAllComponentWalker faceSelector(false, SelectionSystem::eFace);
        Node_traverseSubgraph(GlobalSceneGraph().root(), faceSelector);
    }

    if (_undoBegun) {
        // Cancel the undo operation, if one has been begun
        GlobalUndoSystem().cancel();
        _undoBegun = false;
    }

    // Update the views
    SceneChangeNotify();
}
Пример #6
0
void selectAllOfType(const cmd::ArgumentList& args) {
	if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent) {
		if (GlobalSelectionSystem().ComponentMode() == SelectionSystem::eFace) {
			// Deselect all faces
			GlobalSelectionSystem().setSelectedAllComponents(false);
			// Select all faces carrying the shader selected in the Texture Browser
			Scene_BrushSelectByShader_Component(GlobalSceneGraph(), GlobalTextureBrowser().getSelectedShader());
		}
	}
	else {
		// Find any classnames of selected entities
		EntityGetSelectedClassnamesWalker classnameFinder;
		GlobalSelectionSystem().foreachSelected(classnameFinder);

		// De-select everything
		GlobalSelectionSystem().setSelectedAll(false);

		if (!classnameFinder.getClassnameList().empty()) {
			// Instantiate a selector class
			EntitySelectByClassnameWalker classnameSelector(
				classnameFinder.getClassnameList()
			);

			// Traverse the scenegraph, select all matching the classname list
			Node_traverseSubgraph(GlobalSceneGraph().root(), classnameSelector);
		}
		else {
			Scene_BrushSelectByShader(GlobalSceneGraph(), GlobalTextureBrowser().getSelectedShader());
			Scene_PatchSelectByShader(GlobalSceneGraph(), GlobalTextureBrowser().getSelectedShader());
		}
	}

	SceneChangeNotify();
}
Пример #7
0
void Scene_applyClosestFaceTexture(SelectionTest& test)
{
  UndoableCommand command("facePaintTexture");

  Scene_BrushSetClosestFaceTexture(GlobalSceneGraph(), test, TextureBrowser_GetSelectedShader(g_TextureBrowser), g_faceTextureClipboard.m_projection, g_faceTextureClipboard.m_flags);

  SceneChangeNotify();
}
Пример #8
0
void deleteSelection() 
{
	// Traverse the scene, deleting all selected nodes
	DeleteSelectedVisitor walker;
	GlobalSelectionSystem().foreachSelected(walker);
    walker.performDeletion();
	
	SceneChangeNotify();
}
Пример #9
0
void hideDeselected(const cmd::ArgumentList& args) {
	HideDeselectedWalker walker(true);
	Node_traverseSubgraph(GlobalSceneGraph().root(), walker);

	// Hide all components, there might be faces selected
	GlobalSelectionSystem().setSelectedAllComponents(false);

	SceneChangeNotify();
}
Пример #10
0
void hideSelected(const cmd::ArgumentList& args) {
	// Traverse the selection, hiding all nodes
	GlobalSelectionSystem().foreachSelected(HideSelectedWalker(true));

	// Then de-select the hidden nodes
	GlobalSelectionSystem().setSelectedAll(false);

	SceneChangeNotify();
}
Пример #11
0
		void valueChanged (const std::string& value)
		{
			if (value.empty()) {
				setDefault();
			} else {
				m_shader.setName(value);
			}
			SceneChangeNotify();
		}
Пример #12
0
// greebo: This toggles the brush size info display in the ortho views
void ToggleShowSizeInfo ()
{
	if (GlobalRegistry().get("user/ui/showSizeInfo") == "1") {
		GlobalRegistry().set("user/ui/showSizeInfo", "0");
	} else {
		GlobalRegistry().set("user/ui/showSizeInfo", "1");
	}
	SceneChangeNotify();
}
Пример #13
0
void Map::rename(const std::string& filename) {
    if (_mapName != filename) {
        setMapName(filename);
        SceneChangeNotify();
    }
    else {
        m_resource->save();
        setModified(false);
    }
}
Пример #14
0
void constructBrushPrefabs(EBrushPrefab type, std::size_t sides, const std::string& shader)
{
	GlobalSelectionSystem().foreachBrush([&] (Brush& brush)
	{
		AABB bounds = brush.localAABB(); // copy bounds because the brush will be modified
		constructBrushPrefab(brush, type, bounds, sides, shader, TextureProjection());
	});

	SceneChangeNotify();
}
Пример #15
0
void FaceInstance::select_edge(std::size_t index, bool select) {
	if (select) {
		VertexSelection_insert(m_edgeSelection, getFace().getWinding()[index].adjacent);
	}
	else {
		VertexSelection_erase(m_edgeSelection, getFace().getWinding()[index].adjacent);
	}

	SceneChangeNotify();
	update_selection_edge();
}
Пример #16
0
void Map::createNew() {
    setMapName(_(MAP_UNNAMED_STRING));

    m_resource = GlobalMapResourceManager().capture(_mapName);
    m_resource->addObserver(*this);

    SceneChangeNotify();

    setModified(false);

    focusViews(Vector3(0,0,0), Vector3(0,0,0));
}
Пример #17
0
void FaceInstance::select_vertex (std::size_t index, bool select)
{
	const Winding& winding = m_face->getWinding();
	if (select) {
		VertexSelection_insert(m_vertexSelection, winding[index].adjacent);
	} else {
		VertexSelection_erase(m_vertexSelection, winding[index].adjacent);
	}

	SceneChangeNotify();
	update_selection_vertex();
}
Пример #18
0
void Scene_BrushResize_Selected(scene::Graph& graph, const AABB& bounds, const std::string& shader)
{
  if(GlobalSelectionSystem().countSelected() != 0)
  {
    const scene::INodePtr& node = GlobalSelectionSystem().ultimateSelected();

    Brush* brush = Node_getBrush(node);
    if(brush != 0)
    {
      Brush_ConstructCuboid(*brush, bounds, shader, TextureTransform_getDefault());
      SceneChangeNotify();
    }
  }
}
Пример #19
0
void makeRoomForSelectedBrushes(const cmd::ArgumentList& args) {
	UndoableCommand undo("brushMakeRoom");

	// Find all brushes
	BrushPtrVector brushes = selection::algorithm::getSelectedBrushes();

	// Cycle through the brushes and hollow them
	// We assume that all these selected brushes are visible as well.
	for (std::size_t i = 0; i < brushes.size(); ++i)
	{
		hollowBrush(brushes[i], true);
	}

	SceneChangeNotify();
}
Пример #20
0
void resizeBrushesToBounds(const AABB& aabb, const std::string& shader)
{
	if (GlobalSelectionSystem().getSelectionInfo().brushCount == 0)
	{
		gtkutil::MessageBox::ShowError(_("No brushes selected."), GlobalMainFrame().getTopLevelWindow());
		return;
	}

	GlobalSelectionSystem().foreachBrush([&] (Brush& brush)
	{ 
		brush.constructCuboid(aabb, shader, TextureProjection());
	});

	SceneChangeNotify();
}
Пример #21
0
void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::size_t sides, const std::string& shader)
{
  if(GlobalSelectionSystem().countSelected() != 0)
  {
    const scene::INodePtr& node = GlobalSelectionSystem().ultimateSelected();

    Brush* brush = Node_getBrush(node);
    if(brush != 0)
    {
      AABB bounds = brush->localAABB(); // copy bounds because the brush will be modified
      Brush_ConstructPrefab(*brush, type, bounds, sides, shader, TextureTransform_getDefault());
      SceneChangeNotify();
    }
  }
}
Пример #22
0
void hollowSelectedBrushes(const cmd::ArgumentList& args) {
	UndoableCommand undo("hollowSelectedBrushes");

	// Find all brushes
	BrushPtrVector brushes = selection::algorithm::getSelectedBrushes();

	// Cycle through the brushes and hollow them
	// We assume that all these selected brushes are visible as well.
	for (const BrushNodePtr& brush : brushes)
	{
		hollowBrush(brush, false);
	}

	SceneChangeNotify();
}
Пример #23
0
		void Path_parent (const scene::Path& parent, const scene::Path& child) const
		{
			ENodeType contains = node_get_contains(parent.top());
			ENodeType type = node_get_nodetype(child.top());

			if (contains != eNodeUnknown && contains == type) {
				NodeSmartReference node(child.top().get());
				Path_deleteTop(child);
				Node_getTraversable(parent.top())->insert(node);
				SceneChangeNotify();
			} else {
				globalErrorStream() << "failed - " << nodetype_get_name(type) << " cannot be parented to "
						<< nodetype_get_name(contains) << " container.\n";
			}
		}
Пример #24
0
void CPointfile::saxEndElement (message_info_t *ctx, const xmlChar *name)
{
  if(string_equal(reinterpret_cast<const char*>(name), "polyline"))
  {
    // we are done
    GenerateDisplayList();
    SceneChangeNotify();
  }
  else if(string_equal(reinterpret_cast<const char*>(name), "point"))
  {
    Vector3 v;  
    sscanf(m_characters.c_str(), "%f %f %f\n", &v[0], &v[1], &v[2]);
    PushPoint(v);
    m_characters.clear();
  }
}
Пример #25
0
void Scene_BrushResize_Selected(scene::Graph& graph, const AABB& bounds, const char* shader)
{
  if(GlobalSelectionSystem().countSelected() != 0)
  {
    const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();

    Brush* brush = Node_getBrush(path.top());
    if(brush != 0)
    {
      TextureProjection projection;
      TexDef_Construct_Default(projection);
      Brush_ConstructCuboid(*brush, bounds, shader, projection);
      SceneChangeNotify();
    }
  }
}
Пример #26
0
void GroupCycle::updateSelection() {
	_updateActive = true;

	// Do some sanity checking before we run into crashes
	if (_index >= 0 && _index < static_cast<int>(_list.size())) {
		for (std::size_t i = 0; i < _list.size(); i++) {
			Node_setSelected(_list[i], false);
		}

		Node_setSelected(_list[_index], true);
	}

	SceneChangeNotify();

	_updateActive = false;
}
// End the move, this freezes the current transforms
void RadiantSelectionSystem::endMove() {
    freezeTransforms();

    // greebo: Deselect all faces if we are in brush and drag mode
    if ((Mode() == ePrimitive || Mode() == eGroupPart) &&
        ManipulatorMode() == eDrag)
    {
        SelectAllComponentWalker faceSelector(false, SelectionSystem::eFace);
        Node_traverseSubgraph(GlobalSceneGraph().root(), faceSelector);
    }

    // Remove all degenerated brushes from the scene graph (should emit a warning)
    foreachSelected(RemoveDegenerateBrushWalker());

    _pivotMoving = false;
    pivotChanged();

    // Update the views
    SceneChangeNotify();

    // If we started an undoable operation, end it now and tell the console what happened
    if (_undoBegun)
    {
        std::ostringstream command;

        if (ManipulatorMode() == eTranslate) {
            command << "translateTool";
            outputTranslation(command);
        }
        else if (ManipulatorMode() == eRotate) {
            command << "rotateTool";
            outputRotation(command);
        }
        else if (ManipulatorMode() == eScale) {
            command << "scaleTool";
            outputScale(command);
        }
        else if (ManipulatorMode() == eDrag) {
            command << "dragTool";
        }

        _undoBegun = false;

        // Finish the undo move
        GlobalUndoSystem().finish(command.str());
    }
}
Пример #28
0
/**
 * greebo: Splits the selected brushes by the given plane.
 */
void splitBrushesByPlane(const Vector3 planePoints[3], EBrushSplit split)
{
	// Collect all selected brushes
	BrushPtrVector brushes = selection::algorithm::getSelectedBrushes();

	// Instantiate a scoped walker
	BrushByPlaneClipper splitter(
		planePoints[0],
		planePoints[1],
		planePoints[2],
		split
	);

	splitter.split(brushes);

	SceneChangeNotify();
}
Пример #29
0
void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::size_t sides, const char* shader)
{
  if(GlobalSelectionSystem().countSelected() != 0)
  {
    const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();

    Brush* brush = Node_getBrush(path.top());
    if(brush != 0)
    {
      AABB bounds = brush->localAABB();
      TextureProjection projection;
      TexDef_Construct_Default(projection);
      Brush_ConstructPrefab(*brush, type, bounds, sides, shader, projection);
      SceneChangeNotify();
    }
  }
}
Пример #30
0
virtual void activate() const {
	switch ( mIndex )
	{
	case 0: filter_level( CONTENTS_LEVEL1 ); break;
	case 1: filter_level( CONTENTS_LEVEL2 ); break;
	case 2: filter_level( CONTENTS_LEVEL3 ); break;
	case 3: filter_level( CONTENTS_LEVEL4 ); break;
	case 4: filter_level( CONTENTS_LEVEL5 ); break;
	case 5: filter_level( CONTENTS_LEVEL6 ); break;
	case 6: filter_level( CONTENTS_LEVEL7 ); break;
	case 7: filter_level( CONTENTS_LEVEL8 ); break;
	case 8: filter_stepon(); break;
	case 9: filter_actorclip(); break;
	case 10: filter_weaponclip(); break;
	case 11: filter_nodraw(); break;
	}
	SceneChangeNotify();
}