*/
#include "mapblock_mesh.h"
-#include "light.h"
#include "mapblock.h"
#include "map.h"
#include "profiler.h"
-#include "nodedef.h"
#include "mesh.h"
#include "minimap.h"
#include "content_mapblock.h"
-#include "noise.h"
-#include "shader.h"
-#include "settings.h"
#include "util/directiontables.h"
-#include <IMeshManipulator.h>
+#include "client/renderingengine.h"
/*
MeshMakeData
Calculate smooth lighting at the XYZ- corner of p.
Both light banks
*/
-static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
+static u16 getSmoothLightCombined(const v3s16 &p, MeshMakeData *data)
{
static const v3s16 dirs8[8] = {
v3s16(0,0,0),
if (layer->texture_id == 0)
continue;
- dest.push_back(FastFace());
+ // equivalent to dest.push_back(FastFace()) but faster
+ dest.emplace_back();
FastFace& face = *dest.rbegin();
for (u8 i = 0; i < 4; i++) {
*/
static void updateFastFaceRow(
MeshMakeData *data,
- v3s16 startpos,
+ const v3s16 &&startpos,
v3s16 translate_dir,
- v3f translate_dir_f,
- v3s16 face_dir,
- v3f face_dir_f,
+ const v3f &&translate_dir_f,
+ const v3s16 &&face_dir,
std::vector<FastFace> &dest)
{
v3s16 p = startpos;
v3s16(1,0,0), //dir
v3f (1,0,0),
v3s16(0,1,0), //face dir
- v3f (0,1,0),
dest);
}
}
v3s16(0,0,1), //dir
v3f (0,0,1),
v3s16(1,0,0), //face dir
- v3f (1,0,0),
dest);
}
}
v3s16(1,0,0), //dir
v3f (1,0,0),
v3s16(0,0,1), //face dir
- v3f (0,0,1),
dest);
}
}
MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_minimap_mapblock(NULL),
- m_client(data->m_client),
- m_driver(m_client->tsrc()->getDevice()->getVideoDriver()),
- m_tsrc(m_client->getTextureSource()),
- m_shdrsrc(m_client->getShaderSource()),
+ m_tsrc(data->m_client->getTextureSource()),
+ m_shdrsrc(data->m_client->getShaderSource()),
m_animation_force_timer(0), // force initial animation
m_last_crack(-1),
- m_crack_materials(),
- m_last_daynight_ratio((u32) -1),
- m_daynight_diffs()
+ m_last_daynight_ratio((u32) -1)
{
for (int m = 0; m < MAX_TILE_LAYERS; m++)
m_mesh[m] = new scene::SMesh();
m_animation_frame_offsets[std::pair<u8, u32>(layer, i)] = 0;
}
// Replace tile texture with the first animation frame
- p.layer.texture = p.layer.frames[0].texture;
+ p.layer.texture = (*p.layer.frames)[0].texture;
}
if (!m_enable_shaders) {
if (m_use_tangent_vertices) {
scene::IMeshManipulator* meshmanip =
- m_client->getSceneManager()->getMeshManipulator();
+ RenderingEngine::get_scene_manager()->getMeshManipulator();
meshmanip->recalculateTangents(m_mesh[layer], true, false, false);
}
if (m_enable_vbo && m_mesh[m])
for (u32 i = 0; i < m_mesh[m]->getMeshBufferCount(); i++) {
scene::IMeshBuffer *buf = m_mesh[m]->getMeshBuffer(i);
- m_driver->removeHardwareBuffer(buf);
+ RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
}
m_mesh[m]->drop();
m_mesh[m] = NULL;
scene::IMeshBuffer *buf = m_mesh[i->first.first]->
getMeshBuffer(i->first.second);
- const FrameSpec &animation_frame = tile.frames[frame];
+ const FrameSpec &animation_frame = (*tile.frames)[frame];
buf->getMaterial().setTexture(0, animation_frame.texture);
if (m_enable_shaders) {
if (animation_frame.normal_texture) {
{
if (m_use_tangent_vertices)
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
- std::vector<PreMeshBuffer> *p = &prebuffers[layer];
- for (std::vector<PreMeshBuffer>::iterator it = p->begin();
- it != p->end(); ++it) {
- video::SColor tc = it->layer.color;
+ for (auto &pmb : prebuffers[layer]) {
+ video::SColor tc = pmb.layer.color;
if (tc == video::SColor(0xFFFFFFFF))
continue;
- for (u32 index = 0; index < it->tangent_vertices.size(); index++) {
- video::SColor *c = &it->tangent_vertices[index].Color;
+ for (auto &tangent_vertice : pmb.tangent_vertices) {
+ video::SColor *c = &tangent_vertice.Color;
c->set(c->getAlpha(), c->getRed() * tc.getRed() / 255,
c->getGreen() * tc.getGreen() / 255,
c->getBlue() * tc.getBlue() / 255);
}
else
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
- std::vector<PreMeshBuffer> *p = &prebuffers[layer];
- for (std::vector<PreMeshBuffer>::iterator it = p->begin();
- it != p->end(); ++it) {
- video::SColor tc = it->layer.color;
+ for (auto &pmb : prebuffers[layer]) {
+ video::SColor tc = pmb.layer.color;
if (tc == video::SColor(0xFFFFFFFF))
continue;
- for (u32 index = 0; index < it->vertices.size(); index++) {
- video::SColor *c = &it->vertices[index].Color;
+ for (auto &vertice : pmb.vertices) {
+ video::SColor *c = &vertice.Color;
c->set(c->getAlpha(), c->getRed() * tc.getRed() / 255,
c->getGreen() * tc.getGreen() / 255,
c->getBlue() * tc.getBlue() / 255);