Skip to content

Commit

Permalink
Remove texture atlas / AtlasPointer, rename getTextureRaw to getTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrl committed Jul 2, 2013
1 parent caf0b67 commit 8161ab5
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 753 deletions.
3 changes: 0 additions & 3 deletions minetest.conf.example
Expand Up @@ -112,9 +112,6 @@
# Enable smooth lighting with simple ambient occlusion;
# disable for speed or for different looks.
#smooth_lighting = true
# Enable combining mainly used textures to a bigger one for improved speed
# disable if it causes graphics glitches.
#enable_texture_atlas = false
# Path to texture directory. All textures are first searched from here.
#texture_path =
# Video back-end.
Expand Down
11 changes: 0 additions & 11 deletions src/client.cpp
Expand Up @@ -320,12 +320,6 @@ Client::Client(
m_playerpos_send_timer = 0.0;
m_ignore_damage_timer = 0.0;

// Build main texture atlas, now that the GameDef exists (that is, us)
if(g_settings->getBool("enable_texture_atlas"))
m_tsrc->buildMainAtlas(this);
else
infostream<<"Not building texture atlas."<<std::endl;

/*
Add local player
*/
Expand Down Expand Up @@ -2855,11 +2849,6 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
infostream<<"- Rebuilding images and textures"<<std::endl;
m_tsrc->rebuildImagesAndTextures();

// Update texture atlas
infostream<<"- Updating texture atlas"<<std::endl;
if(g_settings->getBool("enable_texture_atlas"))
m_tsrc->buildMainAtlas(this);

// Rebuild shaders
m_shsrc->rebuildShaders();

Expand Down
25 changes: 10 additions & 15 deletions src/content_cao.cpp
Expand Up @@ -223,7 +223,7 @@ void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
// Set material
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
buf->getMaterial().setTexture(0, tsrc->getTextureRaw("rat.png"));
buf->getMaterial().setTexture(0, tsrc->getTexture("rat.png"));
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
Expand Down Expand Up @@ -393,7 +393,7 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
// Initialize with a generated placeholder texture
buf->getMaterial().setTexture(0, tsrc->getTextureRaw(""));
buf->getMaterial().setTexture(0, tsrc->getTexture(""));
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
Expand Down Expand Up @@ -864,7 +864,7 @@ class GenericCAO : public ClientActiveObject
m_spritenode = smgr->addBillboardSceneNode(
NULL, v2f(1, 1), v3f(0,0,0), -1);
m_spritenode->setMaterialTexture(0,
tsrc->getTextureRaw("unknown_node.png"));
tsrc->getTexture("unknown_node.png"));
m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false);
m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
Expand Down Expand Up @@ -1273,7 +1273,7 @@ class GenericCAO : public ClientActiveObject
texturestring = m_prop.textures[0];
texturestring += mod;
m_spritenode->setMaterialTexture(0,
tsrc->getTextureRaw(texturestring));
tsrc->getTexture(texturestring));

// This allows setting per-material colors. However, until a real lighting
// system is added, the code below will have no effect. Once MineTest
Expand All @@ -1300,7 +1300,7 @@ class GenericCAO : public ClientActiveObject
if(texturestring == "")
continue; // Empty texture string means don't modify that material
texturestring += mod;
video::ITexture* texture = tsrc->getTextureRaw(texturestring);
video::ITexture* texture = tsrc->getTexture(texturestring);
if(!texture)
{
errorstream<<"GenericCAO::updateTextures(): Could not load texture "<<texturestring<<std::endl;
Expand Down Expand Up @@ -1338,20 +1338,15 @@ class GenericCAO : public ClientActiveObject
if(m_prop.textures.size() > i)
texturestring = m_prop.textures[i];
texturestring += mod;
AtlasPointer ap = tsrc->getTexture(texturestring);

// Get the tile texture and atlas transformation
video::ITexture* atlas = ap.atlas;
v2f pos = ap.pos;
v2f size = ap.size;

// Set material flags and texture
video::SMaterial& material = m_meshnode->getMaterial(i);
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setTexture(0, atlas);
material.getTextureMatrix(0).setTextureTranslate(pos.X, pos.Y);
material.getTextureMatrix(0).setTextureScale(size.X, size.Y);
material.setTexture(0,
tsrc->getTexture(texturestring));
material.getTextureMatrix(0).makeIdentity();

// This allows setting per-material colors. However, until a real lighting
// system is added, the code below will have no effect. Once MineTest
Expand All @@ -1378,7 +1373,7 @@ class GenericCAO : public ClientActiveObject
tname += mod;
scene::IMeshBuffer *buf = mesh->getMeshBuffer(0);
buf->getMaterial().setTexture(0,
tsrc->getTextureRaw(tname));
tsrc->getTexture(tname));

// This allows setting per-material colors. However, until a real lighting
// system is added, the code below will have no effect. Once MineTest
Expand All @@ -1403,7 +1398,7 @@ class GenericCAO : public ClientActiveObject
tname += mod;
scene::IMeshBuffer *buf = mesh->getMeshBuffer(1);
buf->getMaterial().setTexture(0,
tsrc->getTextureRaw(tname));
tsrc->getTexture(tname));

// This allows setting per-material colors. However, until a real lighting
// system is added, the code below will have no effect. Once MineTest
Expand Down
2 changes: 1 addition & 1 deletion src/content_cso.cpp
Expand Up @@ -50,7 +50,7 @@ class SmokePuffCSO: public ClientSimpleObject
m_spritenode = smgr->addBillboardSceneNode(
NULL, v2f(1,1), pos, -1);
m_spritenode->setMaterialTexture(0,
env->getGameDef()->tsrc()->getTextureRaw("smoke_puff.png"));
env->getGameDef()->tsrc()->getTexture("smoke_puff.png"));
m_spritenode->setMaterialFlag(video::EMF_LIGHTING, false);
m_spritenode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
//m_spritenode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
Expand Down

0 comments on commit 8161ab5

Please sign in to comment.