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 <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-02-27 11:10:40 +10:30
parent dcbad73b48
commit 92ff448966
2 changed files with 13 additions and 34 deletions

View File

@ -1,3 +1,7 @@
????-??-?? (unreleased)
* qbsp: respect floating point texture rotation and shift in map files
2013-02-25 TyrUtils v0.5 2013-02-25 TyrUtils v0.5
* New changelog to summarise changes going forward * New changelog to summarise changes going forward

View File

@ -191,7 +191,7 @@ ParseExtendedTX(parser_t *parser)
} }
static void 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) const vec_t scale[2], texinfo_t *out)
{ {
int i, j; 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]); TextureAxisFromPlane(plane, vecs[0], vecs[1]);
/* Normalize the Texture rotation */ /* Rotate axis */
rotate %= 360; ang = (vec_t)rotate / 180 * Q_PI;
while (rotate < 0) sinv = sin(ang);
rotate += 360; cosv = cos(ang);
// 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);
}
if (vecs[0][0]) if (vecs[0][0])
sv = 0; sv = 0;
@ -334,8 +310,7 @@ ParseBrush(parser_t *parser, mapbrush_t *brush)
int i, j; int i, j;
texinfo_t tx; texinfo_t tx;
vec_t d; vec_t d;
int shift[2], rotate; vec_t shift[2], rotate, scale[2];
vec_t scale[2];
int tx_type; int tx_type;
plane_t *plane; plane_t *plane;
mapface_t *face, *checkface; mapface_t *face, *checkface;
@ -367,11 +342,11 @@ ParseBrush(parser_t *parser, mapbrush_t *brush)
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);
tx.miptex = FindMiptex(parser->token); tx.miptex = FindMiptex(parser->token);
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);
shift[0] = atoi(parser->token); shift[0] = atof(parser->token);
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);
shift[1] = atoi(parser->token); shift[1] = atof(parser->token);
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);
rotate = atoi(parser->token); rotate = atof(parser->token);
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);
scale[0] = atof(parser->token); scale[0] = atof(parser->token);
ParseToken(parser, PARSE_SAMELINE); ParseToken(parser, PARSE_SAMELINE);