Skip to content

Commit 9bf6fd0

Browse files
vtfpp: all console platform cubemaps do not have a spheremap, not just xbox
1 parent f2a13ef commit 9bf6fd0

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/vtfpp/VTF.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -971,11 +971,7 @@ void VTF::setPlatform(Platform newPlatform) {
971971
case PLATFORM_PC:
972972
break;
973973
case PLATFORM_XBOX:
974-
// Have to do it this roundabout way to fix cubemaps, v7.5 has 6 faces
975-
this->setVersion(5);
976-
this->platform = newPlatform;
977-
// It's safe to do this, and we can't use VTF::setVersion now that platform is set
978-
this->version = 2;
974+
this->setVersion(2);
979975
break;
980976
case PLATFORM_X360:
981977
case PLATFORM_PS3_ORANGEBOX:
@@ -987,6 +983,11 @@ void VTF::setPlatform(Platform newPlatform) {
987983
}
988984
this->platform = newPlatform;
989985

986+
// Remove spheremap if on console (VTF::setVersion has already added it back on PC)
987+
if (newPlatform != PLATFORM_PC && this->hasImageData()) {
988+
this->regenerateImageData(this->format, this->width, this->height, this->mipCount, this->frameCount, 6, this->depth);
989+
}
990+
990991
// Update flags
991992
if (this->platform == PLATFORM_XBOX || newPlatform == PLATFORM_XBOX) {
992993
this->removeFlags(FLAG_MASK_XBOX);
@@ -1053,9 +1054,9 @@ void VTF::setVersion(uint32_t newVersion) {
10531054
if ((this->version < 5 && newVersion >= 5) || (this->version >= 5 && newVersion < 5)) {
10541055
this->removeFlags(FLAG_MASK_V5 | FLAG_MASK_V5_CSGO);
10551056
}
1056-
this->setSRGB(srgb);
10571057

10581058
this->version = newVersion;
1059+
this->setSRGB(srgb);
10591060
}
10601061

10611062
ImageConversion::ResizeMethod VTF::getImageWidthResizeMethod() const {
@@ -1315,7 +1316,7 @@ uint8_t VTF::getFaceCount() const {
13151316
if (!(this->flags & FLAG_V0_ENVMAP)) {
13161317
return 1;
13171318
}
1318-
if (this->platform == PLATFORM_XBOX || this->version >= 6) {
1319+
if (this->platform != PLATFORM_PC || this->version >= 6) {
13191320
// All v7.6 VTFs are sane, and we need this special case to fix a bug in the parser where
13201321
// it won't recognize cubemaps as cubemaps because the image resource is compressed!
13211322
return 6;
@@ -1858,7 +1859,7 @@ bool VTF::setImage(std::span<const std::byte> imageData_, ImageFormat format_, u
18581859
if (const auto newMipCount = ImageDimensions::getMaximumMipCount(resizedWidth, resizedHeight, this->depth); newMipCount <= mip) {
18591860
mip = newMipCount - 1;
18601861
}
1861-
if (face > 6 || (face == 6 && (this->platform == PLATFORM_XBOX || this->version < 1 || this->version > 4))) {
1862+
if (face > 6 || (face == 6 && (this->platform != PLATFORM_PC || this->version < 1 || this->version > 4))) {
18621863
return false;
18631864
}
18641865
this->regenerateImageData(format_, resizedWidth, resizedHeight, mip + 1, frame + 1, face ? (face < 6 ? 6 : face) : 0, slice + 1);

0 commit comments

Comments
 (0)