Optimizations...
This commit is contained in:
parent
e96b8ca53b
commit
c68ebbc920
|
|
@ -1,5 +1,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <hash_map>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//#include <wrap/strip/tristrip.h>
|
//#include <wrap/strip/tristrip.h>
|
||||||
|
|
@ -19,6 +20,11 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
assert(nexus.signature & NXS_NORMALS_SHORT ||
|
assert(nexus.signature & NXS_NORMALS_SHORT ||
|
||||||
nexus.signature & NXS_NORMALS_FLOAT);
|
nexus.signature & NXS_NORMALS_FLOAT);
|
||||||
|
|
||||||
|
//setting borders readonly:
|
||||||
|
|
||||||
|
assert(!nexus.borders.IsReadonly());
|
||||||
|
nexus.borders.SetReadOnly(true);
|
||||||
|
|
||||||
bool use_short = (nexus.signature & NXS_NORMALS_SHORT) != 0;
|
bool use_short = (nexus.signature & NXS_NORMALS_SHORT) != 0;
|
||||||
|
|
||||||
//TODO use a temporary file to store border normals
|
//TODO use a temporary file to store border normals
|
||||||
|
|
@ -46,11 +52,13 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
//first step normals in the same patch.
|
//first step normals in the same patch.
|
||||||
cerr << "First Step\n";
|
cerr << "First Step\n";
|
||||||
Report report(nexus.index.size(), 5);
|
Report report(nexus.index.size(), 5);
|
||||||
|
vector<Point3f> normals;
|
||||||
|
|
||||||
for(unsigned int p = 0; p < nexus.index.size(); p++) {
|
for(unsigned int p = 0; p < nexus.index.size(); p++) {
|
||||||
report.Step(p);
|
report.Step(p);
|
||||||
Patch &patch = nexus.GetPatch(p);
|
Patch &patch = nexus.GetPatch(p);
|
||||||
|
|
||||||
vector<Point3f> normals;
|
normals.clear();
|
||||||
normals.resize(patch.nv, Point3f(0, 0, 0));
|
normals.resize(patch.nv, Point3f(0, 0, 0));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -103,12 +111,14 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
map<unsigned int, map<unsigned short, Point3f> > bnorm;
|
map<unsigned int, map<unsigned short, Point3f> > bnorm;
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int poff = tmpb_start[p];
|
||||||
for(unsigned int i = 0; i < border.Size(); i++) {
|
for(unsigned int i = 0; i < border.Size(); i++) {
|
||||||
Link &link = border[i];
|
Link &link = border[i];
|
||||||
if(link.IsNull()) continue;
|
if(link.IsNull()) continue;
|
||||||
Point3f pt = normals[link.start_vert];
|
Point3f pt = normals[link.start_vert];
|
||||||
bnorm[p][link.start_vert] = pt;
|
//bnorm[p][link.start_vert] = pt;
|
||||||
bnorm[link.end_patch][link.end_vert] = pt;
|
bnorm[link.end_patch][link.end_vert] = pt;
|
||||||
|
tmpb[poff + i] += pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
map<unsigned int, map<unsigned short, Point3f> >::iterator k;
|
map<unsigned int, map<unsigned short, Point3f> >::iterator k;
|
||||||
|
|
@ -118,10 +128,11 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
unsigned int offset = tmpb_start[patch];
|
unsigned int offset = tmpb_start[patch];
|
||||||
for(unsigned int i = 0; i < border.Size(); i++) {
|
for(unsigned int i = 0; i < border.Size(); i++) {
|
||||||
Link &link = border[i];
|
Link &link = border[i];
|
||||||
assert(!link.IsNull());
|
//assert(!link.IsNull());
|
||||||
//TODO not accurate
|
//TODO not accurate
|
||||||
|
if(link.end_patch != p) continue;
|
||||||
if((*k).second.count(link.start_vert))
|
if((*k).second.count(link.start_vert))
|
||||||
tmpb[offset + i] = (*k).second[link.start_vert];
|
tmpb[offset + i] += (*k).second[link.start_vert];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,6 +195,7 @@ void nxs::ComputeNormals(Nexus &nexus) {
|
||||||
tmpb.Close();
|
tmpb.Close();
|
||||||
tmpb.Delete();
|
tmpb.Delete();
|
||||||
//TODO remove temporary file.
|
//TODO remove temporary file.
|
||||||
|
nexus.borders.SetReadOnly(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void nxs::ComputeTriStrip(unsigned short nfaces, unsigned short *faces,
|
/*void nxs::ComputeTriStrip(unsigned short nfaces, unsigned short *faces,
|
||||||
|
|
|
||||||
|
|
@ -389,11 +389,11 @@ int main(int argc, char *argv[]) {
|
||||||
dst_entry.error = src_entry.error;
|
dst_entry.error = src_entry.error;
|
||||||
|
|
||||||
//adding borders.
|
//adding borders.
|
||||||
for(unsigned int i = 0; i < src_border.Size(); i++) {
|
/*for(unsigned int i = 0; i < src_border.Size(); i++) {
|
||||||
Link &link = src_border[i];
|
Link &link = src_border[i];
|
||||||
if(link.IsNull()) continue;
|
if(link.IsNull()) continue;
|
||||||
assert(link.end_patch < nexus.index.size());
|
assert(link.end_patch < nexus.index.size());
|
||||||
}
|
}*/
|
||||||
Border dst_border = out.GetBorder(patch);
|
Border dst_border = out.GetBorder(patch);
|
||||||
out.borders.ResizeBorder(patch, src_border.Size());
|
out.borders.ResizeBorder(patch, src_border.Size());
|
||||||
memcpy(dst_border.Start(), src_border.Start(),
|
memcpy(dst_border.Start(), src_border.Start(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue