mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- transitioned all tileLeftOffset and tileTopOffset calls to use the texture manager.
This commit is contained in:
parent
e37de147dc
commit
f479f995a1
13 changed files with 71 additions and 53 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "printf.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "coreactor.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
enum { MAXCLIPDIST = 1024 };
|
||||
|
||||
|
@ -463,12 +464,12 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
continue;
|
||||
|
||||
// the rest is for slope sprites only.
|
||||
const int32_t tilenum = actor->spr.picnum;
|
||||
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
||||
const int32_t cosang = bcos(actor->int_ang());
|
||||
const int32_t sinang = bsin(actor->int_ang());
|
||||
vec2_t const span = { tileWidth(tilenum), tileHeight(tilenum) };
|
||||
vec2_t const span = { (int)tex->GetDisplayWidth(), (int)tex->GetDisplayHeight() };
|
||||
vec2_t const repeat = { int(actor->spr.scale.X * scaletoint), int(actor->spr.scale.Y * scaletoint) };
|
||||
vec2_t adjofs = { tileLeftOffset(tilenum), tileTopOffset(tilenum) };
|
||||
vec2_t adjofs = { (int)tex->GetDisplayTopOffset(), (int)tex->GetDisplayTopOffset() };
|
||||
|
||||
if (actor->spr.cstat & CSTAT_SPRITE_XFLIP)
|
||||
adjofs.X = -adjofs.X;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "gamefuncs.h"
|
||||
#include "raze_sound.h"
|
||||
#include "vm.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
// Doubly linked ring list of Actors
|
||||
|
||||
|
@ -528,9 +529,10 @@ size_t DCoreActor::PropagateMark()
|
|||
|
||||
double DCoreActor::GetOffsetAndHeight(double& height)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(spr.spritetexture());
|
||||
double yscale = spr.scale.Y;
|
||||
height = tileHeight(spr.picnum) * yscale;
|
||||
height = tex->GetDisplayHeight() * yscale;
|
||||
double zofs = (spr.cstat & CSTAT_SPRITE_YCENTER) ? height * 0.5 : 0;
|
||||
return zofs - tileTopOffset(spr.picnum) * yscale;
|
||||
return zofs - tex->GetDisplayTopOffset() * yscale;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "gamefuncs.h"
|
||||
#include "hw_sections.h"
|
||||
#include "coreactor.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE)
|
||||
CVAR(Bool, am_rotate, true, CVAR_ARCHIVE)
|
||||
CVAR(Float, am_linealpha, 1.0f, CVAR_ARCHIVE)
|
||||
|
@ -637,15 +639,16 @@ void DrawAutomapAlignmentFacing(const spritetype& spr, const DVector2& bpos, con
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Draws lines for alls in Duke/SW when cstat is CSTAT_SPRITE_ALIGNMENT_WALL.
|
||||
// Draws lines for sprites in Duke/SW when cstat is CSTAT_SPRITE_ALIGNMENT_WALL.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DrawAutomapAlignmentWall(const spritetype& spr, const DVector2& bpos, const DVector2& cangvect, const double czoom, const DVector2& xydim, const PalEntry& col)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(spr.spritetexture());
|
||||
auto xrep = spr.scale.X;
|
||||
auto xspan = tileWidth(spr.picnum);
|
||||
auto xoff = tileLeftOffset(spr.picnum) + spr.xoffset;
|
||||
int xspan = (int)tex->GetDisplayWidth();
|
||||
int xoff = (int)tex->GetDisplayLeftOffset() + spr.xoffset;
|
||||
|
||||
if ((spr.cstat & CSTAT_SPRITE_XFLIP) > 0) xoff = -xoff;
|
||||
|
||||
|
@ -669,12 +672,14 @@ void DrawAutomapAlignmentWall(const spritetype& spr, const DVector2& bpos, const
|
|||
|
||||
void DrawAutomapAlignmentFloor(const spritetype& spr, const DVector2& bpos, const DVector2& cangvect, const double czoom, const DVector2& xydim, const PalEntry& col)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(spr.spritetexture());
|
||||
|
||||
auto xrep = spr.scale.X;
|
||||
auto yrep = spr.scale.Y;
|
||||
auto xspan = tileWidth(spr.picnum);
|
||||
auto yspan = tileHeight(spr.picnum);
|
||||
auto xoff = tileLeftOffset(spr.picnum);
|
||||
auto yoff = tileTopOffset(spr.picnum);
|
||||
int xspan = (int)tex->GetDisplayWidth();
|
||||
int yspan = (int)tex->GetDisplayHeight();
|
||||
int xoff = (int)tex->GetDisplayLeftOffset();
|
||||
int yoff = (int)tex->GetDisplayTopOffset();
|
||||
|
||||
if (isSWALL() || (spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLOPE)
|
||||
{
|
||||
|
|
|
@ -160,12 +160,13 @@ void processTileImport(const char* cmd, FScriptPosition& pos, TileImport& imp)
|
|||
// This is not quite the same as originally, for two reasons:
|
||||
// 1: Since these are texture properties now, there's no need to clear them.
|
||||
// 2: The original code assumed that an imported texture cannot have an offset. But this can import Doom patches and PNGs with grAb, so the situation is very different.
|
||||
if (imp.xoffset == INT_MAX) imp.xoffset = tileLeftOffset(imp.tile);
|
||||
auto tex = tileGetTexture(imp.tile);
|
||||
|
||||
if (imp.xoffset == INT_MAX) imp.xoffset = tex->GetTexelLeftOffset();
|
||||
else imp.xoffset = clamp(imp.xoffset, -128, 127);
|
||||
if (imp.yoffset == INT_MAX) imp.yoffset = tileTopOffset(imp.tile);
|
||||
if (imp.yoffset == INT_MAX) imp.yoffset = tex->GetTexelTopOffset();
|
||||
else imp.yoffset = clamp(imp.yoffset, -128, 127);
|
||||
|
||||
auto tex = tileGetTexture(imp.tile);
|
||||
if (tex)
|
||||
{
|
||||
tex->SetOffsets(imp.xoffset, imp.yoffset);
|
||||
|
|
|
@ -394,20 +394,6 @@ inline int tileHeight(int num)
|
|||
return (int)TileFiles.tiledata[num].texture->GetDisplayHeight();
|
||||
}
|
||||
|
||||
inline int tileLeftOffset(int num)
|
||||
{
|
||||
assert((unsigned)num < MAXTILES);
|
||||
if ((unsigned)num >= MAXTILES) return 0;
|
||||
return (int)TileFiles.tiledata[num].texture->GetDisplayLeftOffset();
|
||||
}
|
||||
|
||||
inline int tileTopOffset(int num)
|
||||
{
|
||||
assert((unsigned)num < MAXTILES);
|
||||
if ((unsigned)num >= MAXTILES) return 0;
|
||||
return (int)TileFiles.tiledata[num].texture->GetDisplayTopOffset();
|
||||
}
|
||||
|
||||
int tileAnimateOfs(int tilenum, int randomize = -1);
|
||||
|
||||
inline void tileUpdatePicnum(int* const tileptr, bool mayrotate = false, int randomize = -1)
|
||||
|
|
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "v_font.h"
|
||||
#include "hw_voxels.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "texturemanager.h"
|
||||
#include "models/modeldata.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
@ -389,8 +390,9 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
|
|||
if (!VanillaMode() && (pTSprite->type == kThingDroppedLifeLeech)) // fix shadow for thrown lifeleech
|
||||
pNSprite->picnum = 800;
|
||||
pNSprite->pal = 5;
|
||||
int height = tileHeight(pNSprite->picnum);
|
||||
int center = height / 2 + tileTopOffset(pNSprite->picnum);
|
||||
auto tex = TexMan.GetGameTexture(pNSprite->spritetexture());
|
||||
double height = tex->GetDisplayHeight();
|
||||
double center = height / 2 + tex->GetDisplayTopOffset();
|
||||
pNSprite->pos.Z -= (pNSprite->scale.Y) * (height - center);
|
||||
break;
|
||||
}
|
||||
|
@ -636,7 +638,8 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
|
|||
{
|
||||
pTSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
|
||||
pTSprite->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
|
||||
pTSprite->yoffset += tileTopOffset(pTSprite->picnum);
|
||||
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());
|
||||
pTSprite->yoffset += (uint8_t)tex->GetDisplayTopOffset();
|
||||
pTSprite->picnum = tprops[pTSprite->spritetexture()].voxelIndex;
|
||||
if ((picanm[nTile].extra & 7) == 7)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
//-------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mapstructs.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -85,8 +87,9 @@ void GetSpriteExtents(spritetypebase const* const pSprite, double* top, double*
|
|||
*top = *bottom = pSprite->pos.Z;
|
||||
if ((pSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_FLOOR)
|
||||
{
|
||||
int height = tileHeight(pSprite->picnum);
|
||||
int center = height / 2 + tileTopOffset(pSprite->picnum);
|
||||
auto tex = TexMan.GetGameTexture(pSprite->spritetexture());
|
||||
double height = tex->GetDisplayHeight();
|
||||
double center = height / 2 + tex->GetDisplayTopOffset();
|
||||
*top -= pSprite->scale.Y * center;
|
||||
*bottom += pSprite->scale.Y * (height - center);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ static void viewBurnTime(int gScale)
|
|||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
int nTile = burnTable[i].nTile + tileAnimateOfs(burnTable[i].nTile, i);
|
||||
int nTile = burnTable[i].nTile;
|
||||
tileUpdatePicnum(&nTile);
|
||||
int nScale = burnTable[i].nScale;
|
||||
if (gScale < 600)
|
||||
{
|
||||
|
|
|
@ -3311,8 +3311,12 @@ void useEffectGen(DBloodActor* sourceactor, DBloodActor* actor)
|
|||
pos = bottom;
|
||||
break;
|
||||
case 2: // middle
|
||||
pos = actor->spr.pos.Z + (tileHeight(actor->spr.picnum) / 2 + tileTopOffset(actor->spr.picnum)) * actor->spr.scale.Y;
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
||||
double center = tex->GetDisplayHeight() / 2 + tex->GetDisplayTopOffset();
|
||||
pos = actor->spr.pos.Z + center * actor->spr.scale.Y;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
if (actor->insector())
|
||||
|
@ -3752,9 +3756,13 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, sectortype* pSector
|
|||
pos.Z = top;
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
// this had no value shift and no repeat handling, which looks like a bug.
|
||||
pos.Z += (tileHeight(iactor->spr.picnum) / 2 + tileTopOffset(iactor->spr.picnum)) * iactor->spr.scale.Y;
|
||||
auto tex = TexMan.GetGameTexture(iactor->spr.spritetexture());
|
||||
double center = tex->GetDisplayHeight() / 2 + tex->GetDisplayTopOffset();
|
||||
pos.Z += center * iactor->spr.scale.Y;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
case 6:
|
||||
if (!iactor->insector()) pos.Z = top;
|
||||
|
|
|
@ -246,7 +246,9 @@ void UpdateSprite(DBloodActor* actor, SEQFRAME* pFrame)
|
|||
assert(actor->hasX());
|
||||
if (actor->spr.flags & 2)
|
||||
{
|
||||
if (tileHeight(actor->spr.picnum) != tileHeight(seqGetTile(pFrame)) || tileTopOffset(actor->spr.picnum) != tileTopOffset(seqGetTile(pFrame))
|
||||
auto atex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
||||
auto stex = TexMan.GetGameTexture(seqGetTexture(pFrame));
|
||||
if (atex->GetDisplayHeight() != stex->GetDisplayHeight() || atex->GetDisplayTopOffset() != stex->GetDisplayTopOffset()
|
||||
|| (pFrame->scaley && pFrame->scaley != int(actor->spr.scale.Y * INV_REPEAT_SCALE)))
|
||||
actor->spr.flags |= 4;
|
||||
}
|
||||
|
|
|
@ -62,8 +62,9 @@ void DrawAbs(int tile, double x, double y, int shade = 0)
|
|||
void DrawRel(int tile, double x, double y, int shade)
|
||||
{
|
||||
// This is slightly different than what the backend does here, but critical for some graphics.
|
||||
int offx = (tileWidth(tile) >> 1) + tileLeftOffset(tile);
|
||||
int offy = (tileHeight(tile) >> 1) + tileTopOffset(tile);
|
||||
auto tex = tileGetTexture(tile);
|
||||
int offx = (int(tex->GetDisplayWidth()) >> 1) + int(tex->GetDisplayLeftOffset());
|
||||
int offy = (int(tex->GetDisplayHeight()) >> 1) + int(tex->GetDisplayTopOffset());
|
||||
DrawAbs(tile, x - offx, y - offy, shade);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "packet.h"
|
||||
#include "gameinput.h"
|
||||
#include "serialize_obj.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
EXTERN_CVAR(Bool, sw_ninjahack)
|
||||
EXTERN_CVAR(Bool, sw_darts)
|
||||
|
@ -202,24 +203,23 @@ constexpr int NORM_ANGLE(int ang) { return ((ang) & 2047); }
|
|||
int StdRandomRange(int range);
|
||||
|
||||
|
||||
inline double GetSpriteSizeZ(const spritetypebase* sp)
|
||||
{
|
||||
return (tileHeight(sp->picnum) * sp->scale.Y);
|
||||
}
|
||||
|
||||
|
||||
// actual Z for TOS and BOS - handles both WYSIWYG and old style
|
||||
inline double GetSpriteZOfTop(const spritetypebase* sp)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(sp->spritetexture());
|
||||
auto sizez = tex->GetDisplayHeight() * sp->scale.Y;
|
||||
return (sp->cstat & CSTAT_SPRITE_YCENTER) ?
|
||||
sp->pos.Z - ((GetSpriteSizeZ(sp) * 0.5) + tileTopOffset(sp->picnum)) :
|
||||
sp->pos.Z - GetSpriteSizeZ(sp);
|
||||
sp->pos.Z - ((sizez * 0.5) + tex->GetDisplayTopOffset()) :
|
||||
sp->pos.Z - sizez;
|
||||
}
|
||||
|
||||
inline double GetSpriteZOfBottom(const spritetypebase* sp)
|
||||
{
|
||||
auto tex = TexMan.GetGameTexture(sp->spritetexture());
|
||||
auto sizez = tex->GetDisplayHeight() * sp->scale.Y;
|
||||
return (sp->cstat & CSTAT_SPRITE_YCENTER) ?
|
||||
sp->pos.Z + ((GetSpriteSizeZ(sp) * 0.5) - tileTopOffset(sp->picnum)) :
|
||||
sp->pos.Z + ((sizez * 0.5) - tex->GetDisplayTopOffset()) :
|
||||
sp->pos.Z;
|
||||
}
|
||||
|
||||
|
@ -2071,12 +2071,14 @@ inline DVector3 ActorLowerVect(DSWActor* actor)
|
|||
// Z size of top (TOS) and bottom (BOS) part of sprite
|
||||
inline double ActorSizeToTop(DSWActor* a)
|
||||
{
|
||||
return (ActorSizeZ(a) + tileTopOffset(a->spr.picnum)) * 0.5;
|
||||
auto tex = TexMan.GetGameTexture(a->spr.spritetexture());
|
||||
return (ActorSizeZ(a) + tex->GetDisplayTopOffset()) * 0.5;
|
||||
}
|
||||
|
||||
inline void SetActorSizeX(DSWActor* sp)
|
||||
{
|
||||
sp->clipdist = tileWidth(sp->spr.picnum) * sp->spr.scale.X * 0.25;
|
||||
auto tex = TexMan.GetGameTexture(sp->spr.spritetexture());
|
||||
sp->clipdist = tex->GetDisplayWidth() * sp->spr.scale.X * 0.25;
|
||||
}
|
||||
|
||||
inline bool Facing(DSWActor* actor1, DSWActor* actor2)
|
||||
|
@ -2087,7 +2089,8 @@ inline bool Facing(DSWActor* actor1, DSWActor* actor2)
|
|||
// Given a z height and sprite return the correct y repeat value
|
||||
inline int GetRepeatFromHeight(DSWActor* sp, double zh)
|
||||
{
|
||||
return int(zh * 64) / tileHeight(sp->spr.picnum);
|
||||
auto tex = TexMan.GetGameTexture(sp->spr.spritetexture());
|
||||
return int(zh * 64) / int(tex->GetDisplayHeight());
|
||||
}
|
||||
|
||||
inline bool SpriteInDiveArea(DSWActor* a)
|
||||
|
|
|
@ -240,7 +240,8 @@ int SetupSkull(DSWActor* actor)
|
|||
|
||||
if (ActorZOfBottom(actor) > actor->user.loz - 16)
|
||||
{
|
||||
actor->spr.pos.Z = actor->user.loz + tileTopOffset(actor->spr.picnum);
|
||||
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
||||
actor->spr.pos.Z = actor->user.loz + tex->GetDisplayTopOffset();
|
||||
|
||||
actor->user.loz = actor->spr.pos.Z;
|
||||
// leave 8 pixels above the ground
|
||||
|
@ -658,7 +659,8 @@ int SetupBetty(DSWActor* actor)
|
|||
|
||||
if (ActorZOfBottom(actor) > actor->user.loz - 16)
|
||||
{
|
||||
actor->spr.pos.Z = actor->user.loz + tileTopOffset(actor->spr.picnum);
|
||||
auto tex = TexMan.GetGameTexture(actor->spr.spritetexture());
|
||||
actor->spr.pos.Z = actor->user.loz + tex->GetDisplayTopOffset();
|
||||
|
||||
actor->user.loz = actor->spr.pos.Z;
|
||||
// leave 8 pixels above the ground
|
||||
|
|
Loading…
Reference in a new issue