28 #ifndef NO_GFX //Server cannot depend on GL, but still needs a mesh library.
31 #define GFX_BUFFER_MAP_UNMAP false
36 #define GFX_SCALE 1./1024.
47 if ((
sizeof(
GFXVertex) %
sizeof(
unsigned int)) != 0) {
48 return memcmp( a, b,
sizeof (
GFXVertex) ) < 0;
51 const unsigned int *ia =
reinterpret_cast<const unsigned int*
>(
a);
52 const unsigned int *ib =
reinterpret_cast<const unsigned int*
>(
b);
54 for (
size_t i=0;
i < (
sizeof(*a) /
sizeof(*ia)); ++
i) {
57 else if (ia[i] > ib[i])
70 std::map< GFXVertex*, int, VertexCompare >vtxcache;
72 *ind = (
unsigned int*) malloc(
sizeof (
unsigned int)*numV );
74 int _nnewV = *nnewV = 0;
76 bool quickpath =
true;
77 for (i = 0; i < numV; i++) {
78 std::map< GFXVertex*, int, VertexCompare >::const_iterator it = vtxcache.find( old+i );
79 if ( it != vtxcache.end() ) {
80 if (quickpath && i > 0) {
84 (*ind)[i] = it->second;
88 vtxcache[old+i] = ( (*ind)[i] ) = _nnewV;
92 if (quickpath && i > 0)
106 unsigned int *indices )
117 for (
int pol = 0; pol <
numlists; pol++) {
118 mode[pol] = poly[pol];
148 memcpy( this->offsets, offsets,
sizeof (
int)*numlists );
150 unsigned int numindices = 0;
152 numindices += offsets[i];
160 if (numVertices > 255)
162 if (numVertices > 65535)
165 index.
b = (
unsigned char*) malloc( stride*numindices );
170 for (
unsigned int i = 0; i < numindices; i++)
175 for (
unsigned int i = 0; i < numindices; i++)
180 for (
unsigned int i = 0; i < numindices; i++)
263 for (
int i = 0;
i < howmany;
i++)
283 float mag = firstNormal.Magnitude();
287 firstNormal.Set( 1, 0, 0 );
288 firstNormal.Normalize();
313 return (
changed&
sizeof (
unsigned char) )
315 : ( (
changed&
sizeof (
unsigned short) )
322 for (
int i = 0;
i < howmany;
i++) {
336 for (
int i = 0;
i < howmany;
i++) {
371 this->
Map(
true,
false );
387 int curquad = 3*(*numtris);
388 res = (
GFXVertex*) malloc( ( (*numtris)*3+4*( *numpolys-(*numtris) ) )*
sizeof (
GFXVertex) );
395 (*vtxcpy)(
this, &res[curtri], cur,
offsets[i]);
400 for (j = 1; j <
offsets[i]-1; j++) {
401 (*vtxcpy)(
this, &res[curtri++], cur, 1);
402 (*vtxcpy)(
this, &res[curtri++], (cur+j), 1);
403 (*vtxcpy)(
this, &res[curtri++], (cur+j+1), 1);
407 for (j = 2; j < offsets[i]; j += 2) {
408 (*vtxcpy)(
this, &res[curtri++], (cur+j-2), 1);
409 (*vtxcpy)(
this, &res[curtri++], (cur+j-1), 1);
410 (*vtxcpy)(
this, &res[curtri++], (cur+j), 1);
411 if (j+1 < offsets[i]) {
413 (*vtxcpy)(
this, &res[curtri++], (cur+j), 1);
414 (*vtxcpy)(
this, &res[curtri++], (cur+j-1), 1);
415 (*vtxcpy)(
this, &res[curtri++], (cur+j+1), 1);
420 (*vtxcpy)(
this, &res[curquad], (cur), offsets[i]);
421 curquad += offsets[i];
424 for (j = 2; j < offsets[i]-1; j += 2) {
425 (*vtxcpy)(
this, &res[curquad++], (cur+j-2), 1);
426 (*vtxcpy)(
this, &res[curquad++], (cur+j-1), 1);
427 (*vtxcpy)(
this, &res[curquad++], (cur+j+1), 1);
428 (*vtxcpy)(
this, &res[curquad++], (cur+j), 1);