diff --git a/editor.conf.example b/editor.conf.example index 01c5949..b5fbf19 100644 --- a/editor.conf.example +++ b/editor.conf.example @@ -22,6 +22,10 @@ viewport_bottom_right = right # 2: Normal lighting (like in Minetest) lighting = 2 +# If true, nodes that are not selected will be hidden +# when not in the node tool +hide_other_nodes = true + # Driver used to render driver = opengl diff --git a/src/FileDialog.cpp b/src/FileDialog.cpp index d317ea4..9eefc6b 100644 --- a/src/FileDialog.cpp +++ b/src/FileDialog.cpp @@ -213,7 +213,6 @@ void FileDialog::doOpen(const SEvent &event) win->remove(); win = NULL; state->project = tmp; - state->project->remesh(); state->project->SelectNode(0); state->Mode()->unload(); state->menu->init(); diff --git a/src/NBEditor.cpp b/src/NBEditor.cpp index 6078d4d..7e91d48 100644 --- a/src/NBEditor.cpp +++ b/src/NBEditor.cpp @@ -43,6 +43,11 @@ void NBEditor::load() IGUIStaticText* sidebar = state->menu->sidebar; IGUIEnvironment* guienv = state->device->getGUIEnvironment(); + if (state->settings->getBool("hide_other_nodes")) + state->project->hideAllButCurrentNode(); + else + state->project->remesh(); + if (sidebar) { sidebar->setText(L"Node Box Tool"); IGUIStaticText* t = guienv->addStaticText(L"No node selected", diff --git a/src/Node.cpp b/src/Node.cpp index b3d9d9e..a92d3a8 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -28,7 +28,8 @@ void Node::setAllTextures(Media::Image *def) } } -Node::~Node() { +Node::~Node() +{ for (int i = 0; i < 6; i++) { if (images[i]) images[i]->drop(); @@ -42,11 +43,13 @@ Node::~Node() { boxes.clear(); } -NodeBox* Node::GetCurrentNodeBox() { +NodeBox* Node::GetCurrentNodeBox() +{ return GetNodeBox(GetId()); } -NodeBox* Node::GetNodeBox(int id) { +NodeBox* Node::GetNodeBox(int id) +{ if (id < 0 || id > boxes.size()) { return NULL; } @@ -55,7 +58,8 @@ NodeBox* Node::GetNodeBox(int id) { } // Operation functions -NodeBox* Node::addNodeBox(){ +NodeBox* Node::addNodeBox() +{ _box_count++; // Name it std::string name = "NodeBox" + num_to_str(_box_count); @@ -103,4 +107,17 @@ void Node::remesh() { } } +void Node::hide() +{ + for (std::vector::iterator it = boxes.begin(); + it != boxes.end(); + ++it) { + NodeBox *box = *it; + if (box->model) { + box->model->remove(); + box->model = NULL; + } + } +} + diff --git a/src/Node.hpp b/src/Node.hpp index bb51ed7..58973ac 100644 --- a/src/Node.hpp +++ b/src/Node.hpp @@ -28,6 +28,7 @@ public: // Node bulk updaters void remesh(); // creates the node mesh void setAllTextures(Media::Image *def); + void hide(); void setTexture(CubeSide face, Media::Image *image); Media::Image *getTexture(CubeSide face) { return images[face]; } diff --git a/src/NodeEditor.cpp b/src/NodeEditor.cpp index 735e5d4..014b466 100644 --- a/src/NodeEditor.cpp +++ b/src/NodeEditor.cpp @@ -11,6 +11,7 @@ NodeEditor::NodeEditor(EditorState* st) : void NodeEditor::load() { + state->project->remesh(); IGUIStaticText* sidebar = state->menu->sidebar; IGUIEnvironment* guienv = state->device->getGUIEnvironment(); diff --git a/src/Project.cpp b/src/Project.cpp index c6ea4dd..a049963 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -26,13 +26,28 @@ Node* Project::GetNode(int id) const for (std::list::const_iterator it = nodes.begin(); it != nodes.end(); ++it, ++curid) { - if (*it && curid == id) { + if (curid == id) { return *it; } } return NULL; } + +void Project::hideAllButCurrentNode() +{ + int curid = 0; + for (std::list::const_iterator it = nodes.begin(); + it != nodes.end(); + ++it, ++curid) { + if (snode == curid) { + (*it)->remesh(); + } else { + (*it)->hide(); + } + } +} + Node* Project::GetNode(vector3di pos) const { for (std::list::const_iterator it = nodes.begin(); diff --git a/src/Project.hpp b/src/Project.hpp index 9fcd4bf..d11e0ed 100644 --- a/src/Project.hpp +++ b/src/Project.hpp @@ -29,6 +29,7 @@ public: void AddNode(Node* node, bool select = true); void DeleteNode(int id); void SelectNode(int id) { snode = id; } + void hideAllButCurrentNode(); void remesh(); Node* GetNode(int id) const; Node* GetNode(vector3di pos) const; diff --git a/src/TextureEditor.cpp b/src/TextureEditor.cpp index 907a294..903c90b 100644 --- a/src/TextureEditor.cpp +++ b/src/TextureEditor.cpp @@ -9,7 +9,12 @@ TextureEditor::TextureEditor(EditorState* st) : } void TextureEditor::load() -{ +{ + if (state->settings->getBool("hide_other_nodes")) + state->project->hideAllButCurrentNode(); + else + state->project->remesh(); + IGUIStaticText* sidebar = state->menu->sidebar; if (!sidebar) diff --git a/src/main.cpp b/src/main.cpp index 4b68704..c99c6e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,6 +75,7 @@ int main(int argc, char *argv[]) { conf->set("viewport_bottom_left", "front"); conf->set("viewport_bottom_right", "right"); conf->set("lighting", "2"); + conf->set("hide_other_nodes", "true"); conf->set("fullscreen", "false"); conf->set("width", "896"); conf->set("height", "520");