diff --git a/qbsp/map.c b/qbsp/map.c index f5d7d798..cd1fa450 100644 --- a/qbsp/map.c +++ b/qbsp/map.c @@ -534,6 +534,7 @@ ParseBrushFace(parser_t *parser, mapface_t *face) vec_t length; plane_t *plane; texinfo_t tx; + int i, j; face->linenum = parser->linenum; ParsePlaneDef(parser, planepts); @@ -553,6 +554,18 @@ ParseBrushFace(parser_t *parser, mapface_t *face) return false; } + // ericw -- round texture vector values that are within ZERO_EPSILON of integers, + // to attempt to attempt to work around corrupted lightmap sizes in DarkPlaces + // (it uses 32 bit precision in CalcSurfaceExtents) + for (i = 0; i < 2; i++) { + for (j = 0; j < 4; j++) { + vec_t r = Q_rint(tx.vecs[i][j]); + if (fabs(tx.vecs[i][j] - r) < ZERO_EPSILON) + tx.vecs[i][j] = r; + } + } + + face->texinfo = FindTexinfo(&tx); return true;