summaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-11-29 13:04:03 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-11-29 13:04:03 +0200
commitaaafb5add0914f0b120d7400e9615f8ab03d6be2 (patch)
treefef01c5239c0ed359737038ba3fe9d1dc24ade6f /src/mapblock.cpp
parent3ad212c90b280f2f9630d3ffe453ff82c71e7516 (diff)
downloadminetest-aaafb5add0914f0b120d7400e9615f8ab03d6be2.tar.gz
minetest-aaafb5add0914f0b120d7400e9615f8ab03d6be2.tar.bz2
minetest-aaafb5add0914f0b120d7400e9615f8ab03d6be2.zip
reversed meshbuffer cache
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp62
1 files changed, 14 insertions, 48 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index f525ed3e9..25561008a 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -297,8 +297,6 @@ void MapBlock::updateMesh()
core::list<FastFace*> *fastfaces_new = new core::list<FastFace*>;
- //TimeTaker timer1("updateMesh1", g_device);
-
/*
We are including the faces of the trailing edges of the block.
This means that when something changes, the caller must
@@ -342,26 +340,12 @@ void MapBlock::updateMesh()
}
}
- //timer1.stop();
- //TimeTaker timer2("updateMesh2", g_device);
-
scene::SMesh *mesh_new = NULL;
-
- //s32 appendtime = 0;
if(fastfaces_new->getSize() > 0)
{
mesh_new = new scene::SMesh();
scene::IMeshBuffer *buf = NULL;
-
- /*
- Buffer for lesser calls to
- mesh_new->getMeshBuffer(g_materials[f->material]),
- which is slow.
-
- key = material id, value = meshbuffer of that material
- */
- core::map<u8, scene::IMeshBuffer*> bufs;
core::list<FastFace*>::Iterator i = fastfaces_new->begin();
@@ -375,43 +359,27 @@ void MapBlock::updateMesh()
if(f->material != material_in_use || buf == NULL)
{
// Try to get a meshbuffer associated with the material
- core::map<u8, scene::IMeshBuffer*>::Node*
- n = bufs.find(f->material);
-
- if(n != NULL)
+ buf = mesh_new->getMeshBuffer(g_materials[f->material]);
+ // If not found, create one
+ if(buf == NULL)
{
- buf = n->getValue();
- }
- else
- {
- buf = mesh_new->getMeshBuffer(g_materials[f->material]);
- // If not found, create one
- if(buf == NULL)
- {
- // This is a "Standard MeshBuffer",
- // it's a typedeffed CMeshBuffer<video::S3DVertex>
- buf = new scene::SMeshBuffer();
- bufs[f->material] = buf;
- // Set material
- ((scene::SMeshBuffer*)buf)->Material = g_materials[f->material];
- // Use VBO
- //buf->setHardwareMappingHint(scene::EHM_STATIC);
- // Add to mesh
- mesh_new->addMeshBuffer(buf);
- // Mesh grabbed it
- buf->drop();
- }
+ // This is a "Standard MeshBuffer",
+ // it's a typedeffed CMeshBuffer<video::S3DVertex>
+ buf = new scene::SMeshBuffer();
+ // Set material
+ ((scene::SMeshBuffer*)buf)->Material = g_materials[f->material];
+ // Use VBO
+ //buf->setHardwareMappingHint(scene::EHM_STATIC);
+ // Add to mesh
+ mesh_new->addMeshBuffer(buf);
+ // Mesh grabbed it
+ buf->drop();
}
material_in_use = f->material;
}
u16 indices[] = {0,1,2,2,3,0};
-
- //TimeTaker timer("", g_device);
-
buf->append(f->vertices, 4, indices, 6);
-
- //appendtime += timer.stop(true);
}
// Use VBO for mesh (this just would set this for ever buffer)
@@ -422,8 +390,6 @@ void MapBlock::updateMesh()
<<" materials"<<std::endl;*/
}
- //dstream<<"appendtime="<<appendtime<<std::endl;
-
// TODO: Get rid of the FastFace stage
core::list<FastFace*>::Iterator i;
i = fastfaces_new->begin();