28 #include "../idlib/precompiled.h"
56 for ( i = 0 ; i < numIndexes ; i++ ) {
59 if ( inCache[ ( fifo + j ) % CACHE_SIZE ] == v ) {
63 if ( j == CACHE_SIZE ) {
108 oldIndexes = (
glIndex_t *)_alloca( numIndexes *
sizeof( *oldIndexes ) );
109 memcpy( oldIndexes, indexes, numIndexes *
sizeof( *oldIndexes ) );
110 numOldIndexes = numIndexes;
113 numTris = numIndexes / 3;
114 triangleUsed = (
bool *)_alloca( numTris *
sizeof( *triangleUsed ) );
115 memset( triangleUsed, 0, numTris *
sizeof( *triangleUsed ) );
119 for ( i = 0 ; i < numIndexes ; i++ ) {
120 if ( indexes[i] > numVerts ) {
121 numVerts = indexes[
i];
127 vrefs = (
vertRef_t **)_alloca( numVerts *
sizeof( *vrefs ) );
128 memset( vrefs, 0, numVerts *
sizeof( *vrefs ) );
130 vrefTable = (
vertRef_t *)_alloca( numIndexes *
sizeof( *vrefTable ) );
131 for ( i = 0 ; i < numIndexes ; i++ ) {
135 vrefTable[
i].
next = vrefs[oldIndexes[
i]];
136 vrefs[oldIndexes[
i]] = &vrefTable[
i];
142 while ( numIndexes != numOldIndexes ) {
144 for ( tri = 0 ; tri < numTris ; tri++ ) {
145 if ( !triangleUsed[tri] ) {
149 if ( tri == numTris ) {
150 common->
Error(
"R_OrderIndexes: ran out of unused tris" );
157 base = oldIndexes + tri * 3;
158 indexes[numIndexes+0] = base[0];
159 indexes[numIndexes+1] = base[1];
160 indexes[numIndexes+2] = base[2];
163 triangleUsed[
tri] =
true;
166 for ( i = 0 ; i < 3 ; i++ ) {
170 for ( vref = vrefs[v1] ; vref ; vref = vref->
next ) {
172 if ( triangleUsed[tri] ) {
177 if ( oldIndexes[tri*3+0] == v2
178 || oldIndexes[tri*3+1] == v2
179 || oldIndexes[tri*3+2] == v2 ) {
struct vertRef_s vertRef_t
idCVar r_orderIndexes("r_orderIndexes","1", CVAR_RENDERER|CVAR_BOOL,"perform index reorganization to optimize vertex use")
GLfloat GLfloat GLfloat v2
void R_OrderIndexes(int numIndexes, glIndex_t *indexes)
virtual void Error(const char *fmt,...) id_attribute((format(printf
int R_MeshCost(int numIndexes, glIndex_t *indexes)