mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
ref: gl: merge refactoring changes from litwater branch
This commit is contained in:
@@ -2014,7 +2014,7 @@ static void Mod_SetupSubmodels( model_t *mod, dbspmodel_t *bmod )
|
||||
SetBits( mod->flags, MODEL_HAS_ORIGIN );
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
// c2a1 doesn't have origin brush it's just placed at center of the level
|
||||
if( !Q_stricmp( name, "maps/c2a1.bsp" ) && ( i == 11 ))
|
||||
if( i == 11 && !Q_stricmp( name, "maps/c2a1.bsp" ))
|
||||
SetBits( mod->flags, MODEL_HAS_ORIGIN );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ GNU General Public License for more details.
|
||||
#define MODEL_CLIENT BIT( 30 ) // client sprite
|
||||
|
||||
// goes into world.flags
|
||||
#define FWORLD_SKYSPHERE BIT( 0 )
|
||||
#define FWORLD_CUSTOM_SKYBOX BIT( 1 )
|
||||
#define FWORLD_WATERALPHA BIT( 2 )
|
||||
#define FWORLD_HAS_DELUXEMAP BIT( 3 )
|
||||
#define FWORLD_SKYSPHERE BIT( 0 )
|
||||
#define FWORLD_CUSTOM_SKYBOX BIT( 1 )
|
||||
#define FWORLD_WATERALPHA BIT( 2 )
|
||||
#define FWORLD_HAS_DELUXEMAP BIT( 3 )
|
||||
|
||||
// special rendermode for screenfade modulate
|
||||
// (probably will be expanded at some point)
|
||||
|
||||
@@ -493,7 +493,6 @@ void R_ClearSkyBox( void );
|
||||
void R_DrawSkyBox( void );
|
||||
void R_DrawClouds( void );
|
||||
void R_UnloadSkybox( void );
|
||||
void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples );
|
||||
void R_ResetRipples( void );
|
||||
void R_AnimateRipples( void );
|
||||
qboolean R_UploadRipples( texture_t *image );
|
||||
|
||||
@@ -17,6 +17,14 @@ GNU General Public License for more details.
|
||||
#include "xash3d_mathlib.h"
|
||||
#include "mod_local.h"
|
||||
|
||||
#define TURBSCALE ( 256.0f / ( M_PI2 ))
|
||||
|
||||
// speed up sin calculations
|
||||
static const float r_turbsin[] =
|
||||
{
|
||||
#include "warpsin.h"
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int allocated[BLOCK_SIZE_MAX];
|
||||
@@ -324,7 +332,8 @@ void GL_SubdivideSurface( model_t *loadmodel, msurface_t *fa )
|
||||
for( i = 0; i < fa->numedges; i++ )
|
||||
R_GetEdgePosition( loadmodel, fa, i, verts[i] );
|
||||
|
||||
SetBits( fa->flags, SURF_DRAWTURB_QUADS ); // predict state
|
||||
if( glConfig.context == CONTEXT_TYPE_GL )
|
||||
SetBits( fa->flags, SURF_DRAWTURB_QUADS ); // predict state
|
||||
|
||||
// do subdivide
|
||||
SubdividePolygon_r( loadmodel, fa, fa->numedges, verts[0] );
|
||||
@@ -944,6 +953,89 @@ static void DrawGLPoly( glpoly2_t *p, float xScale, float yScale )
|
||||
GL_SetupFogColorForSurfaces();
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
EmitWaterPolys
|
||||
|
||||
Does a water warp on the pre-fragmented glpoly_t chain
|
||||
=============
|
||||
*/
|
||||
void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples )
|
||||
{
|
||||
float *v, nv, waveHeight;
|
||||
float s, t, os, ot;
|
||||
glpoly2_t *p;
|
||||
int i;
|
||||
|
||||
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS ) && glConfig.context == CONTEXT_TYPE_GL;
|
||||
|
||||
if( !warp->polys ) return;
|
||||
|
||||
// set the current waveheight
|
||||
if( warp->polys->verts[0][2] >= RI.vieworg[2] )
|
||||
waveHeight = -RI.currententity->curstate.scale;
|
||||
else waveHeight = RI.currententity->curstate.scale;
|
||||
|
||||
// reset fog color for nonlightmapped water
|
||||
GL_ResetFogColor();
|
||||
|
||||
if( useQuads )
|
||||
pglBegin( GL_QUADS );
|
||||
|
||||
for( p = warp->polys; p; p = p->next )
|
||||
{
|
||||
if( reverse )
|
||||
v = p->verts[0] + ( p->numverts - 1 ) * VERTEXSIZE;
|
||||
else v = p->verts[0];
|
||||
|
||||
if( !useQuads )
|
||||
pglBegin( GL_POLYGON );
|
||||
|
||||
for( i = 0; i < p->numverts; i++ )
|
||||
{
|
||||
if( waveHeight )
|
||||
{
|
||||
nv = r_turbsin[(int)(gp_cl->time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
|
||||
nv = (r_turbsin[(int)(v[0] * 5.0f + gp_cl->time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
|
||||
nv = nv * waveHeight + v[2];
|
||||
}
|
||||
else nv = v[2];
|
||||
|
||||
os = v[3];
|
||||
ot = v[4];
|
||||
|
||||
if( !ripples )
|
||||
{
|
||||
s = os + r_turbsin[(int)((ot * 0.125f + gp_cl->time) * TURBSCALE) & 255];
|
||||
t = ot + r_turbsin[(int)((os * 0.125f + gp_cl->time) * TURBSCALE) & 255];
|
||||
}
|
||||
else
|
||||
{
|
||||
s = os;
|
||||
t = ot;
|
||||
}
|
||||
|
||||
s *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
t *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
|
||||
pglTexCoord2f( s, t );
|
||||
pglVertex3f( v[0], v[1], nv );
|
||||
|
||||
if( reverse )
|
||||
v -= VERTEXSIZE;
|
||||
else v += VERTEXSIZE;
|
||||
}
|
||||
|
||||
if( !useQuads )
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
if( useQuads )
|
||||
pglEnd();
|
||||
|
||||
GL_SetupFogColorForSurfaces();
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
DrawGLPolyChain
|
||||
@@ -2461,14 +2553,13 @@ static texture_t *R_SetupVBOTexture( texture_t *tex, int number )
|
||||
}
|
||||
else R_DisableDetail();
|
||||
|
||||
GL_Bind( mtst.tmu_gl, r_lightmap->value ?tr.whiteTexture:tex->gl_texturenum );
|
||||
if(number)
|
||||
GL_Bind( mtst.tmu_gl, r_lightmap->value ? tr.whiteTexture : tex->gl_texturenum );
|
||||
if( number )
|
||||
vboarray.itexture = number;
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
static void R_SetupVBOArrayStatic( vboarray_t *vbo, qboolean drawlightmap, qboolean drawtextures )
|
||||
{
|
||||
if( vboarray.astate != VBO_ARRAY_STATIC )
|
||||
@@ -2483,7 +2574,6 @@ static void R_SetupVBOArrayStatic( vboarray_t *vbo, qboolean drawlightmap, qbool
|
||||
pglVertexPointer( 3, GL_FLOAT, sizeof( vbovertex_t ), (void*)offsetof(vbovertex_t,pos) );
|
||||
}
|
||||
|
||||
|
||||
// setup multitexture
|
||||
if( drawtextures && vboarray.tstate != VBO_TEXTURE_MAIN )
|
||||
{
|
||||
@@ -2512,11 +2602,8 @@ static void R_SetupVBOArrayStatic( vboarray_t *vbo, qboolean drawlightmap, qbool
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void R_SetupVBOArrayDlight( vboarray_t *vbo, texture_t *texture )
|
||||
{
|
||||
|
||||
if( vboarray.astate != VBO_ARRAY_DLIGHT )
|
||||
{
|
||||
if( vboarray.astate == VBO_ARRAY_DECAL_DLIGHT )
|
||||
@@ -2584,7 +2671,6 @@ static void R_SetupVBOArrayDecalDlight( int decalcount )
|
||||
vboarray.lstate = VBO_LIGHTMAP_DYNAMIC;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
R_AdditionalPasses
|
||||
@@ -2652,11 +2738,9 @@ static void R_AdditionalPasses( vboarray_t *vbo, int indexlen, void *indexarray,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define MINIMIZE_UPLOAD
|
||||
#define DISCARD_DLIGHTS
|
||||
|
||||
|
||||
static void R_DrawDlightedDecals( vboarray_t *vbo, msurface_t *newsurf, msurface_t *surf, int decalcount, texture_t *texture )
|
||||
{
|
||||
msurface_t *decalsurf;
|
||||
|
||||
@@ -19,7 +19,6 @@ GNU General Public License for more details.
|
||||
|
||||
#define SKYCLOUDS_QUALITY 12
|
||||
#define MAX_CLIP_VERTS 128 // skybox clip vertices
|
||||
#define TURBSCALE ( 256.0f / ( M_PI2 ))
|
||||
|
||||
static const int r_skyTexOrder[SKYBOX_MAX_SIDES] = { 0, 2, 1, 3, 4, 5 };
|
||||
|
||||
@@ -55,12 +54,6 @@ static const int vec_to_st[SKYBOX_MAX_SIDES][3] =
|
||||
{ -2, 1, -3 }
|
||||
};
|
||||
|
||||
// speed up sin calculations
|
||||
static float r_turbsin[] =
|
||||
{
|
||||
#include "warpsin.h"
|
||||
};
|
||||
|
||||
#define RIPPLES_CACHEWIDTH_BITS 7
|
||||
#define RIPPLES_CACHEWIDTH ( 1 << RIPPLES_CACHEWIDTH_BITS )
|
||||
#define RIPPLES_CACHEWIDTH_MASK (( RIPPLES_CACHEWIDTH ) - 1 )
|
||||
@@ -563,89 +556,6 @@ void R_DrawClouds( void )
|
||||
pglFogf( GL_FOG_DENSITY, RI.fogDensity );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
EmitWaterPolys
|
||||
|
||||
Does a water warp on the pre-fragmented glpoly_t chain
|
||||
=============
|
||||
*/
|
||||
void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples )
|
||||
{
|
||||
float *v, nv, waveHeight;
|
||||
float s, t, os, ot;
|
||||
glpoly2_t *p;
|
||||
int i;
|
||||
|
||||
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS ) && glConfig.context == CONTEXT_TYPE_GL;
|
||||
|
||||
if( !warp->polys ) return;
|
||||
|
||||
// set the current waveheight
|
||||
if( warp->polys->verts[0][2] >= RI.vieworg[2] )
|
||||
waveHeight = -RI.currententity->curstate.scale;
|
||||
else waveHeight = RI.currententity->curstate.scale;
|
||||
|
||||
// reset fog color for nonlightmapped water
|
||||
GL_ResetFogColor();
|
||||
|
||||
if( useQuads )
|
||||
pglBegin( GL_QUADS );
|
||||
|
||||
for( p = warp->polys; p; p = p->next )
|
||||
{
|
||||
if( reverse )
|
||||
v = p->verts[0] + ( p->numverts - 1 ) * VERTEXSIZE;
|
||||
else v = p->verts[0];
|
||||
|
||||
if( !useQuads )
|
||||
pglBegin( GL_POLYGON );
|
||||
|
||||
for( i = 0; i < p->numverts; i++ )
|
||||
{
|
||||
if( waveHeight )
|
||||
{
|
||||
nv = r_turbsin[(int)(gp_cl->time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
|
||||
nv = (r_turbsin[(int)(v[0] * 5.0f + gp_cl->time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
|
||||
nv = nv * waveHeight + v[2];
|
||||
}
|
||||
else nv = v[2];
|
||||
|
||||
os = v[3];
|
||||
ot = v[4];
|
||||
|
||||
if( !ripples )
|
||||
{
|
||||
s = os + r_turbsin[(int)((ot * 0.125f + gp_cl->time) * TURBSCALE) & 255];
|
||||
t = ot + r_turbsin[(int)((os * 0.125f + gp_cl->time) * TURBSCALE) & 255];
|
||||
}
|
||||
else
|
||||
{
|
||||
s = os;
|
||||
t = ot;
|
||||
}
|
||||
|
||||
s *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
t *= ( 1.0f / SUBDIVIDE_SIZE );
|
||||
|
||||
pglTexCoord2f( s, t );
|
||||
pglVertex3f( v[0], v[1], nv );
|
||||
|
||||
if( reverse )
|
||||
v -= VERTEXSIZE;
|
||||
else v += VERTEXSIZE;
|
||||
}
|
||||
|
||||
if( !useQuads )
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
if( useQuads )
|
||||
pglEnd();
|
||||
|
||||
GL_SetupFogColorForSurfaces();
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user