From 30112e1289c54384f90621892e875e71227be7ea Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 4 Oct 2022 19:35:00 +0200 Subject: [PATCH] - deal with clipdist in nnexts --- source/games/blood/src/aiunicult.cpp | 3 ++- source/games/blood/src/nnexts.cpp | 14 ++++++++------ source/games/blood/src/nnexts.h | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index c51e955ed..30e0d0478 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -2304,7 +2304,8 @@ bool genDudePrepare(DBloodActor* actor, int propId) case kGenDudePropertyMass: { // to ensure mass gets updated, let's clear all cache SPRITEMASS* pMass = &actor->spriteMass; - pMass->seqId = pMass->picnum = pMass->xrepeat = pMass->yrepeat = pMass->clipdist = 0; + pMass->seqId = pMass->picnum = pMass->xrepeat = pMass->yrepeat = 0; + pMass->clipDist = 0; pMass->mass = pMass->airVel = pMass->fraction = 0; getSpriteMassBySize(actor); if (propId) break; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 1b6152cd2..a43cda088 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1403,7 +1403,9 @@ void sfxPlayVectorSound(DBloodActor* actor, int vectorId) int getSpriteMassBySize(DBloodActor* actor) { - int mass = 0; int seqId = -1; int clipDist = actor->native_clipdist(); + int mass = 0; + int seqId = -1; + double clipDist = actor->clipdist; if (!actor->hasX()) { I_Error("getSpriteMassBySize: actor->spr.hasX == false"); @@ -1431,7 +1433,7 @@ int getSpriteMassBySize(DBloodActor* actor) SPRITEMASS* cached = &actor->spriteMass; if (((seqId >= 0 && seqId == cached->seqId) || actor->spr.picnum == cached->picnum) && actor->spr.xrepeat == cached->xrepeat && - actor->spr.yrepeat == cached->yrepeat && clipDist == cached->clipdist) + actor->spr.yrepeat == cached->yrepeat && clipDist == cached->clipDist) { return cached->mass; } @@ -1452,7 +1454,7 @@ int getSpriteMassBySize(DBloodActor* actor) picnum = actor->spr.picnum; } - clipDist = ClipLow(actor->native_clipdist(), 1); + clipDist = max(actor->clipdist, 0.25); int x = tileWidth(picnum); int y = tileHeight(picnum); int xrepeat = actor->spr.xrepeat; @@ -1477,7 +1479,7 @@ int getSpriteMassBySize(DBloodActor* actor) case 14: massDiv = 23; break; // lava } - mass = ((x + y) * (clipDist / 2)) / massDiv; + mass = ((x + y) * int(clipDist * 2)) / massDiv; if (xrepeat > 64) mass += ((xrepeat - 64) * addMul); else if (xrepeat < 64 && mass > 0) @@ -1515,7 +1517,7 @@ int getSpriteMassBySize(DBloodActor* actor) cached->yrepeat = actor->spr.yrepeat; cached->picnum = actor->spr.picnum; cached->seqId = seqId; - cached->clipdist = actor->native_clipdist(); + cached->clipDist = actor->clipdist; return cached->mass; } @@ -9349,7 +9351,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEMASS& w, SPR ("picnum", w.picnum, &nul.picnum) ("xrepeat", w.xrepeat, &nul.xrepeat) ("yrepeat", w.yrepeat, &nul.yrepeat) - ("clipdist", w.clipdist) + ("clipdist", w.clipDist) ("mass", w.mass) ("airvel", w.airVel) ("fraction", w.fraction) diff --git a/source/games/blood/src/nnexts.h b/source/games/blood/src/nnexts.h index 14c9c1453..83ef8f9ca 100644 --- a/source/games/blood/src/nnexts.h +++ b/source/games/blood/src/nnexts.h @@ -196,9 +196,9 @@ struct SPRITEMASS { // sprite mass info for getSpriteMassBySize(); int16_t picnum; // mainly needs for moving debris int16_t xrepeat; int16_t yrepeat; - int16_t clipdist; // mass multiplier - int mass; int16_t airVel; // mainly needs for moving debris + double clipDist; // mass multiplier + int mass; int fraction; // mainly needs for moving debris };