mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 00:55:20 +02:00
Add static glTF support (#14557)
Co-authored-by: Lars Mueller <appgurulars@gmx.de> Co-authored-by: jordan4ibanez <jordan4ibanez@users.noreply.github.com> Co-authored-by: sfan5 <sfan5@live.de> Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
This commit is contained in:
@@ -844,14 +844,19 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
|
||||
if (m_animated_meshnode) {
|
||||
u32 mat_count = m_animated_meshnode->getMaterialCount();
|
||||
assert(mat_count == m_animated_meshnode->getMesh()->getMeshBufferCount());
|
||||
u32 max_tex_idx = 0;
|
||||
for (u32 i = 0; i < mat_count; ++i) {
|
||||
max_tex_idx = std::max(max_tex_idx,
|
||||
m_animated_meshnode->getMesh()->getTextureSlot(i));
|
||||
}
|
||||
if (mat_count == 0 || m_prop.textures.empty()) {
|
||||
// nothing
|
||||
} else if (mat_count > m_prop.textures.size()) {
|
||||
} else if (max_tex_idx >= m_prop.textures.size()) {
|
||||
std::ostringstream oss;
|
||||
oss << "GenericCAO::addToScene(): Model "
|
||||
<< m_prop.mesh << " loaded with " << mat_count
|
||||
<< " mesh buffers but only " << m_prop.textures.size()
|
||||
<< " texture(s) specified, this is deprecated.";
|
||||
<< m_prop.mesh << " is missing " << (max_tex_idx + 1 - m_prop.textures.size())
|
||||
<< " more texture(s), this is deprecated.";
|
||||
logOnce(oss, warningstream);
|
||||
|
||||
video::ITexture *last = m_animated_meshnode->getMaterial(0).TextureLayers[0].Texture;
|
||||
@@ -1370,9 +1375,11 @@ void GenericCAO::updateTextures(std::string mod)
|
||||
|
||||
else if (m_animated_meshnode) {
|
||||
if (m_prop.visual == "mesh") {
|
||||
for (u32 i = 0; i < m_prop.textures.size() &&
|
||||
i < m_animated_meshnode->getMaterialCount(); ++i) {
|
||||
std::string texturestring = m_prop.textures[i];
|
||||
for (u32 i = 0; i < m_animated_meshnode->getMaterialCount(); ++i) {
|
||||
const auto texture_idx = m_animated_meshnode->getMesh()->getTextureSlot(i);
|
||||
if (texture_idx >= m_prop.textures.size())
|
||||
continue;
|
||||
std::string texturestring = m_prop.textures[texture_idx];
|
||||
if (texturestring.empty())
|
||||
continue; // Empty texture string means don't modify that material
|
||||
texturestring += mod;
|
||||
|
Reference in New Issue
Block a user