Skip to content

Commit

Permalink
[rend2] Add missing weather functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaZ committed Oct 8, 2023
1 parent f319d69 commit 83c3984
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
8 changes: 2 additions & 6 deletions code/rd-rend2/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2190,10 +2190,6 @@ void RE_SetLightStyle(int style, int color)
}

void RE_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal);
void RE_WorldEffectCommand(const char *cmd);
bool R_IsShaking(vec3_t pos);
bool R_GetWindVector(vec3_t windVector, vec3_t atPoint); // doesn't work?
bool R_GetWindGusting(vec3_t atPoint); // doesn't work


void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} // Intentionally left blank. Rend2 reads the zones manually on bsp load
Expand Down Expand Up @@ -2385,8 +2381,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) {
re.GetWindVector = R_GetWindVector;
re.GetWindGusting = R_GetWindGusting;
re.IsOutside = R_IsOutside;
re.IsOutsideCausingPain = stub_R_IsOutsideCausingPain;
re.GetChanceOfSaberFizz = stub_R_GetChanceOfSaberFizz;
re.IsOutsideCausingPain = R_IsOutsideCausingPain;
re.GetChanceOfSaberFizz = R_GetChanceOfSaberFizz;
re.IsShaking = R_IsShaking;
re.AddWeatherZone = stub_RE_AddWeatherZone;
re.SetTempGlobalFogColor = stub_R_SetTempGlobalFogColor;
Expand Down
58 changes: 51 additions & 7 deletions shared/rd-rend2/tr_weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ void RE_WorldEffectCommand(const char *command)

tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f;

tr.weatherSystem->pain = 0.1f;

imgType_t type = IMGTYPE_COLORALPHA;
int flags = IMGFLAG_CLAMPTOEDGE;
tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags);
Expand Down Expand Up @@ -1071,7 +1073,11 @@ void RE_WorldEffectCommand(const char *command)
}
else if (Q_stricmp(token, "outsidepain") == 0)
{
#ifdef REND2_SP
tr.weatherSystem->pain = !tr.weatherSystem->pain;
#else
ri.Printf(PRINT_DEVELOPER, "outsidepain isn't supported in MP\n");
#endif
}
else
{
Expand Down Expand Up @@ -1339,17 +1345,55 @@ bool R_GetWindVector(vec3_t windVector, vec3_t atPoint)
}

VectorCopy(tr.weatherSystem->windDirection, windVector);

VectorNormalize(windVector);
// everything is processed in RB_SurfaceWeather, no need to add something here
return (tr.weatherSystem->activeWindObjects > 0);
return (VectorLength(windVector) > 0.0f);
}

bool R_GetWindGusting(vec3_t atPoint)
{
float windSpeed = 0.f;
// @TODO: need to process "Windzone" command
//R_GetWindSpeed(windSpeed, atPoint);
if (!tr.weatherSystem)
return false;

// this line doesn't work
return (tr.weatherSystem && tr.weatherSystem->windSpeed > 1000.0f);
float windSpeed = VectorLength(tr.weatherSystem->windDirection);
return (windSpeed > 1.0f);
}

float R_IsOutsideCausingPain(vec3_t pos)
{
return (R_IsOutside(pos) && tr.weatherSystem->pain);
}

float R_GetChanceOfSaberFizz()
{
float chance = 0.0f;
int numWater = 0;
if (tr.weatherSystem->weatherSlots[WEATHER_RAIN].active)
{
chance += (tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity / 20.0f);
numWater++;
}
if (tr.weatherSystem->weatherSlots[WEATHER_SNOW].active)
{
chance += (tr.weatherSystem->weatherSlots[WEATHER_SNOW].gravity / 20.0f);
numWater++;
}
if (numWater)
{
return (chance / numWater);
}
return 0.0f;
}

bool R_IsRaining()
{
if (!tr.weatherSystem)
return false;

return tr.weatherSystem->weatherSlots[WEATHER_RAIN].active;
}

bool R_IsPuffing()
{
return false;
}
7 changes: 7 additions & 0 deletions shared/rd-rend2/tr_weather.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct weatherSystem_t
int numWeatherBrushes = 0;
bool frozen;
bool shaking;
float pain = 0.0f;

srfWeather_t weatherSurface;

Expand All @@ -119,5 +120,11 @@ void R_AddWeatherBrush(uint8_t numPlanes, vec4_t *planes);
void R_ShutdownWeatherSystem();
void RB_SurfaceWeather( srfWeather_t *surfaceType );
bool R_IsOutside(vec3_t pos);
bool R_IsShaking(vec3_t pos);
float R_IsOutsideCausingPain(vec3_t pos);
float R_GetChanceOfSaberFizz();
bool R_GetWindVector(vec3_t windVector, vec3_t atPoint); // doesn't work?
bool R_GetWindGusting(vec3_t atPoint); // doesn't work

void RE_WorldEffectCommand(const char *cmd);
void R_WorldEffect_f(void);

0 comments on commit 83c3984

Please sign in to comment.