Refactor TextmapFixFlatOffsets().

This commit is contained in:
Nev3r 2019-12-30 12:31:55 +01:00
parent 493c6c8ae2
commit f9aabe753e

View file

@ -1523,6 +1523,7 @@ static void P_LoadTextmap (void)
TextmapParse(sectorsPos[i], i, TextmapSector); TextmapParse(sectorsPos[i], i, TextmapSector);
P_InitializeSector(sc); P_InitializeSector(sc);
TextmapFixFlatOffsets(sc);
} }
for (i = 0, ld = lines; i < numlines; i++, ld++) for (i = 0, ld = lines; i < numlines; i++, ld++)
@ -1563,37 +1564,30 @@ static void P_LoadTextmap (void)
/** Provides a fix to the flat alignment coordinate transform from standard Textmaps. /** Provides a fix to the flat alignment coordinate transform from standard Textmaps.
*/ */
static void TextmapFixFlatOffsets (void) static void TextmapFixFlatOffsets (sector_t* sec)
{ {
fixed_t pc, ps; if (sec->floorpic_angle)
fixed_t xoffs, yoffs;
size_t i;
sector_t* sec = sectors;
for (i = 0; i < numsectors; i++, sec++)
{ {
if (sec->floorpic_angle) fixed_t pc = FINECOSINE(sec->floorpic_angle>>ANGLETOFINESHIFT);
{ fixed_t ps = FINESINE (sec->floorpic_angle>>ANGLETOFINESHIFT);
pc = FINECOSINE(sec->floorpic_angle>>ANGLETOFINESHIFT); fixed_t xoffs = sec->floor_xoffs;
ps = FINESINE (sec->floorpic_angle>>ANGLETOFINESHIFT); fixed_t yoffs = sec->floor_yoffs;
xoffs = sec->floor_xoffs; #define MAXFLATSIZE (2048<<FRACBITS)
yoffs = sec->floor_yoffs; sec->floor_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE);
#define MAXFLATSIZE (2048<<FRACBITS) sec->floor_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE);
sec->floor_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE); #undef MAXFLATSIZE
sec->floor_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE); }
#undef MAXFLATSIZE
}
if (sec->ceilingpic_angle) if (sec->ceilingpic_angle)
{ {
pc = FINECOSINE(sec->ceilingpic_angle>>ANGLETOFINESHIFT); fixed_t pc = FINECOSINE(sec->ceilingpic_angle>>ANGLETOFINESHIFT);
ps = FINESINE (sec->ceilingpic_angle>>ANGLETOFINESHIFT); fixed_t ps = FINESINE (sec->ceilingpic_angle>>ANGLETOFINESHIFT);
xoffs = sec->ceiling_xoffs; fixed_t xoffs = sec->ceiling_xoffs;
yoffs = sec->ceiling_yoffs; fixed_t yoffs = sec->ceiling_yoffs;
#define MAXFLATSIZE (2048<<FRACBITS) #define MAXFLATSIZE (2048<<FRACBITS)
sec->ceiling_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE); sec->ceiling_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE);
sec->ceiling_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE); sec->ceiling_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE);
#undef MAXFLATSIZE #undef MAXFLATSIZE
}
} }
} }
@ -1666,10 +1660,7 @@ static void P_LoadMapData(const virtres_t *virt)
// Load map data. // Load map data.
if (textmap) if (textmap)
{
P_LoadTextmap(); P_LoadTextmap();
TextmapFixFlatOffsets();
}
else else
{ {
P_LoadVertices(virtvertexes->data); P_LoadVertices(virtvertexes->data);