void MeshMakeData::setSmoothLighting(bool smooth_lighting)
{
- m_smooth_lighting = smooth_lighting;
+ m_smooth_lighting = smooth_lighting && ! g_settings->getBool("fullbright");
}
/*
u8 light = n.getLight(bank, ndef);
if (light > 0)
light = rangelim(light + increment, 0, LIGHT_SUN);
+ if(g_settings->getBool("fullbright"))
+ return 255;
return decode_light(light);
}
ndef->get(n2).light_source);
if(light_source > light)
light = light_source;
-
+ if(g_settings->getBool("fullbright"))
+ return 255;
return decode_light(light);
}
u8 c1 = f1.solidness;
u8 c2 = f2.solidness;
+
if (c1 == c2)
return 0;
else if (c2 == 0)
c2 = f2.visual_solidness;
+
if (c1 == c2) {
*equivalent = true;
// If same solidness, liquid takes precense
tile.rotation = tile.world_aligned ? 0 : dir_to_tile[tile_index + 1];
}
+std::set<content_t> splitToContentT(std::string str, const NodeDefManager *ndef)
+{
+ str += "\n";
+ std::set<content_t> dat;
+ std::string buf;
+ for (char c : str) {
+ if (c == ',' || c == '\n') {
+ if (! buf.empty()) {
+ dat.insert(ndef->getId(buf));
+ }
+ buf.clear();
+ } else if (c != ' ') {
+ buf += c;
+ }
+ }
+ return dat;
+}
+
static void getTileInfo(
// Input:
MeshMakeData *data,
v3s16 &face_dir_corrected,
u16 *lights,
u8 &waving,
- TileSpec &tile
- )
+ TileSpec &tile,
+ // lol more Input
+ bool xray,
+ std::set<content_t> xraySet)
{
VoxelManipulator &vmanip = data->m_vmanip;
const NodeDefManager *ndef = data->m_client->ndef();
const MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p);
+ content_t c0 = n0.getContent();
+ if (xray && xraySet.find(c0) != xraySet.end())
+ c0 = CONTENT_AIR;
// Don't even try to get n1 if n0 is already CONTENT_IGNORE
- if (n0.getContent() == CONTENT_IGNORE) {
+ if (c0 == CONTENT_IGNORE) {
makes_face = false;
return;
}
const MapNode &n1 = vmanip.getNodeRefUnsafeCheckFlags(blockpos_nodes + p + face_dir);
- if (n1.getContent() == CONTENT_IGNORE) {
+ content_t c1 = n1.getContent();
+ if (xray && xraySet.find(c1) != xraySet.end())
+ c1 = CONTENT_AIR;
+
+ if (c1 == CONTENT_IGNORE) {
makes_face = false;
return;
}
// This is hackish
bool equivalent = false;
- u8 mf = face_contents(n0.getContent(), n1.getContent(),
+ u8 mf = face_contents(c0, c1,
&equivalent, ndef);
if (mf == 0) {
v3s16 translate_dir,
const v3f &&translate_dir_f,
const v3s16 &&face_dir,
- std::vector<FastFace> &dest)
+ std::vector<FastFace> &dest,
+ bool xray,
+ std::set<content_t> xraySet)
{
static thread_local const bool waving_liquids =
g_settings->getBool("enable_shaders") &&
// Get info of first tile
getTileInfo(data, p, face_dir,
makes_face, p_corrected, face_dir_corrected,
- lights, waving, tile);
+ lights, waving, tile, xray, xraySet);
// Unroll this variable which has a significant build cost
TileSpec next_tile;
next_makes_face, next_p_corrected,
next_face_dir_corrected, next_lights,
waving,
- next_tile);
+ next_tile,
+ xray,
+ xraySet);
if (!force_not_tiling
&& next_makes_face == makes_face
}
static void updateAllFastFaceRows(MeshMakeData *data,
- std::vector<FastFace> &dest)
+ std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet)
{
/*
Go through every y,z and get top(y+) faces in rows of x+
v3s16(1, 0, 0), //dir
v3f (1, 0, 0),
v3s16(0, 1, 0), //face dir
- dest);
+ dest,
+ xray,
+ xraySet);
/*
Go through every x,y and get right(x+) faces in rows of z+
v3s16(0, 0, 1), //dir
v3f (0, 0, 1),
v3s16(1, 0, 0), //face dir
- dest);
+ dest,
+ xray,
+ xraySet);
/*
Go through every y,z and get back(z+) faces in rows of x+
v3s16(1, 0, 0), //dir
v3f (1, 0, 0),
v3s16(0, 0, 1), //face dir
- dest);
+ dest,
+ xray,
+ xraySet);
}
static void applyTileColor(PreMeshBuffer &pmb)
std::vector<FastFace> fastfaces_new;
fastfaces_new.reserve(512);
+ /*
+ X-Ray
+ */
+ bool xray = g_settings->getBool("xray");
+ std::set<content_t> xraySet, nodeESPSet;
+ if (xray)
+ xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef());
+
+ nodeESPSet = splitToContentT(g_settings->get("node_esp_nodes"), data->m_client->ndef());
/*
We are including the faces of the trailing edges of the block.
{
// 4-23ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated)
//TimeTaker timer2("updateAllFastFaceRows()");
- updateAllFastFaceRows(data, fastfaces_new);
+ updateAllFastFaceRows(data, fastfaces_new, xray, xraySet);
}
// End of slow part
+ /*
+ NodeESP
+ */
+ {
+ v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
+ for (s16 x = 0; x < MAP_BLOCKSIZE; x++) {
+ for (s16 y = 0; y < MAP_BLOCKSIZE; y++) {
+ for (s16 z = 0; z < MAP_BLOCKSIZE; z++) {
+ v3s16 pos = v3s16(x, y, z) + blockpos_nodes;
+ const MapNode &node = data->m_vmanip.getNodeRefUnsafeCheckFlags(pos);
+ if (nodeESPSet.find(node.getContent()) != nodeESPSet.end())
+ esp_nodes.insert(pos);
+ }
+ }
+ }
+ }
+
/*
Convert FastFaces to MeshCollector
*/
Convert MeshCollector to SMesh
*/
+ const bool desync_animations = g_settings->getBool(
+ "desynchronize_mapblock_texture_animation");
+
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
for(u32 i = 0; i < collector.prebuffers[layer].size(); i++)
{
// - Texture animation
if (p.layer.material_flags & MATERIAL_FLAG_ANIMATION) {
// Add to MapBlockMesh in order to animate these tiles
- m_animation_tiles[std::pair<u8, u32>(layer, i)] = p.layer;
- m_animation_frames[std::pair<u8, u32>(layer, i)] = 0;
- if (g_settings->getBool(
- "desynchronize_mapblock_texture_animation")) {
+ auto &info = m_animation_info[{layer, i}];
+ info.tile = p.layer;
+ info.frame = 0;
+ if (desync_animations) {
// Get starting position from noise
- m_animation_frame_offsets[std::pair<u8, u32>(layer, i)] =
+ info.frame_offset =
100000 * (2.0 + noise3d(
data->m_blockpos.X, data->m_blockpos.Y,
data->m_blockpos.Z, 0));
} else {
// Play all synchronized
- m_animation_frame_offsets[std::pair<u8, u32>(layer, i)] = 0;
+ info.frame_offset = 0;
}
// Replace tile texture with the first animation frame
p.layer.texture = (*p.layer.frames)[0].texture;
// Dummy sunlight to handle non-sunlit areas
video::SColorf sunlight;
get_sunlight_color(&sunlight, 0);
- u32 vertex_count = p.vertices.size();
+
+ std::map<u32, video::SColor> colors;
+ const u32 vertex_count = p.vertices.size();
for (u32 j = 0; j < vertex_count; j++) {
video::SColor *vc = &p.vertices[j].Color;
video::SColor copy = *vc;
if (vc->getAlpha() == 0) // No sunlight - no need to animate
final_color_blend(vc, copy, sunlight); // Finalize color
else // Record color to animate
- m_daynight_diffs[std::pair<u8, u32>(layer, i)][j] = copy;
+ colors[j] = copy;
// The sunlight ratio has been stored,
// delete alpha (for the final rendering).
vc->setAlpha(255);
}
+ if (!colors.empty())
+ m_daynight_diffs[{layer, i}] = std::move(colors);
}
// Create material
m_has_animation =
!m_crack_materials.empty() ||
!m_daynight_diffs.empty() ||
- !m_animation_tiles.empty();
+ !m_animation_info.empty();
}
MapBlockMesh::~MapBlockMesh()
{
for (scene::IMesh *m : m_mesh) {
+#if IRRLICHT_VERSION_MT_REVISION < 5
if (m_enable_vbo) {
for (u32 i = 0; i < m->getMeshBufferCount(); i++) {
scene::IMeshBuffer *buf = m->getMeshBuffer(i);
RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
}
}
+#endif
m->drop();
}
delete m_minimap_mapblock;
for (auto &crack_material : m_crack_materials) {
scene::IMeshBuffer *buf = m_mesh[crack_material.first.first]->
getMeshBuffer(crack_material.first.second);
- std::string basename = crack_material.second;
// Create new texture name from original
- std::ostringstream os;
- os << basename << crack;
+ std::string s = crack_material.second + itos(crack);
u32 new_texture_id = 0;
video::ITexture *new_texture =
- m_tsrc->getTextureForMesh(os.str(), &new_texture_id);
+ m_tsrc->getTextureForMesh(s, &new_texture_id);
buf->getMaterial().setTexture(0, new_texture);
- // If the current material is also animated,
- // update animation info
- auto anim_iter = m_animation_tiles.find(crack_material.first);
- if (anim_iter != m_animation_tiles.end()) {
- TileLayer &tile = anim_iter->second;
+ // If the current material is also animated, update animation info
+ auto anim_it = m_animation_info.find(crack_material.first);
+ if (anim_it != m_animation_info.end()) {
+ TileLayer &tile = anim_it->second.tile;
tile.texture = new_texture;
tile.texture_id = new_texture_id;
// force animation update
- m_animation_frames[crack_material.first] = -1;
+ anim_it->second.frame = -1;
}
}
}
// Texture animation
- for (auto &animation_tile : m_animation_tiles) {
- const TileLayer &tile = animation_tile.second;
+ for (auto &it : m_animation_info) {
+ const TileLayer &tile = it.second.tile;
// Figure out current frame
- int frameoffset = m_animation_frame_offsets[animation_tile.first];
- int frame = (int)(time * 1000 / tile.animation_frame_length_ms
- + frameoffset) % tile.animation_frame_count;
+ int frameno = (int)(time * 1000 / tile.animation_frame_length_ms
+ + it.second.frame_offset) % tile.animation_frame_count;
// If frame doesn't change, skip
- if (frame == m_animation_frames[animation_tile.first])
+ if (frameno == it.second.frame)
continue;
- m_animation_frames[animation_tile.first] = frame;
+ it.second.frame = frameno;
- scene::IMeshBuffer *buf = m_mesh[animation_tile.first.first]->
- getMeshBuffer(animation_tile.first.second);
+ scene::IMeshBuffer *buf = m_mesh[it.first.first]->getMeshBuffer(it.first.second);
- const FrameSpec &animation_frame = (*tile.frames)[frame];
- buf->getMaterial().setTexture(0, animation_frame.texture);
+ const FrameSpec &frame = (*tile.frames)[frameno];
+ buf->getMaterial().setTexture(0, frame.texture);
if (m_enable_shaders) {
- if (animation_frame.normal_texture)
- buf->getMaterial().setTexture(1,
- animation_frame.normal_texture);
- buf->getMaterial().setTexture(2, animation_frame.flags_texture);
+ if (frame.normal_texture)
+ buf->getMaterial().setTexture(1, frame.normal_texture);
+ buf->getMaterial().setTexture(2, frame.flags_texture);
}
}