Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quadsquare Class Reference

#include <quadsquare.h>

Public Member Functions

 quadsquare (quadcornerdata *pcd)
 
 ~quadsquare ()
 
void AddHeightMap (const quadcornerdata &cd, const HeightMapInfo &hm)
 Createsa lookup table for the terrain texture. More...
 
void AddHeightMapAux (const quadcornerdata &cd, const HeightMapInfo &hm)
 
void StaticCullData (const quadcornerdata &cd, float ThresholdDetail)
 
float RecomputeErrorAndLighting (const quadcornerdata &cd)
 
int CountNodes () const
 
void Update (const quadcornerdata &cd, const Vector &ViewerLocation, float Detail, unsigned short numstages, unsigned short whichstage, updateparity *whichordertoupdate)
 Make sure to translate into Quadtree Space. More...
 
int Render (const quadcornerdata &cd, const Vector &camera)
 
float GetHeight (const quadcornerdata &cd, float x, float z, Vector &normal)
 

Static Public Member Functions

static Vector MakeLightness (float xslope, float zslope, const Vector &loc)
 
static void SetCurrentTerrain (unsigned int *VertexAllocated, unsigned int *VertexCount, GFXVertexList *vertices, std::vector< unsigned int > *unusedvertices, IdentityTransform *transform, std::vector< TerrainTexture > *texturelist, const Vector &NormalScale, quadsquare *neighbor[4])
 

Public Attributes

quadsquareChild [4]
 
VertInfo Vertex [5]
 
unsigned short Error [6]
 
unsigned short MinY
 
unsigned short MaxY
 
unsigned char EnabledFlags
 
unsigned char SubEnabledCount [2]
 
bool Static
 
bool Dirty
 

Detailed Description

