Skip to content

Commit f6d5449

Browse files
authored
Merge pull request #32 from gimhael/fixminimap
Fix RE_RotatedPic and RE_StretchPicGradient rendering.
2 parents 143da99 + 03c4199 commit f6d5449

File tree

3 files changed

+51
-58
lines changed

3 files changed

+51
-58
lines changed

src/engine/renderer/tr_backend.cpp

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5236,28 +5236,21 @@ const RenderCommand *Poly2dIndexedCommand::ExecuteSelf( ) const
52365236

52375237
// NERVE - SMF
52385238

5239-
#if 0 // unused ?
52405239
/*
52415240
=============
52425241
RB_RotatedPic
52435242
=============
52445243
*/
5245-
const void *RB_RotatedPic( const void *data )
5244+
const RenderCommand *RotatedPicCommand::ExecuteSelf( ) const
52465245
{
5247-
const stretchPicCommand_t *cmd;
5248-
shader_t *shader;
52495246
int numVerts, numIndexes;
52505247
float mx, my, cosA, sinA, cw, ch, sw, sh;
52515248

5252-
cmd = ( const stretchPicCommand_t * ) data;
5253-
52545249
if ( !backEnd.projection2D )
52555250
{
52565251
RB_SetGL2D();
52575252
}
52585253

5259-
shader = cmd->shader;
5260-
52615254
if ( shader != tess.surfaceShader )
52625255
{
52635256
if ( tess.numIndexes )
@@ -5287,50 +5280,50 @@ const void *RB_RotatedPic( const void *data )
52875280
tess.indexes[ numIndexes + 4 ] = numVerts + 0;
52885281
tess.indexes[ numIndexes + 5 ] = numVerts + 1;
52895282

5290-
mx = cmd->x + ( cmd->w / 2 );
5291-
my = cmd->y + ( cmd->h / 2 );
5292-
cosA = cos( DEG2RAD( cmd->angle ) );
5293-
sinA = sin( DEG2RAD( cmd->angle ) );
5294-
cw = cosA * ( cmd->w / 2 );
5295-
ch = cosA * ( cmd->h / 2 );
5296-
sw = sinA * ( cmd->w / 2 );
5297-
sh = sinA * ( cmd->h / 2 );
5283+
mx = x + ( w / 2 );
5284+
my = y + ( h / 2 );
5285+
cosA = cos( DEG2RAD( angle ) );
5286+
sinA = sin( DEG2RAD( angle ) );
5287+
cw = cosA * ( w / 2 );
5288+
ch = cosA * ( h / 2 );
5289+
sw = sinA * ( w / 2 );
5290+
sh = sinA * ( h / 2 );
52985291

52995292
tess.verts[ numVerts ].xyz[ 0 ] = mx - cw - sh;
53005293
tess.verts[ numVerts ].xyz[ 1 ] = my + sw - ch;
53015294
tess.verts[ numVerts ].xyz[ 2 ] = 0.0f;
53025295
tess.verts[ numVerts + 0 ].color = backEnd.color2D;
53035296

5304-
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
5305-
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
5297+
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( s1 );
5298+
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( t1 );
53065299

53075300
tess.verts[ numVerts + 1 ].xyz[ 0 ] = mx + cw - sh;
53085301
tess.verts[ numVerts + 1 ].xyz[ 1 ] = my - sw - ch;
53095302
tess.verts[ numVerts + 1 ].xyz[ 2 ] = 0.0f;
53105303
tess.verts[ numVerts + 1 ].color = backEnd.color2D;
53115304

5312-
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
5313-
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
5305+
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( s2 );
5306+
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( t1 );
53145307

53155308
tess.verts[ numVerts + 2 ].xyz[ 0 ] = mx + cw + sh;
53165309
tess.verts[ numVerts + 2 ].xyz[ 1 ] = my - sw + ch;
53175310
tess.verts[ numVerts + 2 ].xyz[ 2 ] = 0.0f;
53185311
tess.verts[ numVerts + 2 ].color = backEnd.color2D;
53195312

5320-
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
5321-
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
5313+
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( s2 );
5314+
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( t2 );
53225315

53235316
tess.verts[ numVerts + 3 ].xyz[ 0 ] = mx - cw + sh;
53245317
tess.verts[ numVerts + 3 ].xyz[ 1 ] = my + sw + ch;
53255318
tess.verts[ numVerts + 3 ].xyz[ 2 ] = 0.0f;
53265319
tess.verts[ numVerts + 3 ].color = backEnd.color2D;
53275320

5328-
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
5329-
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
5321+
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( s1 );
5322+
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( t2 );
53305323

53315324
tess.attribsSet |= ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR;
53325325

5333-
return ( const void * )( cmd + 1 );
5326+
return this + 1;
53345327
}
53355328

53365329
// -NERVE - SMF
@@ -5340,21 +5333,15 @@ const void *RB_RotatedPic( const void *data )
53405333
RB_StretchPicGradient
53415334
==============
53425335
*/
5343-
const void *RB_StretchPicGradient( const void *data )
5336+
const RenderCommand *GradientPicCommand::ExecuteSelf( ) const
53445337
{
5345-
const stretchPicCommand_t *cmd;
5346-
shader_t *shader;
53475338
int numVerts, numIndexes;
53485339

5349-
cmd = ( const stretchPicCommand_t * ) data;
5350-
53515340
if ( !backEnd.projection2D )
53525341
{
53535342
RB_SetGL2D();
53545343
}
53555344

5356-
shader = cmd->shader;
5357-
53585345
if ( shader != tess.surfaceShader )
53595346
{
53605347
if ( tess.numIndexes )
@@ -5386,41 +5373,40 @@ const void *RB_StretchPicGradient( const void *data )
53865373

53875374
tess.verts[ numVerts + 0 ].color = backEnd.color2D;
53885375
tess.verts[ numVerts + 1 ].color = backEnd.color2D;
5389-
tess.verts[ numVerts + 2 ].color = cmd->gradientColor;
5390-
tess.verts[ numVerts + 3 ].color = cmd->gradientColor;
5376+
tess.verts[ numVerts + 2 ].color = gradientColor;
5377+
tess.verts[ numVerts + 3 ].color = gradientColor;
53915378

5392-
tess.verts[ numVerts ].xyz[ 0 ] = cmd->x;
5393-
tess.verts[ numVerts ].xyz[ 1 ] = cmd->y;
5379+
tess.verts[ numVerts ].xyz[ 0 ] = x;
5380+
tess.verts[ numVerts ].xyz[ 1 ] = y;
53945381
tess.verts[ numVerts ].xyz[ 2 ] = 0.0f;
53955382

5396-
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
5397-
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
5383+
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( s1 );
5384+
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( t1 );
53985385

5399-
tess.verts[ numVerts + 1 ].xyz[ 0 ] = cmd->x + cmd->w;
5400-
tess.verts[ numVerts + 1 ].xyz[ 1 ] = cmd->y;
5386+
tess.verts[ numVerts + 1 ].xyz[ 0 ] = x + w;
5387+
tess.verts[ numVerts + 1 ].xyz[ 1 ] = y;
54015388
tess.verts[ numVerts + 1 ].xyz[ 2 ] = 0.0f;
54025389

5403-
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
5404-
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
5390+
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( s2 );
5391+
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( t1 );
54055392

5406-
tess.verts[ numVerts + 2 ].xyz[ 0 ] = cmd->x + cmd->w;
5407-
tess.verts[ numVerts + 2 ].xyz[ 1 ] = cmd->y + cmd->h;
5393+
tess.verts[ numVerts + 2 ].xyz[ 0 ] = x + w;
5394+
tess.verts[ numVerts + 2 ].xyz[ 1 ] = y + h;
54085395
tess.verts[ numVerts + 2 ].xyz[ 2 ] = 0.0f;
54095396

5410-
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
5411-
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
5397+
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( s2 );
5398+
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( t2 );
54125399

5413-
tess.verts[ numVerts + 3 ].xyz[ 0 ] = cmd->x;
5414-
tess.verts[ numVerts + 3 ].xyz[ 1 ] = cmd->y + cmd->h;
5400+
tess.verts[ numVerts + 3 ].xyz[ 0 ] = x;
5401+
tess.verts[ numVerts + 3 ].xyz[ 1 ] = y + h;
54155402
tess.verts[ numVerts + 3 ].xyz[ 2 ] = 0.0f;
54165403

5417-
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
5418-
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
5404+
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( s1 );
5405+
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( t2 );
54195406

54205407
tess.attribsSet |= ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR;
5421-
return ( const void * )( cmd + 1 );
5408+
return this + 1;
54225409
}
5423-
#endif
54245410

54255411
/*
54265412
=============

src/engine/renderer/tr_cmds.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,9 @@ RE_RotatedPic
691691
*/
692692
void RE_RotatedPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle )
693693
{
694-
StretchPicCommand *cmd;
694+
RotatedPicCommand *cmd;
695695

696-
cmd = R_GetRenderCommand<StretchPicCommand>();
696+
cmd = R_GetRenderCommand<RotatedPicCommand>();
697697

698698
if ( !cmd )
699699
{
@@ -725,9 +725,9 @@ void RE_StretchPicGradient( float x, float y, float w, float h,
725725
qhandle_t hShader, const Color::Color& gradientColor,
726726
int gradientType )
727727
{
728-
StretchPicCommand *cmd;
728+
GradientPicCommand *cmd;
729729

730-
cmd = R_GetRenderCommand<StretchPicCommand>();
730+
cmd = R_GetRenderCommand<GradientPicCommand>();
731731

732732
if ( !cmd )
733733
{

src/engine/renderer/tr_local.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,10 +3765,17 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
37653765
float w, h;
37663766
float s1, t1;
37673767
float s2, t2;
3768+
};
3769+
struct RotatedPicCommand : public StretchPicCommand {
3770+
const RenderCommand *ExecuteSelf() const;
3771+
3772+
float angle;
3773+
};
3774+
struct GradientPicCommand : public StretchPicCommand {
3775+
const RenderCommand *ExecuteSelf() const;
37683776

37693777
Color::Color32Bit gradientColor; // color values 0-255
3770-
int gradientType; //----(SA) added
3771-
float angle; // NERVE - SMF
3778+
int gradientType;
37723779
};
37733780
struct Poly2dCommand : public RenderCommand {
37743781
const RenderCommand *ExecuteSelf() const;

0 commit comments

Comments
 (0)