qbsp: get an actual test for #158, currently disabled
This commit is contained in:
parent
fbb72248bb
commit
e848d00f92
|
|
@ -13,10 +13,37 @@ 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"
|
||||
{
|
||||
|
|
@ -27,29 +54,33 @@ TEST(qbsp, testTextureIssue) {
|
|||
( -136 -4 80 ) ( -152 -4 72 ) ( -152 4 72 ) skip 0 0 0 1.000000 1.000000 0 0 0
|
||||
( -152 -4 72.000008 ) ( -104.000168 -4 24.000172 ) ( -104.000168 4 24.000172 ) tech02_1 0 -8 0 1.000000 0.750000 0 0 0
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
parser_t parser;
|
||||
ParserInit(&parser, buf);
|
||||
|
||||
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);
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
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++) {
|
||||
for (int j=0; j<4; j++) {
|
||||
EXPECT_FLOAT_EQ(texvecsExpected[i][j], texvecsActual[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue