Skip to content

Commit 04ea30c

Browse files
committed
gltf add bone remaps and fix MakeSamples
1 parent 6064cee commit 04ea30c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/spike/gltf.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct SavedIndices {
9696

9797
struct GLTFModel : GLTF {
9898
std::optional<es::Matrix44> transform;
99+
std::optional<std::vector<uint8>> boneRemaps;
99100

100101
SavedIndices GLTF_EXTERN SaveIndices(const void *data, size_t numIndices,
101102
size_t indexSize = 2);

src/gltf/gltf.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,14 @@ gltf::Attributes GLTFModel::SaveVertices(const void *data, size_t numVertices,
958958
}
959959
}
960960

961+
if (boneRemaps) {
962+
for (auto &bi : bonesBuffer) {
963+
for (uint8 b = 0; b < 8; b++) {
964+
bi.data[b] = boneRemaps->at(bi.data[b]);
965+
}
966+
}
967+
}
968+
961969
if (weightElement > 1) {
962970
for (size_t idx = 0; auto &bw : weightsBuffer) {
963971
BWBuffer &bones = bonesBuffer.at(idx++);
@@ -1080,7 +1088,9 @@ std::vector<float> MakeSamples(float sampleRate, float duration) {
10801088
cdur += fraction;
10811089
}
10821090

1083-
times.emplace_back(duration);
1091+
if (!fltcmp(times.back(), duration, fraction * 0.01f)) {
1092+
times.emplace_back(duration);
1093+
}
10841094
return times;
10851095
}
10861096

0 commit comments

Comments
 (0)