22 Nov 2008

This commit is contained in:
g-cont 2008-11-22 00:00:00 +03:00 committed by Alibek Omarov
parent 1e2c53dd36
commit 7e4a152091
36 changed files with 1821 additions and 766 deletions

16
baserc/baserc.plg Normal file
View File

@ -0,0 +1,16 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: baserc - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
<h3>Results</h3>
baserc.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -309,31 +309,6 @@ bspbrush_t *CopyBrush (bspbrush_t *brush)
return newbrush;
}
/*
==================
PointInLeaf
==================
*/
node_t *PointInLeaf (node_t *node, vec3_t point)
{
vec_t d;
plane_t *plane;
while (node->planenum != PLANENUM_LEAF)
{
plane = &mapplanes[node->planenum];
d = DotProduct (point, plane->normal) - plane->dist;
if (d > 0)
node = node->children[0];
else
node = node->children[1];
}
return node;
}
//========================================================
/*
@ -600,7 +575,7 @@ void LeafNode( node_t *node, bspbrush_t *brushes )
for (i=0 ; i<b->numsides ; i++)
if (b->sides[i].texinfo != TEXINFO_NODE)
break;
if (i == b->numsides)
if (i == b->numsides )
{
node->contents = CONTENTS_SOLID;
break;

View File

@ -8,6 +8,9 @@
#include "byteorder.h"
#include "const.h"
#define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
#define ENTRYSIZE(a) (sizeof(*(a)))
//=============================================================================
wfile_t *handle;
file_t *wadfile;
@ -58,75 +61,76 @@ dareaportal_t dareaportals[MAX_MAP_AREAPORTALS];
byte dcollision[MAX_MAP_COLLISION];
int dcollisiondatasize;
/*
===============
CompressVis
===============
*/
int CompressVis( byte *vis, byte *dest )
{
int j;
int rep;
int visrow;
byte *dest_p;
dest_p = dest;
visrow = (dvis->numclusters + 7)>>3;
for (j=0 ; j<visrow ; j++)
{
*dest_p++ = vis[j];
if (vis[j])
continue;
rep = 1;
for ( j++; j<visrow ; j++)
if (vis[j] || rep == 255)
break;
else rep++;
*dest_p++ = rep;
j--;
}
return dest_p - dest;
}
/*
===================
DecompressVis
===================
*/
void DecompressVis( byte *in, byte *decompressed )
{
int c;
byte *out;
int row;
row = (dvis->numclusters+7)>>3;
out = decompressed;
do
{
if (*in)
{
*out++ = *in++;
continue;
}
c = in[1];
if (!c) Sys_Error("DecompressVis: 0 repeat");
in += 2;
while (c)
{
*out++ = 0;
c--;
}
} while (out - decompressed < row);
}
//=============================================================================
size_t ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
{
float percentage = maxitems ? items * 100.0 / maxitems : 0.0;
MsgDev( D_INFO, "%-12s %7i/%-7i %7i/%-7i (%4.1f%%)", szItem, items, maxitems, items * itemsize, maxitems * itemsize, percentage );
if( percentage > 80.0 ) MsgDev( D_INFO, "VERY FULL!\n" );
else if( percentage > 95.0 ) MsgDev( D_INFO, "SIZE DANGER!\n" );
else if( percentage > 99.9 ) MsgDev( D_INFO, "SIZE OVERFLOW!!!\n" );
else MsgDev( D_INFO, "\n" );
return items * itemsize;
}
size_t GlobUsage( char *szItem, int itemstorage, int maxstorage )
{
float percentage = maxstorage ? itemstorage * 100.0 / maxstorage : 0.0;
MsgDev( D_INFO, "%-12s [variable] %7i/%-7i (%4.1f%%)", szItem, itemstorage, maxstorage, percentage );
if( percentage > 80.0 ) MsgDev( D_INFO, "VERY FULL!\n" );
else if( percentage > 95.0 ) MsgDev( D_INFO, "SIZE DANGER!\n" );
else if( percentage > 99.9 ) MsgDev( D_INFO, "SIZE OVERFLOW!!!\n" );
else MsgDev( D_INFO, "\n" );
return itemstorage;
}
/*
=============
PrintBSPFileSizes
Dumps info about current file
=============
*/
void PrintBSPFileSizes( void )
{
int totalmemory = 0;
MsgDev( D_INFO, "\n" );
MsgDev( D_INFO, "Object names Objects/Maxobjs Memory / Maxmem Fullness\n" );
MsgDev( D_INFO, "------------ --------------- --------------- --------\n" );
// struct arrays
totalmemory += ArrayUsage( "shaders", numshaders, ENTRIES( dshaders ), ENTRYSIZE( dshaders ));
totalmemory += ArrayUsage( "planes", numplanes, ENTRIES( dplanes ), ENTRYSIZE( dplanes ));
totalmemory += ArrayUsage( "leafs", numleafs, ENTRIES( dleafs ), ENTRYSIZE( dleafs ));
totalmemory += ArrayUsage( "leaffaces", numleafsurfaces, ENTRIES( dleafsurfaces ), ENTRYSIZE( dleafsurfaces ));
totalmemory += ArrayUsage( "leafbrushes", numleafbrushes, ENTRIES( dleafbrushes ), ENTRYSIZE( dleafbrushes ));
totalmemory += ArrayUsage( "nodes", numnodes, ENTRIES( dnodes ), ENTRYSIZE( dnodes ));
totalmemory += ArrayUsage( "vertexes", numvertexes, ENTRIES( dvertexes ), ENTRYSIZE( dvertexes ));
totalmemory += ArrayUsage( "edges", numedges, ENTRIES( dedges ), ENTRYSIZE( dedges ));
totalmemory += ArrayUsage( "surfedges", numsurfedges, ENTRIES( dsurfedges ), ENTRYSIZE( dsurfedges ));
totalmemory += ArrayUsage( "texinfos", numtexinfo, ENTRIES( texinfo ), ENTRYSIZE( texinfo ));
totalmemory += ArrayUsage( "surfaces", numsurfaces, ENTRIES( dsurfaces ), ENTRYSIZE( dsurfaces ));
totalmemory += ArrayUsage( "models", nummodels, ENTRIES( dmodels ), ENTRYSIZE( dmodels ));
totalmemory += ArrayUsage( "brushes", numbrushes, ENTRIES( dbrushes ), ENTRYSIZE( dbrushes ));
totalmemory += ArrayUsage( "brushsides", numbrushsides, ENTRIES( dbrushsides ), ENTRYSIZE( dbrushsides ));
totalmemory += ArrayUsage( "areas", numareas, ENTRIES( dareas ), ENTRYSIZE( dareas ));
totalmemory += ArrayUsage( "areaportals", numareaportals, ENTRIES( dareaportals ), ENTRYSIZE( dareaportals ));
// byte arrays
totalmemory += GlobUsage( "entities", entdatasize, sizeof( dentdata ));
totalmemory += GlobUsage( "lightdata", lightdatasize, sizeof( dlightdata ));
totalmemory += GlobUsage( "visdata", visdatasize, sizeof( dvisdata ));
totalmemory += GlobUsage( "collision", dcollisiondatasize, sizeof( dcollision ));
MsgDev( D_INFO, "=== Total BSP file data space used: %d bytes ===\n", totalmemory );
}
/*
=============

137
common/bsplib/bsplib.c Normal file
View File

@ -0,0 +1,137 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// bsplib.c - bsp level creator
//=======================================================================
#include "bsplib.h"
byte *checkermate_dds;
size_t checkermate_dds_size;
char path[MAX_SYSPATH];
uint bsp_parms;
dll_info_t physic_dll = { "physic.dll", NULL, "CreateAPI", NULL, NULL, false, sizeof(physic_exp_t) };
physic_exp_t *pe;
static void AddCollision( void* handle, const void* buffer, size_t size )
{
if((dcollisiondatasize + size) > MAX_MAP_COLLISION )
Sys_Error( "MAX_MAP_COLLISION limit exceeded\n" );
Mem_Copy( dcollision + dcollisiondatasize, (void *)buffer, size );
dcollisiondatasize += size;
}
void ProcessCollisionTree( void )
{
if( !physic_dll.link ) return;
dcollisiondatasize = 0;
pe->WriteCollisionLump( NULL, AddCollision );
}
void Init_PhysicsLibrary( void )
{
static physic_imp_t pi;
launch_t CreatePhysic;
pi.api_size = sizeof(physic_imp_t);
Sys_LoadLibrary( &physic_dll );
if( physic_dll.link )
{
CreatePhysic = (void *)physic_dll.main;
pe = CreatePhysic( &com, &pi ); // sys_error not overrided
pe->Init(); // initialize phys callback
}
else Mem_Set( &pe, 0, sizeof( pe ));
}
void Free_PhysicLibrary( void )
{
if( physic_dll.link )
{
pe->Shutdown();
Mem_Set( &pe, 0, sizeof( pe ));
}
Sys_FreeLibrary( &physic_dll );
}
bool PrepareBSPModel( const char *dir, const char *name )
{
int numshaders;
bsp_parms = 0;
// get global parms
if( FS_CheckParm( "-vis" )) bsp_parms |= BSPLIB_MAKEVIS;
if( FS_CheckParm( "-qrad" )) bsp_parms |= BSPLIB_MAKEQ2RAD;
if( FS_CheckParm( "-hlrad" )) bsp_parms |= BSPLIB_MAKEHLRAD;
if( FS_CheckParm( "-full" )) bsp_parms |= BSPLIB_FULLCOMPILE;
if( FS_CheckParm( "-onlyents" )) bsp_parms |= BSPLIB_ONLYENTS;
// famous q1 "notexture" image: purple-black checkerboard
checkermate_dds = FS_LoadInternal( "checkerboard.dds", &checkermate_dds_size );
Image_Init( NULL, IL_ALLOW_OVERWRITE|IL_IGNORE_MIPS );
// merge parms
if( bsp_parms & BSPLIB_ONLYENTS )
{
bsp_parms = (BSPLIB_ONLYENTS|BSPLIB_MAKEBSP);
}
else
{
if( bsp_parms & BSPLIB_MAKEQ2RAD && bsp_parms & BSPLIB_MAKEHLRAD )
{
MsgDev( D_WARN, "both type 'hlrad' and 'qrad' specified\ndefaulting to 'qrad'\n" );
bsp_parms &= ~BSPLIB_MAKEHLRAD;
}
if( bsp_parms & BSPLIB_FULLCOMPILE )
{
if((bsp_parms & BSPLIB_MAKEVIS) && (bsp_parms & (BSPLIB_MAKEQ2RAD|BSPLIB_MAKEHLRAD)))
{
bsp_parms |= BSPLIB_MAKEBSP; // rebuild bsp file for final compile
bsp_parms |= BSPLIB_DELETE_TEMP;
}
}
if(!(bsp_parms & (BSPLIB_MAKEVIS|BSPLIB_MAKEQ2RAD|BSPLIB_MAKEHLRAD)))
{
// -vis -light or -rad not specified, just create a .bsp
bsp_parms |= BSPLIB_MAKEBSP;
}
}
FS_LoadGameInfo( "gameinfo.txt" ); // same as normal gamemode
Init_PhysicsLibrary();
numshaders = LoadShaderInfo();
Msg( "%5i shaderInfo\n", numshaders );
return true;
}
bool CompileBSPModel ( void )
{
// now run specified utils
if( bsp_parms & BSPLIB_MAKEBSP )
WbspMain();
if( bsp_parms & BSPLIB_MAKEVIS )
WvisMain();
if( bsp_parms & (BSPLIB_MAKEQ2RAD|BSPLIB_MAKEHLRAD))
WradMain();
Free_PhysicLibrary();
PrintBSPFileSizes();
if( bsp_parms & BSPLIB_DELETE_TEMP )
{
// delete all temporary files after final compile
com.sprintf( path, "%s/maps/%s.prt", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.lin", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.log", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
}
return true;
}

View File

@ -37,21 +37,29 @@ enum
#define MAX_TEXTURE_FRAMES 256
#define MAX_PATCHES 65000 // larger will cause 32 bit overflows
extern bool full_compile;
// compile parms
typedef enum
{
BSPLIB_MAKEBSP = BIT(0), // create a bsp file
BSPLIB_MAKEVIS = BIT(1), // do visibility
BSPLIB_MAKEHLRAD = BIT(2), // do half-life radiosity
BSPLIB_MAKEQ2RAD = BIT(3), // do quake2 radiosity
BSPLIB_FULLCOMPILE = BIT(4), // equals -full for vis, -extra for rad or light
BSPLIB_ONLYENTS = BIT(5), // update only ents lump
BSPLIB_RAD_NOPVS = BIT(6), // ignore pvs while processing radiocity (kill smooth light)
BSPLIB_RAD_NOBLOCK = BIT(7),
BSPLIB_RAD_NOCOLOR = BIT(8),
BSPLIB_DELETE_TEMP = BIT(9), // delete itermediate files
} bsplibFlags_t;
extern bool onlyents;
extern bool onlyvis;
extern bool onlyrad;
extern uint bsp_parms;
extern physic_exp_t *pe;
// parms
extern bool noblock;
extern bool nocolor;
extern char path[MAX_SYSPATH];
// bsplib export functions
void WradMain ( bool option );
void WvisMain ( bool option );
void WbspMain ( bool option );
void WradMain( void );
void WvisMain( void );
void WbspMain( void );
typedef struct plane_s
{
@ -325,7 +333,7 @@ long IntForKey( const bsp_entity_t *ent, const char *key );
void GetVectorForKey( const bsp_entity_t *ent, const char *key, vec3_t vec );
bsp_entity_t *FindTargetEntity( const char *target );
epair_t *ParseEpair( token_t *token );
void PrintBSPFileSizes( void );
extern int entity_num;
extern int g_mapversion;
@ -385,6 +393,11 @@ void WriteBSPFile ( void );
void DecompressVis (byte *in, byte *decompressed);
int CompressVis (byte *vis, byte *dest);
//=============================================================================
// bsplib.c
void ProcessCollisionTree( void );
//=============================================================================
// textures.c
@ -393,8 +406,6 @@ int TexinfoForBrushTexture( plane_t *plane, brush_texture_t *bt, vec3_t origin )
//=============================================================================
void FindGCD (int *v);
mapbrush_t *Brush_LoadEntity (bsp_entity_t *ent);
int PlaneTypeForNormal (vec3_t normal);
bool MakeBrushPlanes (mapbrush_t *b);
@ -558,8 +569,10 @@ void PortalFlow (int portalnum);
extern visportal_t *sorted_portals[MAX_MAP_PORTALS*2];
int CountBits (byte *bits, int numbits);
int CountBits( byte *bits, int numbits );
int PointInLeafnum( vec3_t point );
dleaf_t *PointInLeaf( vec3_t point );
bool PvsForOrigin( vec3_t org, byte *pvs );
//=============================================================================
// rad.c
@ -573,22 +586,6 @@ typedef enum
emit_skylight
} emittype_t;
typedef struct directlight_s
{
struct directlight_s *next;
emittype_t type;
int style;
vec3_t origin;
vec3_t intensity;
vec3_t normal; // for surfaces and spotlights
float stopdot; // for spotlights
float stopdot2; // for spotlights
dplane_t *plane;
dleaf_t *leaf;
} directlight_t;
typedef struct tnode_s
{
int type;
@ -656,11 +653,8 @@ extern float ambient, maxlight;
void LinkPlaneFaces (void);
extern bool extrasamples;
extern int numbounce;
extern directlight_t *directlights[MAX_MAP_LEAFS];
extern byte nodehit[MAX_MAP_NODES];
void BuildLightmaps (void);
@ -668,16 +662,10 @@ void BuildLightmaps (void);
void BuildFacelights (int facenum);
void FinalLightFace (int facenum);
bool PvsForOrigin (vec3_t org, byte *pvs);
int TestLine_r (int node, vec3_t start, vec3_t stop);
void CreateDirectLights (void);
dleaf_t *RadPointInLeaf (vec3_t point);
extern dplane_t backplanes[MAX_MAP_PLANES];
extern int fakeplanes;// created planes for origin offset
@ -686,7 +674,6 @@ extern float subdiv;
extern float direct_scale;
extern float entity_scale;
int PointInLeafnum( vec3_t point );
void MakeTnodes (dmodel_t *bm);
void MakePatches (void);
void SubdividePatches (void);

View File

@ -150,30 +150,8 @@ bool BrushesDisjoint (bspbrush_t *a, bspbrush_t *b)
return false; // might intersect
}
/*
===============
IntersectionContents
Returns a content word for the intersection of two brushes.
Some combinations will generate a combination (water + clip),
but most will be the stronger of the two contents.
===============
*/
int IntersectionContents (int c1, int c2)
{
int out;
out = c1 | c2;
if (out & CONTENTS_SOLID)
out = CONTENTS_SOLID;
return out;
}
int minplanenums[3];
int maxplanenums[3];
int minplanenums[3];
int maxplanenums[3];
/*
===============

View File

@ -12,11 +12,31 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] =
#include "anorms.h"
};
#define MAX_LSTYLES 256
// stupid legacy
#define ANGLE_UP -1
#define ANGLE_DOWN -2
#define ANGLE_UP -1
#define ANGLE_DOWN -2
typedef struct directlight_s
{
struct directlight_s *next;
emittype_t type;
int style;
union
{
vec3_t intensity; // scaled by intensity
vec3_t color; // normalized light scale
};
vec3_t origin;
vec3_t normal; // for surfaces and spotlights
float lightscale; // same as intensity
float stopdot; // for spotlights
float stopdot2; // for spotlights
dplane_t *plane;
dleaf_t *leaf;
} directlight_t;
typedef struct
{
@ -24,8 +44,9 @@ typedef struct
bool coplanar;
} edgeshare_t;
edgeshare_t edgeshare[MAX_MAP_EDGES];
static byte pvs[(MAX_MAP_LEAFS+7)/8];
edgeshare_t edgeshare[MAX_MAP_EDGES];
int facelinks[MAX_MAP_SURFACES];
int planelinks[2][MAX_MAP_PLANES];
@ -669,10 +690,10 @@ void CalcPoints (lightinfo_t *l, float sofs, float tofs)
surf[j] = l->texorg[j] + l->textoworld[0][j]*us
+ l->textoworld[1][j]*ut;
leaf = RadPointInLeaf (surf);
leaf = PointInLeaf (surf);
if (leaf->contents != CONTENTS_SOLID)
{
if (!TestLine_r (0, facemid, surf))
if (!(TestLine_r( 0, facemid, surf ) & CONTENTS_SOLID))
break; // got it
}
@ -721,63 +742,90 @@ void CalcPoints (lightinfo_t *l, float sofs, float tofs)
#define MAX_STYLES 32
typedef struct
{
int numsamples;
float *origins;
int numstyles;
int stylenums[MAX_STYLES];
float *samples[MAX_STYLES];
int numsamples;
float *origins;
int numstyles;
int stylenums[MAX_STYLES];
float *samples[MAX_STYLES];
} facelight_t;
directlight_t *directlights[MAX_MAP_LEAFS];
facelight_t facelight[MAX_MAP_SURFACES];
int numdlights;
//#define DIRECT_LIGHT 3000
#define DIRECT_LIGHT 3
#define LIGHT_SCALE 10
#define LIGHT_FACTOR 10
/*
=============
CreateDirectLights
=============
*/
void CreateDirectLights (void)
void CreateDirectLights( void )
{
int i;
patch_t *p;
directlight_t *dl;
dleaf_t *leaf;
int cluster;
bsp_entity_t *e, *e2;
char *name;
char *target;
char *value;
float angle;
vec3_t dest;
dleaf_t *leaf;
float angle;
int i, cluster;
bsp_entity_t *e, *e2;
char *name, *target;
//
// surfaces
//
for( i = 0, p = patches; i < num_patches; i++, p++ )
if( bsp_parms & BSPLIB_MAKEQ2RAD )
{
if( p->totallight[0] < DIRECT_LIGHT && p->totallight[1] < DIRECT_LIGHT && p->totallight[2] < DIRECT_LIGHT )
continue;
for( i = 0, p = patches; i < num_patches; i++, p++ )
{
if( p->totallight[0] < DIRECT_LIGHT && p->totallight[1] < DIRECT_LIGHT
&& p->totallight[2] < DIRECT_LIGHT )
continue;
numdlights++;
dl = Malloc( sizeof( directlight_t ));
dl = Malloc( sizeof( directlight_t ));
numdlights++;
VectorCopy (p->origin, dl->origin);
VectorCopy( p->origin, dl->origin );
leaf = PointInLeaf( dl->origin );
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
leaf = RadPointInLeaf (dl->origin);
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
dl->type = emit_surface;
VectorCopy( p->plane->normal, dl->normal );
dl->type = emit_surface;
VectorCopy( p->plane->normal, dl->normal );
VectorCopy( p->totallight, dl->intensity );
VectorScale( dl->intensity, p->area, dl->intensity );
VectorScale( dl->intensity, direct_scale, dl->intensity );
VectorClear( p->totallight ); // all sent now
dl->lightscale = ColorNormalize( p->totallight, dl->color );
dl->lightscale *= p->area * direct_scale;
VectorClear( p->totallight ); // all sent now
}
}
else if( bsp_parms & BSPLIB_MAKEHLRAD )
{
for( i = 0, p = patches; i < num_patches; i++, p++ )
{
if( VectorAvg(p->totallight) < 25.0f )
continue;
dl = Malloc( sizeof( directlight_t ));
numdlights++;
VectorCopy( p->origin, dl->origin );
leaf = PointInLeaf( dl->origin );
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
dl->type = emit_surface;
VectorCopy( p->plane->normal, dl->normal );
VectorCopy( p->plane->normal, dl->normal );
VectorCopy( p->totallight, dl->intensity );
VectorScale( dl->intensity, p->area, dl->intensity );
VectorScale( dl->intensity, direct_scale, dl->intensity );
VectorClear( p->totallight ); // all sent now
}
}
//
@ -785,94 +833,107 @@ void CreateDirectLights (void)
//
for( i = 0; i < num_entities; i++ )
{
double r, g, b, scaler;
float l1;
char *value;
int argCnt;
double vec[4];
double col[3];
float intensity;
bool monolight = false;
e = &entities[i];
name = ValueForKey( e, "classname" );
if( com.strncmp( name, "light", 5 ))
continue;
dl = Malloc( sizeof( directlight_t ));
numdlights++;
dl = Malloc(sizeof(directlight_t));
GetVectorForKey( e, "origin", dl->origin );
leaf = RadPointInLeaf (dl->origin);
dl->style = FloatForKey( e, "_style" );
if( !dl->style ) dl->style = FloatForKey( e, "style" );
if( dl->style < 0 || dl->style >= MAX_LSTYLES )
dl->style = 0;
leaf = PointInLeaf( dl->origin );
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
dl->style = FloatForKey( e, "style" );
if( dl->style < 0 || dl->style >= MAX_LSTYLES )
dl->style = 0;
value = ValueForKey( e, "light" );
if( !value[0] ) value = ValueForKey( e, "_light" );
r = g = b = scaler = 0;
value = ValueForKey( e, "_light" );
if( !com.stricmp( value, "" ))
if( bsp_parms & BSPLIB_MAKEQ2RAD )
{
value = ValueForKey( e, "light" );
scaler = com.atof( value );
argCnt = 1;
value = ValueForKey( e, "_color" );
if( com.stricmp( value, "" ))
{
// q2 colored light
argCnt += sscanf( value, "%lf %lf %lf", &r, &g, &b );
// assume default light color
VectorSet( dl->color, 1.0f, 1.0f, 1.0f );
intensity = 0.0f;
}
// convert values to "byte"
r *= 255.0f, g *= 255.0f, b *= 255.0f;
}
else
if( value[0] )
{
argCnt = sscanf( value, "%lf %lf %lf %lf", &vec[0], &vec[1], &vec[2], &vec[3] );
switch( argCnt )
{
// q1 white light
r = g = b = 255.0f;
argCnt = 4;
case 4: // HalfLife light
VectorSet( dl->color, vec[0], vec[1], vec[2] );
VectorDivide( dl->color, 255.0f, dl->color );
if( bsp_parms & BSPLIB_MAKEHLRAD )
VectorScale( dl->intensity, (float)vec[3], dl->intensity );
intensity = vec[3];
break;
case 3: // Half-Life light_environment
VectorSet( dl->intensity, vec[0], vec[1], vec[2] );
if( bsp_parms & BSPLIB_MAKEQ2RAD )
VectorDivide( dl->color, 255.0f, dl->color );
break;
case 1: // Quake light
if( bsp_parms & BSPLIB_MAKEHLRAD )
VectorSet( dl->intensity, vec[0], vec[0], vec[0] );
intensity = vec[0];
monolight = true;
break;
default:
MsgDev( D_WARN, "%s [%i]: '_light' key must be 1 (q1) or 3 or 4 (hl) numbers\n", name, i );
break;
}
}
else
{
argCnt = sscanf( value, "%lf %lf %lf %lf", &r, &g, &b, &scaler );
}
if( argCnt == 1 )
if( monolight )
{
// The R,G,B values are all equal.
VectorSet( dl->intensity, r, g, b );
}
else if ( argCnt == 3 || argCnt == 4 )
{
// save the R G,B values seperately.
VectorSet( dl->intensity, r, g, b );
// did we also get an "intensity" scaler value too?
if( argCnt == 4 )
value = ValueForKey( e, "color" );
if( !value[0] ) value = ValueForKey( e, "_color" );
if( value[0] )
{
// Scale the normalized 0-255 R,G,B values by the intensity scaler
dl->intensity[0] = dl->intensity[0] / 255 * (float)scaler;
dl->intensity[1] = dl->intensity[1] / 255 * (float)scaler;
dl->intensity[2] = dl->intensity[2] / 255 * (float)scaler;
argCnt = sscanf( value, "%lf %lf %lf", &col[0], &col[1], &col[2] );
if( argCnt != 3 )
{
MsgDev( D_WARN, "light at %.0f %.0f %.0f:\ncolor must be given 3 values\n",
dl->origin[0], dl->origin[1], dl->origin[2] );
}
else if( bsp_parms & BSPLIB_MAKEHLRAD )
VectorScale( col, vec[0], dl->intensity ); // already in range 0-1
else if( bsp_parms & BSPLIB_MAKEQ2RAD )
VectorCopy( col, dl->color );
}
}
else
{
MsgDev( D_WARN, "entity at (%f,%f,%f) has bad '_light' value : '%s'\n",
dl->origin[0], dl->origin[1], dl->origin[2], value );
continue;
}
target = ValueForKey( e, "target" );
target = ValueForKey (e, "target");
if( !com.strcmp( name, "light_spot" ) || !com.strcmp( name, "light_environment" ) || target[0] )
{
if( !VectorAvg( dl->intensity ))
if( bsp_parms & BSPLIB_MAKEHLRAD && !VectorAvg( dl->intensity ))
VectorSet( dl->intensity, 500.0f, 500.0f, 500.0f );
else if( bsp_parms & BSPLIB_MAKEQ2RAD && !intensity )
intensity = 500.0f;
dl->type = emit_spotlight;
dl->stopdot = FloatForKey( e, "_cone" );
if( !dl->stopdot ) dl->stopdot = 10;
if( bsp_parms & BSPLIB_MAKEQ2RAD && !com.strcmp( name, "light_environment" ))
dl->stopdot = 90;
dl->stopdot2 = FloatForKey( e, "_cone2" );
if( !dl->stopdot2 ) dl->stopdot2 = dl->stopdot;
@ -922,33 +983,49 @@ void CreateDirectLights (void)
angle = FloatForKey( e, "pitch" );
// if we don't have a specific "pitch" use the "angles" PITCH
if( !angle ) angle = -light_angles[0]; // don't forget about "Stupid Quake Bug"
if( !angle ) angle = light_angles[0]; // don't forget about "Stupid Quake Bug"
dl->normal[2] = com.sin( angle / 180 * M_PI );
dl->normal[0] *= com.cos( angle / 180 * M_PI );
dl->normal[1] *= com.cos( angle / 180 * M_PI );
}
// qlight doesn't have a surface light environment - using spotlight instead
if( FloatForKey( e, "_sky" ) || !com.strcmp( name, "light_environment" ))
{
dl->type = emit_skylight;
dl->stopdot2 = FloatForKey( e, "_sky" ); // hack stopdot2 to a sky key number
}
if( bsp_parms & BSPLIB_MAKEHLRAD )
dl->type = emit_skylight;
else dl->lightscale = 8000.0f; // default sun level
}
}
else
{
if( !VectorAvg( dl->intensity ))
if( bsp_parms & BSPLIB_MAKEHLRAD && !VectorAvg( dl->intensity ))
VectorSet( dl->intensity, 300.0f, 300.0f, 300.0f );
else if( bsp_parms & BSPLIB_MAKEQ2RAD && !intensity )
intensity = 300.0f;
dl->type = emit_point;
}
if( dl->type != emit_skylight )
{
l1 = max( dl->intensity[0], max( dl->intensity[1], dl->intensity[2] ));
l1 = l1 * l1 / 100;
dl->intensity[0] *= l1;
dl->intensity[1] *= l1;
dl->intensity[2] *= l1;
if( bsp_parms & BSPLIB_MAKEHLRAD )
{
float l1 = VectorMax( dl->intensity );
l1 = (l1 * l1) / LIGHT_SCALE;
VectorScale( dl->intensity, l1, dl->intensity );
}
else
{
ColorNormalize( dl->color, dl->color );
dl->lightscale = intensity * entity_scale;
}
}
if( bsp_parms & BSPLIB_MAKEHLRAD )
Msg("intensity ( %g %g %g)\n", dl->intensity[0], dl->intensity[1], dl->intensity[2] );
else Msg( "color( %g %g %g)( %g)\n", dl->color[0], dl->color[1], dl->color[2], dl->lightscale );
}
Msg( "%i direct lights\n", numdlights );
}
@ -963,19 +1040,91 @@ Lightscale is the normalizer for multisampling
void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offset, int mapsize, float lightscale )
{
int i;
vec3_t delta;
float dot, dot2;
float dist;
float scale;
float *dest;
directlight_t *l, *sky_used = NULL;
// get the PVS for the pos to limit the number of checks
Mem_Set( pvs, 0x00, sizeof( pvs ));
if( !PvsForOrigin( pos, pvs )) return;
for( i = 0; i < dvis->numclusters; i++ )
{
if(!( pvs[i>>3] & (1<<(i & 7))))
continue;
for( l = directlights[i]; l; l = l->next )
{
VectorSubtract( l->origin, pos, delta );
dist = VectorNormalizeLength( delta );
dot = DotProduct( delta, normal );
if( dot <= 0.001 ) continue; // behind sample surface
switch( l->type )
{
case emit_point:
// linear falloff
scale = (l->lightscale - dist) * dot;
break;
case emit_surface:
dot2 = -DotProduct (delta, l->normal);
if( dot2 <= 0.001 ) goto skipadd; // behind light surface
scale = (l->lightscale / (dist*dist)) * (dot * dot2);
break;
case emit_spotlight:
// linear falloff
dot2 = -DotProduct( delta, l->normal );
if (dot2 <= l->stopdot)
goto skipadd; // outside light cone
scale = (l->lightscale - dist) * dot;
break;
default:
Sys_Error( "Bad l->type\n" );
}
if( scale <= 0 ) continue;
if( TestLine_r( 0, pos, l->origin ) & CONTENTS_SOLID )
continue; // occluded
// if this style doesn't have a table yet, allocate one
if( !styletable[l->style] )
styletable[l->style] = Malloc (mapsize);
dest = styletable[l->style] + offset;
// add some light to it
VectorMA( dest, scale * lightscale, l->color, dest );
skipadd:;
}
}
}
/*
=============
GatherSampleRad
Lightscale is the normalizer for multisampling
=============
*/
void GatherSampleRad( vec3_t pos, vec3_t normal, float **styletable, int offset, int mapsize, float lightscale )
{
int i;
vec3_t delta, add;
float dot, dot2;
float dist;
float ratio;
float *dest;
directlight_t *l, *sky_used = NULL;
// get the PVS for the pos to limit the number of checks
Mem_Set( pvs, 0x00, sizeof( pvs ));
if( !PvsForOrigin( pos, pvs )) return;
for( i = 0; i < dvis->numclusters; i++ )
{
if( !(pvs[i>>3] & (1<<(i & 7))) )
if(!( pvs[i>>3] & (1<<(i & 7))))
continue;
for( l = directlights[i]; l; l = l->next )
@ -989,12 +1138,12 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
// make sure the angle is okay
dot = -DotProduct( normal, l->normal );
if( dot <= 0.001 ) continue;
if( dot <= ON_EPSILON / LIGHT_FACTOR ) continue;
// search back to see if we can hit a sky brush
VectorScale( l->normal, -10000, delta );
VectorAdd( pos, delta, delta );
if( TestLine_r( 0, pos, delta ))// != CONTENTS_SKY )
if(!(TestLine_r( 0, pos, delta ) & CONTENTS_SKY))
continue; // occluded
VectorScale( l->intensity, dot, add );
}
@ -1003,30 +1152,27 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
VectorSubtract( l->origin, pos, delta );
dist = VectorNormalizeLength( delta );
dot = DotProduct( delta, normal );
if( dot <= 0.001 ) continue; // behind sample surface
if( dist < 1.0 ) dist = 1.0;
if( dot <= ON_EPSILON / LIGHT_FACTOR ) continue; // behind sample surface
switch( l->type )
{
case emit_point:
ratio = dot / (dist * dist);
VectorScale( l->intensity, ratio, add );
VectorScale( l->intensity, ratio * lightscale, add );
break;
case emit_surface:
dot2 = -DotProduct (delta, l->normal);
if( dot2 <= 0.001 )
goto skipadd; // behind light surface
dot2 = -DotProduct( delta, l->normal );
if( dot2 <= ON_EPSILON / LIGHT_FACTOR ) goto skipadd; // behind light surface
ratio = dot * dot2 / (dist * dist);
VectorScale( l->intensity, ratio, add );
VectorScale( l->intensity, ratio * lightscale, add );
break;
case emit_spotlight:
dot2 = -DotProduct (delta, l->normal);
if( dot2 <= l->stopdot2 )
goto skipadd; // outside light cone
dot2 = -DotProduct( delta, l->normal );
if( dot2 <= l->stopdot2 ) goto skipadd; // outside light cone
ratio = dot * dot2 / (dist * dist);
if( dot2 <= l->stopdot )
ratio *= (dot2 - l->stopdot2) / (l->stopdot - l->stopdot2);
VectorScale( l->intensity, ratio, add );
VectorScale( l->intensity, ratio * lightscale, add );
break;
default:
Sys_Error( "Bad l->type\n" );
@ -1034,43 +1180,39 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
if( VectorMax( add ) > ( l->style ? 1.0f : 0.0f ))
{
if( l->type != emit_skylight && TestLine_r( 0, pos, l->origin ))
if( l->type != emit_skylight && TestLine_r( 0, pos, l->origin ) & CONTENTS_SOLID )
continue; // occluded
// if this style doesn't have a table yet, allocate one
if( !styletable[l->style] )
styletable[l->style] = Malloc( mapsize );
dest = styletable[l->style] + offset;
// add some light to it
dest = styletable[l->style] + offset;
VectorAdd( dest, add, dest );
// VectorMA( dest, scale * lightscale, l->color, dest );
}
}
skipadd:;
}
}
if( sky_used )
{
vec3_t total;
vec3_t sky_intensity;
int j;
VectorScale( sky_used->intensity, 1.0f / (NUMVERTEXNORMALS * 2), sky_intensity );
VectorScale( sky_used->intensity, 1.0f/(NUMVERTEXNORMALS * 2), sky_intensity );
VectorClear( total );
for( j = 0; j < NUMVERTEXNORMALS; j++)
for( j = 0; j < NUMVERTEXNORMALS; j++ )
{
// make sure the angle is okay
dot = -DotProduct( normal, r_avertexnormals[j] );
if( dot <= 0.001 ) continue;
if( dot <= ON_EPSILON / LIGHT_FACTOR ) continue;
// search back to see if we can hit a sky brush
VectorScale( r_avertexnormals[j], -10000, delta );
VectorAdd( pos, delta, delta );
if( TestLine_r( 0, pos, delta ))
if(!(TestLine_r (0, pos, delta) & CONTENTS_SKY))
continue; // occluded
VectorScale( sky_intensity, dot, add );
@ -1078,13 +1220,11 @@ skipadd:;
}
if( VectorMax( total ) > 0 )
{
// if this style doesn't have a table yet, allocate one
if( !styletable[l->style] )
styletable[l->style] = Malloc( mapsize );
dest = styletable[l->style] + offset;
// add some light to it
if( !styletable[sky_used->style] )
styletable[sky_used->style] = Malloc( mapsize );
dest = styletable[sky_used->style] + offset;
VectorAdd( dest, total, dest );
}
}
@ -1103,22 +1243,21 @@ any part of it. They are counted and averaged, so it
doesn't generate extra light.
=============
*/
void AddSampleToPatch (vec3_t pos, vec3_t color, int facenum)
void AddSampleToPatch( vec3_t pos, vec3_t color, int facenum )
{
patch_t *patch;
vec3_t mins, maxs;
int i;
int i;
if (numbounce == 0)
return;
if (color[0] + color[1] + color[2] < 3)
if( numbounce == 0 ) return;
if( VectorAvg( color ) < 1.0f )
return;
for (patch = face_patches[facenum] ; patch ; patch=patch->next)
for( patch = face_patches[facenum]; patch; patch = patch->next )
{
// see if the point is in this patch (roughly)
WindingBounds (patch->winding, mins, maxs);
for (i=0 ; i<3 ; i++)
WindingBounds( patch->winding, mins, maxs );
for( i = 0; i < 3; i++ )
{
if( mins[i] > pos[i] + LM_SAMPLE_SIZE )
goto nextpatch;
@ -1128,7 +1267,7 @@ void AddSampleToPatch (vec3_t pos, vec3_t color, int facenum)
// add the sample to the patch
patch->samples++;
VectorAdd (patch->samplelight, color, patch->samplelight);
VectorAdd( patch->samplelight, color, patch->samplelight );
nextpatch:;
}
@ -1140,12 +1279,12 @@ nextpatch:;
BuildFacelights
=============
*/
float sampleofs[5][2] =
float sampleofs[5][2] =
{ {0,0}, {-0.25, -0.25}, {0.25, -0.25}, {0.25, 0.25}, {-0.25, 0.25} };
static lightinfo_t light_info[5];
void BuildFacelights (int facenum)
void BuildFacelights( int facenum )
{
dsurface_t *f;
int i, j;
@ -1158,54 +1297,55 @@ void BuildFacelights (int facenum)
f = &dsurfaces[facenum];
if( dshaders[texinfo[f->texinfo].shadernum].surfaceFlags & ( SURF_WARP|SURF_SKY ))
return; // non-lit texture
if( dshaders[texinfo[f->texinfo].shadernum].surfaceFlags & (SURF_WARP|SURF_SKY))
return; // non-lit texture
Mem_Set( styletable, 0, sizeof( styletable ));
if (extrasamples)
if( bsp_parms & BSPLIB_FULLCOMPILE )
numsamples = 5;
else
numsamples = 1;
for (i=0 ; i<numsamples ; i++)
else numsamples = 1;
for( i = 0; i < numsamples; i++ )
{
memset (&light_info[i], 0, sizeof(light_info[i]));
Mem_Set( &light_info[i], 0, sizeof( light_info[i] ));
light_info[i].surfnum = facenum;
light_info[i].face = f;
VectorCopy (dplanes[f->planenum].normal, light_info[i].facenormal);
light_info[i].facedist = dplanes[f->planenum].dist;
if (f->side)
if( f->side )
{
VectorSubtract (vec3_origin, light_info[i].facenormal, light_info[i].facenormal);
VectorSubtract( vec3_origin, light_info[i].facenormal, light_info[i].facenormal );
light_info[i].facedist = -light_info[i].facedist;
}
// get the origin offset for rotating bmodels
VectorCopy (face_offset[facenum], light_info[i].modelorg);
VectorCopy( face_offset[facenum], light_info[i].modelorg );
CalcFaceVectors (&light_info[i]);
CalcFaceExtents (&light_info[i]);
CalcPoints (&light_info[i], sampleofs[i][0], sampleofs[i][1]);
CalcFaceVectors( &light_info[i] );
CalcFaceExtents( &light_info[i] );
CalcPoints( &light_info[i], sampleofs[i][0], sampleofs[i][1] );
}
tablesize = light_info[0].numsurfpt * sizeof(vec3_t);
styletable[0] = Malloc(tablesize);
tablesize = light_info[0].numsurfpt * sizeof( vec3_t );
styletable[0] = Malloc( tablesize );
fl = &facelight[facenum];
fl->numsamples = light_info[0].numsurfpt;
fl->origins = Malloc (tablesize);
memcpy (fl->origins, light_info[0].surfpt, tablesize);
fl->origins = Malloc( tablesize );
Mem_Copy( fl->origins, light_info[0].surfpt, tablesize );
for (i=0 ; i<light_info[0].numsurfpt ; i++)
for( i = 0; i < light_info[0].numsurfpt; i++ )
{
for (j=0 ; j<numsamples ; j++)
for( j = 0; j < numsamples; j++ )
{
GatherSampleLight (light_info[j].surfpt[i], light_info[0].facenormal, styletable,
i*3, tablesize, 1.0/numsamples);
if( bsp_parms & BSPLIB_MAKEHLRAD )
GatherSampleRad( light_info[j].surfpt[i], light_info[0].facenormal, styletable, i*3, tablesize, 1.0f / numsamples );
else GatherSampleLight( light_info[j].surfpt[i], light_info[0].facenormal, styletable, i*3, tablesize, 1.0f / numsamples );
}
// contribute the sample to one or more patches
AddSampleToPatch (light_info[0].surfpt[i], styletable[0]+i*3, facenum);
AddSampleToPatch( light_info[0].surfpt[i], styletable[0]+i*3, facenum );
}
// average up the direct light on each patch for radiosity

View File

@ -7,20 +7,43 @@
#include "bsplib.h"
#include "const.h"
float r_avertexnormals[NUMVERTEXNORMALS][3] =
{
#include "anorms.h"
};
#define MAX_LSTYLES 256
// stupid legacy
#define ANGLE_UP -1
#define ANGLE_DOWN -2
typedef struct directlight_s
{
struct directlight_s *next;
emittype_t type;
int style;
vec3_t color;
vec3_t origin;
vec3_t normal; // for surfaces and spotlights
float intensity; // light scale
float stopdot; // for spotlights
float stopdot2; // for spotlights
dplane_t *plane;
dleaf_t *leaf;
} directlight_t;
typedef struct
{
dsurface_t *faces[2];
bool coplanar;
} edgeshare_t;
edgeshare_t edgeshare[MAX_MAP_EDGES];
static byte pvs[(MAX_MAP_LEAFS+7)/8];
edgeshare_t edgeshare[MAX_MAP_EDGES];
int facelinks[MAX_MAP_SURFACES];
int planelinks[2][MAX_MAP_PLANES];
@ -667,7 +690,7 @@ void CalcPoints (lightinfo_t *l, float sofs, float tofs)
leaf = RadPointInLeaf (surf);
if (leaf->contents != CONTENTS_SOLID)
{
if (!TestLine_r (0, facemid, surf))
if (!(TestLine_r( 0, facemid, surf ) & CONTENTS_SOLID))
break; // got it
}
@ -745,7 +768,6 @@ void CreateDirectLights (void)
bsp_entity_t *e, *e2;
char *name;
char *target;
char *value;
float angle;
vec3_t dest;
float intensity;
@ -758,12 +780,11 @@ void CreateDirectLights (void)
if( p->totallight[0] < DIRECT_LIGHT && p->totallight[1] < DIRECT_LIGHT && p->totallight[2] < DIRECT_LIGHT )
continue;
numdlights++;
dl = Malloc( sizeof( directlight_t ));
numdlights++;
VectorCopy (p->origin, dl->origin);
leaf = RadPointInLeaf (dl->origin);
VectorCopy( p->origin, dl->origin );
leaf = RadPointInLeaf( dl->origin );
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
@ -779,46 +800,93 @@ void CreateDirectLights (void)
//
// entities
//
for (i=0 ; i<num_entities ; i++)
for( i = 0; i < num_entities; i++ )
{
char *value;
int argCnt;
bool monolight = false;
e = &entities[i];
name = ValueForKey( e, "classname" );
if( com.strncmp( name, "light", 5 ))
continue;
dl = Malloc( sizeof( directlight_t ));
numdlights++;
dl = Malloc(sizeof(directlight_t));
GetVectorForKey( e, "origin", dl->origin );
leaf = RadPointInLeaf (dl->origin);
dl->style = FloatForKey( e, "_style" );
if( !dl->style ) dl->style = FloatForKey( e, "style" );
if( dl->style < 0 || dl->style >= MAX_LSTYLES )
dl->style = 0;
leaf = RadPointInLeaf( dl->origin );
cluster = leaf->cluster;
dl->next = directlights[cluster];
directlights[cluster] = dl;
dl->style = FloatForKey( e, "style" );
if( dl->style < 0 || dl->style >= MAX_LSTYLES )
dl->style = 0;
value = ValueForKey( e, "light" );
if( !value[0] ) value = ValueForKey( e, "_light" );
value = ValueForKey( e, "_light" );
if( !com.stricmp( value, "" ))
// assume default light color
VectorSet( dl->color, 1.0f, 1.0f, 1.0f );
intensity = 0.0f;
if( value[0] )
{
intensity = FloatForKey( e, "light" );
value = ValueForKey( e, "_color" );
if( com.stricmp( value, "" ))
sscanf( value, "%lf %lf %lf", &dl->color[0], &dl->color[1], &dl->color[2] );
else VectorSet( dl->color, 1.0f, 1.0f, 1.0f );
double vec[4];
argCnt = sscanf( value, "%lf %lf %lf %lf", &vec[0], &vec[1], &vec[2], &vec[3] );
switch( argCnt )
{
case 4: // HalfLife light
dl->color[0] = vec[0] / 255.0f;
dl->color[1] = vec[1] / 255.0f;
dl->color[2] = vec[2] / 255.0f;
intensity = vec[3];
break;
case 3: // Half-Life light_environment
dl->color[0] = vec[0] / 255.0f;
dl->color[1] = vec[1] / 255.0f;
dl->color[2] = vec[2] / 255.0f;
break;
case 1: // Quake light
dl->color[0] = vec[0];
dl->color[1] = vec[0];
dl->color[2] = vec[0];
intensity = vec[0];
monolight = true;
break;
default:
MsgDev( D_WARN, "%s [%i]: '_light' key must be 1 (q1) or 3 or 4 (hl) numbers\n", name, i );
break;
}
}
else
{
sscanf( value, "%lf %lf %lf %lf", &dl->color[0], &dl->color[1], &dl->color[2], &dl->intensity );
}
target = ValueForKey( e, "target" );
if( monolight )
{
double col[3];
value = ValueForKey( e, "color" );
if( !value[0] ) value = ValueForKey( e, "_color" );
if( value[0] )
{
argCnt = sscanf( value, "%lf %lf %lf", &col[0], &col[1], &col[2] );
if( argCnt != 3 )
{
MsgDev( D_WARN, "light at %.0f %.0f %.0f:\ncolor must be given 3 values\n",
dl->origin[0], dl->origin[1], dl->origin[2] );
}
else VectorCopy( col, dl->color );
}
}
target = ValueForKey (e, "target");
if( !com.strcmp( name, "light_spot" ) || !com.strcmp( name, "light_environment" ) || target[0] )
{
if( !dl->intensity ) dl->intensity = 500;
if( !intensity ) intensity = 500.0f;
dl->type = emit_spotlight;
dl->stopdot = FloatForKey( e, "_cone" );
if( !dl->stopdot ) dl->stopdot = 10;
@ -884,16 +952,16 @@ void CreateDirectLights (void)
}
else
{
if( !dl->intensity ) dl->intensity = 300;
dl->intensity = intensity * entity_scale;
if( !intensity ) intensity = 300.0f;
dl->type = emit_point;
}
if( dl->type != emit_skylight )
{
ColorNormalize( dl->color, dl->color );
VectorDivide( dl->color, 255.0f, dl->color );
dl->intensity = intensity * entity_scale;
}
Msg("color( %g %g %g)( %g)\n", dl->color[0], dl->color[1], dl->color[2], dl->intensity );
}
Msg( "%i direct lights\n", numdlights );
}
@ -908,19 +976,20 @@ Lightscale is the normalizer for multisampling
void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offset, int mapsize, float lightscale )
{
int i;
directlight_t *l, *sky_used = NULL;
vec3_t delta;
float dot, dot2;
float dist;
float scale;
float *dest;
directlight_t *l, *sky_used = NULL;
// get the PVS for the pos to limit the number of checks
Mem_Set( pvs, 0x00, sizeof( pvs ));
if( !PvsForOrigin( pos, pvs )) return;
for( i = 0; i < dvis->numclusters; i++ )
{
if( !(pvs[i>>3] & (1<<(i & 7))) )
if(!( pvs[i>>3] & (1<<(i & 7))))
continue;
for( l = directlights[i]; l; l = l->next )
@ -939,16 +1008,17 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
// search back to see if we can hit a sky brush
VectorScale( l->normal, -10000, delta );
VectorAdd( pos, delta, delta );
if( TestLine_r( 0, pos, delta ))// != CONTENTS_SKY )
if(!(TestLine_r( 0, pos, delta ) & CONTENTS_SKY ))
continue; // occluded
scale = dot;
scale = VectorMax( l->color ) * dot;
Msg("sky light: %g\n", scale );
}
else
{
VectorSubtract( l->origin, pos, delta );
dist = VectorNormalizeLength( delta );
dot = DotProduct( delta, normal );
if( dot <= 0.001 ) continue; // behind sample surface
if( dot <= 0.001 ) continue; // behind sample surface
switch( l->type )
{
@ -958,13 +1028,12 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
break;
case emit_surface:
dot2 = -DotProduct (delta, l->normal);
if (dot2 <= 0.001)
goto skipadd; // behind light surface
scale = (l->intensity / (dist*dist) ) * dot * dot2;
if( dot2 <= 0.001 ) goto skipadd; // behind light surface
scale = (l->intensity / (dist*dist)) * (dot * dot2);
break;
case emit_spotlight:
// linear falloff
dot2 = -DotProduct (delta, l->normal);
dot2 = -DotProduct( delta, l->normal );
if (dot2 <= l->stopdot)
goto skipadd; // outside light cone
scale = (l->intensity - dist) * dot;
@ -973,13 +1042,14 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
Sys_Error( "Bad l->type\n" );
}
if( TestLine_r( 0, pos, l->origin ))
continue; // occluded
if( scale <= 0 ) continue;
if( TestLine_r( 0, pos, l->origin ) & CONTENTS_SOLID )
continue; // occluded
// if this style doesn't have a table yet, allocate one
if( !styletable[l->style] )
styletable[l->style] = Malloc (mapsize);
dest = styletable[l->style] + offset;
// add some light to it
VectorMA( dest, scale * lightscale, l->color, dest );
@ -987,7 +1057,41 @@ void GatherSampleLight( vec3_t pos, vec3_t normal, float **styletable, int offse
skipadd:;
}
}
if( sky_used )
{
vec3_t total;
int j;
sky_used->intensity *= (1.0f / (NUMVERTEXNORMALS * 2));
VectorClear( total );
for( j = 0; j < NUMVERTEXNORMALS; j++)
{
// make sure the angle is okay
dot = -DotProduct( normal, r_avertexnormals[j] );
if( dot <= 0.001 ) continue;
// search back to see if we can hit a sky brush
VectorScale( r_avertexnormals[j], -10000, delta );
VectorAdd( pos, delta, delta );
if(!(TestLine_r( 0, pos, delta ) & CONTENTS_SKY ))
continue; // occluded
scale *= sky_used->intensity * dot;
VectorAdd( total, sky_used->color, total );
}
if( VectorMax( total ) > 0 )
{
// if this style doesn't have a table yet, allocate one
if( !styletable[sky_used->style] )
styletable[sky_used->style] = Malloc( mapsize );
dest = styletable[sky_used->style] + offset;
// add some light to it
VectorMA( dest, scale, sky_used->color, dest );
}
}
}
/*

View File

@ -616,6 +616,7 @@ void ParseBrush( bsp_entity_t *mapent )
td.vects.quark.vecs[0][3] = -DotProduct( td.vects.quark.vecs[0], planepts[0] );
td.vects.quark.vecs[1][3] = -DotProduct( td.vects.quark.vecs[1], planepts[0] );
}
td.brush_type = g_brushtype; // member map type
td.flags = td.contents = td.value = 0; // reset all values before setting
side->contents = side->surf = 0;
@ -674,6 +675,41 @@ void ParseBrush( bsp_entity_t *mapent )
continue;
}
if( g_brushtype == BRUSH_RADIANT )
{
float m[2][3], vecs[2][4];
float a, ac, as, bc, bs;
plane_t *plane = mapplanes + planenum;
Mem_Copy( m, td.vects.radiant.matrix, sizeof (m )); // save outside
// calculate proper texture vectors from GTKRadiant/Doom3 brushprimitives matrix
a = -com.atan2( plane->normal[2], com.sqrt( plane->normal[0] * plane->normal[0] + plane->normal[1] * plane->normal[1] ));
ac = com.cos( a );
as = com.sin( a );
a = com.atan2( plane->normal[1], plane->normal[0] );
bc = com.cos( a );
bs = com.sin( a );
vecs[0][0] = -bs;
vecs[0][1] = bc;
vecs[0][2] = 0.0f;
vecs[0][3] = 0; // FIXME: set to 1.0f ?
vecs[1][0] = -as*bc;
vecs[1][1] = -as*bs;
vecs[1][2] = -ac;
vecs[1][3] = 0; // FIXME: set to 1.0f ?
td.vects.quark.vecs[0][0] = m[0][0] * vecs[0][0] + m[0][1] * vecs[1][0];
td.vects.quark.vecs[0][1] = m[0][0] * vecs[0][1] + m[0][1] * vecs[1][1];
td.vects.quark.vecs[0][2] = m[0][0] * vecs[0][2] + m[0][1] * vecs[1][2];
td.vects.quark.vecs[0][3] = m[0][0] * vecs[0][3] + m[0][1] * vecs[1][3] + m[0][2];
td.vects.quark.vecs[1][0] = m[1][0] * vecs[0][0] + m[1][1] * vecs[1][0];
td.vects.quark.vecs[1][1] = m[1][0] * vecs[0][1] + m[1][1] * vecs[1][1];
td.vects.quark.vecs[1][2] = m[1][0] * vecs[0][2] + m[1][1] * vecs[1][2];
td.vects.quark.vecs[1][3] = m[1][0] * vecs[0][3] + m[1][1] * vecs[1][3] + m[1][2];
}
// see if the plane has been used already
for( k = 0; k < b->numsides; k++ )
{

View File

@ -78,7 +78,6 @@ void CalcTextureReflectivity( void )
// scale the reflectivity up, because the textures are so dim
scale = ColorNormalize( color, texture_reflectivity[i] );
VectorDivide( texture_reflectivity[i], 255.0f, texture_reflectivity[i] );
texinfo[i].value = (texels * 255.0) / scale; // basic intensity value
FS_FreeImage( pic ); // don't forget free image
}
@ -207,7 +206,7 @@ void MakePatchForFace( int fn, winding_t *w )
WindingCenter (w, patch->origin);
VectorAdd (patch->origin, patch->plane->normal, patch->origin);
leaf = RadPointInLeaf(patch->origin);
leaf = PointInLeaf(patch->origin);
patch->cluster = leaf->cluster;
patch->area = area;
@ -265,7 +264,7 @@ void MakePatches( void )
vec3_t origin;
bsp_entity_t *ent;
Msg( "%i faces\n", numsurfaces );
MsgDev( D_INFO, "%i faces\n", numsurfaces );
for( i = 0; i < nummodels; i++ )
{
@ -288,7 +287,7 @@ void MakePatches( void )
}
}
Msg( "%i sqaure feet\n", (int)( totalarea/64 ));
MsgDev( D_INFO, "%i square feet\n", (int)( totalarea/64 ));
}
/*
@ -319,12 +318,12 @@ void FinishSplit (patch_t *patch, patch_t *newp)
WindingCenter (patch->winding, patch->origin);
VectorAdd (patch->origin, patch->plane->normal, patch->origin);
leaf = RadPointInLeaf(patch->origin);
leaf = PointInLeaf(patch->origin);
patch->cluster = leaf->cluster;
WindingCenter (newp->winding, newp->origin);
VectorAdd (newp->origin, newp->plane->normal, newp->origin);
leaf = RadPointInLeaf(newp->origin);
leaf = PointInLeaf(newp->origin);
newp->cluster = leaf->cluster;
}

View File

@ -245,12 +245,12 @@ void WritePortalFile (tree_t *tree)
FS_Printf (pf, "%i\n", num_visclusters);
FS_Printf (pf, "%i\n", num_visportals);
Msg("%5i visclusters\n", num_visclusters);
Msg("%5i visportals\n", num_visportals);
MsgDev( D_INFO, "%5i visclusters\n", num_visclusters );
MsgDev( D_INFO, "%5i visportals\n", num_visportals );
WritePortalFile_r (headnode);
WritePortalFile_r( headnode );
FS_Close (pf);
FS_Close( pf );
// we need to store the clusters out now because ordering
// issues made us do this after writebsp...

View File

@ -6,20 +6,9 @@
#include "bsplib.h"
#include "const.h"
char outbase[32];
int block_xl = -8, block_xh = 7, block_yl = -8, block_yh = 7;
int entity_num;
bool onlyents;
char path[MAX_SYSPATH];
node_t *block_nodes[10][10];
bool full_compile = false;
bool onlyents = false;
bool onlyvis = false;
bool onlyrad = false;
dll_info_t physic_dll = { "physic.dll", NULL, "CreateAPI", NULL, NULL, false, sizeof( physic_exp_t ) };
physic_exp_t *pe;
node_t *block_nodes[10][10];
/*
============
@ -265,68 +254,26 @@ void ProcessModels (void)
EndBSPFile ();
}
static void AddCollision( void* handle, const void* buffer, size_t size )
{
if((dcollisiondatasize + size) > MAX_MAP_COLLISION )
Sys_Error( "MAX_MAP_COLLISION limit exceeded\n" );
Mem_Copy( dcollision + dcollisiondatasize, (void *)buffer, size );
dcollisiondatasize += size;
}
void ProcessCollisionTree( void )
{
if( !physic_dll.link ) return;
dcollisiondatasize = 0;
pe->WriteCollisionLump( NULL, AddCollision );
}
void Init_PhysicsLibrary( void )
{
static physic_imp_t pi;
launch_t CreatePhysic;
pi.api_size = sizeof(physic_imp_t);
Sys_LoadLibrary( &physic_dll );
if( physic_dll.link )
{
CreatePhysic = (void *)physic_dll.main;
pe = CreatePhysic( &com, &pi ); // sys_error not overrided
pe->Init(); // initialize phys callback
}
else memset( &pe, 0, sizeof(pe));
}
void Free_PhysicLibrary( void )
{
if( physic_dll.link )
{
pe->Shutdown();
memset( &pe, 0, sizeof(pe));
}
Sys_FreeLibrary( &physic_dll );
}
/*
============
WbspMain
============
*/
void WbspMain ( bool option )
void WbspMain( void )
{
onlyents = option;
Msg("---- CSG ---- [%s]\n", onlyents ? "onlyents" : "normal" );
Msg( "\n---- bsp ---- [%s]\n", (bsp_parms & BSPLIB_ONLYENTS) ? "onlyents" : "normal" );
// delete portal and line files
com.sprintf( path, "%s/maps/%s.prt", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.lin", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
if(!( bsp_parms & BSPLIB_ONLYENTS ))
{
// delete portal and line files
com.sprintf( path, "%s/maps/%s.prt", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.lin", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
}
// if onlyents, just grab the entites and resave
if( onlyents )
if( bsp_parms & BSPLIB_ONLYENTS )
{
LoadBSPFile();
num_entities = 0;
@ -348,56 +295,4 @@ void WbspMain ( bool option )
ProcessCollisionTree();
WriteBSPFile();
}
}
bool PrepareBSPModel ( const char *dir, const char *name, byte params )
{
int numshaders;
if( dir ) com.strncpy(gs_basedir, dir, sizeof(gs_basedir));
if( name ) com.strncpy(gs_filename, name, sizeof(gs_filename));
// copy state
onlyents = (params & BSP_ONLYENTS) ? true : false;
onlyvis = (params & BSP_ONLYVIS) ? true : false ;
onlyrad = (params & BSP_ONLYRAD) ? true : false;
full_compile = (params & BSP_FULLCOMPILE) ? true : false;
FS_LoadGameInfo( "gameinfo.txt" ); // same as normal gamemode
Init_PhysicsLibrary();
numshaders = LoadShaderInfo();
Msg( "%5i shaderInfo\n", numshaders );
return true;
}
bool CompileBSPModel ( void )
{
// must be first!
if( onlyents ) WbspMain( true );
else if( onlyvis && !onlyrad ) WvisMain( full_compile );
else if( onlyrad && !onlyvis ) WradMain( full_compile );
else if( onlyrad && onlyvis )
{
WbspMain( false );
WvisMain( full_compile );
WradMain( full_compile );
}
else WbspMain( false ); // just create bsp
Free_PhysicLibrary();
if( onlyrad && onlyvis && full_compile )
{
// delete all temporary files after final compile
com.sprintf( path, "%s/maps/%s.prt", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.lin", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
com.sprintf( path, "%s/maps/%s.log", com.GameInfo->gamedir, gs_filename );
FS_Delete( path );
}
return true;
}

View File

@ -1,8 +1,7 @@
// qrad.c
#include "bsplib.h"
bool extrasamples;
#include "const.h"
/*
NOTES
@ -14,10 +13,8 @@ patch_t *face_patches[MAX_MAP_SURFACES];
bsp_entity_t *face_entity[MAX_MAP_SURFACES];
patch_t patches[MAX_PATCHES];
uint num_patches;
vec3_t radiosity[MAX_PATCHES]; // light leaving a patch
vec3_t illumination[MAX_PATCHES]; // light arriving at a patch
vec3_t face_offset[MAX_MAP_SURFACES]; // for rotating bmodels
dplane_t backplanes[MAX_MAP_PLANES];
@ -30,12 +27,12 @@ int TestLine (vec3_t start, vec3_t stop);
int junk;
int numbounce = 3;
int numbounce = 0;
float ambient = 0;
float maxlight = 196;
float lightscale = 1.0f;
float direct_scale = 0.4f;
float entity_scale = 1.0f;
float direct_scale = 0.4f;
float entity_scale = 1.0f;
/*
===================================================================
@ -94,58 +91,6 @@ TRANSFER SCALES
===================================================================
*/
int PointInLeafnum (vec3_t point)
{
int nodenum;
vec_t dist;
dnode_t *node;
dplane_t *plane;
nodenum = 0;
while (nodenum >= 0)
{
node = &dnodes[nodenum];
plane = &dplanes[node->planenum];
dist = DotProduct (point, plane->normal) - plane->dist;
if (dist > 0)
nodenum = node->children[0];
else
nodenum = node->children[1];
}
return -nodenum - 1;
}
dleaf_t *RadPointInLeaf (vec3_t point)
{
int num;
num = PointInLeafnum (point);
return &dleafs[num];
}
bool PvsForOrigin (vec3_t org, byte *pvs)
{
dleaf_t *leaf;
if (!visdatasize)
{
memset (pvs, 255, (numleafs+7)/8 );
return true;
}
leaf = RadPointInLeaf (org);
if (leaf->cluster == -1)
return false; // in solid leaf
DecompressVis (dvisdata + dvis->bitofs[leaf->cluster][DVIS_PVS], pvs);
return true;
}
/*
=============
MakeTransfers
@ -209,8 +154,8 @@ void MakeTransfers (int i)
if (scale <= 0)
continue;
// check exact tramsfer
if (TestLine_r (0, patch->origin, patch2->origin) )
// check exact transfer
if( TestLine_r( 0, patch->origin, patch2->origin ) & CONTENTS_SOLID )
continue;
trans = scale * patch2->area / (dist*dist);
@ -443,40 +388,28 @@ void RadWorld (void)
RunThreadsOnIndividual( numsurfaces, true, FinalLightFace );
}
void WradMain ( bool option )
void WradMain( void )
{
string cmdparm;
bool light = FS_CheckParm("-light");
extrasamples = option;
if(!LoadBSPFile( ))
{
// map not exist, create it
WbspMain( false );
WbspMain();
LoadBSPFile();
}
if( light ) Msg("---- Light ---- [%s]\n", extrasamples ? "extra" : "normal" );
else Msg("---- Radiocity ---- [%s]\n", extrasamples ? "extra" : "normal" );
if( bsp_parms & BSPLIB_MAKEHLRAD )
Msg( "\n---- hlrad ---- [%s]\n", (bsp_parms & BSPLIB_FULLCOMPILE) ? "extra" : "normal" );
else Msg( "\n---- qrad ---- [%s]\n", (bsp_parms & BSPLIB_FULLCOMPILE) ? "extra" : "normal" );
if( light )
{
ambient = 0.0f;
numbounce = 0;
}
else
{
if( extrasamples )
{
if( FS_GetParmFromCmdLine( "-ambient", cmdparm ))
ambient = com.atof( cmdparm );
ambient = bound( 0, ambient, 512 );
}
if(FS_GetParmFromCmdLine("-bounce", cmdparm ))
numbounce = com.atoi( cmdparm );
numbounce = bound( 0, numbounce, 32 );
}
if( FS_GetParmFromCmdLine( "-ambient", cmdparm ))
ambient = com.atof( cmdparm );
ambient = bound( 0, ambient, 512 );
if( FS_GetParmFromCmdLine( "-bounce", cmdparm ))
numbounce = com.atoi( cmdparm );
numbounce = bound( 0, numbounce, 32 );
ParseEntities();
CalcTextureReflectivity();
@ -488,7 +421,6 @@ void WradMain ( bool option )
ambient = 0.1f;
}
RadWorld ();
RadWorld();
WriteBSPFile();
}

View File

@ -16,11 +16,117 @@ int originalvismapsize;
int leafbytes; // (portalclusters+63)>>3
int leaflongs;
int portalbytes, portallongs;
bool fastvis;
int totalvis;
int totalphs;
visportal_t *sorted_portals[MAX_MAP_PORTALS*2];
/*
===============
CompressVis
===============
*/
int CompressVis( byte *vis, byte *dest )
{
int j, rep, visrow;
byte *dest_p;
dest_p = dest;
visrow = (dvis->numclusters + 7)>>3;
for( j = 0; j < visrow; j++ )
{
*dest_p++ = vis[j];
if( vis[j] ) continue;
rep = 1;
for( j++; j < visrow; j++ )
if( vis[j] || rep == 255 )
break;
else rep++;
*dest_p++ = rep;
j--;
}
return dest_p - dest;
}
/*
===================
DecompressVis
===================
*/
void DecompressVis( byte *in, byte *decompressed )
{
int c;
byte *out;
int row;
row = (dvis->numclusters+7)>>3;
out = decompressed;
do
{
if( *in )
{
*out++ = *in++;
continue;
}
c = in[1];
if( !c ) Sys_Error( "DecompressVis: 0 repeat\n" );
in += 2;
while( c )
{
*out++ = 0;
c--;
}
} while( out - decompressed < row );
}
int PointInLeafnum ( vec3_t point )
{
float dist;
dnode_t *node;
dplane_t *plane;
int nodenum = 0;
while( nodenum >= 0 )
{
node = &dnodes[nodenum];
plane = &dplanes[node->planenum];
dist = DotProduct( point, plane->normal ) - plane->dist;
if( dist > 0 ) nodenum = node->children[0];
else nodenum = node->children[1];
}
return -nodenum - 1;
}
dleaf_t *PointInLeaf( vec3_t point )
{
int num;
num = PointInLeafnum( point );
return &dleafs[num];
}
bool PvsForOrigin( vec3_t org, byte *pvs )
{
dleaf_t *leaf;
if( !visdatasize )
{
Mem_Set( pvs, 0xFF, (numleafs+7)/8 );
return true;
}
leaf = PointInLeaf( org );
if( leaf->cluster == -1 )
return false; // in solid leaf
DecompressVis( dvisdata + dvis->bitofs[leaf->cluster][DVIS_PVS], pvs );
return true;
}
//=============================================================================
@ -28,7 +134,7 @@ void PlaneFromWinding( viswinding_t *w, visplane_t *plane )
{
vec3_t v1, v2;
// calc plane
// calc plane
VectorSubtract (w->points[2], w->points[1], v1);
VectorSubtract (w->points[0], w->points[1], v2);
CrossProduct (v2, v1, plane->normal);
@ -205,46 +311,46 @@ void ClusterMerge (int leafnum)
CalcPortalVis
==================
*/
void CalcPortalVis (void)
void CalcPortalVis( void )
{
int i;
// fastvis just uses mightsee for a very loose bound
if(fastvis)
if( bsp_parms & BSPLIB_FULLCOMPILE )
{
for (i = 0; i < numportals * 2; i++)
RunThreadsOnIndividual( numportals * 2, true, PortalFlow );
}
else
{
int i;
// fastvis just uses mightsee for a very loose bound
for( i = 0; i < numportals * 2; i++ )
{
portals[i].portalvis = portals[i].portalflood;
portals[i].status = stat_done;
}
return;
}
RunThreadsOnIndividual (numportals*2, true, PortalFlow);
}
/*
==================
CalcVis
CalcPVS
==================
*/
void CalcVis (void)
void CalcPVS( void )
{
int i;
int i;
Msg ("Building PVS...\n");
Msg( "Building PVS...\n" );
RunThreadsOnIndividual (numportals*2, true, BasePortalVis);
SortPortals ();
CalcPortalVis ();
RunThreadsOnIndividual( numportals * 2, true, BasePortalVis );
SortPortals();
CalcPortalVis();
//
// assemble the leaf vis lists by oring and compressing the portal lists
//
for (i=0 ; i<portalclusters ; i++)
// assemble the leaf vis lists by oring and compressing the portal lists
for( i = 0; i < portalclusters; i++ )
ClusterMerge (i);
Msg ("Average clusters visible: %i\n", totalvis / portalclusters);
Msg( "Average clusters visible: %i\n", totalvis / portalclusters );
}
@ -297,7 +403,7 @@ void LoadPortals( void )
com.sprintf( path, "maps/%s.prt", gs_filename );
prtfile = Com_OpenScript( path, NULL, 0 );
if( !prtfile ) Sys_Break( "LoadPortals: couldn't read %s\n", path );
Msg( "reading %s\n", path );
MsgDev( D_NOTE, "reading %s\n", path );
Com_ReadString( prtfile, true, magic );
Com_ReadLong( prtfile, true, &portalclusters );
@ -436,16 +542,16 @@ void ClusterPHS( int clusternum )
totalphs++;
// compress the bit string
j = CompressVis (uncompressed, compressed);
j = CompressVis( uncompressed, compressed );
dest = (long *)vismap_p;
vismap_p += j;
if (vismap_p > vismap_end)
Sys_Error ("Vismap expansion overflow");
if( vismap_p > vismap_end )
Sys_Error( "Vismap expansion overflow\n" );
dvis->bitofs[clusternum][DVIS_PHS] = (byte *)dest-vismap;
Mem_Copy (dest, compressed, j);
dvis->bitofs[clusternum][DVIS_PHS] = (byte *)dest - vismap;
Mem_Copy( dest, compressed, j );
}
/*
@ -456,11 +562,11 @@ Calculate the PHS (Potentially Hearable Set)
by ORing together all the PVS visible from a leaf
================
*/
void CalcPHS (void)
void CalcPHS( void )
{
Msg ("Building PHS...\n");
RunThreadsOnIndividual (portalclusters, true, ClusterPHS);
Msg("Average clusters hearable: %i\n", totalphs/portalclusters);
Msg( "Building PHS...\n" );
RunThreadsOnIndividual( portalclusters, true, ClusterPHS );
Msg( "Average clusters hearable: %i\n", totalphs / portalclusters );
}
/*
@ -468,27 +574,25 @@ void CalcPHS (void)
main
===========
*/
void WvisMain ( bool option )
void WvisMain( void )
{
fastvis = !option;
if(!LoadBSPFile())
if( !LoadBSPFile( ))
{
// map not exist, create it
WbspMain( false );
WbspMain();
LoadBSPFile();
}
if( numnodes == 0 || numsurfaces == 0 )
Sys_Break( "Empty map %s.bsp\n", gs_filename );
Msg ("---- Visibility ---- [%s]\n", fastvis ? "fast" : "full" );
LoadPortals ();
CalcVis ();
CalcPHS ();
Msg ("\n---- vis ---- [%s]\n", (bsp_parms & BSPLIB_FULLCOMPILE) ? "full" : "fast" );
LoadPortals();
CalcPVS();
CalcPHS();
visdatasize = vismap_p - dvisdata;
Msg ("visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize*2);
MsgDev( D_INFO, "visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize * 2 );
WriteBSPFile();
}
}

View File

@ -116,7 +116,7 @@ static void ParseShaderFile( const char *filename )
if( shader )
{
FS_FileBase( filename, name );
MsgDev( D_INFO, "Adding: %s.shader\n", name );
MsgDev( D_LOAD, "Adding: %s.shader\n", name );
}
while( shader )
@ -147,7 +147,7 @@ static void ParseShaderFile( const char *filename )
continue;
}
if( !com.stricmp( token.string, "surfaceparm" ))
if( !com.stricmp( token.string, "surfaceParm" ))
{
Com_ReadToken( shader, 0, &token );
for( i = 0; i < numInfoParms; i++ )
@ -156,7 +156,7 @@ static void ParseShaderFile( const char *filename )
{
si->surfaceFlags |= infoParms[i].surfaceFlags;
si->contents |= infoParms[i].contents;
if ( infoParms[i].clearSolid )
if( infoParms[i].clearSolid )
si->contents &= ~CONTENTS_SOLID;
break;
}

View File

@ -33,8 +33,10 @@ void MakeTnode (int nodenum)
for (i=0 ; i<2 ; i++)
{
if (node->children[i] < 0)
t->children[i] = (dleafs[-node->children[i] - 1].contents & CONTENTS_SOLID) | (1<<31);
if( node->children[i] < 0 )
{
t->children[i] = (-node->children[i] - 1)|(1<<31);
}
else
{
t->children[i] = tnode_p - tnodes;
@ -72,11 +74,27 @@ int TestLine_r (int node, vec3_t start, vec3_t stop)
float front, back;
vec3_t mid;
float frac;
int side;
int r;
int side;
int r;
if (node & (1<<31))
return node & ~(1<<31); // leaf node
{
int leafnum = node & ~(1<<31);
int i, sky_found = 0;
dleafface_t *lface = &dleafsurfaces[dleafs[leafnum].firstleafsurface];
for( i = 0; i < dleafs[leafnum].numleafsurfaces; i++, lface++ )
{
dsurface_t *face = &dsurfaces[*lface];
if( dshaders[texinfo[face->texinfo].shadernum].contentFlags & CONTENTS_SKY )
sky_found = true;
if( sky_found ) break;
}
if( sky_found )
return dleafs[leafnum].contents|CONTENTS_SKY;
return dleafs[leafnum].contents;
}
tnode = &tnodes[node];
switch (tnode->type)
@ -114,7 +132,7 @@ int TestLine_r (int node, vec3_t start, vec3_t stop)
mid[2] = start[2] + (stop[2] - start[2])*frac;
r = TestLine_r (tnode->children[side], start, mid);
if (r)
if( r & (CONTENTS_SOLID|CONTENTS_SKY))
return r;
return TestLine_r (tnode->children[!side], mid, stop);
}

View File

@ -121,6 +121,10 @@ SOURCE=.\bsplib\bspfile.c
# End Source File
# Begin Source File
SOURCE=.\bsplib\bsplib.c
# End Source File
# Begin Source File
SOURCE=.\ripper\conv_bsplumps.c
# End Source File
# Begin Source File

139
common/common.plg Normal file
View File

@ -0,0 +1,139 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: common - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29CF.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "./" /I "../public" /I "./bsplib/" /I "./ripper" /I "./common" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\common\!release/" /Fd"..\temp\common\!release/" /FD /c
"D:\Xash3D\src_main\common\bsplib\brushbsp.c"
"D:\Xash3D\src_main\common\bsplib\bspfile.c"
"D:\Xash3D\src_main\common\bsplib\bsplib.c"
"D:\Xash3D\src_main\common\ripper\conv_bsplumps.c"
"D:\Xash3D\src_main\common\ripper\conv_doom.c"
"D:\Xash3D\src_main\common\ripper\conv_image.c"
"D:\Xash3D\src_main\common\ripper\conv_main.c"
"D:\Xash3D\src_main\common\ripper\conv_shader.c"
"D:\Xash3D\src_main\common\ripper\conv_sprite.c"
"D:\Xash3D\src_main\common\bsplib\csg.c"
"D:\Xash3D\src_main\common\bsplib\faces.c"
"D:\Xash3D\src_main\common\bsplib\flow.c"
"D:\Xash3D\src_main\common\bsplib\leakfile.c"
"D:\Xash3D\src_main\common\bsplib\lightmap.c"
"D:\Xash3D\src_main\common\bsplib\map.c"
"D:\Xash3D\src_main\common\bsplib\patches.c"
"D:\Xash3D\src_main\common\platform.c"
"D:\Xash3D\src_main\common\bsplib\portals.c"
"D:\Xash3D\src_main\common\bsplib\prtfile.c"
"D:\Xash3D\src_main\common\bsplib\qbsp3.c"
"D:\Xash3D\src_main\common\bsplib\qrad3.c"
"D:\Xash3D\src_main\common\bsplib\qvis3.c"
"D:\Xash3D\src_main\common\bsplib\shaders.c"
"D:\Xash3D\src_main\common\spritegen.c"
"D:\Xash3D\src_main\common\studio.c"
"D:\Xash3D\src_main\common\studio_utils.c"
"D:\Xash3D\src_main\common\bsplib\textures.c"
"D:\Xash3D\src_main\common\bsplib\trace.c"
"D:\Xash3D\src_main\common\bsplib\tree.c"
"D:\Xash3D\src_main\common\utils.c"
"D:\Xash3D\src_main\common\wadlib.c"
"D:\Xash3D\src_main\common\bsplib\winding.c"
"D:\Xash3D\src_main\common\bsplib\writebsp.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29CF.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D0.tmp" with contents
[
msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\common\!release/common.dll" /implib:"..\temp\common\!release/common.lib" /opt:nowin98
"\Xash3D\src_main\temp\common\!release\brushbsp.obj"
"\Xash3D\src_main\temp\common\!release\bspfile.obj"
"\Xash3D\src_main\temp\common\!release\bsplib.obj"
"\Xash3D\src_main\temp\common\!release\conv_bsplumps.obj"
"\Xash3D\src_main\temp\common\!release\conv_doom.obj"
"\Xash3D\src_main\temp\common\!release\conv_image.obj"
"\Xash3D\src_main\temp\common\!release\conv_main.obj"
"\Xash3D\src_main\temp\common\!release\conv_shader.obj"
"\Xash3D\src_main\temp\common\!release\conv_sprite.obj"
"\Xash3D\src_main\temp\common\!release\csg.obj"
"\Xash3D\src_main\temp\common\!release\faces.obj"
"\Xash3D\src_main\temp\common\!release\flow.obj"
"\Xash3D\src_main\temp\common\!release\leakfile.obj"
"\Xash3D\src_main\temp\common\!release\lightmap.obj"
"\Xash3D\src_main\temp\common\!release\map.obj"
"\Xash3D\src_main\temp\common\!release\patches.obj"
"\Xash3D\src_main\temp\common\!release\platform.obj"
"\Xash3D\src_main\temp\common\!release\portals.obj"
"\Xash3D\src_main\temp\common\!release\prtfile.obj"
"\Xash3D\src_main\temp\common\!release\qbsp3.obj"
"\Xash3D\src_main\temp\common\!release\qrad3.obj"
"\Xash3D\src_main\temp\common\!release\qvis3.obj"
"\Xash3D\src_main\temp\common\!release\shaders.obj"
"\Xash3D\src_main\temp\common\!release\spritegen.obj"
"\Xash3D\src_main\temp\common\!release\studio.obj"
"\Xash3D\src_main\temp\common\!release\studio_utils.obj"
"\Xash3D\src_main\temp\common\!release\textures.obj"
"\Xash3D\src_main\temp\common\!release\trace.obj"
"\Xash3D\src_main\temp\common\!release\tree.obj"
"\Xash3D\src_main\temp\common\!release\utils.obj"
"\Xash3D\src_main\temp\common\!release\wadlib.obj"
"\Xash3D\src_main\temp\common\!release\winding.obj"
"\Xash3D\src_main\temp\common\!release\writebsp.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D0.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D1.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\common\!release\common.dll "D:\Xash3D\bin\common.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D1.bat""
Compiling...
brushbsp.c
bspfile.c
bsplib.c
D:\Xash3D\src_main\common\bsplib\bsplib.c(67) : error C2065: 'BSPLIB_MAKERAD' : undeclared identifier
conv_bsplumps.c
conv_doom.c
conv_image.c
conv_main.c
conv_shader.c
conv_sprite.c
csg.c
faces.c
flow.c
leakfile.c
lightmap.c
D:\Xash3D\src_main\common\bsplib\lightmap.c(804) : error C2065: 'BSPLIB_MAKERAD' : undeclared identifier
map.c
patches.c
platform.c
portals.c
prtfile.c
qbsp3.c
Generating Code...
Compiling...
qrad3.c
qvis3.c
shaders.c
spritegen.c
studio.c
studio_utils.c
textures.c
trace.c
tree.c
utils.c
wadlib.c
winding.c
writebsp.c
Generating Code...
Error executing cl.exe.
<h3>Output Window</h3>
<h3>Results</h3>
common.dll - 2 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -313,6 +313,7 @@ extern int numcommands;
extern int stripcount;
extern int clip_texcoords;
extern int xnode[100][100];
extern byte *studiopool;
extern s_bbox_t hitbox[MAXSTUDIOSRCBONES];
extern s_texture_t *texture[MAXSTUDIOSKINS];

View File

@ -1,6 +1,6 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// platform.c - game common dll
// platform.c - tools common dll
//=======================================================================
#include "platform.h"
@ -21,8 +21,6 @@ byte *basepool;
byte *zonepool;
byte *error_bmp;
size_t error_bmp_size;
byte *checkermate_dds;
size_t checkermate_dds_size;
static double start, end;
uint app_name = HOST_OFFLINE;
@ -51,63 +49,50 @@ platform.dll needs for some setup operations
so do it manually
==================
*/
void InitPlatform ( int argc, char **argv )
void InitCommon( int argc, char **argv )
{
byte bspflags = 0, qccflags = 0, roqflags = 0;
string source, gamedir;
launch_t CreateVprogs;
basepool = Mem_AllocPool( "Temp" );
// blamk image for missed resources
error_bmp = FS_LoadInternal( "blank.bmp", &error_bmp_size );
// for custom cmdline parsing
com_argc = argc;
com_argv = argv;
basepool = Mem_AllocPool( "Common Pool" );
app_name = g_Instance;
switch( app_name )
{
case HOST_BSPLIB:
if(!FS_GetParmFromCmdLine("-game", gamedir ))
com.strncpy(gamedir, Cvar_VariableString( "fs_defaultdir" ), sizeof(gamedir));
if(!FS_GetParmFromCmdLine("+map", source ))
com.strncpy(source, "newmap", sizeof(source));
if(FS_CheckParm("-vis")) bspflags |= BSP_ONLYVIS;
if(FS_CheckParm("-rad")) bspflags |= BSP_ONLYRAD;
if(FS_CheckParm("-light")) bspflags |= BSP_ONLYRAD;
if(FS_CheckParm("-full")) bspflags |= BSP_FULLCOMPILE;
if(FS_CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS;
if( !FS_GetParmFromCmdLine( "-game", gs_basedir ))
com.strncpy( gs_basedir, Cvar_VariableString( "fs_defaultdir" ), sizeof( gs_basedir ));
if( !FS_GetParmFromCmdLine( "+map", gs_filename ))
com.strncpy( gs_filename, "newmap", sizeof( gs_filename ));
// famous q1 "notexture" image: purple-black checkerboard
checkermate_dds = FS_LoadInternal( "checkerboard.dds", &checkermate_dds_size );
// initialize ImageLibrary
start = Sys_DoubleTime();
Image_Init( NULL, IL_ALLOW_OVERWRITE|IL_IGNORE_MIPS );
PrepareBSPModel( gamedir, source, bspflags );
PrepareBSPModel( gamedir, source );
break;
case HOST_QCCLIB:
Sys_LoadLibrary( &vprogs_dll ); // load qcclib
Sys_LoadLibrary( &vprogs_dll ); // load qcclib
CreateVprogs = (void *)vprogs_dll.main;
PRVM = CreateVprogs( &com, NULL ); // second interface not allowed
PRVM = CreateVprogs( &com, NULL ); // second interface not allowed
PRVM->Init( argc, argv );
if(!FS_GetParmFromCmdLine("-dir", gamedir ))
com.strncpy(gamedir, ".", sizeof(gamedir));
if(!FS_GetParmFromCmdLine("+src", source ))
com.strncpy(source, "progs.src", sizeof(source));
if( !FS_GetParmFromCmdLine( "-dir", gs_basedir ))
com.strncpy( gs_basedir, ".", sizeof( gs_basedir ));
if( !FS_GetParmFromCmdLine( "+src", gs_filename ))
com.strncpy( gs_filename, "progs.src", sizeof( gs_filename ));
start = Sys_DoubleTime();
PRVM->PrepareDAT( gamedir, source );
PRVM->PrepareDAT( gs_basedir, gs_filename );
break;
case HOST_SPRITE:
case HOST_STUDIO:
case HOST_WADLIB:
case HOST_RIPPER:
// blamk image for missed resources
error_bmp = FS_LoadInternal( "blank.bmp", &error_bmp_size );
FS_InitRootDir(".");
// initialize ImageLibrary
Image_Init( NULL, IL_KEEP_8BIT );
start = Sys_DoubleTime();
@ -118,7 +103,7 @@ void InitPlatform ( int argc, char **argv )
}
}
void RunPlatform( void )
void CommonMain( void )
{
search_t *search;
bool (*CompileMod)( byte *mempool, const char *name, byte parms ) = NULL;
@ -169,20 +154,20 @@ void RunPlatform( void )
ClrMask(); // clear all previous masks
AddMask( gs_searchmask ); // custom mask
}
zonepool = Mem_AllocPool( "compiler" );
zonepool = Mem_AllocPool( "Zone Pool" );
Msg( "Converting ...\n\n" );
// search by mask
for( i = 0; i < num_searchmask; i++ )
{
// skip blank mask
if(!com.strlen( searchmask[i] )) continue;
if( !com.strlen( searchmask[i] )) continue;
search = FS_Search( searchmask[i], true );
if( !search ) continue; // try next mask
for( j = 0; j < search->numfilenames; j++ )
{
if(CompileMod( zonepool, search->filenames[j], parms ))
if( CompileMod( zonepool, search->filenames[j], parms ))
numCompiledMods++;
}
Mem_Free( search );
@ -192,7 +177,7 @@ void RunPlatform( void )
if( !num_searchmask ) com.strncpy( errorstring, "files", MAX_STRING );
for( j = 0; j < num_searchmask; j++ )
{
if(!com.strlen( searchmask[j] )) continue;
if( !com.strlen( searchmask[j] )) continue;
com.strncat( errorstring, va("%s ", searchmask[j]), MAX_STRING );
}
Sys_Break( "no %s found in this folder!\n", errorstring );
@ -200,10 +185,10 @@ void RunPlatform( void )
elapced_time:
end = Sys_DoubleTime();
Msg( "%5.3f seconds elapsed\n", end - start );
if( numCompiledMods > 1) Msg("total %d files proceed\n", numCompiledMods );
if( numCompiledMods > 1) Msg( "total %d files proceed\n", numCompiledMods );
}
void FreePlatform ( void )
void FreeCommon( void )
{
if( app_name == HOST_QCCLIB )
{
@ -230,9 +215,9 @@ launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, void *unused )
// generic functions
Com.api_size = sizeof(launch_exp_t);
Com.Init = InitPlatform;
Com.Main = RunPlatform;
Com.Free = FreePlatform;
Com.Init = InitCommon;
Com.Main = CommonMain;
Com.Free = FreeCommon;
Com.MSG_Init = NULL;
Com.CPrint = NULL;

View File

@ -5,6 +5,7 @@
#include "ripper.h"
#include "mathlib.h"
#include "utils.h"
// q2 wal contents
#define CONTENTS_SOLID 0x00000001 // an eye is never valid in a solid
@ -52,6 +53,7 @@
// xash 0.45 surfaces replacement table
#define SURF_MIRROR 0x00010000 // mirror surface
#define SURF_PORTAL 0x00020000 // portal surface
#define SURF_ALPHATEST 0x00040000 // alpha surface
string animmap[256]; // should be enoguh
int animcount; // process counter
@ -161,11 +163,27 @@ check_shader:
FS_Printf( f, "\n%s\n{\n", shadername ); // write shadername
if( contents & CONTENTS_CLIP && contents && CONTENTS_PLAYERCLIP )
FS_Print( f, "\tsurfaceparm\tclip\n" );
else if( contents & CONTENTS_MONSTERCLIP ) FS_Print( f, "\tsurfaceparm\tmonsterclip\n" );
else if( contents & CONTENTS_PLAYERCLIP ) FS_Print( f, "\tsurfaceparm\tplayerclip\n" );
else if( contents & CONTENTS_WINDOW ) FS_Print( f, "\tsurfaceparm\twindow\n" );
else if( contents & CONTENTS_ORIGIN ) FS_Print( f, "\tsurfaceparm\torigin\n" );
else if( contents & CONTENTS_TRANSLUCENT ) FS_Print( f, "\tsurfaceparm\ttranslucent\n" );
else if( contents & CONTENTS_AREAPORTAL ) FS_Print( f, "\tsurfaceparm\tareaportal\n" );
else if( contents & CONTENTS_TRIGGER ) FS_Print( f, "\tsurfaceparm\ttrigger\n" );
else if( contents & CONTENTS_DETAIL ) FS_Print( f, "\tsurfaceparm\tdetail\n" );
if( flags & SURF_LIGHT )
{
FS_Print( f, "\tsurfaceparm\tlight\n" );
if(!VectorIsNull( rad )) FS_Printf(f, "\trad_color\t\t%.f %.f %.f\n", rad[0], rad[1], rad[2] );
if( scale ) FS_Printf(f, "\trad_intensity\t%.f\n", scale );
if( !num_anims )
{
FS_Printf( f, "\t{\n\t\tmap\t%s\n\t}\n", shadername );
lightmap_stage = true;
}
}
if( flags & SURF_WARP )
@ -198,25 +216,20 @@ check_shader:
else if( flags & SURF_MIRROR ) FS_Print( f, "\tsurfaceparm\tmirror\n" );
else if( flags & (SURF_TRANS33|SURF_TRANS66))
{
FS_Print( f, "\tentityMergable\n\n" );
FS_Printf( f, "\t{\n\t\tmap\t%s\n\n", shadername ); // save basemap
FS_Print( f, "\t\tblendFunc\tGL_SRC_ALPHA\tGL_ONE_MINUS_SRC_ALPHA\n" );
FS_Print( f, "\t\tAlphaGen\t\tvertex\n\t}\n" );
FS_Print( f, "\t\tAlphaGen\t\tentity\n\t}\n" );
lightmap_stage = true;
}
else if( flags & SURF_ALPHATEST )
{
FS_Printf( f, "\t{\n\t\tmap\t%s\n\n", shadername ); // save basemap
FS_Print( f, "\t\talphaFunc\tGL_GREATER 0.666f\t// id Software magic value\n" );
FS_Print( f, "\t\tAlphaGen\tidentity\n\t}\n" );
lightmap_stage = true;
}
else if( flags & SURF_NODRAW ) FS_Print( f, "\tsurfaceparm\tnull\n" );
if( contents & CONTENTS_CLIP && contents && CONTENTS_PLAYERCLIP )
FS_Print( f, "\tsurfaceparm\tclip\n" );
else if( contents & CONTENTS_MONSTERCLIP ) FS_Print( f, "\tsurfaceparm\tmonsterclip\n" );
else if( contents & CONTENTS_PLAYERCLIP ) FS_Print( f, "\tsurfaceparm\tplayerclip\n" );
else if( contents & CONTENTS_WINDOW ) FS_Print( f, "\tsurfaceparm\twindow\n" );
else if( contents & CONTENTS_ORIGIN ) FS_Print( f, "\tsurfaceparm\torigin\n" );
else if( contents & CONTENTS_TRANSLUCENT ) FS_Print( f, "\tsurfaceparm\tsolid\n" );
else if( contents & CONTENTS_AREAPORTAL ) FS_Print( f, "\tsurfaceparm\tareaportal\n" );
else if( contents & CONTENTS_TRIGGER ) FS_Print( f, "\tsurfaceparm\ttrigger\n" );
else if( contents & CONTENTS_DETAIL ) FS_Print( f, "\tsurfaceparm\tdetail\n" );
if( num_anims )
{
FS_Printf( f, "\t{\n\t\tAnimFrequency\t%i\n", animcount ); // #frames per second
@ -309,9 +322,6 @@ void Conv_ShaderGetFlags( const char *imagename, const char *shadername, const c
{
num_anims = animcount = 0; // valid onlt for current frame so reset it
// light definition
if( com.strchr( imagename, '~' )) *flags |= SURF_LIGHT;
if( com.stristr( imagename, "water" ))
{
*contents |= CONTENTS_WATER;
@ -335,15 +345,21 @@ void Conv_ShaderGetFlags( const char *imagename, const char *shadername, const c
else if( !com.strnicmp( imagename, "hint", 4 )) *flags |= SURF_HINT;
else if( !com.strnicmp( imagename, "skip", 4 )) *flags |= SURF_SKIP;
else if( !com.strnicmp( imagename, "null", 4 )) *flags |= SURF_NODRAW;
else if( !com.strnicmp( imagename, "translucent", 11 )) *flags |= CONTENTS_TRANSLUCENT;
else if( !com.strnicmp( imagename, "translucent", 11 )) *contents |= CONTENTS_TRANSLUCENT;
else if( !com.strnicmp( imagename, "glass", 5 )) *flags |= SURF_TRANS66;
else if( !com.strnicmp( imagename, "mirror", 6 )) *flags |= SURF_MIRROR;
else if( !com.strnicmp( imagename, "portal", 6 )) *flags |= SURF_PORTAL;
else if( com.stristr( imagename, "trigger" )) *contents |= CONTENTS_TRIGGER;
else if( com.stristr( imagename, "lite" )) *flags |= SURF_LIGHT;
// try to exctract contents and flags directly form mip-name
if( imagename[0] == '!' || imagename[0] == '*' ) *flags |= SURF_WARP; // liquids
else if( imagename[0] == '{' ) *contents |= CONTENTS_TRANSLUCENT; // grates
else if( imagename[0] == '{' )
{
*flags |= SURF_ALPHATEST; // grates
*contents |= CONTENTS_TRANSLUCENT;
}
else if( imagename[0] == '~' ) *flags |= SURF_LIGHT; // light definition
else if( imagename[0] == '+' )
{
char c1 = imagename[1];
@ -494,6 +510,7 @@ bool Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const
for( j = 0; j < 3; j++ )
radiocity[j] /= texels;
scale = ColorNormalize( radiocity, radiocity );
VectorScale( radiocity, 255.0f, radiocity );
intencity = texels * 255.0 / scale; // basic intensity value
}
return Conv_WriteShader( shaderpath, imagepath, pic, radiocity, intencity, flags, contents );

View File

@ -9,11 +9,30 @@
#include "bsplib.h"
#include "mdllib.h"
string gs_basedir; // initial dir before loading gameinfo.txt (used for compilers too)
string gs_filename; // used for compilers only
int com_argc;
char **com_argv;
char gs_basedir[ MAX_SYSPATH ]; // initial dir before loading gameinfo.txt (used for compilers too)
string gs_filename; // used for compilers only
float ColorNormalize( const vec3_t in, vec3_t out )
{
float max, scale;
#if 0
max = VectorMax( in );
#else
max = in[0];
if( in[1] > max ) max = in[1];
if( in[2] > max ) max = in[2];
#endif
if( max == 0 )
{
out[0] = out[1] = out[2] = 1.0f;
return 0;
}
scale = 1.0f / max;
VectorScale( in, scale, out );
return max;
}
/*
================
@ -22,7 +41,7 @@ Com_ValidScript
validate qc-script for unexcpected keywords
================
*/
bool Com_ValidScript( const char *token, int scripttype )
bool Com_ValidScript( const char *token, qctype_t scripttype )
{
if( !com.stricmp( token, "$spritename") && scripttype != QC_SPRITEGEN )
{
@ -55,4 +74,4 @@ bool Com_ValidScript( const char *token, int scripttype )
return false;
}
return true;
};
};

View File

@ -1,6 +1,6 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// utils.h - shared engine utility
// utils.h - shared utilities
//=======================================================================
#ifndef UTILS_H
#define UTILS_H
@ -8,14 +8,8 @@
#include <time.h>
// bsplib compile flags
#define BSP_ONLYENTS 0x01
#define BSP_ONLYVIS 0x02
#define BSP_ONLYRAD 0x04
#define BSP_FULLCOMPILE 0x08
#define ALIGN( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3)
extern int com_argc;
extern char **com_argv;
extern byte *basepool;
extern byte *zonepool;
@ -26,28 +20,26 @@ extern vprogs_exp_t *PRVM;
#define Malloc(size) Mem_Alloc( basepool, size )
extern string gs_filename;
extern char gs_basedir[ MAX_SYSPATH ];
extern string gs_basedir;
extern byte *error_bmp;
extern size_t error_bmp_size;
extern byte *studiopool;
enum
typedef enum
{
QC_SPRITEGEN = 1,
QC_STUDIOMDL,
QC_ROQLIB,
QC_WADLIB
};
} qctype_t;
bool Com_ValidScript( const char *token, int scripttype );
bool Com_ValidScript( const char *token, qctype_t script_type );
float ColorNormalize( const vec3_t in, vec3_t out );
// misc
bool CompileStudioModel ( byte *mempool, const char *name, byte parms );
bool CompileSpriteModel ( byte *mempool, const char *name, byte parms );
bool ConvertImagePixels ( byte *mempool, const char *name, byte parms );
bool CompileWad3Archive ( byte *mempool, const char *name, byte parms );
bool CompileROQVideo( byte *mempool, const char *name, byte parms );
bool PrepareBSPModel ( const char *dir, const char *name, byte params );
bool CompileBSPModel ( void );
bool CompileStudioModel( byte *mempool, const char *name, byte parms );
bool CompileSpriteModel( byte *mempool, const char *name, byte parms );
bool CompileWad3Archive( byte *mempool, const char *name, byte parms );
bool PrepareBSPModel( const char *dir, const char *name );
bool CompileBSPModel( void );
#endif//UTILS_H

147
engine/engine.plg Normal file
View File

@ -0,0 +1,147 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: engine - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C0.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "server" /I "client" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\engine\!release/" /Fd"..\temp\engine\!release/" /FD /c
"D:\Xash3D\src_main\engine\common\cinematic.c"
"D:\Xash3D\src_main\engine\client\cl_cmds.c"
"D:\Xash3D\src_main\engine\client\cl_demo.c"
"D:\Xash3D\src_main\engine\client\cl_frame.c"
"D:\Xash3D\src_main\engine\client\cl_fx.c"
"D:\Xash3D\src_main\engine\client\cl_input.c"
"D:\Xash3D\src_main\engine\client\cl_main.c"
"D:\Xash3D\src_main\engine\client\cl_parse.c"
"D:\Xash3D\src_main\engine\client\cl_pred.c"
"D:\Xash3D\src_main\engine\client\cl_progs.c"
"D:\Xash3D\src_main\engine\client\cl_scrn.c"
"D:\Xash3D\src_main\engine\client\cl_tent.c"
"D:\Xash3D\src_main\engine\client\cl_view.c"
"D:\Xash3D\src_main\engine\common\con_keys.c"
"D:\Xash3D\src_main\engine\common\con_main.c"
"D:\Xash3D\src_main\engine\common\con_utils.c"
"D:\Xash3D\src_main\engine\common\engfuncs.c"
"D:\Xash3D\src_main\engine\engine.c"
"D:\Xash3D\src_main\engine\host.c"
"D:\Xash3D\src_main\engine\common\infostring.c"
"D:\Xash3D\src_main\engine\common\input.c"
"D:\Xash3D\src_main\engine\common\menu.c"
"D:\Xash3D\src_main\engine\common\net_chan.c"
"D:\Xash3D\src_main\engine\common\net_huff.c"
"D:\Xash3D\src_main\engine\common\net_msg.c"
"D:\Xash3D\src_main\engine\server\sv_client.c"
"D:\Xash3D\src_main\engine\server\sv_cmds.c"
"D:\Xash3D\src_main\engine\server\sv_frame.c"
"D:\Xash3D\src_main\engine\server\sv_init.c"
"D:\Xash3D\src_main\engine\server\sv_main.c"
"D:\Xash3D\src_main\engine\server\sv_move.c"
"D:\Xash3D\src_main\engine\server\sv_phys.c"
"D:\Xash3D\src_main\engine\server\sv_progs.c"
"D:\Xash3D\src_main\engine\server\sv_spawn.c"
"D:\Xash3D\src_main\engine\server\sv_world.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C0.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C1.tmp" with contents
[
user32.lib msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\engine\!release/engine.dll" /implib:"..\temp\engine\!release/engine.lib" /opt:nowin98
"\Xash3D\src_main\temp\engine\!release\cinematic.obj"
"\Xash3D\src_main\temp\engine\!release\cl_cmds.obj"
"\Xash3D\src_main\temp\engine\!release\cl_demo.obj"
"\Xash3D\src_main\temp\engine\!release\cl_frame.obj"
"\Xash3D\src_main\temp\engine\!release\cl_fx.obj"
"\Xash3D\src_main\temp\engine\!release\cl_input.obj"
"\Xash3D\src_main\temp\engine\!release\cl_main.obj"
"\Xash3D\src_main\temp\engine\!release\cl_parse.obj"
"\Xash3D\src_main\temp\engine\!release\cl_pred.obj"
"\Xash3D\src_main\temp\engine\!release\cl_progs.obj"
"\Xash3D\src_main\temp\engine\!release\cl_scrn.obj"
"\Xash3D\src_main\temp\engine\!release\cl_tent.obj"
"\Xash3D\src_main\temp\engine\!release\cl_view.obj"
"\Xash3D\src_main\temp\engine\!release\con_keys.obj"
"\Xash3D\src_main\temp\engine\!release\con_main.obj"
"\Xash3D\src_main\temp\engine\!release\con_utils.obj"
"\Xash3D\src_main\temp\engine\!release\engfuncs.obj"
"\Xash3D\src_main\temp\engine\!release\engine.obj"
"\Xash3D\src_main\temp\engine\!release\host.obj"
"\Xash3D\src_main\temp\engine\!release\infostring.obj"
"\Xash3D\src_main\temp\engine\!release\input.obj"
"\Xash3D\src_main\temp\engine\!release\menu.obj"
"\Xash3D\src_main\temp\engine\!release\net_chan.obj"
"\Xash3D\src_main\temp\engine\!release\net_huff.obj"
"\Xash3D\src_main\temp\engine\!release\net_msg.obj"
"\Xash3D\src_main\temp\engine\!release\sv_client.obj"
"\Xash3D\src_main\temp\engine\!release\sv_cmds.obj"
"\Xash3D\src_main\temp\engine\!release\sv_frame.obj"
"\Xash3D\src_main\temp\engine\!release\sv_init.obj"
"\Xash3D\src_main\temp\engine\!release\sv_main.obj"
"\Xash3D\src_main\temp\engine\!release\sv_move.obj"
"\Xash3D\src_main\temp\engine\!release\sv_phys.obj"
"\Xash3D\src_main\temp\engine\!release\sv_progs.obj"
"\Xash3D\src_main\temp\engine\!release\sv_spawn.obj"
"\Xash3D\src_main\temp\engine\!release\sv_world.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C1.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C2.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\engine\!release\engine.dll "D:\Xash3D\bin\engine.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29C2.bat""
Compiling...
cinematic.c
cl_cmds.c
cl_demo.c
cl_frame.c
cl_fx.c
cl_input.c
cl_main.c
cl_parse.c
cl_pred.c
cl_progs.c
cl_scrn.c
cl_tent.c
cl_view.c
con_keys.c
con_main.c
con_utils.c
engfuncs.c
engine.c
host.c
infostring.c
Generating Code...
Compiling...
input.c
menu.c
net_chan.c
net_huff.c
net_msg.c
sv_client.c
sv_cmds.c
sv_frame.c
sv_init.c
sv_main.c
sv_move.c
sv_phys.c
sv_progs.c
sv_spawn.c
sv_world.c
Generating Code...
D:\Xash3D\src_main\engine\server\sv_spawn.c(18) : warning C4700: local variable 'pm' used without having been initialized
Linking...
Creating library ..\temp\engine\!release/engine.lib and object ..\temp\engine\!release/engine.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\engine\!release\engine.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
engine.dll - 0 error(s), 1 warning(s)
</pre>
</body>
</html>

View File

@ -23,7 +23,7 @@ char *buildstring = __TIME__ " " __DATE__;
dll_info_t physic_dll = { "physic.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(physic_exp_t) };
dll_info_t render_dll = { "render.dll", NULL, "CreateAPI", NULL, NULL, false, sizeof(render_exp_t) };
dll_info_t vprogs_dll = { "vprogs.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(vprogs_exp_t) };
dll_info_t vsound_dll = { "vsound.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(vsound_exp_t) };
dll_info_t vsound_dll = { "vsound.dll", NULL, "CreateAPI", NULL, NULL, false, sizeof(vsound_exp_t) };
cvar_t *timescale;
cvar_t *host_serverstate;
@ -611,13 +611,8 @@ void Host_Init( int argc, char **argv)
Key_Init();
// get default configuration
#if 1
Cbuf_AddText("exec keys.rc\n");
Cbuf_AddText("exec vars.rc\n");
#else
Cbuf_AddText("exec default.cfg\n");
Cbuf_AddText("exec config.cfg\n");
#endif
Cbuf_Execute();
// init commands and vars

View File

@ -347,7 +347,7 @@ pack_t *FS_LoadPackPK3 (const char *packfile)
return NULL;
}
MsgDev(D_INFO, "Adding packfile %s (%i files)\n", packfile, real_nb_files);
MsgDev( D_LOAD, "Adding packfile %s (%i files)\n", packfile, real_nb_files );
return pack;
}
@ -762,8 +762,8 @@ pack_t *FS_LoadPackPAK(const char *packfile)
FS_AddFileToPack (info[i].name, pack, offset, size, size, PACKFILE_FLAG_TRUEOFFS);
}
Mem_Free(info);
MsgDev(D_INFO, "Adding packfile: %s (%i files)\n", packfile, numpackfiles);
Mem_Free( info );
MsgDev( D_LOAD, "Adding packfile: %s (%i files)\n", packfile, numpackfiles );
return pack;
}
@ -838,8 +838,8 @@ pack_t *FS_LoadPackPK2(const char *packfile)
FS_AddFileToPack(info[i].name, pack, offset, size, size, PACKFILE_FLAG_TRUEOFFS);
}
Mem_Free(info);
MsgDev(D_INFO, "Adding packfile %s (%i files)\n", packfile, numpackfiles);
Mem_Free( info );
MsgDev( D_LOAD, "Adding packfile %s (%i files)\n", packfile, numpackfiles );
return pack;
}
@ -994,7 +994,7 @@ static bool FS_AddWad_Fullpath( const char *wadfile, bool *already_loaded, bool
search->next = fs_searchpaths;
fs_searchpaths = search;
}
MsgDev( D_INFO, "Adding wadfile %s (%i files)\n", wadfile, wad->numlumps );
MsgDev( D_LOAD, "Adding wadfile %s (%i files)\n", wadfile, wad->numlumps );
return true;
}
else
@ -1427,18 +1427,18 @@ void FS_Init( void )
stringlistsort(&dirs);
GI.numgamedirs = 0;
if(!FS_GetParmFromCmdLine("-game", gs_basedir ))
if( !FS_GetParmFromCmdLine( "-game", gs_basedir ))
{
if( Sys.app_name == HOST_BSPLIB )
com_strcpy( gs_basedir, fs_defaultdir->string );
else if(Sys_GetModuleName( gs_basedir, MAX_SYSPATH ));
else com_strcpy( gs_basedir, fs_defaultdir->string ); // default dir
else if( Sys_GetModuleName( gs_basedir, MAX_SYSPATH ));
else com.strcpy( gs_basedir, fs_defaultdir->string ); // default dir
}
// checked nasty path: "bin" it's a reserved word
if(FS_CheckNastyPath( gs_basedir, true ) || !com_stricmp("bin", gs_basedir ))
if( FS_CheckNastyPath( gs_basedir, true ) || !com_stricmp("bin", gs_basedir ))
{
MsgDev( D_INFO, "FS_Init: invalid game directory \"%s\"\n", gs_basedir );
com_strcpy(gs_basedir, fs_defaultdir->string ); // default dir
MsgDev( D_ERROR, "FS_Init: invalid game directory \"%s\"\n", gs_basedir );
com.strcpy( gs_basedir, fs_defaultdir->string ); // default dir
}
// validate directories
@ -1454,18 +1454,18 @@ void FS_Init( void )
com_strcpy(gs_basedir, fs_defaultdir->string ); // default dir
}
// save for game change
// build list of game directories here
FS_AddGameDirectory( "./", 0 );
for( i = 0; i < dirs.numstrings; i++ )
{
// make sure what it's real game directory
if(!FS_FileExists(va("%s/gameinfo.txt", dirs.strings[i] ))) continue;
if( !FS_FileExists( va( "%s/gameinfo.txt", dirs.strings[i] ))) continue;
com_strncpy( GI.gamedirs[GI.numgamedirs++], dirs.strings[i], MAX_STRING );
}
stringlistfreecontents(&dirs);
stringlistfreecontents( &dirs );
}
// enable temporary wad support for some tools
// enable explicit wad support for some tools
switch( Sys.app_name )
{
case HOST_WADLIB:
@ -1478,7 +1478,7 @@ void FS_Init( void )
}
FS_ResetGameInfo();
MsgDev(D_INFO, "FS_Init: done\n");
MsgDev( D_NOTE, "FS_Init: done\n" );
}
void FS_InitRootDir( char *path )

110
launch/launch.plg Normal file
View File

@ -0,0 +1,110 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: launch - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29C8.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "./" /I "./imagelib" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\launch\!release/" /Fd"..\temp\launch\!release/" /FD /c
"D:\Xash3D\src_main\launch\cmd.c"
"D:\Xash3D\src_main\launch\console.c"
"D:\Xash3D\src_main\launch\cpuinfo.c"
"D:\Xash3D\src_main\launch\crclib.c"
"D:\Xash3D\src_main\launch\cvar.c"
"D:\Xash3D\src_main\launch\export.c"
"D:\Xash3D\src_main\launch\filesystem.c"
"D:\Xash3D\src_main\launch\imagelib\img_bmp.c"
"D:\Xash3D\src_main\launch\imagelib\img_dds.c"
"D:\Xash3D\src_main\launch\imagelib\img_jpg.c"
"D:\Xash3D\src_main\launch\imagelib\img_main.c"
"D:\Xash3D\src_main\launch\imagelib\img_pcx.c"
"D:\Xash3D\src_main\launch\imagelib\img_png.c"
"D:\Xash3D\src_main\launch\imagelib\img_tga.c"
"D:\Xash3D\src_main\launch\imagelib\img_utils.c"
"D:\Xash3D\src_main\launch\imagelib\img_vtf.c"
"D:\Xash3D\src_main\launch\imagelib\img_wad.c"
"D:\Xash3D\src_main\launch\memlib.c"
"D:\Xash3D\src_main\launch\network.c"
"D:\Xash3D\src_main\launch\parselib.c"
"D:\Xash3D\src_main\launch\stdlib.c"
"D:\Xash3D\src_main\launch\system.c"
"D:\Xash3D\src_main\launch\utils.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29C8.tmp""
Creating temporary file "C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29C9.tmp" with contents
[
zlib.lib png.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\launch\!release/launch.dll" /implib:"..\temp\launch\!release/launch.lib" /libpath:"./imagelib" /opt:nowin98
"\Xash3D\src_main\temp\launch\!release\cmd.obj"
"\Xash3D\src_main\temp\launch\!release\console.obj"
"\Xash3D\src_main\temp\launch\!release\cpuinfo.obj"
"\Xash3D\src_main\temp\launch\!release\crclib.obj"
"\Xash3D\src_main\temp\launch\!release\cvar.obj"
"\Xash3D\src_main\temp\launch\!release\export.obj"
"\Xash3D\src_main\temp\launch\!release\filesystem.obj"
"\Xash3D\src_main\temp\launch\!release\img_bmp.obj"
"\Xash3D\src_main\temp\launch\!release\img_dds.obj"
"\Xash3D\src_main\temp\launch\!release\img_jpg.obj"
"\Xash3D\src_main\temp\launch\!release\img_main.obj"
"\Xash3D\src_main\temp\launch\!release\img_pcx.obj"
"\Xash3D\src_main\temp\launch\!release\img_png.obj"
"\Xash3D\src_main\temp\launch\!release\img_tga.obj"
"\Xash3D\src_main\temp\launch\!release\img_utils.obj"
"\Xash3D\src_main\temp\launch\!release\img_vtf.obj"
"\Xash3D\src_main\temp\launch\!release\img_wad.obj"
"\Xash3D\src_main\temp\launch\!release\memlib.obj"
"\Xash3D\src_main\temp\launch\!release\network.obj"
"\Xash3D\src_main\temp\launch\!release\parselib.obj"
"\Xash3D\src_main\temp\launch\!release\stdlib.obj"
"\Xash3D\src_main\temp\launch\!release\system.obj"
"\Xash3D\src_main\temp\launch\!release\utils.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29C9.tmp""
Creating temporary file "C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29CA.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\launch\!release\launch.dll "D:\Xash3D\bin\launch.dll"
]
Creating command line ""C:\DOCUME~1\ŔÄĚČÍČ~1.9CC\LOCALS~1\Temp\RSP29CA.bat""
Compiling...
cmd.c
console.c
cpuinfo.c
crclib.c
cvar.c
export.c
filesystem.c
img_bmp.c
img_dds.c
img_jpg.c
img_main.c
img_pcx.c
img_png.c
img_tga.c
img_utils.c
img_vtf.c
img_wad.c
memlib.c
network.c
parselib.c
Generating Code...
Compiling...
stdlib.c
system.c
utils.c
Generating Code...
Linking...
Creating library ..\temp\launch\!release/launch.lib and object ..\temp\launch\!release/launch.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\launch\!release\launch.dll
‘Ş®Ż¨ŕ®˘ ­® ä ©«®˘: 1.
<h3>Results</h3>
launch.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -24,8 +24,8 @@ bool InitPhysics( void )
{
char dev_level[4];
physpool = Mem_AllocPool("Physics Pool");
cmappool = Mem_AllocPool("CM Zone");
physpool = Mem_AllocPool( "Physic Pool" );
cmappool = Mem_AllocPool( "CM Zone" );
gWorld = NewtonCreate( Palloc, Pfree ); // alloc world
app_name = g_Instance;

78
physic/physic.plg Normal file
View File

@ -0,0 +1,78 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: physic - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D3.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\physic\!release/" /Fd"..\temp\physic\!release/" /FD /c
"D:\Xash3D\src_main\physic\cm_callback.c"
"D:\Xash3D\src_main\physic\cm_collision.c"
"D:\Xash3D\src_main\physic\cm_debug.c"
"D:\Xash3D\src_main\physic\cm_materials.c"
"D:\Xash3D\src_main\physic\cm_model.c"
"D:\Xash3D\src_main\physic\cm_pmove.c"
"D:\Xash3D\src_main\physic\cm_polygon.c"
"D:\Xash3D\src_main\physic\cm_portals.c"
"D:\Xash3D\src_main\physic\cm_rigidbody.c"
"D:\Xash3D\src_main\physic\cm_test.c"
"D:\Xash3D\src_main\physic\cm_trace.c"
"D:\Xash3D\src_main\physic\cm_utils.c"
"D:\Xash3D\src_main\physic\physic.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D3.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D4.tmp" with contents
[
user32.lib msvcrt.lib newton.lib opengl32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\physic\!release/physic.dll" /implib:"..\temp\physic\!release/physic.lib" /libpath:"../public/libs/"
"\Xash3D\src_main\temp\physic\!release\cm_callback.obj"
"\Xash3D\src_main\temp\physic\!release\cm_collision.obj"
"\Xash3D\src_main\temp\physic\!release\cm_debug.obj"
"\Xash3D\src_main\temp\physic\!release\cm_materials.obj"
"\Xash3D\src_main\temp\physic\!release\cm_model.obj"
"\Xash3D\src_main\temp\physic\!release\cm_pmove.obj"
"\Xash3D\src_main\temp\physic\!release\cm_polygon.obj"
"\Xash3D\src_main\temp\physic\!release\cm_portals.obj"
"\Xash3D\src_main\temp\physic\!release\cm_rigidbody.obj"
"\Xash3D\src_main\temp\physic\!release\cm_test.obj"
"\Xash3D\src_main\temp\physic\!release\cm_trace.obj"
"\Xash3D\src_main\temp\physic\!release\cm_utils.obj"
"\Xash3D\src_main\temp\physic\!release\physic.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D4.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D5.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\physic\!release\physic.dll "D:\Xash3D\bin\physic.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29D5.bat""
Compiling...
cm_callback.c
cm_collision.c
cm_debug.c
cm_materials.c
cm_model.c
cm_pmove.c
cm_polygon.c
cm_portals.c
cm_rigidbody.c
cm_test.c
cm_trace.c
cm_utils.c
physic.c
Generating Code...
Linking...
Creating library ..\temp\physic\!release/physic.lib and object ..\temp\physic\!release/physic.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\physic\!release\physic.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
physic.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -546,23 +546,6 @@ _inline float *UnpackRGBA( dword icolor )
return color;
}
_inline float ColorNormalize( const vec3_t in, vec3_t out )
{
float max, scale;
max = in[0];
if( in[1] > max ) max = in[1];
if( in[2] > max ) max = in[2];
if( max == 0 )
{
out[0] = out[1] = out[2] = 1.0f;
return 0;
}
scale = 255.0 / max;
VectorScale( in, scale, out );
return max;
}
/*
=================
BoundsIntersect

View File

@ -137,7 +137,7 @@ BRUSH MODELS
#define MAX_MAP_AREAPORTALS 0x400
#define MAX_MAP_ENTITIES 0x2000
#define MAX_MAP_SHADERS 0x1000
#define MAX_MAP_TEXINFO 0x2000
#define MAX_MAP_TEXINFO 0x8000
#define MAX_MAP_BRUSHES 0x8000
#define MAX_MAP_PLANES 0x20000
#define MAX_MAP_NODES 0x20000
@ -164,7 +164,7 @@ BRUSH MODELS
#define MIN_WORLD_COORD (-128 * 1024 )
#define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
#define MAX_SHADERPATH 64
#define NUMVERTEXNORMALS 162 // not a table, only magic value...
#define NUMVERTEXNORMALS 162 // quake avertex normals
#define MAX_BUILD_SIDES 512 // per one brush. (don't touch!)
#define LM_SAMPLE_SIZE 16 // q1, q2, q3 default value (lightmap resoultion)
@ -172,6 +172,7 @@ BRUSH MODELS
#define LS_NORMAL 0x00
#define LS_UNUSED 0xFE
#define LS_NONE 0xFF
#define MAX_LSTYLES 256
#define MAX_LIGHT_STYLES 64
#define MAX_SWITCHED_LIGHTS 32

93
render/render.plg Normal file
View File

@ -0,0 +1,93 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: render - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DA.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\render\!release/" /Fd"..\temp\render\!release/" /FD /c
"D:\Xash3D\src_main\render\gl_backend.c"
"D:\Xash3D\src_main\render\r_backend.c"
"D:\Xash3D\src_main\render\r_backend2.c"
"D:\Xash3D\src_main\render\r_bloom.c"
"D:\Xash3D\src_main\render\r_draw.c"
"D:\Xash3D\src_main\render\r_image.c"
"D:\Xash3D\src_main\render\r_light.c"
"D:\Xash3D\src_main\render\r_main.c"
"D:\Xash3D\src_main\render\r_misc.c"
"D:\Xash3D\src_main\render\r_model.c"
"D:\Xash3D\src_main\render\r_opengl.c"
"D:\Xash3D\src_main\render\r_program.c"
"D:\Xash3D\src_main\render\r_shader.c"
"D:\Xash3D\src_main\render\r_sky.c"
"D:\Xash3D\src_main\render\r_sprite.c"
"D:\Xash3D\src_main\render\r_studio.c"
"D:\Xash3D\src_main\render\r_surface.c"
"D:\Xash3D\src_main\render\r_utils.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DA.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DB.tmp" with contents
[
msvcrt.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\render\!release/render.dll" /implib:"..\temp\render\!release/render.lib" /libpath:"../public/libs/"
"\Xash3D\src_main\temp\render\!release\gl_backend.obj"
"\Xash3D\src_main\temp\render\!release\r_backend.obj"
"\Xash3D\src_main\temp\render\!release\r_backend2.obj"
"\Xash3D\src_main\temp\render\!release\r_bloom.obj"
"\Xash3D\src_main\temp\render\!release\r_draw.obj"
"\Xash3D\src_main\temp\render\!release\r_image.obj"
"\Xash3D\src_main\temp\render\!release\r_light.obj"
"\Xash3D\src_main\temp\render\!release\r_main.obj"
"\Xash3D\src_main\temp\render\!release\r_misc.obj"
"\Xash3D\src_main\temp\render\!release\r_model.obj"
"\Xash3D\src_main\temp\render\!release\r_opengl.obj"
"\Xash3D\src_main\temp\render\!release\r_program.obj"
"\Xash3D\src_main\temp\render\!release\r_shader.obj"
"\Xash3D\src_main\temp\render\!release\r_sky.obj"
"\Xash3D\src_main\temp\render\!release\r_sprite.obj"
"\Xash3D\src_main\temp\render\!release\r_studio.obj"
"\Xash3D\src_main\temp\render\!release\r_surface.obj"
"\Xash3D\src_main\temp\render\!release\r_utils.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DB.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DC.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\render\!release\render.dll "D:\Xash3D\bin\render.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29DC.bat""
Compiling...
gl_backend.c
r_backend.c
r_backend2.c
r_bloom.c
r_draw.c
r_image.c
r_light.c
r_main.c
r_misc.c
r_model.c
r_opengl.c
r_program.c
r_shader.c
r_sky.c
r_sprite.c
r_studio.c
r_surface.c
r_utils.c
Generating Code...
Linking...
Creating library ..\temp\render\!release/render.lib and object ..\temp\render\!release/render.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\render\!release\render.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
render.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -19,12 +19,18 @@ fopen
GLOBAL: Достигнуть уровня xash 0.45 к очередному релизу
qrad3:
0. правильный парсинг light энтитей OK
1. -qrad, -hlrad OK
2. bsp -> wad
0. починить IMAGE_FORCE_RGBA (или избавится ?)
1. droptofloor
2. bsplib и финальный формат карты
3. console garbage OK
4. create indexBuffer
5. light_environment
6. сделать 2 типа расчета освещения OK
TODO LIST
поправить поле movedir в bsplib/map.c

49
viewer/viewer.plg Normal file
View File

@ -0,0 +1,49 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: viewer - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E1.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\viewer\!release/" /Fd"..\temp\viewer\!release/" /FD /c
"D:\Xash3D\src_main\viewer\guiforms.c"
"D:\Xash3D\src_main\viewer\guiutils.c"
"D:\Xash3D\src_main\viewer\viewer.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E1.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E2.tmp" with contents
[
msvcrt.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\viewer\!release/viewer.dll" /implib:"..\temp\viewer\!release/viewer.lib"
"\Xash3D\src_main\temp\viewer\!release\guiforms.obj"
"\Xash3D\src_main\temp\viewer\!release\guiutils.obj"
"\Xash3D\src_main\temp\viewer\!release\viewer.obj"
"\Xash3D\src_main\temp\viewer\!release\viewer.res"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E2.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E3.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\viewer\!release\viewer.dll "D:\Xash3D\bin\viewer.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E3.bat""
Compiling...
guiforms.c
guiutils.c
viewer.c
Generating Code...
Linking...
Creating library ..\temp\viewer\!release/viewer.lib and object ..\temp\viewer\!release/viewer.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\viewer\!release\viewer.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
viewer.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

57
vprogs/vprogs.plg Normal file
View File

@ -0,0 +1,57 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: vprogs - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E8.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "./" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\vprogs\!release/" /Fd"..\temp\vprogs\!release/" /FD /c
"D:\Xash3D\src_main\vprogs\pr_comp.c"
"D:\Xash3D\src_main\vprogs\pr_edict.c"
"D:\Xash3D\src_main\vprogs\pr_exec.c"
"D:\Xash3D\src_main\vprogs\pr_lex.c"
"D:\Xash3D\src_main\vprogs\pr_main.c"
"D:\Xash3D\src_main\vprogs\pr_utils.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E8.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E9.tmp" with contents
[
msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\vprogs\!release/vprogs.dll" /implib:"..\temp\vprogs\!release/vprogs.lib" /opt:nowin98
"\Xash3D\src_main\temp\vprogs\!release\pr_comp.obj"
"\Xash3D\src_main\temp\vprogs\!release\pr_edict.obj"
"\Xash3D\src_main\temp\vprogs\!release\pr_exec.obj"
"\Xash3D\src_main\temp\vprogs\!release\pr_lex.obj"
"\Xash3D\src_main\temp\vprogs\!release\pr_main.obj"
"\Xash3D\src_main\temp\vprogs\!release\pr_utils.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29E9.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29EA.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\vprogs\!release\vprogs.dll "D:\Xash3D\bin\vprogs.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29EA.bat""
Compiling...
pr_comp.c
pr_edict.c
pr_exec.c
pr_lex.c
pr_main.c
pr_utils.c
Generating Code...
Linking...
Creating library ..\temp\vprogs\!release/vprogs.lib and object ..\temp\vprogs\!release/vprogs.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\vprogs\!release\vprogs.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
vprogs.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

54
vsound/vsound.plg Normal file
View File

@ -0,0 +1,54 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: vsound - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29EF.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /I "./" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\vsound\!release/" /Fd"..\temp\vsound\!release/" /FD /c
"D:\Xash3D\src_main\vsound\s_load.c"
"D:\Xash3D\src_main\vsound\s_main.c"
"D:\Xash3D\src_main\vsound\s_openal.c"
"D:\Xash3D\src_main\vsound\s_stream.c"
"D:\Xash3D\src_main\vsound\s_export.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29EF.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29F0.tmp" with contents
[
libogg.lib vorbis.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libcmt.lib" /out:"..\temp\vsound\!release/vsound.dll" /implib:"..\temp\vsound\!release/vsound.lib" /opt:nowin98
"\Xash3D\src_main\temp\vsound\!release\s_load.obj"
"\Xash3D\src_main\temp\vsound\!release\s_main.obj"
"\Xash3D\src_main\temp\vsound\!release\s_openal.obj"
"\Xash3D\src_main\temp\vsound\!release\s_stream.obj"
"\Xash3D\src_main\temp\vsound\!release\s_export.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29F0.tmp""
Creating temporary file "C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29F1.bat" with contents
[
@echo off
copy \Xash3D\src_main\temp\vsound\!release\vsound.dll "D:\Xash3D\bin\vsound.dll"
]
Creating command line ""C:\DOCUME~1\ÀÄÌÈÍÈ~1.9CC\LOCALS~1\Temp\RSP29F1.bat""
Compiling...
s_load.c
s_main.c
s_openal.c
s_stream.c
s_export.c
Generating Code...
Linking...
Creating library ..\temp\vsound\!release/vsound.lib and object ..\temp\vsound\!release/vsound.exp
<h3>Output Window</h3>
Performing Custom Build Step on \Xash3D\src_main\temp\vsound\!release\vsound.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
vsound.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>