mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 07:31:03 +00:00
- replaced spriteheightofsptr with a method in DCoreActor.
This commit is contained in:
parent
6b318c89b6
commit
48b6ce2f4d
5 changed files with 17 additions and 29 deletions
|
@ -188,7 +188,6 @@ int32_t lintersect(int32_t originX, int32_t originY, int32_t originZ,
|
|||
int32_t lineStartX, int32_t lineStartY, int32_t lineEndX, int32_t lineEndY,
|
||||
int32_t *intersectionX, int32_t *intersectionY, int32_t *intersectionZ);
|
||||
|
||||
int32_t spriteheightofsptr(DCoreActor* spr, int32_t *height, int32_t alsotileyofs);
|
||||
|
||||
EXTERN_CVAR(Bool, hw_animsmoothing)
|
||||
EXTERN_CVAR(Bool, hw_hightile)
|
||||
|
|
|
@ -619,7 +619,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
case CSTAT_SPRITE_ALIGNMENT_FACING:
|
||||
if (p1.X >= clipMin.X && p1.X <= clipMax.X && p1.Y >= clipMin.Y && p1.Y <= clipMax.Y)
|
||||
{
|
||||
int32_t height, daz = spr->pos.Z+spriteheightofsptr(actor, &height, 1);
|
||||
int32_t height, daz = spr->pos.Z + actor->GetOffsetAndHeight(height);
|
||||
|
||||
if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist)
|
||||
{
|
||||
|
@ -635,7 +635,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
|
||||
case CSTAT_SPRITE_ALIGNMENT_WALL:
|
||||
{
|
||||
int32_t height, daz = spr->pos.Z+spriteheightofsptr(actor, &height, 1);
|
||||
int32_t height, daz = spr->pos.Z + actor->GetOffsetAndHeight(height);
|
||||
|
||||
if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist)
|
||||
{
|
||||
|
@ -1170,7 +1170,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
int32_t k = walldist+(spr->clipdist<<2)+1;
|
||||
if ((abs(v1.X-pos.X) <= k) && (abs(v1.Y-pos.Y) <= k))
|
||||
{
|
||||
daz = spr->pos.Z + spriteheightofsptr(actor, &k, 1);
|
||||
daz = spr->pos.Z + actor->GetOffsetAndHeight(k);
|
||||
daz2 = daz - k;
|
||||
clipyou = 1;
|
||||
}
|
||||
|
@ -1185,7 +1185,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
if (clipinsideboxline(pos.X,pos.Y,v1.X,v1.Y,v2.X,v2.Y,walldist+1) != 0)
|
||||
{
|
||||
int32_t k;
|
||||
daz = spr->pos.Z + spriteheightofsptr(actor, &k, 1);
|
||||
daz = spr->pos.Z + actor->GetOffsetAndHeight(k);
|
||||
daz2 = daz-k;
|
||||
clipyou = 1;
|
||||
}
|
||||
|
@ -1255,7 +1255,7 @@ int32_t try_facespr_intersect(DCoreActor* spr, vec3_t const in,
|
|||
|
||||
vec3_t newpos = { 0, 0, in.Z + Scale(vz, topt, bot) };
|
||||
int32_t siz;
|
||||
int32_t const z1 = sprpos.Z + spriteheightofsptr(spr, &siz, 1);
|
||||
int32_t const z1 = sprpos.Z + spr->GetOffsetAndHeight(siz);
|
||||
|
||||
if (newpos.Z < z1 - siz || newpos.Z > z1)
|
||||
return 0;
|
||||
|
@ -1462,7 +1462,7 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
|
|||
if (abs(intx-sv->X)+abs(inty-sv->Y) > abs((hitinfo.hitpos.X)-sv->X)+abs((hitinfo.hitpos.Y)-sv->Y))
|
||||
continue;
|
||||
|
||||
daz = spr->pos.Z + spriteheightofsptr(actor, &k, 1);
|
||||
daz = spr->pos.Z + actor->GetOffsetAndHeight(k);
|
||||
if (intz > daz-k && intz < daz)
|
||||
{
|
||||
if (picanm[tilenum].sf&PICANM_TEXHITSCAN_BIT)
|
||||
|
|
|
@ -248,28 +248,6 @@ int32_t getangle(int32_t xvect, int32_t yvect)
|
|||
}
|
||||
|
||||
|
||||
// Gets the BUILD unit height and z offset of a sprite.
|
||||
// Returns the z offset, 'height' may be NULL.
|
||||
int32_t spriteheightofsptr(DCoreActor* spr, int32_t *height, int32_t alsotileyofs)
|
||||
{
|
||||
int32_t hei, zofs=0;
|
||||
const int32_t picnum=spr->spr.picnum, yrepeat=spr->spr.yrepeat;
|
||||
|
||||
hei = (tileHeight(picnum)*yrepeat)<<2;
|
||||
if (height != NULL)
|
||||
*height = hei;
|
||||
|
||||
if (spr->spr.cstat & CSTAT_SPRITE_YCENTER)
|
||||
zofs = hei>>1;
|
||||
|
||||
// NOTE: a positive per-tile yoffset translates the sprite into the
|
||||
// negative world z direction (i.e. upward).
|
||||
if (alsotileyofs)
|
||||
zofs -= tileTopOffset(picnum) *yrepeat<<2;
|
||||
|
||||
return zofs;
|
||||
}
|
||||
|
||||
//
|
||||
// nextsectorneighborz
|
||||
//
|
||||
|
|
|
@ -480,6 +480,16 @@ size_t DCoreActor::PropagateMark()
|
|||
}
|
||||
|
||||
|
||||
int DCoreActor::GetOffsetAndHeight(int& height)
|
||||
{
|
||||
int yrepeat = spr.yrepeat << 2;
|
||||
height = tileHeight(spr.picnum) * yrepeat;
|
||||
int zofs = (spr.cstat & CSTAT_SPRITE_YCENTER)? height >> 1 : 0;
|
||||
return zofs - tileTopOffset(spr.picnum) * yrepeat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DEFINE_FIELD_NAMED(DCoreActor, spr.sectp, sector)
|
||||
DEFINE_FIELD_NAMED(DCoreActor, spr.cstat, cstat)
|
||||
DEFINE_FIELD_NAMED(DCoreActor, spr.cstat2, cstat2)
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
virtual void BeginPlay() {}
|
||||
void OnDestroy() override;
|
||||
size_t PropagateMark() override;
|
||||
int GetOffsetAndHeight(int& height);
|
||||
|
||||
bool exists() const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue