summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-14 22:07:42 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:42 +0200
commit1afed48a2c90548e0b420c9c3d7d4af9e0734d1d (patch)
treed485510b3eaa0b4fcc2aa4a4cf336da025003bfd /src
parentc6fd2986d4261cf742d3bc21e8c12be59ab89f95 (diff)
downloadminetest-1afed48a2c90548e0b420c9c3d7d4af9e0734d1d.tar.gz
minetest-1afed48a2c90548e0b420c9c3d7d4af9e0734d1d.tar.bz2
minetest-1afed48a2c90548e0b420c9c3d7d4af9e0734d1d.zip
Make possible and do update textures in node definitions after late texture atlas making
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp3
-rw-r--r--src/nodedef.cpp15
-rw-r--r--src/nodedef.h6
-rw-r--r--src/tile.h3
4 files changed, 26 insertions, 1 deletions
diff --git a/src/client.cpp b/src/client.cpp
index d0e5cd405..d5abcd7de 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -224,6 +224,9 @@ Client::Client(
tsrc->buildMainAtlas(this);
else
infostream<<"Not building texture atlas."<<std::endl;
+
+ // Update textures
+ m_nodedef->updateTextures(tsrc);
// NOTE: This should be done only after getting possible dynamic
// game definitions from the server, or at least shut down and
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 74d825362..7b723e958 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -164,6 +164,21 @@ public:
assert(c <= MAX_CONTENT);
return &m_content_features[c];
}
+ virtual void updateTextures(ITextureSource *tsrc)
+ {
+#ifndef SERVER
+ infostream<<"CNodeDefManager::updateTextures(): Updating "
+ <<"textures in node definitions"<<std::endl;
+ for(u16 i=0; i<=MAX_CONTENT; i++)
+ {
+ ContentFeatures *f = &m_content_features[i];
+ for(u16 j=0; j<6; j++)
+ tsrc->updateAP(f->tiles[j].texture);
+ if(f->special_atlas)
+ tsrc->updateAP(*(f->special_atlas));
+ }
+#endif
+ }
private:
ContentFeatures m_content_features[MAX_CONTENT+1];
};
diff --git a/src/nodedef.h b/src/nodedef.h
index dece63fcd..5aba69c48 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -320,6 +320,12 @@ public:
// Register node definition
virtual void set(content_t c, const ContentFeatures &def)=0;
virtual ContentFeatures* getModifiable(content_t c)=0;
+
+ /*
+ Update tile textures to latest return values of TextueSource.
+ Call after updating the texture atlas of a TextureSource.
+ */
+ virtual void updateTextures(ITextureSource *tsrc)=0;
};
// If textures not actually available (server), tsrc can be NULL
diff --git a/src/tile.h b/src/tile.h
index ac4e790b4..105692c10 100644
--- a/src/tile.h
+++ b/src/tile.h
@@ -138,6 +138,7 @@ public:
{return AtlasPointer(0);}
virtual video::ITexture* getTextureRaw(const std::string &name)
{return NULL;}
+ virtual void updateAP(AtlasPointer &ap){};
};
class IWritableTextureSource : public ITextureSource
@@ -153,8 +154,8 @@ public:
{return AtlasPointer(0);}
virtual video::ITexture* getTextureRaw(const std::string &name)
{return NULL;}
+ virtual void updateAP(AtlasPointer &ap){};
- virtual void updateAP(AtlasPointer &ap)=0;
virtual void buildMainAtlas(class IGameDef *gamedef)=0;
virtual void processQueue()=0;
};