mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 12:01:47 +00:00
Update light offset on polyobjects when they rotate
This commit is contained in:
parent
d4080e94f7
commit
195920acdc
3 changed files with 25 additions and 10 deletions
|
|
@ -1407,7 +1407,10 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings)
|
||||||
{
|
{
|
||||||
// update seg angles (used only by renderer)
|
// update seg angles (used only by renderer)
|
||||||
for (i = 0; i < po->segCount; ++i)
|
for (i = 0; i < po->segCount; ++i)
|
||||||
|
{
|
||||||
po->segs[i]->angle += delta;
|
po->segs[i]->angle += delta;
|
||||||
|
P_UpdateSegLightOffset(po->segs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// update polyobject's angle
|
// update polyobject's angle
|
||||||
po->angle += delta;
|
po->angle += delta;
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,26 @@ static inline float P_SegLengthFloat(seg_t *seg)
|
||||||
}
|
}
|
||||||
#endif
|
#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.
|
/** Loads the SEGS resource from a level.
|
||||||
*
|
*
|
||||||
* \param lump Lump number of the SEGS resource.
|
* \param lump Lump number of the SEGS resource.
|
||||||
|
|
@ -494,16 +514,7 @@ static void P_LoadRawSegs(UINT8 *data, size_t i)
|
||||||
li->numlights = 0;
|
li->numlights = 0;
|
||||||
li->rlights = NULL;
|
li->rlights = NULL;
|
||||||
|
|
||||||
extralight = -(8*FRACUNIT) +
|
P_UpdateSegLightOffset(li);
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ boolean P_DelWadFile(void);
|
||||||
#endif
|
#endif
|
||||||
boolean P_RunSOC(const char *socfilename);
|
boolean P_RunSOC(const char *socfilename);
|
||||||
void P_WriteThings(lumpnum_t lump);
|
void P_WriteThings(lumpnum_t lump);
|
||||||
|
void P_UpdateSegLightOffset(seg_t *li);
|
||||||
size_t P_PrecacheLevelFlats(void);
|
size_t P_PrecacheLevelFlats(void);
|
||||||
void P_AllocMapHeader(INT16 i);
|
void P_AllocMapHeader(INT16 i);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue