From 244e548569eb006f86a1ac213deb7180455679cc Mon Sep 17 00:00:00 2001 From: ponchio Date: Tue, 18 Jan 2005 22:25:32 +0000 Subject: [PATCH] Small changes. --- apps/nexus/metric.h | 3 ++- apps/nexus/nexus.cpp | 5 +++-- apps/nexus/nxsalgo.cpp | 14 +++++++------- apps/nexus/nxsdispatcher.cpp | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/nexus/metric.h b/apps/nexus/metric.h index 9de3949f..1ecabe7e 100644 --- a/apps/nexus/metric.h +++ b/apps/nexus/metric.h @@ -27,7 +27,8 @@ namespace nxs { virtual void GetView() { frustum.GetView(); } float GetError(Entry &entry) { 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) return 1e20f; if(frustum.IsOutside(sphere.Center(), sphere.Radius())) diff --git a/apps/nexus/nexus.cpp b/apps/nexus/nexus.cpp index 21d30462..7ae1b8bc 100644 --- a/apps/nexus/nexus.cpp +++ b/apps/nexus/nexus.cpp @@ -113,6 +113,7 @@ bool Nexus::LoadHeader() { ReadBuffer(&totvert, sizeof(unsigned int)); ReadBuffer(&totface, sizeof(unsigned int)); ReadBuffer(&sphere, sizeof(Sphere3f)); + return true; } void Nexus::Flush(bool all) { @@ -140,10 +141,10 @@ Patch &Nexus::GetPatch(unsigned int patch, bool flush) { Entry &entry = operator[](patch); if(index.count(patch)) { assert(entry.patch); - list::iterator &i = index[patch]; + list::iterator i = index[patch]; pqueue.erase(i); pqueue.push_front(patch); - + index[patch] = pqueue.begin(); } else { while(flush && ram_used > ram_max) { unsigned int to_flush = pqueue.back(); diff --git a/apps/nexus/nxsalgo.cpp b/apps/nexus/nxsalgo.cpp index b1882515..cef9dc07 100644 --- a/apps/nexus/nxsalgo.cpp +++ b/apps/nexus/nxsalgo.cpp @@ -37,6 +37,7 @@ void nxs::ComputeNormals(Nexus &nexus) { exit(0); } + //TODO optimize! it is not necessary to read all the borders. for(unsigned int p = 0; p < nexus.size(); p++) { Border border = nexus.GetBorder(p); tmpb_start.push_back(tmpb_offset); @@ -47,7 +48,7 @@ void nxs::ComputeNormals(Nexus &nexus) { tmpb.Resize(tmpb_offset); for(unsigned int i = 0; i < tmpb.Size(); i++) - tmpb[i] = zero; + tmpb[i] = zero; tmpb.Flush(); //first step normals in the same patch. @@ -60,8 +61,7 @@ void nxs::ComputeNormals(Nexus &nexus) { Patch &patch = nexus.GetPatch(p); normals.clear(); - normals.resize(patch.nv, Point3f(0, 0, 0)); - + normals.resize(patch.nv, Point3f(0, 0, 0)); if(nexus.signature & NXS_FACES) for(unsigned int i = 0; i < patch.nf; i++) { @@ -95,9 +95,9 @@ void nxs::ComputeNormals(Nexus &nexus) { Point3f &norm = normals[i]; norm.Normalize(); 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[3] = 0; } } else { @@ -111,15 +111,15 @@ void nxs::ComputeNormals(Nexus &nexus) { map > bnorm; - unsigned int poff = tmpb_start[p]; for(unsigned int i = 0; i < border.Size(); i++) { Link &link = border[i]; - if(link.IsNull()) continue; + if(link.IsNull()) continue; //this should never happen now. Point3f pt = normals[link.start_vert]; //bnorm[p][link.start_vert] = pt; bnorm[link.end_patch][link.end_vert] = pt; tmpb[poff + i] += pt; + } map >::iterator k; diff --git a/apps/nexus/nxsdispatcher.cpp b/apps/nexus/nxsdispatcher.cpp index 7c0deb0e..ac4b40c9 100644 --- a/apps/nexus/nxsdispatcher.cpp +++ b/apps/nexus/nxsdispatcher.cpp @@ -155,7 +155,7 @@ void Dispatcher::msghandler(message &msg) { Server *best = BestServer(); Fragment *fragin = (Fragment *)(msg.param); - if(!best) { //no server process locally.... + if(!best || mode == CLUSTER) { //no server process locally.... // cerr << "Local: " << fragin->id << endl; vector newvert; vector newface; @@ -178,7 +178,7 @@ void Dispatcher::msghandler(message &msg) { // cerr << "Server: " << fragin->id << endl; FragIO *frag = new FragIO(best, this, fragin); if(msg.id == MSG_SEND) - assert(!frags.count(fragin->id)); + assert(!frags.count(fragin->id)); frags[fragin->id] = frag; frag->start(); }