1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Allow non-normalized weights in glTF models (#15310)

We are being lax here, but the glTF specification just requires that "when the weights are stored using float component type, their linear sum SHOULD be as close as reasonably possible to 1.0 for a given vertex"

In particular weights > 1 and weight sums well below or above 1 can be observed in models exported by Blender if they aren't manually normalized.
These fail the glTF validator but Irrlicht normalizes weights itself so we can support them just fine.

The docs have been updated to recommend normalizing weights (as well as documenting the status of interpolation support).

Weights < 0, most of them close to 0, also occur. Consistent with Irrlicht, we ignore them, but we also raise a warning.
This commit is contained in:
Lars Müller 2024-12-06 18:05:03 +01:00 committed by GitHub
parent 3e10d9ccf5
commit 05d31222f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 17 deletions

View file

@ -91,7 +91,7 @@ private:
const tiniergltf::GlTF &model,
const std::size_t accessorIdx);
template <std::size_t N>
template <std::size_t N, bool validate = true>
static std::array<f32, N> getNormalizedValues(
const NormalizedValuesAccessor<N> &accessor,
const std::size_t i);
@ -118,7 +118,7 @@ private:
std::size_t getPrimitiveCount(const std::size_t meshIdx) const;
void load();
const std::vector<std::string> &getWarnings() {
const std::unordered_set<std::string> &getWarnings() {
return warnings;
}
@ -129,9 +129,9 @@ private:
std::vector<std::function<void()>> m_mesh_loaders;
std::vector<SkinnedMesh::SJoint *> m_loaded_nodes;
std::vector<std::string> warnings;
std::unordered_set<std::string> warnings;
void warn(const std::string &warning) {
warnings.push_back(warning);
warnings.insert(warning);
}
void copyPositions(const std::size_t accessorIdx,