A node in the quad tree holds its own relevant vertex data (middle and either even or odd 4 sets of data (corners or diagonals Keeps track of its errors and children as well

Definition at line 113 of file quadsquare.h.

Constructor & Destructor Documentation

quadsquare::quadsquare ( quadcornerdata pcd)

Definition at line 100 of file quadsquare.cpp.

References GFXVertexList::BeginMutate(), Child, EnabledFlags, GFXVertexList::EndMutate(), Error, InterpolateTextures(), MaxY, MinY, GFXVertex::SetNormal(), quadcornerdata::Square, Static, SubEnabledCount, Vertex, GFXVertexList::VDAT::vertices, VertInfo::vertindex, quadcornerdata::Verts, VertInfo::Y, y, and AiXml::Y.

Referenced by AddHeightMapAux().

101 {
102  pcd->Square = this;
103  //Set static to true if/when this node contains real data, and
104  //not just interpolated values. When static == false, a node
105  //can be deleted by the Update() function if none of its
106  //vertices or children are enabled.
107  Static = false;
108  int i;
109  for (i = 0; i < 4; i++)
110  Child[i] = NULL;
111  EnabledFlags = 0;
112  for (i = 0; i < 2; i++)
113  SubEnabledCount[i] = 0;
114  //Set default vertex positions by interpolating from given corners.
115  //Just bilinear interpolation.
116  InterpolateTextures( Vertex, pcd->Verts, *pcd );
117  for (i = 0; i < 2; i++)
118  Error[i] = 0;
119  for (i = 0; i < 4; i++)
120  Error[i
121  +2] =
122  (unsigned short) (fabs( (double) ( (Vertex[0].Y
123  +pcd->Verts[i].Y)-(Vertex[i+1].Y+Vertex[( (i+1)&3 )+1].Y) ) )*0.25);
124  //Compute MinY/MaxY based on corner verts.
125  MinY = MaxY = (unsigned short) pcd->Verts[0].Y;
126  for (i = 1; i < 4; i++) {
127  float y = pcd->Verts[i].Y;
128  if (y < MinY) MinY = (unsigned short) y;
129  if (y > MaxY) MaxY = (unsigned short) y;
130  }
131  GFXVertex **vertexs = &(vertices->BeginMutate( 0 )->vertices);
132  GFXVertex v[5];
133  v[0].SetNormal( ( (*vertexs)[pcd->Verts[0].vertindex].GetNormal()+(*vertexs)[pcd->Verts[1].vertindex].GetNormal()
134  +(*vertexs)[pcd->Verts[2].vertindex].GetNormal()
135  +(*vertexs)[pcd->Verts[3].vertindex].GetNormal() ).Normalize() );
136  v[1].SetNormal(
137  ( (*vertexs)[pcd->Verts[0].vertindex].GetNormal()+(*vertexs)[pcd->Verts[3].vertindex].GetNormal() ).Normalize() );
138  v[2].SetNormal(
139  ( (*vertexs)[pcd->Verts[0].vertindex].GetNormal()+(*vertexs)[pcd->Verts[1].vertindex].GetNormal() ).Normalize() );
140  v[3].SetNormal(
141  ( (*vertexs)[pcd->Verts[1].vertindex].GetNormal()+(*vertexs)[pcd->Verts[2].vertindex].GetNormal() ).Normalize() );
142  v[4].SetNormal(
143  ( (*vertexs)[pcd->Verts[2].vertindex].GetNormal()+(*vertexs)[pcd->Verts[3].vertindex].GetNormal() ).Normalize() );
144  //FIXME fill in st!
145  for (i = 0; i < 5; i++) {
146  //v[i].y= Vertex[i].Y;
147  if ( unusedvertices->size() ) {
148  (*vertexs)[unusedvertices->back()] = v[i];
149  Vertex[i].vertindex = unusedvertices->back();
150  unusedvertices->pop_back();
151  } else {
152  Vertex[i].vertindex = *VertexCount;
153  if ( (*VertexCount)+1 >= (*VertexAllocated) ) {
154  (*VertexAllocated) *= 2;
155  (*vertexs) = (GFXVertex*) realloc( (*vertexs), (*VertexAllocated)*sizeof (GFXVertex) );
156  }
157  (*vertexs)[*VertexCount] = v[i];
158  (*VertexCount)++;
159  }
160  }
161  SetVertices( *vertexs, *pcd );
162  vertices->EndMutate( *VertexCount );
163  //interpolate from other vertices;
164 }
quadsquare::~quadsquare ( )

Definition at line 166 of file quadsquare.cpp.

References Child, Vertex, and VertInfo::vertindex.

167 {
168  //Recursively delete sub-trees.
169  int i;
170  for (i = 0; i < 5; i++)
171  unusedvertices->push_back( Vertex[i].vertindex );
172  for (i = 0; i < 4; i++) {
173  if (Child[i]) delete Child[i];
174  Child[i] = NULL;
175  }
176 }

Member Function Documentation

void quadsquare::AddHeightMap ( const quadcornerdata cd,
const HeightMapInfo hm 
)

Createsa lookup table for the terrain texture.

Definition at line 356 of file quadsquare.cpp.

References AddHeightMapAux().

357 {
358  unsigned int i;
359  memset( texturelookup, 0, sizeof (unsigned char)*256 );
360  for (i = 0; i < textures->size(); i++)
361  texturelookup[(*textures)[i].color] = i;
362  AddHeightMapAux( cd, hm );
363 }
void quadsquare::AddHeightMapAux ( const quadcornerdata cd,
const HeightMapInfo hm 
)

Definition at line 365 of file quadsquare.cpp.

References AddHeightMapAux(), GFXVertexList::BeginMutate(), Child, quadcornerdata::ChildIndex, Dirty, GFXVertexList::EndMutate(), int, quadcornerdata::Level, quadcornerdata::Parent, q, quadsquare(), HeightMapInfo::Sample(), HeightMapInfo::Scale, VertInfo::SetTex(), quadcornerdata::Square, Vertex, GFXVertexList::VDAT::vertices, quadcornerdata::xorg, HeightMapInfo::XOrigin, HeightMapInfo::XSize, VertInfo::Y, AiXml::Y, quadcornerdata::zorg, HeightMapInfo::ZOrigin, and HeightMapInfo::ZSize.

Referenced by AddHeightMap(), and AddHeightMapAux().

366 {
367 //Sets the height of all samples within the specified rectangular
368 //region using the given array of floats. Extends the tree to the
369 //level of detail defined by (1 << hm.Scale) as necessary.
370  //If block is outside rectangle, then don't bother.
371  int BlockSize = 2<<cd.Level;
372  if ( cd.xorg > hm.XOrigin+( (int) (hm.XSize+2)<<hm.Scale )
373  || cd.xorg+BlockSize < hm.XOrigin-(1<<hm.Scale)
374  || cd.zorg > hm.ZOrigin+( (int) (hm.ZSize+2)<<hm.Scale )
375  || cd.zorg+BlockSize < hm.ZOrigin-(1<<hm.Scale) )
376  //This square does not touch the given height array area; no need to modify this square or descendants.
377  return;
378  if (cd.Parent && cd.Parent->Square)
379  cd.Parent->Square->EnableChild( cd.ChildIndex, *cd.Parent ); //causes parent edge verts to be enabled, possibly causing neighbor blocks to be created.
380  int i;
381  int half = 1<<cd.Level;
382  //Create and update child nodes.
383  for (i = 0; i < 4; i++) {
385  SetupCornerData( &q, cd, i );
386  if (Child[i] == NULL && cd.Level > hm.Scale)
387  //Create child node w/ current (unmodified) values for corner verts.
388  Child[i] = new quadsquare( &q );
389  //Recurse.
390  if (Child[i])
391  Child[i]->AddHeightMapAux( q, hm );
392  }
393  //don't want to bother changing things if the sample won't change things :-)
394  int s[5];
395  float texture[5];
396  s[0] = (int) hm.Sample( cd.xorg+half, cd.zorg+half, texture[0] );
397  s[1] = (int) hm.Sample( cd.xorg+half*2, cd.zorg+half, texture[1] );
398  s[2] = (int) hm.Sample( cd.xorg+half, cd.zorg, texture[2] );
399  s[3] = (int) hm.Sample( cd.xorg, cd.zorg+half, texture[3] );
400  s[4] = (int) hm.Sample( cd.xorg+half, cd.zorg+half*2, texture[4] );
401  //Modify the vertex heights if necessary, and set the dirty
402  //flag if any modifications occur, so that we know we need to
403  //recompute error data later.
404  /*
405  * float pos[5];
406  * pos[0] = (cd.xorg + half+ cd.zorg + half);
407  * pos[1] = (cd.xorg + half*2+ cd.zorg + half);
408  * pos[2] = (cd.xorg + half+ cd.zorg);
409  * pos[3] = (cd.xorg+ cd.zorg + half);
410  * pos[4] = (cd.xorg + half+ cd.zorg + half*2);
411  *
412  */
413  for (i = 0; i < 5; i++) {
414  //Vertex[i].SetTex(((int)((pos[i])/5000))%10);
415  Vertex[i].SetTex( texture[i] );
416  if (s[i] != 0) {
417  Dirty = true;
418  if (Vertex[i].Y+s[i] > 0)
419  Vertex[i].Y += s[i];
420  else
421  Vertex[i].Y = 0;
422  //vertices[Vertex[i].vertindex].x = v[i].i;//FIXME are we necessary?
423  //vertices[Vertex[i].vertindex].z = v[i].k;
424  }
425  }
426  if (Dirty) {
427  GFXVertex *vertexs = vertices->BeginMutate( 0 )->vertices;
428  SetVertices( vertexs, cd );
429  vertices->EndMutate();
430  } else {
431  //Check to see if any child nodes are dirty, and set the dirty flag if so.
432  for (i = 0; i < 4; i++)
433  if (Child[i] && Child[i]->Dirty) {
434  Dirty = true;
435  break;
436  }
437  }
438  if (Dirty) SetStatic( cd );
439 }
int quadsquare::CountNodes ( ) const

Definition at line 193 of file quadsquare.cpp.

References Child, and CountNodes().

Referenced by CountNodes().

194 {
195 //Debugging function. Counts the number of nodes in this subtree.
196  int count = 1; //Count ourself.
197  //Count descendants.
198  for (int i = 0; i < 4; i++)
199  if (Child[i]) count += Child[i]->CountNodes();
200  return count;
201 }
float quadsquare::GetHeight ( const quadcornerdata cd,
float  x,
float  z,
Vector normal 
)

Returns the height of the heightfield at the specified x,z coordinates. Can be used for collision detection

iz = 1;

Definition at line 207 of file quadsquare.cpp.

References Child, GetHeight(), index, int, quadcornerdata::Level, q, Static, Vector, Vertex, quadcornerdata::Verts, quadcornerdata::xorg, VertInfo::Y, and quadcornerdata::zorg.

Referenced by QuadTree::GetGroundPos(), QuadTree::GetHeight(), and GetHeight().

208 {
209  int half = 1<<cd.Level;
210  float lx = (x-cd.xorg)/float(half);
211  float lz = (z-cd.zorg)/float(half);
212  int ix = (int) floor( lx );
213  int iz = (int) floor( lz );
214  //Clamp.
215  if (ix < 0) return -FLT_MAX; //ix = 0;
216  if (ix > 1) return -FLT_MAX; //ix = 1;
217  if (iz < 0) return -FLT_MAX; //iz = 0;
218  if (iz > 1) return -FLT_MAX;
219 
220  int index = ix^(iz^1)+(iz<<1); //FIXME gcc computes ix^((iz^1)+(iz<<1)).. Was this the intent? Who can understand this code?
221  if (Child[index] && Child[index]->Static) {
222  //Pass the query down to the child which contains it.
224  SetupCornerData( &q, cd, index );
225  return Child[index]->GetHeight( q, x, z, normal );
226  }
227  //Bilinear interpolation.
228  lx -= ix;
229  if (lx < 0) lx = 0;
230  if (lx > 1) lx = 1;
231  lz -= iz;
232  if (lx < 0) lz = 0; //FIXME did this mean to say "if (lz < 0) lz = 0;" ? It says "if (lx..."
233  if (lz > 1) lz = 1;
234  float s00, s01, s10, s11;
235  switch (index)
236  {
237  default:
238  case 0:
239  s00 = Vertex[2].Y;
240  s01 = cd.Verts[0].Y;
241  s10 = Vertex[0].Y;
242  s11 = Vertex[1].Y;
243  break;
244  case 1:
245  s00 = cd.Verts[1].Y;
246  s01 = Vertex[2].Y;
247  s10 = Vertex[3].Y;
248  s11 = Vertex[0].Y;
249  break;
250  case 2:
251  s00 = Vertex[3].Y;
252  s01 = Vertex[0].Y;
253  s10 = cd.Verts[2].Y;
254  s11 = Vertex[4].Y;
255  break;
256  case 3:
257  s00 = Vertex[0].Y;
258  s01 = Vertex[1].Y;
259  s10 = Vertex[4].Y;
260  s11 = cd.Verts[3].Y;
261  break;
262  }
263  normal = ( Vector( 0, s10-s00, half ) ).Cross( Vector( half, s01-s00, 0 ) );
264  return (s00*(1-lx)+s01*lx)*(1-lz)+(s10*(1-lx)+s11*lx)*lz;
265 }
Vector quadsquare::MakeLightness ( float  xslope,
float  zslope,
const Vector loc 
)
static

Definition at line 379 of file quadsquare_update.cpp.

References QVector, IdentityTransform::TransformNormal(), and Vector.

Referenced by RecomputeErrorAndLighting().

380 {
381  Vector tmp( nonlinear_trans->TransformNormal( loc.Cast(), QVector( -xslope, 1, -zslope ) ).Cast() );
382  tmp.Normalize();
383  return Vector( tmp.i*normalscale.i, tmp.j*normalscale.j, tmp.k*normalscale.k );
384 }
float quadsquare::RecomputeErrorAndLighting ( const quadcornerdata cd)

Recomputes the error values for this tree. Returns the max error. Also updates MinY & MaxY. Also computes quick & dirty vertex lighting for the demo.

Definition at line 392 of file quadsquare_update.cpp.

References GFXVertexList::BeginMutate(), Child, quadcornerdata::ChildIndex, Dirty, e, GFXVertexList::EndMutate(), Error, GFXVertex::GetConstVertex(), i, quadcornerdata::Level, MakeLightness(), MaxY, MinY, q, GFXVertex::SetNormal(), v, V, Vertex, GFXVertexList::VDAT::vertices, VertInfo::vertindex, quadcornerdata::Verts, VertInfo::Y, y, and AiXml::Y.

Referenced by StaticCullData().

393 {
394  int i;
395  //Measure error of center and edge vertices.
396  float maxerror = 0;
397  //Compute error of center vert.
398  float e;
399  if (cd.ChildIndex&1)
400  e = fabs( Vertex[0].Y-(cd.Verts[1].Y+cd.Verts[3].Y)*0.5 );
401  else
402  e = fabs( Vertex[0].Y-(cd.Verts[0].Y+cd.Verts[2].Y)*0.5 );
403  if (e > maxerror) maxerror = e;
404  //Initial min/max.
405  MaxY = (unsigned short) Vertex[0].Y;
406  MinY = (unsigned short) Vertex[0].Y;
407  //Check min/max of corners.
408  for (i = 0; i < 4; i++) {
409  float y = cd.Verts[i].Y;
410  if (y < MinY) MinY = (unsigned short) y;
411  if (y > MaxY) MaxY = (unsigned short) y;
412  }
413  //Edge verts.
414  e = fabs( Vertex[1].Y-(cd.Verts[0].Y+cd.Verts[3].Y)*0.5 );
415  if (e > maxerror) maxerror = e;
416  Error[0] = (unsigned short) e;
417  e = fabs( Vertex[4].Y-(cd.Verts[2].Y+cd.Verts[3].Y)*0.5 );
418  if (e > maxerror) maxerror = e;
419  Error[1] = (unsigned short) e;
420  //Min/max of edge verts.
421  for (i = 0; i < 4; i++) {
422  float y = Vertex[1+i].Y;
423  if (y < MinY) MinY = (unsigned short) y;
424  if (y > MaxY) MaxY = (unsigned short) y;
425  }
426  //Check child squares.
427  for (i = 0; i < 4; i++) {
429  if (Child[i]) {
430  SetupCornerData( &q, cd, i );
431  Error[i+2] = (unsigned short) Child[i]->RecomputeErrorAndLighting( q );
432  if (Child[i]->MinY < MinY) MinY = Child[i]->MinY;
433  if (Child[i]->MaxY > MaxY) MaxY = Child[i]->MaxY;
434  } else {
435  //Compute difference between bilinear average at child center, and diagonal edge approximation.
436  Error[i
437  +2] =
438  (unsigned short) (fabs( (double) ( (Vertex[0].Y
439  +cd.Verts[i].Y)-(Vertex[i+1].Y+Vertex[( (i+1)&3 )+1].Y) ) )*0.25);
440  }
441  if (Error[i+2] > maxerror) maxerror = Error[i+2];
442  }
443  //
444  //Compute quickie demo lighting.
445  //
446  float OneOverSize = 1.0/(2<<cd.Level);
447  GFXVertex *vertexs = vertices->BeginMutate( 0 )->vertices;
448  GFXVertex *V = &vertexs[Vertex[0].vertindex];
449  V->SetNormal( MakeLightness( (Vertex[1].Y-Vertex[3].Y)*OneOverSize,
450  (Vertex[4].Y-Vertex[2].Y)*OneOverSize,
451  V->GetConstVertex() ) );
452  float v;
453  quadsquare *s = GetFarNeighbor( 0, cd );
454  if (s)
455  v = s->Vertex[0].Y;
456  else
457  v = Vertex[1].Y;
458  V = &vertexs[Vertex[1].vertindex];
459  V->SetNormal( MakeLightness( (v-Vertex[0].Y)*OneOverSize,
460  (cd.Verts[3].Y-cd.Verts[0].Y)*OneOverSize,
461  V->GetConstVertex() ) );
462  s = GetFarNeighbor( 1, cd );
463  if (s)
464  v = s->Vertex[0].Y;
465  else
466  v = Vertex[2].Y;
467  V = &vertexs[Vertex[2].vertindex];
468  V->SetNormal( MakeLightness( (cd.Verts[0].Y-cd.Verts[1].Y)*OneOverSize,
469  (Vertex[0].Y-v)*OneOverSize,
470  V->GetConstVertex() ) );
471  s = GetFarNeighbor( 2, cd );
472  if (s)
473  v = s->Vertex[0].Y;
474  else
475  v = Vertex[3].Y;
476  V = &vertexs[Vertex[3].vertindex];
477  V->SetNormal( MakeLightness( (Vertex[0].Y-v)*OneOverSize,
478  (cd.Verts[2].Y-cd.Verts[1].Y)*OneOverSize,
479  V->GetConstVertex() ) );
480  s = GetFarNeighbor( 3, cd );
481  if (s)
482  v = s->Vertex[0].Y;
483  else
484  v = Vertex[4].Y;
485  V = &vertexs[Vertex[4].vertindex];
486  V->SetNormal( MakeLightness( (cd.Verts[3].Y-cd.Verts[2].Y)*OneOverSize,
487  (v-Vertex[0].Y)*OneOverSize,
488  V->GetConstVertex() ) );
489  vertices->EndMutate();
490  //The error, MinY/MaxY, and lighting values for this node and descendants are correct now.
491  Dirty = false;
492  return maxerror;
493 }
int quadsquare::Render ( const quadcornerdata cd,
const Vector camvec 
)

Draws the heightfield represented by this tree Returns teh number of triangles rendered (not including multipass

Definition at line 40 of file quadsquare_render.cpp.

References AMBIENT, GFXVertexList::BeginDrawState(), GFXVertexList::BeginMutate(), GFXVertexList::VDAT::colors, DIFFUSE, GFXVertexList::Draw(), GFXVertexList::EndDrawState(), GFXVertexList::EndMutate(), GFX_PARTIALLY_VISIBLE, GFXColorMaterial(), GFXFALSE, GFXPolygonOffset(), GFXTRI, i, j, k, GFXVertexList::LoadDrawState(), TerrainMakeActive(), TerrainMakeClearActive(), and TerrainMakeDeactive().

Referenced by QuadTree::Render().

41 {
42  quadsquare::camerapos = camvec;
43  vertices->LoadDrawState();
44  vertices->BeginDrawState( GFXFALSE );
45  int totsize = 0;
46  RenderAux( cd, GFX_PARTIALLY_VISIBLE );
47  vecTextureIndex::iterator i = indices.begin();
48  vecTextureStar::iterator k;
49  for (k = textures->begin(); k != textures->end(); i++, k++) {
50  TerrainMakeActive( *k );
51  unsigned int isize = (*i).q.size();
52  totsize += isize;
53  vertices->Draw( GFXTRI, isize, (*i).q.begin() );
54  TerrainMakeDeactive( *k );
55  }
56  vertices->EndDrawState();
57  i = indices.begin();
58  int j = 0;
59  for (k = textures->begin(); k != textures->end(); i++, j++, k++) {
60  if ( (*i).c.size() > 2 ) {
62  GFXPolygonOffset( 0, -j );
64  GFXColorVertex **cv = (&blendVertices->BeginMutate( 0 )->colors);
65  GFXColorVertex *tmp = *cv;
66  *cv = (*i).c.begin();
67  blendVertices->EndMutate( (*i).c.size() );
68  blendVertices->LoadDrawState();
69  blendVertices->BeginDrawState( GFXFALSE );
70  blendVertices->Draw( GFXTRI, (*i).c.size() );
71  blendVertices->EndDrawState( GFXFALSE );
72  cv = (&blendVertices->BeginMutate( 0 )->colors);
73  *cv = tmp;
74  blendVertices->EndMutate( 3 );
75  GFXColorMaterial( 0 );
76  GFXPolygonOffset( 0, 0 );
77  TerrainMakeDeactive( *k );
78  }
79  (*i).Clear();
80  }
81  return totsize;
82 }
void quadsquare::SetCurrentTerrain ( unsigned int VertexAllocated,
unsigned int VertexCount,
GFXVertexList vertices,
std::vector< unsigned int > *  unusedvertices,
IdentityTransform transform,
std::vector< TerrainTexture > *  texturelist,
const Vector NormalScale,
quadsquare neighbor[4] 
)
static

Definition at line 325 of file quadsquare.cpp.

References GFXTRI.

Referenced by QuadTree::QuadTree(), QuadTree::Render(), and QuadTree::Update().

333 {
334  normalscale = NormScale;
335  neighbor[0] = neighbors[0];
336  neighbor[1] = neighbors[1];
337  neighbor[2] = neighbors[2];
338  neighbor[3] = neighbors[3];
339  if (quadsquare::blendVertices == NULL) {
340  GFXColorVertex tmp[3];
341  blendVertices = new GFXVertexList( GFXTRI, 3, tmp, 3, true );
342  }
343  quadsquare::VertexAllocated = VertexAllocated;
344  quadsquare::VertexCount = VertexCount;
345  quadsquare::vertices = vertices;
346  quadsquare::unusedvertices = unvert;
347  nonlinear_trans = nlt;
348  textures = tex;
349  if ( indices.size() < tex->size() )
350  while ( indices.size() < tex->size() )
351  indices.push_back( TextureIndex() );
352 }
void quadsquare::StaticCullData ( const quadcornerdata cd,
float  ThresholdDetail 
)

Definition at line 21 of file quadsquare_cull.cpp.

References Dirty, BeamXML::level, and RecomputeErrorAndLighting().

Referenced by QuadTree::StaticCullData().

22 {
23 //Examine the tree and remove nodes which don't contain necessary
24 //detail. Necessary detail is defined as vertex data with a
25 //edge-length to height ratio less than ThresholdDetail.
26  //First, clean non-static nodes out of the tree.
27  ResetTree();
28  //Make sure error values are up-to-date.
30  //Recursively check all the nodes and do necessary removal.
31  //We must start at the bottom of the tree, and do one level of
32  //the tree at a time, to ensure the dependencies are accounted
33  //for properly.
34  int level;
35  for (level = 0; level < 15; level++)
36  StaticCullAux( cd, ThresholdDetail, level );
37 }
void quadsquare::Update ( const quadcornerdata cd,
const Vector ViewerLocation,
float  Detail,
unsigned short  numstages,
unsigned short  whichstage,
updateparity par 
)

Make sure to translate into Quadtree Space.

Refresh the vertex enabled states in the tree, according to the location of the viewer. May force creation or deletion of qsquares in areas which need to be interpolated.

Definition at line 266 of file quadsquare_update.cpp.

References calculatestage(), and transformstage().

Referenced by QuadTree::Update().

272 {
273  DetailThreshold = Detail;
274  UpdateAux( cd, ViewerLocation, 0, transformstage( calculatestage( numstages, whichstage ), par ) );
275 }

Member Data Documentation

quadsquare* quadsquare::Child[4]
bool quadsquare::Dirty

Definition at line 123 of file quadsquare.h.

Referenced by AddHeightMapAux(), RecomputeErrorAndLighting(), and StaticCullData().

unsigned char quadsquare::EnabledFlags

Definition at line 120 of file quadsquare.h.

Referenced by quadsquare().

unsigned short quadsquare::Error[6]

Definition at line 118 of file quadsquare.h.

Referenced by quadsquare(), and RecomputeErrorAndLighting().

unsigned short quadsquare::MaxY

Definition at line 119 of file quadsquare.h.

Referenced by quadsquare(), and RecomputeErrorAndLighting().

unsigned short quadsquare::MinY

Definition at line 119 of file quadsquare.h.

Referenced by quadsquare(), and RecomputeErrorAndLighting().

bool quadsquare::Static

Definition at line 122 of file quadsquare.h.

Referenced by GetHeight(), and quadsquare().

unsigned char quadsquare::SubEnabledCount[2]

Definition at line 121 of file quadsquare.h.

Referenced by quadsquare().

VertInfo quadsquare::Vertex[5]

The documentation for this class was generated from the following files: