29 #include "../idlib/precompiled.h"
35 #define LIQUID_MAX_SKIP_FRAMES 5
36 #define LIQUID_MAX_TYPES 3
73 inv_lerp = 1.0f - lerp;
75 for( i = 0; i <
verts.
Num(); i++, vert++ ) {
136 float invlength = 1.0f / (
float )radsquare;
150 if ( x - drop_radius < 1 ) {
151 left -= (x-drop_radius-1);
153 if ( y - drop_radius < 1 ) {
154 top -= (y-drop_radius-1);
156 if ( x + drop_radius >
verts_x - 1 ) {
157 right -= (x+drop_radius-
verts_x+1);
159 if ( y + drop_radius >
verts_y - 1 ) {
160 bottom-= (y+drop_radius-
verts_y+1);
163 for ( cy = top; cy <
bottom; cy++ ) {
164 for ( cx = left; cx <
right; cx++ ) {
165 square = cy*cy + cx*cx;
166 if ( square < radsquare ) {
189 down = bounds[ 0 ].z;
192 if ( ( right < 1 ) || ( left >=
verts_x ) || ( bottom < 1 ) || ( top >=
verts_x ) ) {
210 for ( cy = top; cy <
bottom; cy++ ) {
211 for ( cx = left; cx <
right; cx++ ) {
247 for ( y = 1; y <
verts_y - 1; y++ ) {
250 for ( x = 1; x <
verts_x - 1; x++ ) {
256 p2[ x - verts_x - 1 ] +
257 p2[ x - verts_x + 1 ] +
258 p2[ x + verts_x - 1 ] +
259 p2[ x + verts_x + 1 ] +
260 p2[
x ] ) * ( 2.0
f / 9.0
f ) -
269 for ( y = 1; y < verts_y - 1; y++ ) {
272 for ( x = 1; x <
verts_x - 1; x++ ) {
278 p2[ x - verts_x - 1 ] +
279 p2[ x - verts_x + 1 ] +
280 p2[ x + verts_x - 1 ] +
281 p2[ x + verts_x + 1 ] ) * 0.25
f -
290 for ( y = 1; y < verts_y - 1; y++ ) {
293 for ( x = 1; x <
verts_x - 1; x++ ) {
299 p2[ x - verts_x - 1 ] +
300 p2[ x - verts_x + 1 ] +
301 p2[ x + verts_x - 1 ] +
302 p2[ x + verts_x + 1 ] +
303 p2[
x ] ) * ( 1.0
f / 9.0
f );
331 for ( i = 0, y = 0; y <
verts_y; y++ ) {
332 for ( x = 0; x <
verts_x; x++, i++ ) {
350 float size_x, size_y;
355 if ( !parser.
LoadFile( fileName ) ) {
364 if ( !token.
Icmp(
"seed" ) ) {
366 }
else if ( !token.
Icmp(
"size_x" ) ) {
368 }
else if ( !token.
Icmp(
"size_y" ) ) {
370 }
else if ( !token.
Icmp(
"verts_x" ) ) {
373 parser.
Warning(
"Invalid # of verts. Using default model." );
377 }
else if ( !token.
Icmp(
"verts_y" ) ) {
380 parser.
Warning(
"Invalid # of verts. Using default model." );
384 }
else if ( !token.
Icmp(
"liquid_type" ) ) {
387 parser.
Warning(
"Invalid liquid_type. Using default model." );
391 }
else if ( !token.
Icmp(
"density" ) ) {
393 }
else if ( !token.
Icmp(
"drop_height" ) ) {
395 }
else if ( !token.
Icmp(
"drop_radius" ) ) {
397 }
else if ( !token.
Icmp(
"drop_delay" ) ) {
399 }
else if ( !token.
Icmp(
"shader" ) ) {
402 }
else if ( !token.
Icmp(
"seed" ) ) {
404 }
else if ( !token.
Icmp(
"update_rate" ) ) {
406 if ( ( rate <= 0.0
f ) || ( rate > 60.0
f ) ) {
407 parser.
Warning(
"Invalid update_rate. Must be between 0 and 60. Using default model." );
413 parser.
Warning(
"Unknown parameter '%s'. Using default model.", token.
c_str() );
419 scale_x = size_x / ( verts_x - 1 );
420 scale_y = size_y / ( verts_y - 1 );
427 for ( i = 0, y = 0; y <
verts_y; y++ ) {
428 for ( x = 0; x <
verts_x; x++, i++ ) {
433 verts[
i ].st.Set( (
float) x / (
float)( verts_x - 1 ), (
float) -y / (
float)( verts_y - 1 ) );
437 tris.
SetNum( ( verts_x - 1 ) * ( verts_y - 1 ) * 6 );
438 for( i = 0, y = 0; y < verts_y - 1; y++ ) {
439 for( x = 1; x <
verts_x; x++, i += 6 ) {
440 tris[ i + 0 ] = y * verts_x +
x;
441 tris[ i + 1 ] = y * verts_x + x - 1;
442 tris[ i + 2 ] = ( y + 1 ) * verts_x + x - 1;
444 tris[ i + 3 ] = ( y + 1 ) * verts_x + x - 1;
445 tris[ i + 4 ] = ( y + 1 ) * verts_x + x;
446 tris[ i + 5 ] = y * verts_x +
x;
499 while( frames > 0 ) {
deformInfo_t * R_BuildDeformInfo(int numVerts, const idDrawVert *verts, int numIndexes, const int *indexes, bool useUnsmoothedTangents)
GLsizei const GLfloat * value
virtual dynamicModel_t IsDynamicModel() const
void SetNum(int newnum, bool resize=true)
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp=NULL)=0
idList< idDrawVert > verts
idFileSystem * fileSystem
const idMaterial * shader
static float Sqrt(float x)
void R_DeriveTangents(srfTriangles_t *tri, bool allocFacePlanes=true)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
srfTriangles_t * R_AllocStaticTriSurf(void)
virtual idBounds Bounds(const struct renderEntity_s *ent) const
int Icmp(const char *text) const
static float Cos16(float a)
int ReadToken(idToken *token)
bool AddPoint(const idVec3 &v)
idCVar r_useDeferredTangents("r_useDeferredTangents","1", CVAR_RENDERER|CVAR_BOOL,"defer tangents calculations after deform")
srfTriangles_t * geometry
virtual void InitFromFile(const char *fileName)
void WaterDrop(int x, int y, float *page)
void void Warning(const char *str,...) const id_attribute((format(printf
void R_BoundTriSurf(srfTriangles_t *tri)
ID_INLINE void idSwap(type &a, type &b)
GLdouble GLdouble GLdouble top
virtual void VPCALL Memcpy(void *dst, const void *src, const int count)=0
idDeclManager * declManager
virtual idRenderModel * InstantiateDynamicModel(const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel)
int LoadFile(const char *filename, bool OSPath=false)
void IntersectBounds(const idBounds &bounds, float displacement)
const idMaterial * shader
const char * c_str(void) const
#define LIQUID_MAX_SKIP_FRAMES
modelSurface_t GenerateSurface(float lerp)
void R_AllocStaticTriSurfVerts(srfTriangles_t *tri, int numVerts)
struct deformInfo_s * deformInfo
virtual void AddSurface(modelSurface_t surface)
idSIMDProcessor * SIMDProcessor
dominantTri_t * dominantTris