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_update.cpp File Reference
#include "quadsquare.h"

Go to the source code of this file.

Functions

bool VertexTest (float x, float y, float z, float error, const Vector &Viewer)
 
bool BoxTest (float x, float z, float size, float miny, float maxy, float error, const Vector &Viewer)
 
static unsigned int calculatestage (unsigned int numstages, unsigned int whichstage)
 
static unsigned int transformstage (unsigned int stage, updateparity *updateorder)
 transforms our stages to little endian notation so most significant half-byte is on the right :-) More...
 
int identityparity (int i)
 
int sideparityodd (int i)
 
int upparityodd (int i)
 
int sideupparityodd (int i)
 
Vector Normalise (const Vector &vec, const float scale)
 

Variables

int MaxCreateDepth = 0
 
static float DetailThreshold = 100
 

Function Documentation

bool BoxTest ( float  x,
float  z,
float  size,
float  miny,
float  maxy,
float  error,
const Vector Viewer 
)

Definition at line 138 of file quadsquare_update.cpp.

References d, and miny.

139 {
140 //Returns true if any vertex within the specified box (origin at x,z,
141 //edges of length size) with the given error value could be enabled
142 //based on the given viewer location.
143  //Find the minimum distance to the box.
144  float half = size*0.5;
145  float dx = fabs( x+half-Viewer.i )-half;
146  float dy = fabs( (miny+maxy)*0.5-Viewer.j )-(maxy-miny)*0.5;
147  float dz = fabs( z+half-Viewer.k )-half;
148  float d = dx;
149  if (dy > d) d = dy;
150  if (dz > d) d = dz;
151  return (error*DetailThreshold) > d;
152 }
static unsigned int calculatestage ( unsigned int  numstages,
unsigned int  whichstage 
)
static

calculates the bitmasks for which children to do and not to do Tries to preserve some locality for 16 the results are Stage 0 Number: 00000000000000000000000000010001 Stage 1 Number: 00000000000000000000000000010010 Stage 2 Number: 00000000000000000000000000010100 Stage 3 Number: 00000000000000000000000000011000 Stage 4 Number: 00000000000000000000000000100001 Stage 5 Number: 00000000000000000000000000100010 Stage 6 Number: 00000000000000000000000000100100 Stage 7 Number: 00000000000000000000000000101000 Stage 8 Number: 00000000000000000000000001000001 Stage 9 Number: 00000000000000000000000001000010 Stage 0 Number: 00000000000000000000000001000100 Stage 1 Number: 00000000000000000000000001001000 Stage 2 Number: 00000000000000000000000010000001 Stage 3 Number: 00000000000000000000000010000010 Stage 4 Number: 00000000000000000000000010000100 Stage 5 Number: 00000000000000000000000010001000

Definition at line 174 of file quadsquare_update.cpp.

Referenced by quadsquare::Update().

175 {
176  unsigned int stage = 0;
177  int count = 0;
178  numstages -= 1;
179  while (numstages) {
180  int tmp = 1<<(whichstage%4);
181  stage += ( tmp<<( (count++)*4 ) );
182  whichstage /= 4;
183  numstages /= 4;
184  }
185  return stage;
186 }
int identityparity ( int  i)

Definition at line 201 of file quadsquare_update.cpp.

202 {
203  return i;
204 }
Vector Normalise ( const Vector vec,
const float  scale 
)
inline

Definition at line 374 of file quadsquare_update.cpp.

375 {
376  return vec*( scale/vec.Magnitude() );
377 }
int sideparityodd ( int  i)

Definition at line 206 of file quadsquare_update.cpp.

207 {
208  switch (i)
209  {
210  case 1:
211  return 2;
212 
213  case 2:
214  return 1;
215 
216  case 4:
217  return 8;
218 
219  case 8:
220  return 4;
221  }
222  return 0;
223 }
int sideupparityodd ( int  i)

Definition at line 244 of file quadsquare_update.cpp.

245 {
246  switch (i)
247  {
248  case 8:
249  return 1;
250 
251  case 4:
252  return 2;
253 
254  case 2:
255  return 4;
256 
257  case 1:
258  return 8;
259  }
260  return 0;
261 }
static unsigned int transformstage ( unsigned int  stage,
updateparity updateorder 
)
static

transforms our stages to little endian notation so most significant half-byte is on the right :-)

Definition at line 189 of file quadsquare_update.cpp.

Referenced by quadsquare::Update().

190 {
191  int tmp;
192  unsigned int transformedstage = 0;
193  while ( ( tmp = ( stage&(1|2|4|8) ) ) != 0 ) {
194  stage >>= 4;
195  transformedstage <<= 4;
196  transformedstage |= ( (*updateorder)(tmp) );
197  }
198  return transformedstage;
199 }
int upparityodd ( int  i)

Definition at line 225 of file quadsquare_update.cpp.

226 {
227  switch (i)
228  {
229  case 1:
230  return 4;
231 
232  case 2:
233  return 8;
234 
235  case 4:
236  return 1;
237 
238  case 8:
239  return 2;
240  }
241  return 0;
242 }
bool VertexTest ( float  x,
float  y,
float  z,
float  error,
const Vector Viewer 
)

Definition at line 124 of file quadsquare_update.cpp.

References d.

125 {
126 //Returns true if the vertex at (x,z) with the given world-space error between
127 //its interpolated location and its true location, should be enabled, given that
128 //the viewpoint is located at Viewer[].
129  float dx = fabs( x-Viewer.i );
130  float dy = fabs( y-Viewer.j );
131  float dz = fabs( z-Viewer.k );
132  float d = dx;
133  if (dy > d) d = dy;
134  if (dz > d) d = dz;
135  return (error*DetailThreshold) > d;
136 }

Variable Documentation

float DetailThreshold = 100
static

Definition at line 122 of file quadsquare_update.cpp.

int MaxCreateDepth = 0

Definition at line 2 of file quadsquare_update.cpp.