From 2ac7f5a56b8fc72d268bf7deec0d79eed4848f35 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 10 Sep 2015 21:19:22 +0100 Subject: [PATCH] Fix NB mesh not being built correctly on .nbe file load --- src/FileFormat/NBE.cpp | 27 ++++++++++++++------------- src/project/node.cpp | 13 ++++++------- src/project/node.hpp | 3 ++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/FileFormat/NBE.cpp b/src/FileFormat/NBE.cpp index 7a2610c..283048d 100644 --- a/src/FileFormat/NBE.cpp +++ b/src/FileFormat/NBE.cpp @@ -292,19 +292,20 @@ void NBEFileFormat::parseLine(Project * project, std::string & line) s[i] = trim(n.substr(0, nid)); n = trim(n.substr(nid)); } - node->addNodeBox(); - node->GetCurrentNodeBox()->name = s[0]; - node->GetCurrentNodeBox()->one = vector3df( - (f32)atof(s[1].c_str()), - (f32)atof(s[2].c_str()), - (f32)atof(s[3].c_str()) - ); - node->GetCurrentNodeBox()->two = vector3df( - (f32)atof(s[4].c_str()), - (f32)atof(s[5].c_str()), - (f32)atof(s[6].c_str()) - ); - node->remesh(); + NodeBox *box = node->addNodeBox( + vector3df( + (f32)atof(s[1].c_str()), + (f32)atof(s[2].c_str()), + (f32)atof(s[3].c_str()) + ), + vector3df( + (f32)atof(s[4].c_str()), + (f32)atof(s[5].c_str()), + (f32)atof(s[6].c_str()) + )); + box->name = s[0]; + box->rebuild_needed = true; + node->remesh(box); } else if (lower.find("end node") == 0){ project->AddNode(node); node = NULL; diff --git a/src/project/node.cpp b/src/project/node.cpp index f89d517..28299cc 100644 --- a/src/project/node.cpp +++ b/src/project/node.cpp @@ -60,19 +60,18 @@ NodeBox* Node::GetNodeBox(int id) } // Operation functions -NodeBox* Node::addNodeBox() +NodeBox* Node::addNodeBox(vector3df one, vector3df two) { _box_count++; - // Name it - std::string name = "NodeBox" + num_to_str(_box_count); // Set up structure - NodeBox* tmp = new NodeBox(name, - vector3df(-0.5, -0.5, -0.5), - vector3df(0.5, 0.5, 0.5)); - + std::string name = "NodeBox" + num_to_str(_box_count); + NodeBox *tmp = new NodeBox(name, one, two); boxes.push_back(tmp); + + // Select select(boxes.size() - 1); + tmp->buildMesh(state, position, device, images); return tmp; diff --git a/src/project/node.hpp b/src/project/node.hpp index 2b59aed..842bfcb 100644 --- a/src/project/node.hpp +++ b/src/project/node.hpp @@ -21,7 +21,8 @@ public: unsigned int NodeId() const { return _nid; } NodeBox* GetCurrentNodeBox(); NodeBox* GetNodeBox(int id); - NodeBox* addNodeBox(); + NodeBox* addNodeBox(vector3df one = vector3df(-0.5, -0.5, -0.5), + vector3df two = vector3df(0.5, 0.5, 0.5)); void deleteNodebox(int id); void cloneNodebox(int id); void select(int id) { _selected = id; }