Skip to content

Commit 2f3b0fa

Browse files
fix(vtfpp): detect correct face count based on image buffer length
1 parent b94d21b commit 2f3b0fa

File tree

2 files changed

+68
-67
lines changed

2 files changed

+68
-67
lines changed

include/vtfpp/VTF.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,17 @@ class VTF {
152152
ImageConversion::ResizeMethod widthResizeMethod = ImageConversion::ResizeMethod::POWER_OF_TWO_BIGGER;
153153
ImageConversion::ResizeMethod heightResizeMethod = ImageConversion::ResizeMethod::POWER_OF_TWO_BIGGER;
154154
ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::BILINEAR;
155+
Flags flags = FLAG_NONE;
155156
uint16_t initialFrameCount = 1;
156-
uint16_t initialSliceCount = 1;
157+
uint16_t startFrame = 0;
157158
bool isCubeMap = false;
159+
bool hasSphereMap = false;
160+
uint16_t initialSliceCount = 1;
158161
bool createMips = true;
159162
bool createThumbnail = true;
160163
bool createReflectivity = true;
161-
Flags flags = FLAG_NONE;
162-
float bumpMapScale = 1.f;
163-
uint16_t startFrame = 0;
164164
uint8_t compressionLevel = 6;
165+
float bumpMapScale = 1.f;
165166
};
166167

167168
/// This value is only valid when passed to VTF::create through CreationOptions
@@ -172,8 +173,6 @@ class VTF {
172173

173174
static constexpr int32_t MAX_RESOURCES = 32;
174175

175-
static constexpr uint16_t SPHEREMAP_START_FRAME = 0xffff;
176-
177176
VTF();
178177

179178
explicit VTF(std::vector<std::byte>&& vtfData, bool parseHeaderOnly = false);
@@ -246,19 +245,19 @@ class VTF {
246245

247246
[[nodiscard]] uint8_t getFaceCount() const;
248247

249-
bool setFaceCount(bool hasMultipleFaces, bool hasSphereMap = false);
248+
bool setFaceCount(bool isCubemap, bool hasSphereMap = false);
250249

251250
//bool computeSphereMap();
252251

253252
[[nodiscard]] uint16_t getSliceCount() const;
254253

255254
bool setSliceCount(uint16_t newSliceCount);
256255

257-
bool setFrameFaceAndSliceCount(uint16_t newFrameCount, bool hasMultipleFaces, bool hasSphereMap = false, uint16_t newSliceCount = 1);
256+
bool setFrameFaceAndSliceCount(uint16_t newFrameCount, bool isCubemap, bool hasSphereMap = false, uint16_t newSliceCount = 1);
258257

259258
[[nodiscard]] uint16_t getStartFrame() const;
260259

261-
bool setStartFrame(uint16_t newStartFrame);
260+
void setStartFrame(uint16_t newStartFrame);
262261

263262
[[nodiscard]] sourcepp::math::Vec3f getReflectivity() const;
264263

@@ -347,8 +346,6 @@ class VTF {
347346

348347
static void createInternal(VTF& writer, CreationOptions options);
349348

350-
[[nodiscard]] static uint8_t getFaceCountFor(uint16_t width, uint16_t height, uint32_t majorVersion, uint32_t minorVersion, Flags flags, uint16_t startFrame);
351-
352349
[[nodiscard]] Resource* getResourceInternal(Resource::Type type);
353350

354351
void setResourceInternal(Resource::Type type, std::span<const std::byte> data_);

0 commit comments

Comments
 (0)