diff --git a/apps/nexus/nxsalgo.cpp b/apps/nexus/nxsalgo.cpp index 13cccec9..4a039599 100644 --- a/apps/nexus/nxsalgo.cpp +++ b/apps/nexus/nxsalgo.cpp @@ -39,6 +39,7 @@ void nxs::ComputeNormals(Nexus &nexus) { tmpb.Resize(tmpb_offset); for(unsigned int i = 0; i < tmpb.Size(); i++) tmpb[i] = zero; + tmpb.Flush(); //first step normals in the same patch. for(unsigned int p = 0; p < nexus.index.size(); p++) { @@ -96,7 +97,10 @@ void nxs::ComputeNormals(Nexus &nexus) { Link &link = border[i]; if(link.IsNull()) continue; unsigned int off = tmpb_start[p]; - tmpb[off + i] += normals[link.start_vert]; + Point3f p = tmpb.read(off + i); + p += normals[link.start_vert]; + tmpb.write(off + i, p); + // tmpb[off + i] += normals[link.start_vert]; close.insert(link.end_patch); } @@ -109,7 +113,10 @@ void nxs::ComputeNormals(Nexus &nexus) { Link &link = remote[i]; if(link.IsNull()) continue; if(link.end_patch != p) continue; - tmpb[off + i] += normals[link.end_vert]; + Point3f p = tmpb.read(off + i); + p += normals[link.end_vert]; + tmpb.write(off + i, p); + // tmpb[off + i] += normals[link.end_vert]; } } } @@ -123,7 +130,8 @@ void nxs::ComputeNormals(Nexus &nexus) { Link &link = border[i]; if(link.IsNull()) continue; unsigned int off = tmpb_start[p]; - Point3f &n = tmpb[off + i]; + // Point3f &n = tmpb[off + i]; + Point3f n = tmpb.read(off + i); n.Normalize(); if(use_short) { n *= 32766; diff --git a/apps/nexus/vfile.h b/apps/nexus/vfile.h index c507bb0d..a9370fdd 100644 --- a/apps/nexus/vfile.h +++ b/apps/nexus/vfile.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.13 2004/10/08 15:12:04 ponchio +Working version (maybe) + Revision 1.12 2004/10/04 16:49:54 ponchio Daily backup. Preparing for compression. @@ -256,7 +259,18 @@ template class VFile: public File { SetPosition(chunk * chunk_size * sizeof(T)); ReadBuffer((char *)(buffer.data), buffer.size * sizeof(T)); return buffer.data; - } + } + //non buffered read only acces. + T read(unsigned int element) { + SetPosition(element * sizeof(T)); + T t; + ReadBuffer(&t, sizeof(T)); + return t; + } + void write(unsigned int element, T &t) { + SetPosition(element * sizeof(T)); + WriteBuffer(&t, sizeof(T)); + } void PushBack(const T &t) { Resize(n_elements+1);