Skip to content

Commit

Permalink
- fixed sprting of non-translucent sprites.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Jan 8, 2022
1 parent fe0581e commit 415dc52
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/core/actorlist.cpp
Expand Up @@ -353,7 +353,7 @@ DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail)
InsertActorSect(actor, sector, tail);

Numsprites++;
actor->spr.time = leveltimer++;
actor->time = leveltimer++;
return actor;
}

Expand Down
2 changes: 1 addition & 1 deletion source/core/automap.cpp
Expand Up @@ -608,7 +608,7 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
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.
return A->time - B->time; // ensures stable sort.
});

vertices.Resize(4);
Expand Down
3 changes: 2 additions & 1 deletion source/core/coreactor.h
Expand Up @@ -21,6 +21,7 @@ class DCoreActor : public DObject
spritesmooth_t spsmooth;

vec3_t opos;
int time;
int16_t oang;

DCoreActor() = default;
Expand All @@ -42,7 +43,7 @@ class DCoreActor : public DObject
int GetIndex() const
{
// 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)
Expand Down
2 changes: 1 addition & 1 deletion source/core/gamefuncs.cpp
Expand Up @@ -434,7 +434,7 @@ tspritetype* renderAddTsprite(tspritetype* tsprite, int& spritesortcnt, DCoreAct
tspr->lotag = actor->spr.lotag;
tspr->hitag = actor->spr.hitag;
tspr->extra = actor->spr.extra;
tspr->time = actor->spr.time;
tspr->time = actor->time;
tspr->ownerActor = actor;

// need to copy the slope sprite flag around because for tsprites the bit combination means 'voxel'.
Expand Down
4 changes: 1 addition & 3 deletions source/core/maptypes.h
Expand Up @@ -447,9 +447,6 @@ struct spritetypebase
uint8_t yrepeat;
int8_t xoffset;
int8_t yoffset;

// extensions not from the binary map format.
int time;
};


Expand All @@ -470,6 +467,7 @@ struct spritetype : public spritetypebase
struct tspritetype : public spritetypebase
{
DCoreActor* ownerActor;
int time;
};

extern TArray<sectortype> sector;
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_drawlist.cpp
Expand Up @@ -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;
return s1->Sprite->time - s2->Sprite->time;
return s2->Sprite->time - s1->Sprite->time;
}

//==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion source/core/savegamehelp.cpp
Expand Up @@ -470,7 +470,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("hitag", c.hitag, def->hitag)
("extra", c.extra, def->extra)
("detail", c.detail, def->detail)
("time", c.time, def->time)
("cstat2", c.cstat2, def->cstat2)
.EndObject();
}
Expand Down Expand Up @@ -674,6 +673,7 @@ void DCoreActor::Serialize(FSerializer& arc)
("prevsect", prevSect)
("nextsect", nextSect)
("sprite", spr)
("time", time)
("spriteext", sprext);

if (arc.isReading()) spsmooth = {};
Expand Down
1 change: 0 additions & 1 deletion source/games/blood/src/db.cpp
Expand Up @@ -501,7 +501,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
pSprite->detail = load.detail;
pSprite->shade = load.shade;
pSprite->blend = 0;
pSprite->time = i;
validateSprite(*pSprite, secno, i);

if (pSprite->extra > 0)
Expand Down
2 changes: 0 additions & 2 deletions source/games/sw/src/sprite.cpp
Expand Up @@ -925,9 +925,7 @@ bool ActorTestSpawn(DSWActor* actor)
if (actor->spr.statnum == STAT_DEFAULT && actor->spr.lotag == TAG_SPAWN_ACTOR)
{
auto actorNew = insertActor(actor->sector(), STAT_DEFAULT);
int t = actorNew->spr.time; // must be preserved!
actorNew->spr = actor->spr;
actorNew->spr.time = t;
change_actor_stat(actorNew, STAT_SPAWN_TRIGGER);
actorNew->spr.cstat &= ~(CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
return false;
Expand Down

0 comments on commit 415dc52

Please sign in to comment.