summaryrefslogtreecommitdiff
path: root/src/client/content_cao.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-11-22 18:27:49 +0100
committerGitHub <noreply@github.com>2021-11-22 17:27:49 +0000
commit206e131854392ed2d39b3456f7a1b5a54bd1bff9 (patch)
tree9b032e1b7a50b807985b6cfc25521cae6811dfd1 /src/client/content_cao.cpp
parent52bfbf6ed02e16d11f353c4066a0f4129d045e15 (diff)
downloadminetest-206e131854392ed2d39b3456f7a1b5a54bd1bff9.tar.gz
minetest-206e131854392ed2d39b3456f7a1b5a54bd1bff9.tar.bz2
minetest-206e131854392ed2d39b3456f7a1b5a54bd1bff9.zip
Add backwards-compatible behaviour if too few CAO textures specified
(#11766)
Diffstat (limited to 'src/client/content_cao.cpp')
-rw-r--r--src/client/content_cao.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index bb78b594d..24a9e7921 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/sound.h"
#include "client/tile.h"
#include "util/basic_macros.h"
-#include "util/numeric.h" // For IntervalLimiter & setPitchYawRoll
+#include "util/numeric.h"
#include "util/serialize.h"
#include "camera.h" // CameraModes
#include "collision.h"
@@ -171,6 +171,20 @@ static void updatePositionRecursive(scene::ISceneNode *node)
node->updateAbsolutePosition();
}
+static bool logOnce(const std::ostringstream &from, std::ostream &log_to)
+{
+ thread_local std::vector<u64> logged;
+
+ std::string message = from.str();
+ u64 hash = murmur_hash_64_ua(message.data(), message.length(), 0xBADBABE);
+
+ if (std::find(logged.begin(), logged.end(), hash) != logged.end())
+ return false;
+ logged.push_back(hash);
+ log_to << message << std::endl;
+ return true;
+}
+
/*
TestCAO
*/
@@ -822,6 +836,28 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
updateAttachments();
setNodeLight(m_last_light);
updateMeshCulling();
+
+ if (m_animated_meshnode) {
+ u32 mat_count = m_animated_meshnode->getMaterialCount();
+ if (mat_count == 0 || m_prop.textures.empty()) {
+ // nothing
+ } else if (mat_count > 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) specifed, this is deprecated.";
+ logOnce(oss, warningstream);
+
+ video::ITexture *last = m_animated_meshnode->getMaterial(0).TextureLayer[0].Texture;
+ for (s32 i = 1; i < mat_count; i++) {
+ auto &layer = m_animated_meshnode->getMaterial(i).TextureLayer[0];
+ if (!layer.Texture)
+ layer.Texture = last;
+ last = layer.Texture;
+ }
+ }
+ }
}
void GenericCAO::updateLight(u32 day_night_ratio)