Skip to content

Commit

Permalink
[MP] Add support for surfaceSprites flatten type in MP.
Browse files Browse the repository at this point in the history
Fixes issues with the sprites not working on t2_trip.
Thanks to Didz for pointing out there was an issue here even in base.
  • Loading branch information
ensiform committed Mar 3, 2014
1 parent 2ddcb4e commit 455e592
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ Key: - removed, + added, * modified
[MP] * gamecode: Fix cg_smoothClients affecting local player negatively
[MP] * gamecode: Rewrote callvote code to allow disabling specific votes, added more options (e.g. display map list)
[SP] + gamecode: Added cg_smoothCamera (default 1)
[SP] + gamecode: Added cg_dynamicCrosshair (default 1)
[SP] + gamecode: Added cg_dynamicCrosshair (default 1)
[MP] + Added support for surfaceSprites flattened in MP. (Fixes surface sprites on t2_trip)
1 change: 1 addition & 0 deletions codemp/rd-dedicated/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ typedef struct texModInfo_s {
#define SURFSPRITE_ORIENTED 2
#define SURFSPRITE_EFFECT 3
#define SURFSPRITE_WEATHERFX 4
#define SURFSPRITE_FLATTENED 5

#define SURFSPRITE_FACING_NORMAL 0
#define SURFSPRITE_FACING_UP 1
Expand Down
4 changes: 4 additions & 0 deletions codemp/rd-dedicated/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@ static void ParseSurfaceSprites( const char *_text, shaderStage_t *stage )
{
sstype = SURFSPRITE_EFFECT;
}
else if (!Q_stricmp(token, "flattened"))
{
sstype = SURFSPRITE_FLATTENED;
}
else
{
Com_Printf (S_COLOR_YELLOW "WARNING: invalid type in shader '%s'\n", shader.name );
Expand Down
1 change: 1 addition & 0 deletions codemp/rd-vanilla/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ typedef struct texModInfo_s {
#define SURFSPRITE_ORIENTED 2
#define SURFSPRITE_EFFECT 3
#define SURFSPRITE_WEATHERFX 4
#define SURFSPRITE_FLATTENED 5

#define SURFSPRITE_FACING_NORMAL 0
#define SURFSPRITE_FACING_UP 1
Expand Down
4 changes: 4 additions & 0 deletions codemp/rd-vanilla/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ static void ParseSurfaceSprites( const char *_text, shaderStage_t *stage )
{
sstype = SURFSPRITE_EFFECT;
}
else if (!Q_stricmp(token, "flattened"))
{
sstype = SURFSPRITE_FLATTENED;
}
else
{
ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid type in shader '%s'\n", shader.name );
Expand Down
36 changes: 28 additions & 8 deletions codemp/rd-vanilla/tr_surfacesprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ qboolean SSUsingFog=qfalse;
// Vertical surface sprites

static void RB_VerticalSurfaceSprite(vec3_t loc, float width, float height, byte light,
byte alpha, float wind, float windidle, vec2_t fog, int hangdown, vec2_t skew)
byte alpha, float wind, float windidle, vec2_t fog, int hangdown, vec2_t skew, bool flattened)
{
vec3_t loc2, right;
float angle;
Expand Down Expand Up @@ -366,7 +366,16 @@ static void RB_VerticalSurfaceSprite(vec3_t loc, float width, float height, byte
loc2[2] += sin(angle*2.5)*windsway;
}

VectorScale(ssrightvectors[rightvectorcount], width*0.5, right);
if ( flattened )
{
right[0] = sin( DEG2RAD( loc[0] ) ) * width;
right[1] = cos( DEG2RAD( loc[0] ) ) * height;
right[2] = 0.0f;
}
else
{
VectorScale(ssrightvectors[rightvectorcount], width*0.5, right);
}

color[0]=light;
color[1]=light;
Expand Down Expand Up @@ -407,7 +416,7 @@ static void RB_VerticalSurfaceSprite(vec3_t loc, float width, float height, byte

static void RB_VerticalSurfaceSpriteWindPoint(vec3_t loc, float width, float height, byte light,
byte alpha, float wind, float windidle, vec2_t fog,
int hangdown, vec2_t skew, vec2_t winddiff, float windforce)
int hangdown, vec2_t skew, vec2_t winddiff, float windforce, bool flattened)
{
vec3_t loc2, right;
float angle;
Expand Down Expand Up @@ -452,7 +461,17 @@ static void RB_VerticalSurfaceSpriteWindPoint(vec3_t loc, float width, float hei
loc2[1] += height*winddiff[1]*windforce;
loc2[2] -= height*windforce*(0.75 + 0.15*sin((tr.refdef.time + 500*windforce)*0.01));

VectorScale(ssrightvectors[rightvectorcount], width*0.5, right);
if ( flattened )
{
right[0] = sin( DEG2RAD( loc[0] ) ) * width;
right[1] = cos( DEG2RAD( loc[0] ) ) * height;
right[2] = 0.0f;
}
else
{
VectorScale(ssrightvectors[rightvectorcount], width*0.5, right);
}


color[0]=light;
color[1]=light;
Expand Down Expand Up @@ -759,26 +778,26 @@ static void RB_DrawVerticalSurfaceSprites( shaderStage_t *stage, shaderCommands_
{
RB_VerticalSurfaceSpriteWindPoint(curpoint, width, height, (byte)light, (byte)(alpha*255.0),
stage->ss->wind, stage->ss->windIdle, fogv, stage->ss->facing, skew,
winddiffv, windforce);
winddiffv, windforce, SURFSPRITE_FLATTENED == stage->ss->surfaceSpriteType);
}
else
{
RB_VerticalSurfaceSpriteWindPoint(curpoint, width, height, (byte)light, (byte)(alpha*255.0),
stage->ss->wind, stage->ss->windIdle, NULL, stage->ss->facing, skew,
winddiffv, windforce);
winddiffv, windforce, SURFSPRITE_FLATTENED == stage->ss->surfaceSpriteType);
}
}
else
{
if (SSUsingFog)
{
RB_VerticalSurfaceSprite(curpoint, width, height, (byte)light, (byte)(alpha*255.0),
stage->ss->wind, stage->ss->windIdle, fogv, stage->ss->facing, skew);
stage->ss->wind, stage->ss->windIdle, fogv, stage->ss->facing, skew, SURFSPRITE_FLATTENED == stage->ss->surfaceSpriteType);
}
else
{
RB_VerticalSurfaceSprite(curpoint, width, height, (byte)light, (byte)(alpha*255.0),
stage->ss->wind, stage->ss->windIdle, NULL, stage->ss->facing, skew);
stage->ss->wind, stage->ss->windIdle, NULL, stage->ss->facing, skew, SURFSPRITE_FLATTENED == stage->ss->surfaceSpriteType);
}
}

Expand Down Expand Up @@ -1441,6 +1460,7 @@ void RB_DrawSurfaceSprites( shaderStage_t *stage, shaderCommands_t *input)

switch(stage->ss->surfaceSpriteType)
{
case SURFSPRITE_FLATTENED:
case SURFSPRITE_VERTICAL:
RB_DrawVerticalSurfaceSprites(stage, input);
break;
Expand Down

0 comments on commit 455e592

Please sign in to comment.