kb1
Junior Member
Posts: 163
Registered: 11-06 |
Upon working on my home source port (details pending), I loaded DV map 5, and noticed some screwed-up texture offset rendering. Sorry, no screenshots, but it can be seen also in PrBoom-Plus, and, perhaps others by navigating to coordinates (400, -12345), and looking west. The wall is actually two textures, MARB_1A on the top, and MARB_1B on the bottom. The top is where the trouble occurs.
It appears that the trouble is caused by the node builder (I'm assuming ZDBSP?) applying offsets to the wrong segs.
This code, placed at the bottom of P_LoadSegs, inside the for loop fixes it, by recalculating all seg offsets:
// [kb] recalculate seg offsets that are sometimes incorrect
// with certain nodebuilders. Fixes among others, line 20365
// of DV.wad, map 5
{
vertex_t *start_vertex;
start_vertex = side ? ldef->v2 : ldef->v1;
if (start_vertex == li->v1)
li->offset = 0;
else
{
int dx = (start_vertex->x - li->v1->x) >> FRACBITS;
int dy = (start_vertex->y - li->v1->y) >> FRACBITS;
if (dx)
{
if (dy)
li->offset = ((int)(sqrt(dx * dx + dy * dy) + 0.5)) << FRACBITS;
else
li->offset = abs(dx) << FRACBITS;
}
else
li->offset = abs(dy) << FRACBITS;
}
}
Apparently, ZDoom doesn't use the SEGS offsets, so maps created with ZDBSP for ZDoom don't exhibit the problem.
Honestly, I haven't tested it too thoroughly to see if it causes any trouble elsewhere, but, it seems correct on the maps I've tried so far, and I wanted to share it.
|