Update light offset on polyobjects when they rotate

This commit is contained in:
Alug committed 2024-08-17 16:09:34 +02:00
1 parent 6ab99218f2
commit 7d4b1d0852
3 files changed
+24 -10

No files matched your search

+3
View File
@@ -1415,7 +1415,10 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings)
{
// update seg angles (used only by renderer)
for (i = 0; i < po->segCount; ++i)
{
po->segs[i]->angle += delta;
P_UpdateSegLightOffset(po->segs[i]);
}
// update polyobject's angle
po->angle += delta;
+20 -10
View File
@@ -427,6 +427,25 @@ static inline float P_SegLengthFloat(seg_t *seg)
}
#endif
/** Updates the light offset
*
* \param li Seg to update the light offsets of
*/
void P_UpdateSegLightOffset(seg_t *li)
{
fixed_t extralight = 0;
extralight = -(8*FRACUNIT) +
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
abs(li->v1->x - li->v2->x),
abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16;
// Between -1 and 1 for software, -8 and 8 for hardware
li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
#ifdef HWRENDER
li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
#endif
}
// Loads the SEGS resource from a level.
static void P_LoadRawSegs(UINT8 *data)
@@ -466,16 +485,7 @@ static void P_LoadRawSegs(UINT8 *data)
li->numlights = 0;
li->rlights = NULL;
extralight = -(8*FRACUNIT) +
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
abs(li->v1->x - li->v2->x),
abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16;
// Between -1 and 1 for software, -8 and 8 for hardware
li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
#ifdef HWRENDER
li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
#endif
P_UpdateSegLightOffset(li);
}
}
+1
View File
@@ -88,6 +88,7 @@ SINT8 P_PartialAddGetStage(void);
boolean P_RunSOC(const char *socfilename);
void P_WriteThings(lumpnum_t lump);
void P_UpdateSegLightOffset(seg_t *li);
size_t P_PrecacheLevelFlats(void);
void P_AllocMapHeader(INT16 i);