- SOP spriteofang

Still needs work
This commit is contained in:
Christoph Oelckers 2021-11-02 18:40:56 +01:00
parent 5078750569
commit e75258f57b

View file

@ -62,7 +62,7 @@ static struct so_interp
int32_t lastipos; int32_t lastipos;
int32_t lastoldipos; int32_t lastoldipos;
int32_t lastangdiff; int32_t lastangdiff;
int32_t spriteofang; DSWActor* actorofang;
} data[SO_MAXINTERPOLATIONS]; } data[SO_MAXINTERPOLATIONS];
int32_t numinterpolations; int32_t numinterpolations;
@ -122,7 +122,7 @@ static void so_setpointinterpolation(so_interp *interp, int element)
data->oldipos = data->oldipos =
data->lastipos = data->lastipos =
data->lastoldipos = getvalue(element, false); data->lastoldipos = getvalue(element, false);
data->spriteofang = -1; data->actorofang = nullptr;
} }
static void so_setspriteanginterpolation(so_interp *interp, int32_t spritenum) static void so_setspriteanginterpolation(so_interp *interp, int32_t spritenum)
@ -132,7 +132,7 @@ static void so_setspriteanginterpolation(so_interp *interp, int32_t spritenum)
return; return;
for (i = 0; i < interp->numinterpolations; i++) for (i = 0; i < interp->numinterpolations; i++)
if (interp->data[i].curelement == -1 && interp->data[i].spriteofang == spritenum) if (interp->data[i].curelement == -1 && interp->data[i].actorofang->GetSpriteIndex() == spritenum)
return; return;
so_interp::interp_data *data = &interp->data[interp->numinterpolations++]; so_interp::interp_data *data = &interp->data[interp->numinterpolations++];
@ -142,7 +142,7 @@ static void so_setspriteanginterpolation(so_interp *interp, int32_t spritenum)
data->lastipos = data->lastipos =
data->lastoldipos = sprite[spritenum].ang; data->lastoldipos = sprite[spritenum].ang;
data->lastangdiff = 0; data->lastangdiff = 0;
data->spriteofang = spritenum; data->actorofang = &swActors[spritenum];
} }
// Covers points and angles altogether // Covers points and angles altogether
@ -154,7 +154,7 @@ static void so_stopdatainterpolation(so_interp *interp, int element)
{ {
if (interp->data[i].curelement == -1) if (interp->data[i].curelement == -1)
{ {
if (interp->data[i].spriteofang == element) break; if (interp->data[i].actorofang->GetSpriteIndex() == element) break;
} }
else if (interp->data[i].curelement == element) else if (interp->data[i].curelement == element)
break; break;
@ -270,14 +270,14 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
interp->tic += synctics; interp->tic += synctics;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++) for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)
{ {
if (data->spriteofang >= 0) if (data->actorofang != nullptr)
{ {
USERp u = User[data->spriteofang].Data(); USERp u = data->actorofang->u();
if (u) if (u)
u->oangdiff = 0; u->oangdiff = 0;
if (!interpolating) if (!interpolating)
data->lastangdiff = 0; data->lastangdiff = 0;
data->oldipos = sprite[data->spriteofang].ang; data->oldipos = data->actorofang->s().ang;
} }
else else
data->oldipos = getvalue(data->curelement, false); data->oldipos = getvalue(data->curelement, false);
@ -307,8 +307,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
continue; continue;
for (i = 0; i < interp->numinterpolations; i++) for (i = 0; i < interp->numinterpolations; i++)
interp->data[i].bakipos = (interp->data[i].spriteofang >= 0) ? interp->data[i].bakipos = (interp->data[i].actorofang != nullptr) ?
sprite[interp->data[i].spriteofang].ang : interp->data[i].actorofang->s().ang :
getvalue(interp->data[i].curelement, false); getvalue(interp->data[i].curelement, false);
if (interp->tic == 0) // Only if the SO has just moved if (interp->tic == 0) // Only if the SO has just moved
@ -317,9 +317,9 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
{ {
data->lastipos = data->bakipos; data->lastipos = data->bakipos;
data->lastoldipos = data->oldipos; data->lastoldipos = data->oldipos;
if (data->spriteofang >= 0) if (data->actorofang != nullptr)
{ {
USERp u = User[data->spriteofang].Data(); USERp u = data->actorofang->u();
data->lastangdiff = u ? u->oangdiff : 0; data->lastangdiff = u ? u->oangdiff : 0;
} }
} }
@ -368,8 +368,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
continue; continue;
} }
if (data->spriteofang >= 0) if (data->actorofang != nullptr)
sprite[data->spriteofang].ang = NORM_ANGLE(data->lastoldipos + MulScale(data->lastangdiff, ratio, 16)); data->actorofang->s().ang = NORM_ANGLE(data->lastoldipos + MulScale(data->lastangdiff, ratio, 16));
else else
{ {
delta = data->lastipos - data->lastoldipos; delta = data->lastipos - data->lastoldipos;
@ -394,8 +394,8 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
continue; continue;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++) for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)
if (data->spriteofang >= 0) if (data->actorofang != nullptr)
sprite[data->spriteofang].ang = data->bakipos; data->actorofang->s().ang = data->bakipos;
else else
getvalue(data->curelement, true) = data->bakipos; getvalue(data->curelement, true) = data->bakipos;
} }
@ -423,7 +423,7 @@ void so_serializeinterpolations(FSerializer& arc)
{ {
arc("curelement", data->curelement) arc("curelement", data->curelement)
("oldipos", data->oldipos) ("oldipos", data->oldipos)
("spriteofang", data->spriteofang) ("spriteofang", data->actorofang)
.EndObject(); .EndObject();
if (arc.isReading()) if (arc.isReading())
{ {