29 #include "../../../idlib/precompiled.h"
35 #define TEXTURE_OFFSET_EQUAL_EPSILON 0.005
36 #define TEXTURE_VECTOR_EQUAL_EPSILON 0.001
56 area = &e->
areas[areaNum];
62 for ( i = 0 ; i < 2 ; i++ ) {
63 for ( j = 0 ; j < 3 ; j++ ) {
86 memset( group, 0,
sizeof( *group ) );
113 d0[0] = b->
xyz[0] - a->
xyz[0];
114 d0[1] = b->
xyz[1] - a->
xyz[1];
115 d0[2] = b->
xyz[2] - a->
xyz[2];
116 d0[3] = b->
st[0] - a->
st[0];
117 d0[4] = b->
st[1] - a->
st[1];
119 d1[0] = c->
xyz[0] - a->
xyz[0];
120 d1[1] = c->
xyz[1] - a->
xyz[1];
121 d1[2] = c->
xyz[2] - a->
xyz[2];
122 d1[3] = c->
st[0] - a->
st[0];
123 d1[4] = c->
st[1] - a->
st[1];
125 area = d0[3] * d1[4] - d0[4] * d1[3];
128 temp[0] = (d0[0] * d1[4] - d0[4] * d1[0]) * inva;
129 temp[1] = (d0[1] * d1[4] - d0[4] * d1[1]) * inva;
130 temp[2] = (d0[2] * d1[4] - d0[4] * d1[2]) * inva;
133 texVec->
v[0][3] = tri->
v[0].
xyz * texVec->
v[0].
ToVec3() - tri->
v[0].
st[0];
135 temp[0] = (d0[3] * d1[0] - d0[0] * d1[3]) * inva;
136 temp[1] = (d0[3] * d1[1] - d0[1] * d1[3]) * inva;
137 temp[2] = (d0[3] * d1[2] - d0[2] * d1[3]) * inva;
140 texVec->
v[1][3] = tri->
v[0].
xyz * texVec->
v[0].
ToVec3() - tri->
v[0].
st[1];
150 #define SNAP_FLOAT_TO_INT 256
151 #define SNAP_INT_TO_FLOAT (1.0/SNAP_FLOAT_TO_INT)
183 for ( j = 0 ; j < 3 ; j++ ) {
185 vec = &((*w)[0]).ToVec3();
186 }
else if ( j == 1 ) {
187 vec = &((*w)[i-1]).ToVec3();
189 vec = &((*w)[
i]).ToVec3();
195 for ( k = 0 ; k < 3 ; k++ ) {
225 for ( j = 0 ; j < 3 ; j++ ) {
229 }
else if ( j == 1 ) {
230 vec = &((*w)[
i]).ToVec3();
255 for ( tri = triList ; tri ; tri = tri->
next ) {
281 ClipSideByTree_r( w, side, node->
children[0] );
285 ClipSideByTree_r( w, side, node->
children[1] );
292 ClipSideByTree_r( front, side, node->
children[0] );
293 ClipSideByTree_r( back, side, node->
children[1] );
339 for ( i = 0 ; i < b->
numsides ; i++ ) {
398 TexVecForTri( &texVec, originalTri );
400 AddTriListToArea( e, list, planeNum, node->
area, &texVec );
431 return CheckWindingInAreas_r( w, node->
children[0] );
434 return CheckWindingInAreas_r( w, node->
children[1] );
439 a1 = CheckWindingInAreas_r( front, node->
children[0] );
441 a2 = CheckWindingInAreas_r( back, node->
children[1] );
444 if ( a1 == -2 || a2 == -2 ) {
483 PutWindingIntoAreas_r( e, w, side, node->
children[0] );
487 PutWindingIntoAreas_r( e, w, side, node->
children[1] );
496 area = CheckWindingInAreas_r( w, node );
509 PutWindingIntoAreas_r( e, front, side, node->
children[0] );
514 PutWindingIntoAreas_r( e, back, side, node->
children[1] );
573 TexVecForTri( &texVec, newTri );
575 AddTriListToArea( e, newTri, planeNum, area, &texVec );
609 for ( tri = prim->
tris ; tri ; tri = tri->
next ) {
616 for ( i = 0 ; i < b->
numsides ; i++ ) {
651 if ( angle != 0.0
f ) {
665 memset( &mapTri, 0,
sizeof( mapTri ) );
672 for (
int k = 0 ; k < 3 ; k++ ) {
675 mapTri.
v[k].
xyz = v * axis + origin;
717 for ( i = 0 ; i < 6 ; i++ ) {
735 for ( i = 0 ; i < 6 ; i++ ) {
764 for ( i = 0 ; i < 6 ; i++ ) {
803 bool hasPerforatedSurface =
false;
813 shadowerGroups =
NULL;
820 for ( i = 0 ; i < e->
numAreas ; i++ ) {
842 for ( tri = group->
triList ; tri ; tri = tri->
next ) {
846 ClipTriByLight( light, tri, &in, &out );
862 for ( check = shadowerGroups ; check ; check = check->
nextGroup ) {
872 shadowerGroups = check;
879 hasPerforatedSurface =
true;
890 if ( light->
shadowTris && hasPerforatedSurface ) {
915 for ( i = 0 ; i < e->
numAreas ; i++ ) {
920 for ( group = area->
groups ; group ; group = nextGroup ) {
928 carvedGroups = group;
944 carvedGroups = group;
952 for ( tri = group->
triList ; tri ; tri = tri->
next ) {
955 ClipTriByLight( light, tri, &in, &out );
967 carvedGroups = newGroup;
975 carvedGroups = newGroup;
984 area->
groups = carvedGroups;
1011 for ( i = 0 ; i < e->
numAreas ; i++ ) {
1015 BoundOptimizeGroup( group );
1021 BuildLightShadows( e, light );
1025 common->
Printf(
"%5.1f seconds for BuildLightShadows\n", ( end - start ) / 1000.0 );
1036 CarveGroupsByLight( e, light );
1040 common->
Printf(
"%5.1f seconds for CarveGroupsByLight\n", ( end - start ) / 1000.0 );
int numShadowIndexesNoFrontCaps
bool SurfaceCastsShadow(void) const
bool LightEffectsBackSides() const
const idMaterial * lightShader
float GetFloat(const char *key, const char *defaultString="0") const
mapTri_t * CopyMapTri(const mapTri_t *tri)
void PutPrimitivesInAreas(uEntity_t *e)
bool ReceivesLighting(void) const
void AddToConvexHull(const idWinding *winding, const idVec3 &normal, const float epsilon=ON_EPSILON)
void ClipSidesByTree(uEntity_t *e)
idList< mapLight_t * > mapLights
int Sys_Milliseconds(void)
const idMaterial * shader
idWinding * WindingForTri(const mapTri_t *tri)
int FindFloatPlane(const idPlane &plane, bool *fixedDegeneracies=NULL)
mapTri_t * WindingToTriList(const idWinding *w, const mapTri_t *originalTri)
shadowOptLevel_t shadowOptLevel
mapLight_t * groupLights[MAX_GROUP_LIGHTS]
srfTriangles_t * shadowTris
mapTri_t * MergeTriLists(mapTri_t *a, mapTri_t *b)
int Icmp(const char *text) const
void FreeTriList(mapTri_t *a)
bool LightCastsShadows() const
struct optimizeGroup_s * groups
const idMaterial * material
materialCoverage_t Coverage(void) const
float MapTriArea(const mapTri_t *tri)
bool AddPoint(const idVec3 &v)
void AddMapTriToAreas(mapTri_t *tri, uEntity_t *e)
int GetNumPoints(void) const
struct node_s * children[2]
const char * GetString(const char *key, const char *defaultString="") const
GLubyte GLubyte GLubyte GLubyte w
static float Fabs(float f)
bool GetBool(const char *key, const char *defaultString="0") const
bool NoFragment(void) const
srfTriangles_t * geometry
virtual idRenderModel * FindModel(const char *modelName)=0
void FreeOptimizeGroupList(optimizeGroup_t *groups)
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
virtual const modelSurface_t * Surface(int surfaceNum) const =0
void PlaneForTri(const mapTri_t *tri, idPlane &plane)
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
bool ReceivesFog(void) const
mapTri_t * AllocTri(void)
srfTriangles_t * frustumTris
int numShadowIndexesNoCaps
int Split(const idPlane &plane, const float epsilon, idWinding **front, idWinding **back) const
srfTriangles_t * CreateLightShadow(optimizeGroup_t *shadowerGroups, const mapLight_t *light)
struct primitive_s * next
idRenderModelManager * renderModelManager
const idMaterial * material
#define TEXTURE_OFFSET_EQUAL_EPSILON
idMat3 ToMat3(void) const
bool IntersectsBounds(const idBounds &a) const
#define SNAP_FLOAT_TO_INT
idVec3 GetCenter(void) const
mapTri_t * TriListForSide(const side_t *s, const idWinding *w)
idWinding * Copy(void) const
bool ReceivesLightingOnBackSides(void) const
struct optimizeGroup_s * nextGroup
void ClipTriIntoTree_r(idWinding *w, mapTri_t *originalTri, uEntity_t *e, node_t *node)
const idMaterial * material
const idVec3 & ToVec3(void) const
void * Mem_Alloc(const int size)
#define TEXTURE_VECTOR_EQUAL_EPSILON
idMat3 GetMatrix(const char *key, const char *defaultString=NULL) const
struct bspbrush_s * brush
dmapGlobals_t dmapGlobals
#define SNAP_INT_TO_FLOAT
virtual void Error(const char *fmt,...) id_attribute((format(printf
bool IsDiscrete(void) const
void Prelight(uEntity_t *e)
virtual int NumSurfaces() const =0