- fixed sprting of non-translucent sprites.

This commit is contained in:
Christoph Oelckers 2022-01-08 21:18:18 +01:00
parent fe0581ed97
commit 415dc5246d
9 changed files with 8 additions and 12 deletions

View file

@ -353,7 +353,7 @@ DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail)
InsertActorSect(actor, sector, tail); InsertActorSect(actor, sector, tail);
Numsprites++; Numsprites++;
actor->spr.time = leveltimer++; actor->time = leveltimer++;
return actor; return actor;
} }

View file

@ -608,7 +608,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
auto A = *(DCoreActor**)a; auto A = *(DCoreActor**)a;
auto B = *(DCoreActor**)b; auto B = *(DCoreActor**)b;
if (A->spr.pos.Z != B->spr.pos.Z) return B->spr.pos.Z - A->spr.pos.Z; 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. return A->time - B->time; // ensures stable sort.
}); });
vertices.Resize(4); vertices.Resize(4);

View file

@ -21,6 +21,7 @@ public:
spritesmooth_t spsmooth; spritesmooth_t spsmooth;
vec3_t opos; vec3_t opos;
int time;
int16_t oang; int16_t oang;
DCoreActor() = default; DCoreActor() = default;
@ -42,7 +43,7 @@ public:
int GetIndex() const int GetIndex() const
{ {
// This is only identical with the sprite index for items spawned at map start. // This is only identical with the sprite index for items spawned at map start.
return spr.time; return time;
} }
int32_t interpolatedx(double const smoothratio, int const scale = 16) int32_t interpolatedx(double const smoothratio, int const scale = 16)

View file

@ -434,7 +434,7 @@ tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreAct
tspr->lotag = actor->spr.lotag; tspr->lotag = actor->spr.lotag;
tspr->hitag = actor->spr.hitag; tspr->hitag = actor->spr.hitag;
tspr->extra = actor->spr.extra; tspr->extra = actor->spr.extra;
tspr->time = actor->spr.time; tspr->time = actor->time;
tspr->ownerActor = actor; tspr->ownerActor = actor;
// need to copy the slope sprite flag around because for tsprites the bit combination means 'voxel'. // need to copy the slope sprite flag around because for tsprites the bit combination means 'voxel'.

View file

@ -447,9 +447,6 @@ struct spritetypebase
uint8_t yrepeat; uint8_t yrepeat;
int8_t xoffset; int8_t xoffset;
int8_t yoffset; int8_t yoffset;
// extensions not from the binary map format.
int time;
}; };
@ -470,6 +467,7 @@ struct spritetype : public spritetypebase
struct tspritetype : public spritetypebase struct tspritetype : public spritetypebase
{ {
DCoreActor* ownerActor; DCoreActor* ownerActor;
int time;
}; };
extern TArray<sectortype> sector; extern TArray<sectortype> sector;

View file

@ -688,7 +688,7 @@ inline int HWDrawList::CompareSprites(SortNode * a,SortNode * b)
if (s1->depth < s2->depth) return 1; if (s1->depth < s2->depth) return 1;
if (s1->depth > s2->depth) return -1; if (s1->depth > s2->depth) return -1;
return s1->Sprite->time - s2->Sprite->time; return s2->Sprite->time - s1->Sprite->time;
} }
//========================================================================== //==========================================================================

View file

@ -470,7 +470,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("hitag", c.hitag, def->hitag) ("hitag", c.hitag, def->hitag)
("extra", c.extra, def->extra) ("extra", c.extra, def->extra)
("detail", c.detail, def->detail) ("detail", c.detail, def->detail)
("time", c.time, def->time)
("cstat2", c.cstat2, def->cstat2) ("cstat2", c.cstat2, def->cstat2)
.EndObject(); .EndObject();
} }
@ -674,6 +673,7 @@ void DCoreActor::Serialize(FSerializer& arc)
("prevsect", prevSect) ("prevsect", prevSect)
("nextsect", nextSect) ("nextsect", nextSect)
("sprite", spr) ("sprite", spr)
("time", time)
("spriteext", sprext); ("spriteext", sprext);
if (arc.isReading()) spsmooth = {}; if (arc.isReading()) spsmooth = {};

View file

@ -501,7 +501,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
pSprite->detail = load.detail; pSprite->detail = load.detail;
pSprite->shade = load.shade; pSprite->shade = load.shade;
pSprite->blend = 0; pSprite->blend = 0;
pSprite->time = i;
validateSprite(*pSprite, secno, i); validateSprite(*pSprite, secno, i);
if (pSprite->extra > 0) if (pSprite->extra > 0)

View file

@ -925,9 +925,7 @@ bool ActorTestSpawn(DSWActor* actor)
if (actor->spr.statnum == STAT_DEFAULT && actor->spr.lotag == TAG_SPAWN_ACTOR) if (actor->spr.statnum == STAT_DEFAULT && actor->spr.lotag == TAG_SPAWN_ACTOR)
{ {
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT); auto actorNew = insertActor(actor->sector(), STAT_DEFAULT);
int t = actorNew->spr.time; // must be preserved!
actorNew->spr = actor->spr; actorNew->spr = actor->spr;
actorNew->spr.time = t;
change_actor_stat(actorNew, STAT_SPAWN_TRIGGER); change_actor_stat(actorNew, STAT_SPAWN_TRIGGER);
actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
return false; return false;