Fix NB mesh not being built correctly on .nbe file load

master
rubenwardy 2015-09-10 21:19:22 +01:00
parent 2da4ad0718
commit 2ac7f5a56b
3 changed files with 22 additions and 21 deletions

View File

@ -292,19 +292,20 @@ void NBEFileFormat::parseLine(Project * project, std::string & line)
s[i] = trim(n.substr(0, nid)); s[i] = trim(n.substr(0, nid));
n = trim(n.substr(nid)); n = trim(n.substr(nid));
} }
node->addNodeBox(); NodeBox *box = node->addNodeBox(
node->GetCurrentNodeBox()->name = s[0]; vector3df(
node->GetCurrentNodeBox()->one = vector3df( (f32)atof(s[1].c_str()),
(f32)atof(s[1].c_str()), (f32)atof(s[2].c_str()),
(f32)atof(s[2].c_str()), (f32)atof(s[3].c_str())
(f32)atof(s[3].c_str()) ),
); vector3df(
node->GetCurrentNodeBox()->two = vector3df( (f32)atof(s[4].c_str()),
(f32)atof(s[4].c_str()), (f32)atof(s[5].c_str()),
(f32)atof(s[5].c_str()), (f32)atof(s[6].c_str())
(f32)atof(s[6].c_str()) ));
); box->name = s[0];
node->remesh(); box->rebuild_needed = true;
node->remesh(box);
} else if (lower.find("end node") == 0){ } else if (lower.find("end node") == 0){
project->AddNode(node); project->AddNode(node);
node = NULL; node = NULL;

View File

@ -60,19 +60,18 @@ NodeBox* Node::GetNodeBox(int id)
} }
// Operation functions // Operation functions
NodeBox* Node::addNodeBox() NodeBox* Node::addNodeBox(vector3df one, vector3df two)
{ {
_box_count++; _box_count++;
// Name it
std::string name = "NodeBox" + num_to_str(_box_count);
// Set up structure // Set up structure
NodeBox* tmp = new NodeBox(name, std::string name = "NodeBox" + num_to_str(_box_count);
vector3df(-0.5, -0.5, -0.5), NodeBox *tmp = new NodeBox(name, one, two);
vector3df(0.5, 0.5, 0.5));
boxes.push_back(tmp); boxes.push_back(tmp);
// Select
select(boxes.size() - 1); select(boxes.size() - 1);
tmp->buildMesh(state, position, device, images); tmp->buildMesh(state, position, device, images);
return tmp; return tmp;

View File

@ -21,7 +21,8 @@ public:
unsigned int NodeId() const { return _nid; } unsigned int NodeId() const { return _nid; }
NodeBox* GetCurrentNodeBox(); NodeBox* GetCurrentNodeBox();
NodeBox* GetNodeBox(int id); 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 deleteNodebox(int id);
void cloneNodebox(int id); void cloneNodebox(int id);
void select(int id) { _selected = id; } void select(int id) { _selected = id; }