29 #include "../idlib/precompiled.h"
50 memset( &
tri, 0,
sizeof(
tri ) );
141 float len, texArea, inva;
156 texArea = ( d0[3] * d1[4] ) - ( d0[4] * d1[3] );
157 inva = 1.0f / texArea;
159 temp[0] = ( d0[0] * d1[4] - d0[4] * d1[0] ) * inva;
160 temp[1] = ( d0[1] * d1[4] - d0[4] * d1[1] ) * inva;
161 temp[2] = ( d0[2] * d1[4] - d0[4] * d1[2] ) * inva;
166 temp[0] = ( d0[3] * d1[0] - d0[0] * d1[3] ) * inva;
167 temp[1] = ( d0[3] * d1[1] - d0[1] * d1[3] ) * inva;
168 temp[2] = ( d0[3] * d1[2] - d0[2] * d1[3] ) * inva;
182 float modelMatrix[16];
211 float invFadeDepth, fade;
222 invFadeDepth = -1.0f / fadeDepth;
225 fade = fadePlanes[0].
Distance( w[i].ToVec3() ) * invFadeDepth;
227 fade = fadePlanes[1].
Distance( w[i].ToVec3() ) * invFadeDepth;
231 }
else if ( fade > 0.99
f ) {
239 for (
int k = 0 ; k < 4 ; k++ ) {
243 }
else if ( icolor > 255 ) {
280 AddWinding( back, decalMaterial, fadePlanes, fadeDepth, startTime );
284 AddWinding( back, decalMaterial, fadePlanes, fadeDepth, startTime );
287 AddWinding( front, decalMaterial, fadePlanes, fadeDepth, startTime );
298 for (
int surfNum = 0; surfNum < model->
NumSurfaces(); surfNum++ ) {
319 byte *cullBits = (
byte *)_alloca16( stri->
numVerts *
sizeof( cullBits[0] ) );
331 if ( cullBits[v1] & cullBits[v2] & cullBits[v3] ) {
345 for (
int j = 0;
j < 3;
j++ ) {
351 for (
int j = 0;
j < 3;
j++ ) {
358 dir = fw[
j].ToVec3() + scale * dir;
364 int orBits = cullBits[
v1] | cullBits[
v2] | cullBits[
v3];
368 if ( orBits & ( 1 <<
j ) ) {
390 int i,
j, minTime, newNumIndexes, newNumVerts;
395 if ( decals ==
NULL ) {
416 if ( newNumIndexes != i ) {
417 for ( j = 0; j < 3; j++ ) {
427 if ( newNumIndexes == 0 ) {
435 memset( inUse, 0,
sizeof( inUse ) );
447 inUse[
i] = newNumVerts;
481 if ( deltaTime > maxTime ) {
485 if ( deltaTime <= decalInfo.
stayTime ) {
492 for ( j = 0; j < 3; j++ ) {
495 for (
int k = 0; k < 4; k++ ) {
496 float fcolor = decalInfo.
start[k] + ( decalInfo.
end[k] - decalInfo.
start[k] ) * f;
500 }
else if ( icolor > 255 ) {
void GetBounds(idBounds &bounds) const
idBounds & TranslateSelf(const idVec3 &translation)
assert(prefInfo.fullscreenBtn)
bool FromPoints(const idVec3 &p1, const idVec3 &p2, const idVec3 &p3, bool fixDegenerate=true)
const idVec3 & Normal(void) const
idBounds projectionBounds
void ReadFromDemoFile(class idDemoFile *f)
static bool CreateProjectionInfo(decalProjectionInfo_t &info, const idFixedWinding &winding, const idVec3 &projectionOrigin, const bool parallel, const float fadeDepth, const idMaterial *material, const int startTime)
void R_AddDrawSurf(const srfTriangles_t *tri, const viewEntity_t *space, const renderEntity_t *renderEntity, const idMaterial *shader, const idScreenRect &scissor)
idBounds & RotateSelf(const idMat3 &rotation)
const idVec3 & ToVec3(void) const
GLenum GLenum GLenum GLenum GLenum scale
idMat3 Transpose(void) const
float Distance(const idVec3 &v) const
int indexStartTime[MAX_DECAL_INDEXES]
const idMaterial * shader
decalInfo_t GetDecalInfo(void) const
bool facePlanesCalculated
GLint GLint GLsizei GLsizei GLsizei depth
void AddDepthFadedWinding(const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime)
idVec3 Cross(const idVec3 &a) const
struct vertCache_s * ambientCache
int Split(idFixedWinding *back, const idPlane &plane, const float epsilon=ON_EPSILON)
static const int MAX_DECAL_INDEXES
bool AllowOverlays(void) const
bool AddPoint(const idVec3 &v)
GLfloat GLfloat GLfloat v2
const idMaterial * material
const int NUM_DECAL_BOUNDING_PLANES
idPlane boundingPlanes[6]
void WriteToDemoFile(class idDemoFile *f) const
int GetNumPoints(void) const
GLubyte GLubyte GLubyte GLubyte w
static const int MAX_DECAL_VERTS
static int FtoiFast(float f)
const idMaterial * material
void AddWinding(const idWinding &w, const idMaterial *decalMaterial, const idPlane fadePlanes[2], float fadeDepth, int startTime)
srfTriangles_t * geometry
virtual const modelSurface_t * Surface(int surfaceNum) const =0
void GetPlane(idVec3 &normal, float &dist) const
void AddDecalDrawSurf(struct viewEntity_s *space)
idRenderEntityLocal * entityDef
GLubyte GLubyte GLubyte a
bool RayIntersection(const idVec3 &start, const idVec3 &dir, float &scale) const
virtual void Printf(const char *fmt,...) id_attribute((format(printf
float Normalize(bool fixDegenerate=true)
vertCache_t * AllocFrameTemp(void *data, int bytes)
static idRenderModelDecal * RemoveFadedDecals(idRenderModelDecal *decals, int time)
void R_GlobalPointToLocal(const float modelMatrix[16], const idVec3 &in, idVec3 &out)
GLfloat GLfloat GLfloat GLfloat v3
float vertDepthFade[MAX_DECAL_VERTS]
bool IntersectsBounds(const idBounds &a) const
void CreateDecal(const idRenderModel *model, const decalProjectionInfo_t &localInfo)
void * R_FrameAlloc(int bytes)
idVertexCache vertexCache
static idRenderModelDecal * Alloc(void)
static void GlobalProjectionInfoToLocal(decalProjectionInfo_t &localInfo, const decalProjectionInfo_t &info, const idVec3 &origin, const idMat3 &axis)
idDrawVert verts[MAX_DECAL_VERTS]
idBounds & ExpandSelf(const float d)
glIndex_t indexes[MAX_DECAL_INDEXES]
idRenderModelDecal * nextDecal
void R_AxisToModelMatrix(const idMat3 &axis, const idVec3 &origin, float modelMatrix[16])
bool ClipInPlace(const idPlane &plane, const float epsilon=ON_EPSILON, const bool keepOn=false)
~idRenderModelDecal(void)
void R_GlobalPlaneToLocal(const float modelMatrix[16], const idPlane &in, idPlane &out)
virtual void VPCALL DecalPointCull(byte *cullBits, const idPlane *planes, const idDrawVert *verts, const int numVerts)=0
static void Free(idRenderModelDecal *decal)
void FitThroughPoint(const idVec3 &p)
idSIMDProcessor * SIMDProcessor
virtual int NumSurfaces() const =0