Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Move all nodes up when a node is placed below the ground
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Mar 1, 2015
1 parent 229649a commit 3b1060e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion editor.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ viewport_bottom_right = right

# Lighting
# 0: no lighting / shadows
# 1: Depth lighting (things further away from camera are darker)
# 1: Depth lighting (things further away from camera are darker) (TODO)
# 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

# Move all nodes up when a node is placed at negative y
no_negative_node_y = true

# Driver used to render
driver = opengl

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int main(int argc, char *argv[]) {
conf->set("viewport_bottom_right", "right");
conf->set("lighting", "2");
conf->set("hide_other_nodes", "true");
conf->set("no_negative_node_y", "true");
conf->set("fullscreen", "false");
conf->set("width", "896");
conf->set("height", "520");
Expand Down
14 changes: 13 additions & 1 deletion src/modes/NodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,21 @@ void NodeEditor::updateProperties() {
try {
irr::core::stringc name = prop->getElementFromId(ENG_GUI_PROP_NAME)->getText();
node->name = str_replace(std::string(name.c_str(), name.size()), ' ', '_');
int y = wcstod(prop->getElementFromId(ENG_GUI_PROP_Y)->getText(), NULL);
if (state->settings->getBool("no_negative_node_y") && y < 0) {
std::list<Node*> & nodes = state->project->nodes;
for (std::list<Node*>::const_iterator it = nodes.begin();
it != nodes.end();
++it) {
(*it)->position.Y -= y; // Remember, y is negative
}
state->project->remesh();
y = 0;
}

node->position = vector3di(
wcstod(prop->getElementFromId(ENG_GUI_PROP_X)->getText(), NULL),
wcstod(prop->getElementFromId(ENG_GUI_PROP_Y)->getText(), NULL),
y,
wcstod(prop->getElementFromId(ENG_GUI_PROP_Z)->getText(), NULL)
);
node->remesh();
Expand Down

0 comments on commit 3b1060e

Please sign in to comment.