Small changes.

This commit is contained in:
Federico Ponchio 2005-01-18 22:25:32 +00:00
parent 4636a37a27
commit 244e548569
4 changed files with 14 additions and 12 deletions

View File

@ -27,7 +27,8 @@ namespace nxs {
virtual void GetView() { frustum.GetView(); } virtual void GetView() { frustum.GetView(); }
float GetError(Entry &entry) { float GetError(Entry &entry) {
vcg::Sphere3f &sphere = entry.sphere; vcg::Sphere3f &sphere = entry.sphere;
float dist = Distance(sphere, frustum.ViewPoint()); float dist = (sphere.Center() - frustum.ViewPoint()).Norm() - sphere.Radius();
//float dist = Distance(sphere, frustum.ViewPoint());
if(dist < 0) if(dist < 0)
return 1e20f; return 1e20f;
if(frustum.IsOutside(sphere.Center(), sphere.Radius())) if(frustum.IsOutside(sphere.Center(), sphere.Radius()))

View File

@ -113,6 +113,7 @@ bool Nexus::LoadHeader() {
ReadBuffer(&totvert, sizeof(unsigned int)); ReadBuffer(&totvert, sizeof(unsigned int));
ReadBuffer(&totface, sizeof(unsigned int)); ReadBuffer(&totface, sizeof(unsigned int));
ReadBuffer(&sphere, sizeof(Sphere3f)); ReadBuffer(&sphere, sizeof(Sphere3f));
return true;
} }
void Nexus::Flush(bool all) { void Nexus::Flush(bool all) {
@ -140,10 +141,10 @@ Patch &Nexus::GetPatch(unsigned int patch, bool flush) {
Entry &entry = operator[](patch); Entry &entry = operator[](patch);
if(index.count(patch)) { if(index.count(patch)) {
assert(entry.patch); assert(entry.patch);
list<unsigned int>::iterator &i = index[patch]; list<unsigned int>::iterator i = index[patch];
pqueue.erase(i); pqueue.erase(i);
pqueue.push_front(patch); pqueue.push_front(patch);
index[patch] = pqueue.begin();
} else { } else {
while(flush && ram_used > ram_max) { while(flush && ram_used > ram_max) {
unsigned int to_flush = pqueue.back(); unsigned int to_flush = pqueue.back();

View File

@ -37,6 +37,7 @@ void nxs::ComputeNormals(Nexus &nexus) {
exit(0); exit(0);
} }
//TODO optimize! it is not necessary to read all the borders.
for(unsigned int p = 0; p < nexus.size(); p++) { for(unsigned int p = 0; p < nexus.size(); p++) {
Border border = nexus.GetBorder(p); Border border = nexus.GetBorder(p);
tmpb_start.push_back(tmpb_offset); tmpb_start.push_back(tmpb_offset);
@ -62,7 +63,6 @@ void nxs::ComputeNormals(Nexus &nexus) {
normals.clear(); normals.clear();
normals.resize(patch.nv, Point3f(0, 0, 0)); normals.resize(patch.nv, Point3f(0, 0, 0));
if(nexus.signature & NXS_FACES) if(nexus.signature & NXS_FACES)
for(unsigned int i = 0; i < patch.nf; i++) { for(unsigned int i = 0; i < patch.nf; i++) {
unsigned short *f = patch.Face(i); unsigned short *f = patch.Face(i);
@ -95,9 +95,9 @@ void nxs::ComputeNormals(Nexus &nexus) {
Point3f &norm = normals[i]; Point3f &norm = normals[i];
norm.Normalize(); norm.Normalize();
short *n = patch.Norm16(i); short *n = patch.Norm16(i);
for(int k = 0; k < 3; k++) { for(int k = 0; k < 3; k++)
n[k] = (short)(norm[k] * 32766); n[k] = (short)(norm[k] * 32766);
}
n[3] = 0; n[3] = 0;
} }
} else { } else {
@ -111,15 +111,15 @@ 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]; 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; //this should never happen now.
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; tmpb[poff + i] += pt;
} }
map<unsigned int, map<unsigned short, Point3f> >::iterator k; map<unsigned int, map<unsigned short, Point3f> >::iterator k;

View File

@ -155,7 +155,7 @@ void Dispatcher::msghandler(message &msg) {
Server *best = BestServer(); Server *best = BestServer();
Fragment *fragin = (Fragment *)(msg.param); Fragment *fragin = (Fragment *)(msg.param);
if(!best) { //no server process locally.... if(!best || mode == CLUSTER) { //no server process locally....
// cerr << "Local: " << fragin->id << endl; // cerr << "Local: " << fragin->id << endl;
vector<Point3f> newvert; vector<Point3f> newvert;
vector<unsigned int> newface; vector<unsigned int> newface;