From 92ff448966505b1aa3d69f6801826396cb579319 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Wed, 27 Feb 2013 11:10:40 +1030 Subject: [PATCH] qbsp: parse texture rotation and shift as floats Some editors will work with floating point rotations, so let them keep the precise texture alignment written to the .map file. Signed-off-by: Kevin Shanahan --- changelog.txt | 4 ++++ qbsp/map.c | 43 +++++++++---------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/changelog.txt b/changelog.txt index 79b86009..357b6729 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +????-??-?? (unreleased) + +* qbsp: respect floating point texture rotation and shift in map files + 2013-02-25 TyrUtils v0.5 * New changelog to summarise changes going forward diff --git a/qbsp/map.c b/qbsp/map.c index b5b4a79d..ae37786c 100644 --- a/qbsp/map.c +++ b/qbsp/map.c @@ -191,7 +191,7 @@ ParseExtendedTX(parser_t *parser) } static void -SetTexinfo_QuakeEd(const plane_t *plane, const int shift[2], int rotate, +SetTexinfo_QuakeEd(const plane_t *plane, const vec_t shift[2], vec_t rotate, const vec_t scale[2], texinfo_t *out) { int i, j; @@ -202,34 +202,10 @@ SetTexinfo_QuakeEd(const plane_t *plane, const int shift[2], int rotate, TextureAxisFromPlane(plane, vecs[0], vecs[1]); - /* Normalize the Texture rotation */ - rotate %= 360; - while (rotate < 0) - rotate += 360; - - // rotate axis - switch (rotate) { - case 0: - sinv = 0; - cosv = 1; - break; - case 90: - sinv = 1; - cosv = 0; - break; - case 180: - sinv = 0; - cosv = -1; - break; - case 270: - sinv = -1; - cosv = 0; - break; - default: - ang = (vec_t)rotate / 180 * Q_PI; - sinv = sin(ang); - cosv = cos(ang); - } + /* Rotate axis */ + ang = (vec_t)rotate / 180 * Q_PI; + sinv = sin(ang); + cosv = cos(ang); if (vecs[0][0]) sv = 0; @@ -334,8 +310,7 @@ ParseBrush(parser_t *parser, mapbrush_t *brush) int i, j; texinfo_t tx; vec_t d; - int shift[2], rotate; - vec_t scale[2]; + vec_t shift[2], rotate, scale[2]; int tx_type; plane_t *plane; mapface_t *face, *checkface; @@ -367,11 +342,11 @@ ParseBrush(parser_t *parser, mapbrush_t *brush) ParseToken(parser, PARSE_SAMELINE); tx.miptex = FindMiptex(parser->token); ParseToken(parser, PARSE_SAMELINE); - shift[0] = atoi(parser->token); + shift[0] = atof(parser->token); ParseToken(parser, PARSE_SAMELINE); - shift[1] = atoi(parser->token); + shift[1] = atof(parser->token); ParseToken(parser, PARSE_SAMELINE); - rotate = atoi(parser->token); + rotate = atof(parser->token); ParseToken(parser, PARSE_SAMELINE); scale[0] = atof(parser->token); ParseToken(parser, PARSE_SAMELINE);