qbsp: get an actual test for #158, currently disabled

This commit is contained in:
Eric Wasylishen 2017-07-08 16:53:16 -06:00
parent fbb72248bb
commit e848d00f92
1 changed files with 61 additions and 30 deletions

View File

@ -13,9 +13,36 @@ static face_t *Brush_FirstFaceWithTextureName(brush_t *brush, const char *texnam
return nullptr;
}
static const mapface_t *Mapbrush_FirstFaceWithTextureName(const mapbrush_t *brush, const std::string &texname) {
for (int i=0; i<brush->numfaces; i++) {
const mapface_t *face = &brush->face(i);
if (face->texname == texname) {
return face;
}
}
return nullptr;
}
static std::array<qvec4f, 2>
GetTexvecs(const char *map, const char *texname)
{
parser_t parser;
ParserInit(&parser, map);
mapentity_t worldspawn;
// FIXME: adds the brush to the global map...
Q_assert(ParseEntity(&parser, &worldspawn));
const mapbrush_t *mapbrush = &worldspawn.mapbrush(0);
const mapface_t *mapface = Mapbrush_FirstFaceWithTextureName(mapbrush, "tech02_1");
Q_assert(nullptr != mapface);
return mapface->get_texvecs();
}
// https://github.com/ericwa/tyrutils-ericw/issues/158
TEST(qbsp, testTextureIssue) {
const char *buf = R"(
const char *bufActual = R"(
{
"classname" "worldspawn"
"wad" "Q.wad"
@ -30,26 +57,30 @@ TEST(qbsp, testTextureIssue) {
}
)";
parser_t parser;
ParserInit(&parser, buf);
const char *bufExpected = R"(
{
"classname" "worldspawn"
"wad" "Q.wad"
{
( -104 -4 23.999998 ) ( -96.000252 -4 39.999489 ) ( -96.000252 4 39.999489 ) skip 0 0 0 1.000000 1.000000 0 0 0
( -135.996902 4 80.001549 ) ( -152 4 72 ) ( -104 4 23.999998 ) skip 0 -11 -45 1.000000 -1.070000 0 0 0
( -152 -4 72 ) ( -135.996902 -4 80.001549 ) ( -95.998451 -4 40.003094 ) skip 0 -11 -45 1.000000 -1.070000 0 0 0
( -96.000633 -4 40.000637 ) ( -136 -4 80.000008 ) ( -136 4 80.000008 ) skip 0 0 0 1.000000 1.000000 0 0 0
( -136 -4 80 ) ( -152 -4 72 ) ( -152 4 72 ) skip 0 0 0 1.000000 1.000000 0 0 0
( -152 -4 72 ) ( -104 -4 24 ) ( -104 4 24 ) tech02_1 0 -8 0 1 0.75 0 0 0
}
}
)";
mapentity_t worldspawn;
// FIXME: adds the brush to the global map...
ASSERT_TRUE(ParseEntity(&parser, &worldspawn));
brush_t *brush = LoadBrush(&worldspawn.mapbrush(0), vec3_origin, 0);
ASSERT_NE(nullptr, brush);
face_t *face = Brush_FirstFaceWithTextureName(brush, "tech02_1");
ASSERT_NE(nullptr, face);
const mtexinfo_t &texinfo = map.mtexinfos.at(face->texinfo);
const auto texvecsExpected = GetTexvecs(bufExpected, "tech02_1");
const auto texvecsActual = GetTexvecs(bufActual, "tech02_1");
// not going to fix #158 for now
#if 0
for (int i=0; i<2; i++) {
printf ("%f %f %f %f\n",
texinfo.vecs[i][0],
texinfo.vecs[i][1],
texinfo.vecs[i][2],
texinfo.vecs[i][3]);
for (int j=0; j<4; j++) {
EXPECT_FLOAT_EQ(texvecsExpected[i][j], texvecsActual[i][j]);
}
}
#endif
}