cleaning (a bit more).
This commit is contained in:
parent
80ddbed065
commit
0ccff41441
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.10 2005/02/20 18:07:00 ponchio
|
||||
cleaning.
|
||||
|
||||
Revision 1.9 2005/02/20 00:43:23 ponchio
|
||||
Less memory x extraction. (removed frags)
|
||||
|
||||
|
@ -106,13 +109,12 @@ void Extraction::Init() {
|
|||
bool cancoarse = true;
|
||||
|
||||
Node::iterator n;
|
||||
for(n = node.out_begin(); n != node.out_end(); n++) {
|
||||
for(n = node.out_begin; n != node.out_end; n++) {
|
||||
if(!Visited((*n).node)) {
|
||||
float maxerror = -1;
|
||||
|
||||
Link &link = *n;
|
||||
for(Link::iterator k = link.begin(); k != link.end(); k++) {
|
||||
unsigned int patch = k;
|
||||
for(unsigned int patch = link.begin; patch != link.end; patch++) {
|
||||
Entry &entry = (*mt)[patch];
|
||||
|
||||
bool visible;
|
||||
|
@ -232,7 +234,7 @@ void Extraction::Update(NexusMt *_mt) {
|
|||
if(Visited(hnode.node)) {
|
||||
bool recursive = false;
|
||||
Node::iterator i;
|
||||
for(i = hnode.node->out_begin(); i != hnode.node->out_end(); i++) {
|
||||
for(i = hnode.node->out_begin; i != hnode.node->out_end; i++) {
|
||||
Node *child = (*i).node;
|
||||
if(Visited(child)) recursive = true;
|
||||
}
|
||||
|
@ -258,9 +260,9 @@ void Extraction::Update(NexusMt *_mt) {
|
|||
Node *node = hnode.node;
|
||||
front.pop_back();
|
||||
Node::iterator l;
|
||||
for(l = node->out_begin(); l != node->out_end(); l++) {
|
||||
for(l = node->out_begin; l != node->out_end; l++) {
|
||||
Link &link = (*l);
|
||||
for(Link::iterator k = link.begin(); k != link.end(); k++) {
|
||||
for(unsigned int k = link.begin; k != link.end; k++) {
|
||||
selected.push_back(Item(k, i));
|
||||
errors[k] = i;
|
||||
}
|
||||
|
@ -270,10 +272,10 @@ void Extraction::Update(NexusMt *_mt) {
|
|||
HeapNode hnode = back.back();
|
||||
Node *node = hnode.node;
|
||||
back.pop_back();
|
||||
Node::iterator l;
|
||||
for(l = node->in_begin(); l != node->in_end(); l++) {
|
||||
|
||||
for(Node::iterator l = node->in_begin; l != node->in_end; l++) {
|
||||
Link &link = (*l);
|
||||
for(Link::iterator k = link.begin(); k != link.end(); k++) {
|
||||
for(unsigned int k = link.begin; k != link.end; k++) {
|
||||
selected.push_back(Item(k, i));
|
||||
errors[k] = i;
|
||||
}
|
||||
|
@ -284,10 +286,9 @@ void Extraction::Update(NexusMt *_mt) {
|
|||
|
||||
float Extraction::GetRefineError(Node *node) {
|
||||
float maxerror = -1;
|
||||
Node::iterator i;
|
||||
for(i = node->in_begin(); i != node->in_end(); i++) {
|
||||
for(Node::iterator i = node->in_begin; i != node->in_end; i++) {
|
||||
Link &link = *i;
|
||||
for(Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
Entry &entry = (*mt)[p];
|
||||
bool visible;
|
||||
float error = metric->GetError(entry, visible);
|
||||
|
@ -303,8 +304,7 @@ bool Extraction::Refine(HeapNode hnode) {
|
|||
Node *node = hnode.node;
|
||||
|
||||
//recursively refine parent if applicable.
|
||||
Node::iterator i;
|
||||
for(i = node->in_begin(); i != node->in_end(); i++) {
|
||||
for(Node::iterator i = node->in_begin; i != node->in_end; i++) {
|
||||
Node *parent = (*i).node;
|
||||
if(!Visited(parent)) {
|
||||
//Here i use parent refine error!!!
|
||||
|
@ -343,7 +343,7 @@ bool Extraction::Refine(HeapNode hnode) {
|
|||
|
||||
//now add to the front children (unless sink node)
|
||||
|
||||
for(i = node->out_begin(); i != node->out_end(); i++) {
|
||||
for(Node::iterator i = node->out_begin; i != node->out_end; i++) {
|
||||
Link &link = *i;
|
||||
if(link.node == sink) continue;
|
||||
float maxerror = GetRefineError(link.node);
|
||||
|
@ -363,8 +363,7 @@ bool Extraction::Coarse(HeapNode hnode) {
|
|||
Node *node = hnode.node;
|
||||
|
||||
//recursively coarse children if applicable.
|
||||
Node::iterator i;
|
||||
for(i = node->out_begin(); i != node->out_end(); i++) {
|
||||
for(Node::iterator i = node->out_begin; i != node->out_end; i++) {
|
||||
Node *child = (*i).node;
|
||||
float error = GetRefineError(child);
|
||||
HeapNode hchild(child, error);
|
||||
|
@ -385,7 +384,7 @@ bool Extraction::Coarse(HeapNode hnode) {
|
|||
SetVisited(node, false);
|
||||
|
||||
//now add to the back parents (unless root node)
|
||||
for(i = node->in_begin(); i != node->in_end(); i++) {
|
||||
for(Node::iterator i = node->in_begin; i != node->in_end; i++) {
|
||||
Link &link = *i;
|
||||
if(link.node == root) continue;
|
||||
float maxerror = GetRefineError(link.node);
|
||||
|
@ -409,11 +408,11 @@ void Extraction::Select() {
|
|||
Node &node = nodes[i];
|
||||
|
||||
Node::iterator n;
|
||||
for(n = node.out_begin(); n != node.out_end(); n++) {
|
||||
for(n = node.out_begin; n != node.out_end; n++) {
|
||||
unsigned int n_out = (*n).node - root;
|
||||
if(!visited[n_out]) {
|
||||
Link &link = *n;
|
||||
for(Link::iterator p= link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
selected.push_back(Item(p, 0));
|
||||
errors[p] = 0.0f;
|
||||
}
|
||||
|
@ -427,8 +426,7 @@ void Extraction::Visit(Node *node) {
|
|||
|
||||
SetVisited(node, true);
|
||||
|
||||
Node::iterator i;
|
||||
for(i = node->in_begin(); i != node->in_end(); i++) {
|
||||
for(Node::iterator i = node->in_begin; i != node->in_end; i++) {
|
||||
if(Visited((*i).node)) continue;
|
||||
Visit((*i).node);
|
||||
}
|
||||
|
@ -439,10 +437,10 @@ void Extraction::Visit(Node *node) {
|
|||
draw_used += cost.draw;
|
||||
disk_used += cost.disk;
|
||||
|
||||
for(i = node->out_begin(); i != node->out_end(); i++) {
|
||||
for(Node::iterator i = node->out_begin; i != node->out_end; i++) {
|
||||
float maxerror = -1;
|
||||
Link &link = *i;
|
||||
for(Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
Entry &entry = (*mt)[p];
|
||||
bool visible;
|
||||
float error = metric->GetError(entry, visible);
|
||||
|
@ -467,9 +465,9 @@ bool Extraction::Expand(HeapNode &node) {
|
|||
|
||||
void Extraction::Diff(Node *node, Cost &cost) {
|
||||
Node::iterator i;
|
||||
for(i = node->in_begin(); i != node->in_end(); i++) {
|
||||
for(i = node->in_begin; i != node->in_end; i++) {
|
||||
Link &link = *i;
|
||||
for(Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
Entry &entry = (*mt)[p];
|
||||
cost.extr -= entry.ram_size;
|
||||
if(Visible(p)) cost.draw -= entry.ram_size;
|
||||
|
@ -479,9 +477,9 @@ void Extraction::Diff(Node *node, Cost &cost) {
|
|||
}
|
||||
}
|
||||
|
||||
for(i = node->out_begin(); i != node->out_end(); i++) {
|
||||
for(i = node->out_begin; i != node->out_end; i++) {
|
||||
Link &link = *i;
|
||||
for(Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
Entry &entry = (*mt)[p];
|
||||
cost.extr += entry.ram_size;
|
||||
if(Visible(p)) cost.draw += entry.ram_size;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.9 2005/02/20 00:43:23 ponchio
|
||||
Less memory x extraction. (removed frags)
|
||||
|
||||
Revision 1.8 2005/02/19 17:14:02 ponchio
|
||||
History quick by default.
|
||||
|
||||
|
@ -125,10 +128,12 @@ bool History::LoadPointers() {
|
|||
//now convert integer to pointers
|
||||
for(unsigned int i = 0; i < n_nodes(); i++) {
|
||||
Node &node = nodes[i];
|
||||
assert(((unsigned int)node.in_link_begin) <= n_in_links());
|
||||
assert(((unsigned int)node.out_link_begin) <= n_out_links());
|
||||
node.in_link_begin = in_links + (unsigned int)(node.in_link_begin);
|
||||
node.out_link_begin = out_links + (unsigned int)(node.out_link_begin);
|
||||
assert(((unsigned int)node.in_begin) <= n_in_links());
|
||||
assert(((unsigned int)node.out_begin) <= n_out_links());
|
||||
node.in_begin = in_links + (unsigned int)(node.in_begin);
|
||||
node.in_end = in_links + (unsigned int)(node.in_end);
|
||||
node.out_begin = out_links + (unsigned int)(node.out_begin);
|
||||
node.out_end = out_links + (unsigned int)(node.out_end);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < n_in_links(); i++) {
|
||||
|
@ -156,8 +161,10 @@ char *History::SaveQuick(unsigned int &_size) {
|
|||
assert(buffer);
|
||||
for(unsigned int i = 0; i < n_nodes(); i++) {
|
||||
Node &node = nodes[i];
|
||||
node.in_link_begin = (Link *)(node.in_link_begin - in_links);
|
||||
node.out_link_begin = (Link *)(node.out_link_begin - out_links);
|
||||
node.in_begin = (Link *)(node.in_begin - in_links);
|
||||
node.in_end = (Link *)(node.in_end - in_links);
|
||||
node.out_begin = (Link *)(node.out_begin - out_links);
|
||||
node.out_end = (Link *)(node.out_end - out_links);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < n_in_links(); i++) {
|
||||
|
@ -247,13 +254,13 @@ bool History::UpdatesToQuick(Nexus &nexus) {
|
|||
|
||||
Link inlink;
|
||||
inlink.node = (Node *)floor_node;
|
||||
inlink.frag_begin = tmp_frags.size();
|
||||
inlink.frag_size = cells.size();
|
||||
inlink.begin = tmp_frags.size();
|
||||
inlink.end = inlink.begin + cells.size();
|
||||
|
||||
Link outlink;
|
||||
outlink.node = (Node *)current_node;
|
||||
outlink.frag_begin = tmp_frags.size();
|
||||
outlink.frag_size = cells.size();
|
||||
outlink.begin = tmp_frags.size();
|
||||
outlink.end = outlink.begin + cells.size();
|
||||
|
||||
//Fill it with erased cells.
|
||||
vector<unsigned int>::iterator k;
|
||||
|
@ -271,8 +278,10 @@ bool History::UpdatesToQuick(Nexus &nexus) {
|
|||
for(k = node_outlinks.begin(); k != node_outlinks.end(); k++) {
|
||||
unsigned int inode = (*k).first;
|
||||
vector<Link> &links = (*k).second;
|
||||
tmp_nodes[inode].out_link_begin = (Link *)(tmp_out_links.size());
|
||||
tmp_nodes[inode].out_link_size = links.size();
|
||||
tmp_nodes[inode].out_begin = (Link *)(tmp_out_links.size());
|
||||
tmp_nodes[inode].out_end = (Link *)(tmp_out_links.size() + links.size());
|
||||
// tmp_nodes[inode].out_link_begin = (Link *)(tmp_out_links.size());
|
||||
// tmp_nodes[inode].out_link_size = links.size();
|
||||
|
||||
for(unsigned int i = 0; i < links.size(); i++)
|
||||
tmp_out_links.push_back(links[i]);
|
||||
|
@ -281,8 +290,10 @@ bool History::UpdatesToQuick(Nexus &nexus) {
|
|||
for(k = node_inlinks.begin(); k != node_inlinks.end(); k++) {
|
||||
unsigned int inode = (*k).first;
|
||||
vector<Link> &links = (*k).second;
|
||||
tmp_nodes[inode].in_link_begin = (Link *)(tmp_in_links.size());
|
||||
tmp_nodes[inode].in_link_size = links.size();
|
||||
// tmp_nodes[inode].in_link_begin = (Link *)(tmp_in_links.size());
|
||||
// tmp_nodes[inode].in_link_size = links.size();
|
||||
tmp_nodes[inode].in_begin = (Link *)(tmp_in_links.size());
|
||||
tmp_nodes[inode].in_end = (Link *)(tmp_in_links.size() + links.size());
|
||||
|
||||
for(unsigned int i = 0; i < links.size(); i++)
|
||||
tmp_in_links.push_back(links[i]);
|
||||
|
@ -358,17 +369,15 @@ void History::BuildLevels(vector<int> &levels) {
|
|||
Node::iterator l;
|
||||
unsigned int current = 0;
|
||||
if(node != nodes) { //not root
|
||||
Link *inlink = node->in_begin();
|
||||
unsigned int p = (inlink->begin());
|
||||
Link *inlink = node->in_begin;
|
||||
unsigned int p = inlink->begin;
|
||||
assert(p < levels.size());
|
||||
assert(p >= 0);
|
||||
current = levels[p]+1;
|
||||
}
|
||||
for(l = node->out_begin(); l != node->out_end(); l++) {
|
||||
for(l = node->out_begin; l != node->out_end; l++) {
|
||||
Link &link = *l;
|
||||
Link::iterator c;
|
||||
for(c = link.begin(); c != link.end(); c++) {
|
||||
unsigned int p = c;
|
||||
for(unsigned int p = link.begin; p != link.end; p++) {
|
||||
while(p >= levels.size()) levels.push_back(-1);
|
||||
levels[p] = current;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.6 2005/02/20 00:43:23 ponchio
|
||||
Less memory x extraction. (removed frags)
|
||||
|
||||
Revision 1.5 2005/02/19 16:22:45 ponchio
|
||||
Minor changes (visited and Cell)
|
||||
|
||||
|
@ -57,49 +60,26 @@ namespace nxs {
|
|||
std::vector<unsigned int> created;
|
||||
};
|
||||
|
||||
// struct Cell {
|
||||
// unsigned int patch;
|
||||
// float error;
|
||||
// };
|
||||
|
||||
struct Node;
|
||||
|
||||
struct Link {
|
||||
Node *node;
|
||||
unsigned int begin; //begin patch of the fragment
|
||||
unsigned int end; //end patch of the fragment
|
||||
|
||||
//TODO move to frag_begin frag_end (instead of frag_size)
|
||||
//and test speed... before so maybe also for node
|
||||
typedef unsigned int iterator;
|
||||
iterator begin() { return frag_begin; }
|
||||
iterator end() { return frag_begin + frag_size; }
|
||||
unsigned int size() { return frag_size; }
|
||||
|
||||
unsigned int frag_begin;
|
||||
unsigned int frag_size;
|
||||
unsigned int size() { return end - begin; }
|
||||
};
|
||||
|
||||
struct Node {
|
||||
typedef Link *iterator;
|
||||
|
||||
iterator in_begin() { return in_link_begin; }
|
||||
iterator in_end() { return in_link_begin + in_link_size; }
|
||||
unsigned int size() { return in_link_size; }
|
||||
|
||||
iterator out_begin() { return out_link_begin; }
|
||||
iterator out_end() { return out_link_begin + out_link_size; }
|
||||
unsigned int out_size() { return out_link_size; }
|
||||
|
||||
Link *in_link_begin;
|
||||
unsigned int in_link_size;
|
||||
Link *out_link_begin;
|
||||
unsigned int out_link_size;
|
||||
Link *in_begin, *in_end;
|
||||
Link *out_begin, *out_end;
|
||||
};
|
||||
|
||||
Node *nodes;
|
||||
Link *in_links;
|
||||
Link *out_links;
|
||||
//TODO this list is really not necessary if we order our cells
|
||||
// unsigned int *frags;
|
||||
|
||||
std::vector<Update> updates;
|
||||
|
||||
|
@ -132,11 +112,10 @@ namespace nxs {
|
|||
int &n_nodes() { return ((int *)buffer)[1]; }
|
||||
int &n_in_links() { return ((int *)buffer)[2]; }
|
||||
int &n_out_links() { return ((int *)buffer)[3]; }
|
||||
// int &n_frags() { return ((int *)buffer)[4]; }
|
||||
|
||||
typedef Node *iterator;
|
||||
iterator begin() { return nodes; }
|
||||
iterator end() { return nodes + n_nodes(); }
|
||||
// typedef Node *iterator;
|
||||
// iterator begin() { return nodes; }
|
||||
// iterator end() { return nodes + n_nodes(); }
|
||||
protected:
|
||||
unsigned int size;
|
||||
char *buffer;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.6 2005/02/20 18:07:01 ponchio
|
||||
cleaning.
|
||||
|
||||
Revision 1.5 2005/02/19 16:22:45 ponchio
|
||||
Minor changes (visited and Cell)
|
||||
|
||||
|
@ -76,6 +79,9 @@ namespace nxs {
|
|||
if(culling) {
|
||||
float remote = frustum.Remoteness(sph.Center(), sph.Radius());
|
||||
if(remote > 0) {
|
||||
//TODO remoteness is bugged when the sphere is really close
|
||||
//FIX it!
|
||||
if(frustum.IsOutside(sph.Center(), sph.Radius()))
|
||||
visible = false;
|
||||
error /= remote;
|
||||
} else if(entry.cone.Backface(sph, frustum.ViewPoint())) {
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.34 2005/02/20 18:07:01 ponchio
|
||||
cleaning.
|
||||
|
||||
Revision 1.33 2005/02/20 00:43:23 ponchio
|
||||
Less memory x extraction. (removed frags)
|
||||
|
||||
|
@ -257,8 +260,11 @@ void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
|
|||
|
||||
|
||||
if(signature.vnorm && contest.attrs & DrawContest::NORMAL) {
|
||||
assert(signature.vnorm == Encodings::SHORT4);
|
||||
// assert(signature.vnorm == Encodings::SHORT4);
|
||||
if(signature.vnorm == Encodings::SHORT4)
|
||||
glNormalPointer(GL_SHORT, 8, nstart);
|
||||
else
|
||||
glNormalPointer(GL_FLOAT, 0, nstart);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.23 2005/02/20 18:07:01 ponchio
|
||||
cleaning.
|
||||
|
||||
Revision 1.22 2005/02/20 00:43:24 ponchio
|
||||
Less memory x extraction. (removed frags)
|
||||
|
||||
|
@ -584,10 +587,10 @@ void printInfo(Nexus &nexus, bool verbose, bool dump_history) {
|
|||
cout << "\n\tCompressed: " << nexus.IsCompressed()
|
||||
<< "\n\tStripped : "
|
||||
<< (int)(nexus.signature.face == Signature::STRIPS)
|
||||
<< "\n\tColor : " << (int)(nexus.signature.vcolor !=0)
|
||||
<< "\n\tNormal : " << (int)((nexus.signature.vnorm) !=0)
|
||||
<< "\n\tTexture : " << (int)((nexus.signature.vtext) !=0)
|
||||
<< "\n\tData : " << (int)((nexus.signature.vdata) !=0)
|
||||
<< "\n\tColor : " << (int)(nexus.signature.vcolor)
|
||||
<< "\n\tNormal : " << (int)(nexus.signature.vnorm)
|
||||
<< "\n\tTexture : " << (int)(nexus.signature.vtext)
|
||||
<< "\n\tData : " << (int)(nexus.signature.vdata)
|
||||
<< "\n\n\tVertices: " << nexus.totvert
|
||||
<< "\tFaces : " << nexus.totface
|
||||
<< "\tPatches : " << nexus.size()
|
||||
|
@ -604,21 +607,17 @@ void printInfo(Nexus &nexus, bool verbose, bool dump_history) {
|
|||
cout << "Quick format\n";
|
||||
for(unsigned int i = 0; i < nexus.history.n_nodes(); i++) {
|
||||
cout << "Node: " << i << " out: ";
|
||||
History::History::Node node = nexus.history.nodes[i];
|
||||
for(History::Node::iterator l = node.out_begin();
|
||||
l != node.out_end(); l++) {
|
||||
History::Node node = nexus.history.nodes[i];
|
||||
for(History::Link *l = node.out_begin; l != node.out_end; l++) {
|
||||
cout << ".";
|
||||
History::Link &link = *l;
|
||||
for(History::Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = l->begin; p != l->end; p++) {
|
||||
cout << p << " ";
|
||||
}
|
||||
}
|
||||
cout << " in: ";
|
||||
for(History::Node::iterator j = node.in_begin();
|
||||
j != node.in_end(); j++) {
|
||||
for(History::Link *j = node.in_begin; j != node.in_end; j++) {
|
||||
cout << ".";
|
||||
History::Link &link = *j;
|
||||
for(History::Link::iterator p = link.begin(); p != link.end(); p++) {
|
||||
for(unsigned int p = j->begin; p != j->end; p++) {
|
||||
cout << p << " ";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue