mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- use actors in the sloped sprite utilities.
This commit is contained in:
parent
dc50ad154e
commit
4bc32e2777
8 changed files with 81 additions and 76 deletions
|
@ -92,39 +92,6 @@ enum {
|
|||
int32_t getwalldist(vec2_t const in, int const wallnum);
|
||||
int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out);
|
||||
|
||||
enum
|
||||
{
|
||||
SPREXT_NOTMD = 1,
|
||||
SPREXT_NOMDANIM = 2,
|
||||
SPREXT_AWAY1 = 4,
|
||||
SPREXT_AWAY2 = 8,
|
||||
SPREXT_TSPRACCESS = 16,
|
||||
SPREXT_TEMPINVISIBLE = 32,
|
||||
};
|
||||
|
||||
struct spriteext_t
|
||||
{
|
||||
uint32_t mdanimtims;
|
||||
int16_t mdanimcur;
|
||||
int16_t angoff, pitch, roll;
|
||||
vec3_t pivot_offset, position_offset;
|
||||
uint8_t flags;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
struct spritesmooth_t
|
||||
{
|
||||
float smoothduration;
|
||||
int16_t mdcurframe, mdoldframe;
|
||||
int16_t mdsmooth;
|
||||
};
|
||||
|
||||
struct SpawnSpriteDef
|
||||
{
|
||||
TArray<spritetype> sprites;
|
||||
TArray<spriteext_t> sprext;
|
||||
};
|
||||
|
||||
// using the clipdist field
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -133,14 +133,14 @@ int clipinsidebox(vec2_t *vect, int wallnum, int walldist)
|
|||
return (v2.X >= v2.Y) << 1;
|
||||
}
|
||||
|
||||
static int32_t spriteGetZOfSlope(const spritetype* spr, int32_t dax, int32_t day)
|
||||
static int32_t spriteGetZOfSlope(DCoreActor* actor, int32_t dax, int32_t day)
|
||||
{
|
||||
int16_t const heinum = spriteGetSlope(spr);
|
||||
int16_t const heinum = spriteGetSlope(actor);
|
||||
if (heinum == 0)
|
||||
return spr->pos.Z;
|
||||
return actor->spr.pos.Z;
|
||||
|
||||
int const j = DMulScale(bsin(spr->ang + 1024), day - spr->pos.Y, -bsin(spr->ang + 512), dax - spr->pos.X, 4);
|
||||
return spr->pos.Z + MulScale(heinum, j, 18);
|
||||
int const j = DMulScale(bsin(actor->spr.ang + 1024), day - actor->spr.pos.Y, -bsin(actor->spr.ang + 512), dax - actor->spr.pos.X, 4);
|
||||
return actor->spr.pos.Z + MulScale(heinum, j, 18);
|
||||
}
|
||||
|
||||
|
||||
|
@ -662,8 +662,8 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
|
||||
if ((cstat & (CSTAT_SPRITE_ALIGNMENT_MASK)) == CSTAT_SPRITE_ALIGNMENT_SLOPE)
|
||||
{
|
||||
heinum = spriteGetSlope(spr);
|
||||
sz = spriteGetZOfSlope(spr, pos->X, pos->Y);
|
||||
heinum = spriteGetSlope(actor);
|
||||
sz = spriteGetZOfSlope(actor, pos->X, pos->Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1176,7 +1176,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
||||
{
|
||||
if ((cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR) daz = spr->pos.Z;
|
||||
else daz = spriteGetZOfSlope(spr, pos.X, pos.Y);
|
||||
else daz = spriteGetZOfSlope(actor, pos.X, pos.Y);
|
||||
daz2 = daz;
|
||||
|
||||
if ((cstat & CSTAT_SPRITE_ONE_SIDE) != 0 && (pos.Z > daz) == ((cstat & CSTAT_SPRITE_YFLIP)==0))
|
||||
|
@ -1184,7 +1184,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
|
||||
vec2_t v2, v3, v4;
|
||||
get_floorspr_points(actor, pos.X, pos.Y, &v1.X, &v2.X, &v3.X, &v4.X,
|
||||
&v1.Y, &v2.Y, &v3.Y, &v4.Y, spriteGetSlope(spr));
|
||||
&v1.Y, &v2.Y, &v3.Y, &v4.Y, spriteGetSlope(actor));
|
||||
|
||||
vec2_t const da = { MulScale(bcos(spr->ang - 256), walldist + 4, 14),
|
||||
MulScale(bsin(spr->ang - 256), walldist + 4, 14) };
|
||||
|
@ -1490,7 +1490,7 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
|
|||
continue;
|
||||
|
||||
get_floorspr_points(actor, intx, inty, &x1, &x2, &x3, &x4,
|
||||
&y1, &y2, &y3, &y4, spriteGetSlope(spr));
|
||||
&y1, &y2, &y3, &y4, spriteGetSlope(actor));
|
||||
|
||||
if (get_floorspr_clipyou({x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}))
|
||||
hit_set(&hitinfo, sec, nullptr, actor, intx, inty, intz);
|
||||
|
@ -1501,7 +1501,7 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
|
|||
case CSTAT_SPRITE_ALIGNMENT_SLOPE:
|
||||
{
|
||||
int32_t x3, y3, x4, y4;
|
||||
int32_t const heinum = spriteGetSlope(spr);
|
||||
int32_t const heinum = spriteGetSlope(actor);
|
||||
int32_t const dax = (heinum * sintable[(spr->ang + 1024) & 2047]) << 1;
|
||||
int32_t const day = (heinum * sintable[(spr->ang + 512) & 2047]) << 1;
|
||||
int32_t const j = (vz << 8) - DMulScale(dax, vy, -day, vx, 15);
|
||||
|
@ -1520,7 +1520,7 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
|
|||
continue;
|
||||
|
||||
get_floorspr_points(actor, intx, inty, &x1, &x2, &x3, &x4,
|
||||
&y1, &y2, &y3, &y4, spriteGetSlope(spr));
|
||||
&y1, &y2, &y3, &y4, spriteGetSlope(actor));
|
||||
|
||||
if (get_floorspr_clipyou({ x1, y1 }, { x2, y2 }, { x3, y3 }, { x4, y4 }))
|
||||
hit_set(&hitinfo, sec, nullptr, actor, intx, inty, intz);
|
||||
|
|
|
@ -553,7 +553,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
|
|||
int width = screen->GetWidth();
|
||||
int height = screen->GetHeight();
|
||||
TArray<FVector4> vertices;
|
||||
TArray<spritetype*> floorsprites;
|
||||
TArray<DCoreActor*> floorsprites;
|
||||
|
||||
|
||||
for (int i = (int)sector.Size() - 1; i >= 0; i--)
|
||||
|
@ -572,7 +572,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
|
|||
{
|
||||
if ((act->spr.cstat & (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_YFLIP)) == (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_YFLIP))
|
||||
continue; // upside down
|
||||
floorsprites.Push(&act->spr);
|
||||
floorsprites.Push(act);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,18 +605,18 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
|
|||
}
|
||||
qsort(floorsprites.Data(), floorsprites.Size(), sizeof(spritetype*), [](const void* a, const void* b)
|
||||
{
|
||||
auto A = *(spritetype**)a;
|
||||
auto B = *(spritetype**)b;
|
||||
if (A->pos.Z != B->pos.Z) return B->pos.Z - A->pos.Z;
|
||||
return A->time - B->time; // ensures stable sort.
|
||||
auto A = *(DCoreActor**)a;
|
||||
auto B = *(DCoreActor**)b;
|
||||
if (A->spr.pos.Z != B->spr.pos.Z) return B->spr.pos.Z - A->spr.pos.Z;
|
||||
return A->spr.time - B->spr.time; // ensures stable sort.
|
||||
});
|
||||
|
||||
vertices.Resize(4);
|
||||
for (auto spr : floorsprites)
|
||||
for (auto actor : floorsprites)
|
||||
{
|
||||
if (!gFullMap && !(spr->cstat2 & CSTAT2_SPRITE_MAPPED)) continue;
|
||||
if (!gFullMap && !(actor->spr.cstat2 & CSTAT2_SPRITE_MAPPED)) continue;
|
||||
vec2_t pp[4];
|
||||
GetFlatSpritePosition(spr, spr->pos.vec2, pp, true);
|
||||
GetFlatSpritePosition(actor, actor->spr.pos.vec2, pp, true);
|
||||
|
||||
for (unsigned j = 0; j < 4; j++)
|
||||
{
|
||||
|
@ -627,21 +627,21 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
|
|||
vertices[j] = { x1 / 4096.f, y1 / 4096.f, j == 1 || j == 2 ? 1.f : 0.f, j == 2 || j == 3 ? 1.f : 0.f };
|
||||
}
|
||||
int shade;
|
||||
if ((spr->sector()->ceilingstat & CSTAT_SECTOR_SKY)) shade = spr->sector()->ceilingshade;
|
||||
else shade = spr->sector()->floorshade;
|
||||
shade += spr->shade;
|
||||
if ((actor->spr.sector()->ceilingstat & CSTAT_SECTOR_SKY)) shade = actor->spr.sector()->ceilingshade;
|
||||
else shade = actor->spr.sector()->floorshade;
|
||||
shade += actor->spr.shade;
|
||||
PalEntry color = shadeToLight(shade);
|
||||
FRenderStyle rs = LegacyRenderStyles[STYLE_Translucent];
|
||||
float alpha = 1;
|
||||
if (spr->cstat & CSTAT_SPRITE_TRANSLUCENT)
|
||||
if (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT)
|
||||
{
|
||||
rs = GetRenderStyle(0, !!(spr->cstat & CSTAT_SPRITE_TRANS_FLIP));
|
||||
alpha = GetAlphaFromBlend((spr->cstat & CSTAT_SPRITE_TRANS_FLIP) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
|
||||
rs = GetRenderStyle(0, !!(actor->spr.cstat & CSTAT_SPRITE_TRANS_FLIP));
|
||||
alpha = GetAlphaFromBlend((actor->spr.cstat & CSTAT_SPRITE_TRANS_FLIP) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
|
||||
color.a = uint8_t(alpha * 255);
|
||||
}
|
||||
|
||||
int translation = TRANSLATION(Translation_Remap + curbasepal, spr->pal);
|
||||
int picnum = spr->picnum;
|
||||
int translation = TRANSLATION(Translation_Remap + curbasepal, actor->spr.pal);
|
||||
int picnum = actor->spr.picnum;
|
||||
gotpic.Set(picnum);
|
||||
const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
twod->AddPoly(tileGetTexture(picnum, true), vertices.Data(), vertices.Size(), indices, 6, translation, color, rs,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "build.h"
|
||||
#include "maptypes.h"
|
||||
|
||||
class DCoreActor : public DObject
|
||||
{
|
||||
|
|
|
@ -331,9 +331,9 @@ void TGetFlatSpritePosition(const spritetypebase* spr, vec2_t pos, vec2_t* out,
|
|||
}
|
||||
}
|
||||
|
||||
void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render)
|
||||
void GetFlatSpritePosition(DCoreActor* actor, vec2_t pos, vec2_t* out, bool render)
|
||||
{
|
||||
TGetFlatSpritePosition(spr, pos, out, nullptr, spriteGetSlope(spr), render);
|
||||
TGetFlatSpritePosition(&actor->spr, pos, out, nullptr, spriteGetSlope(actor), render);
|
||||
}
|
||||
|
||||
void GetFlatSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, int* outz, bool render)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "binaryangle.h"
|
||||
#include "build.h"
|
||||
#include "coreactor.h"
|
||||
|
||||
// breadth first search, this gets used multiple times throughout the engine, mainly for iterating over sectors.
|
||||
// Only works on indices, this has no knowledge of the actual objects being looked at.
|
||||
|
@ -163,7 +164,7 @@ int getslopeval(sectortype* sect, int x, int y, int z, int planez);
|
|||
|
||||
void setWallSectors();
|
||||
void GetWallSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, bool render = false);
|
||||
void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false);
|
||||
void GetFlatSpritePosition(DCoreActor* spr, vec2_t pos, vec2_t* out, bool render = false);
|
||||
void GetFlatSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, int* outz = nullptr, bool render = false);
|
||||
void checkRotatedWalls();
|
||||
bool sectorsConnected(int sect1, int sect2);
|
||||
|
@ -273,19 +274,19 @@ inline void copyfloorpal(tspritetype* spr, const sectortype* sect)
|
|||
if (!lookups.noFloorPal(sect->floorpal)) spr->pal = sect->floorpal;
|
||||
}
|
||||
|
||||
inline void spriteSetSlope(spritetype* spr, int heinum)
|
||||
inline void spriteSetSlope(DCoreActor* actor, int heinum)
|
||||
{
|
||||
if (spr->cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)
|
||||
if (actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)
|
||||
{
|
||||
spr->xoffset = heinum & 255;
|
||||
spr->yoffset = (heinum >> 8) & 255;
|
||||
spr->cstat = (spr->cstat & ~CSTAT_SPRITE_ALIGNMENT_MASK) | (heinum != 0 ? CSTAT_SPRITE_ALIGNMENT_SLOPE : CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
||||
actor->spr.xoffset = heinum & 255;
|
||||
actor->spr.yoffset = (heinum >> 8) & 255;
|
||||
actor->spr.cstat = (actor->spr.cstat & ~CSTAT_SPRITE_ALIGNMENT_MASK) | (heinum != 0 ? CSTAT_SPRITE_ALIGNMENT_SLOPE : CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
||||
}
|
||||
}
|
||||
|
||||
inline int spriteGetSlope(const spritetype* spr)
|
||||
inline int spriteGetSlope(DCoreActor* actor)
|
||||
{
|
||||
return ((spr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLOPE) ? 0 : uint8_t(spr->xoffset) + (uint8_t(spr->yoffset) << 8);
|
||||
return ((actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLOPE) ? 0 : uint8_t(actor->spr.xoffset) + (uint8_t(actor->spr.yoffset) << 8);
|
||||
}
|
||||
|
||||
// same stuff, different flag...
|
||||
|
|
|
@ -759,6 +759,43 @@ inline int32_t* sectortype::floorzptr(bool temp)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
// copied from build.h so that coreactor.h does not have to include build.h
|
||||
|
||||
enum
|
||||
{
|
||||
SPREXT_NOTMD = 1,
|
||||
SPREXT_NOMDANIM = 2,
|
||||
SPREXT_AWAY1 = 4,
|
||||
SPREXT_AWAY2 = 8,
|
||||
SPREXT_TSPRACCESS = 16,
|
||||
SPREXT_TEMPINVISIBLE = 32,
|
||||
};
|
||||
|
||||
struct spriteext_t
|
||||
{
|
||||
uint32_t mdanimtims;
|
||||
int16_t mdanimcur;
|
||||
int16_t angoff, pitch, roll;
|
||||
vec3_t pivot_offset, position_offset;
|
||||
uint8_t flags;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
struct spritesmooth_t
|
||||
{
|
||||
float smoothduration;
|
||||
int16_t mdcurframe, mdoldframe;
|
||||
int16_t mdsmooth;
|
||||
};
|
||||
|
||||
struct SpawnSpriteDef
|
||||
{
|
||||
TArray<spritetype> sprites;
|
||||
TArray<spriteext_t> sprext;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Map loader stuff
|
||||
|
|
|
@ -4316,7 +4316,7 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH)
|
|||
case 0: return condCmp((objActor->spr.ang & 2047), arg1, arg2, cmpOp);
|
||||
case 5: return condCmp(objActor->spr.statnum, arg1, arg2, cmpOp);
|
||||
case 6: return ((objActor->spr.flags & kHitagRespawn) || objActor->spr.statnum == kStatRespawn);
|
||||
case 7: return condCmp(spriteGetSlope(&objActor->spr), arg1, arg2, cmpOp);
|
||||
case 7: return condCmp(spriteGetSlope(objActor), arg1, arg2, cmpOp);
|
||||
case 10: return condCmp(objActor->spr.clipdist, arg1, arg2, cmpOp);
|
||||
case 15:
|
||||
if (!objActor->GetOwner()) return false;
|
||||
|
@ -6339,7 +6339,7 @@ void sprite2sectorSlope(DBloodActor* actor, sectortype* pSector, char rel, bool
|
|||
break;
|
||||
}
|
||||
|
||||
spriteSetSlope(&actor->spr, slope);
|
||||
spriteSetSlope(actor, slope);
|
||||
if (forcez) actor->spr.pos.Z = z;
|
||||
}
|
||||
|
||||
|
@ -6474,7 +6474,7 @@ void useSlopeChanger(DBloodActor* sourceactor, int objType, sectortype* pSect, D
|
|||
}
|
||||
break;
|
||||
default:
|
||||
spriteSetSlope(&objActor->spr, slope);
|
||||
spriteSetSlope(objActor, slope);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue