29 #include "../../../idlib/precompiled.h"
39 should we
try and snap
values very close to 0.5, 0.25, 0.125, etc?
41 do we write out normals, or just
a "smooth shade" flag?
42 resolved: normals. otherwise adjacent facet shaded surfaces
get their
43 vertexes merged, and they would have to be split apart before drawing
45 do we save out
"wings" for shadow silhouette info?
52 #define AREANUM_DIFFERENT -2
91 static void WriteFloat(
idFile *
f,
float v )
106 for ( i = 0; i <
x; i++ ) {
107 WriteFloat( f, m[i] );
123 for ( b = groups ; b !=
a ; b = b->
nextGroup ) {
149 #define XYZ_EPSILON 0.01
150 #define ST_EPSILON 0.001
151 #define COSINE_EPSILON 0.999
209 for ( step = tris ; step ; step = step->
next ) {
210 for ( i = 0 ; i < 3 ; i++ ) {
216 for ( j = 0 ; j < numVerts ; j++ ) {
217 if ( MatchVert( &uTri->
verts[j], dv ) ) {
221 if ( j == numVerts ) {
273 for ( i = 0 ; i < uTris->
numVerts ; i++ ) {
326 procFile->
WriteFloatString(
"/* numVerts = */ %i /* noCaps = */ %i /* noFrontCaps = */ %i /* numIndexes = */ %i /* planeBits = */ %i\n",
331 for ( i = 0 ; i < tri->
numVerts ; i++ ) {
382 static void WriteOutputSurfaces(
int entityNum,
int areaNum ) {
393 typedef struct interactionTris_s {
394 struct interactionTris_s *next;
399 interactionTris_t *interactions, *checkInter;
405 numSurfaces = CountUniqueShaders( area->
groups );
408 if ( entityNum == 0 ) {
409 procFile->
WriteFloatString(
"model { /* name = */ \"_area%i\" /* numSurfaces = */ %i\n\n",
410 areaNum, numSurfaces );
416 common->
Error(
"Entity %i has surfaces, but no name key", entityNum );
418 procFile->
WriteFloatString(
"model { /* name = */ \"%s\" /* numSurfaces = */ %i\n\n",
439 for ( groupStep = group ; groupStep ; groupStep = groupStep->
nextGroup ) {
443 if ( !GroupsAreSurfaceCompatible( group, groupStep ) ) {
454 for ( checkInter = interactions ; checkInter ; checkInter = checkInter->next ) {
455 if ( checkInter->light == groupStep->
groupLights[i] ) {
461 checkInter = (interactionTris_t *)
Mem_ClearedAlloc(
sizeof( *checkInter ) );
463 checkInter->next = interactions;
464 interactions = checkInter;
467 checkInter->triList =
MergeTriLists( checkInter->triList, copy );
475 if ( surfaceNum >= numSurfaces ) {
476 common->
Error(
"WriteOutputSurfaces: surfaceNum >= numSurfaces" );
486 CleanupUTriangles( uTri );
487 WriteUTriangles( uTri );
502 static void WriteNode_r(
node_t *node ) {
514 for ( i = 0 ; i < 2 ; i++ ) {
528 if ( child[0] > 0 ) {
531 if ( child[1] > 0 ) {
536 static int NumberNodes_r(
node_t *node,
int nextNumber ) {
542 nextNumber = NumberNodes_r( node->
children[0], nextNumber );
543 nextNumber = NumberNodes_r( node->
children[1], nextNumber );
553 static void WriteOutputNodes(
node_t *node ) {
558 numNodes = NumberNodes_r( node, 0 );
562 procFile->
WriteFloatString(
"/* node format is: ( planeVector ) positiveChild negativeChild */\n" );
563 procFile->
WriteFloatString(
"/* a child number of 0 is an opaque, solid area */\n" );
564 procFile->
WriteFloatString(
"/* negative child numbers are areas: (-1-child) */\n" );
576 static void WriteOutputPortals(
uEntity_t *e ) {
581 procFile->
WriteFloatString(
"interAreaPortals { /* numAreas = */ %i /* numIAP = */ %i\n\n",
583 procFile->
WriteFloatString(
"/* interAreaPortal format is: numPoints positiveSideArea negativeSideArea ( point) ... */\n" );
603 static void WriteOutputEntity(
int entityNum ) {
609 if ( entityNum != 0 ) {
616 for ( i = 0 ; i < e->
numAreas ; i++ ) {
617 WriteOutputSurfaces( entityNum, i );
621 if ( entityNum == 0 && e->
numAreas > 1 ) {
623 WriteOutputPortals( e );
663 WriteOutputEntity( i );
int numShadowIndexesNoFrontCaps
GLboolean GLenum GLenum GLvoid * values
void WriteOutputFile(void)
idList< mapLight_t * > mapLights
void FreeTree_r(node_t *node)
idFileSystem * fileSystem
#define AREANUM_DIFFERENT
const float * ToFloatPtr(void) const
void R_FreeStaticTriSurfSilIndexes(srfTriangles_t *tri)
const char * GetName(void) const
int PruneNodes_r(node_t *node)
srfTriangles_t * R_AllocStaticTriSurf(void)
void Write1DMatrix(idFile *f, int x, float *m)
mapLight_t * groupLights[MAX_GROUP_LIGHTS]
static float Rint(float f)
srfTriangles_t * shadowTris
mapTri_t * MergeTriLists(mapTri_t *a, mapTri_t *b)
void FreeTriList(mapTri_t *a)
void R_RemoveDegenerateTriangles(srfTriangles_t *tri)
struct optimizeGroup_s * groups
GLuint GLuint GLsizei count
int GetNumPoints(void) const
struct node_s * children[2]
const char * GetString(const char *key, const char *defaultString="") const
GLubyte GLubyte GLubyte GLubyte w
srfTriangles_t * ShareMapTriVerts(const mapTri_t *tris)
void FreeTreePortals_r(node_t *node)
mapTri_t * CopyTriList(const mapTri_t *a)
static float Fabs(float f)
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")=0
void R_FreeStaticTriSurf(srfTriangles_t *tri)
shadowCache_t * shadowVertexes
virtual int WriteFloatString(const char *fmt,...) id_attribute((format(printf
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
int numShadowIndexesNoCaps
const idMaterial * material
interAreaPortal_t interAreaPortals[MAX_INTER_AREA_PORTALS]
int CountTriList(const mapTri_t *list)
struct optimizeGroup_s * nextGroup
void * Mem_ClearedAlloc(const int size)
const char * c_str(void) const
const idMaterial * material
void R_AllocStaticTriSurfIndexes(srfTriangles_t *tri, int numIndexes)
dmapGlobals_t dmapGlobals
virtual void CloseFile(idFile *f)=0
void R_CreateSilIndexes(srfTriangles_t *tri)
virtual void Error(const char *fmt,...) id_attribute((format(printf
void R_AllocStaticTriSurfVerts(srfTriangles_t *tri, int numVerts)
void R_RangeCheckIndexes(const srfTriangles_t *tri)
int sprintf(idStr &string, const char *fmt,...)