mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Meshgen: Handle enable_water_reflections like smooth_lighting
This commit is contained in:
parent
9a60b83061
commit
c0ce918d77
8 changed files with 13 additions and 19 deletions
|
@ -63,8 +63,7 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector
|
|||
data(input),
|
||||
collector(output),
|
||||
nodedef(data->nodedef),
|
||||
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE),
|
||||
smooth_liquids(g_settings->getBool("enable_water_reflections"))
|
||||
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -733,7 +732,7 @@ void MapblockMeshGenerator::drawLiquidTop()
|
|||
int u = corner_resolve[i][0];
|
||||
int w = corner_resolve[i][1];
|
||||
|
||||
if (smooth_liquids) {
|
||||
if (data->m_enable_water_reflections) {
|
||||
int x = vertices[i].Pos.X > 0;
|
||||
int z = vertices[i].Pos.Z > 0;
|
||||
|
||||
|
@ -785,7 +784,7 @@ void MapblockMeshGenerator::drawLiquidTop()
|
|||
|
||||
vertex.TCoords += tcoord_translate;
|
||||
|
||||
if (!smooth_liquids) {
|
||||
if (!data->m_enable_water_reflections) {
|
||||
vertex.Normal = v3f(dx, 1., dz).normalize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,6 @@ private:
|
|||
f32 corner_levels[2][2];
|
||||
};
|
||||
LiquidData cur_liquid;
|
||||
bool smooth_liquids = false;
|
||||
|
||||
void prepareLiquidNodeDrawing();
|
||||
void getLiquidNeighborhood();
|
||||
|
|
|
@ -58,11 +58,6 @@ void MeshMakeData::setCrack(int crack_level, v3s16 crack_pos)
|
|||
m_crack_pos_relative = crack_pos - m_blockpos*MAP_BLOCKSIZE;
|
||||
}
|
||||
|
||||
void MeshMakeData::setSmoothLighting(bool smooth_lighting)
|
||||
{
|
||||
m_smooth_lighting = smooth_lighting;
|
||||
}
|
||||
|
||||
/*
|
||||
Light and vertex color functions
|
||||
*/
|
||||
|
|
|
@ -39,6 +39,7 @@ struct MeshMakeData
|
|||
v3s16 m_blockpos = v3s16(-1337,-1337,-1337);
|
||||
v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337);
|
||||
bool m_smooth_lighting = false;
|
||||
bool m_enable_water_reflections = false;
|
||||
u16 side_length;
|
||||
|
||||
const NodeDefManager *nodedef;
|
||||
|
@ -55,11 +56,6 @@ struct MeshMakeData
|
|||
Set the (node) position of a crack
|
||||
*/
|
||||
void setCrack(int crack_level, v3s16 crack_pos);
|
||||
|
||||
/*
|
||||
Enable or disable smooth lighting
|
||||
*/
|
||||
void setSmoothLighting(bool smooth_lighting);
|
||||
};
|
||||
|
||||
// represents a triangle as indexes into the vertex buffer in SMeshBuffer
|
||||
|
|
|
@ -40,6 +40,7 @@ MeshUpdateQueue::MeshUpdateQueue(Client *client):
|
|||
m_client(client)
|
||||
{
|
||||
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
|
||||
m_cache_enable_water_reflections = g_settings->getBool("enable_water_reflections");
|
||||
}
|
||||
|
||||
MeshUpdateQueue::~MeshUpdateQueue()
|
||||
|
@ -191,7 +192,8 @@ void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
|
|||
}
|
||||
|
||||
data->setCrack(q->crack_level, q->crack_pos);
|
||||
data->setSmoothLighting(m_cache_smooth_lighting);
|
||||
data->m_smooth_lighting = m_cache_smooth_lighting;
|
||||
data->m_enable_water_reflections = m_cache_enable_water_reflections;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -69,8 +69,9 @@ private:
|
|||
std::unordered_set<v3s16> m_inflight_blocks;
|
||||
std::mutex m_mutex;
|
||||
|
||||
// TODO: Add callback to update these when g_settings changes
|
||||
// TODO: Add callback to update these when g_settings changes, and update all meshes
|
||||
bool m_cache_smooth_lighting;
|
||||
bool m_cache_enable_water_reflections;
|
||||
|
||||
void fillDataFromMapBlocks(QueuedMeshUpdate *q);
|
||||
};
|
||||
|
|
|
@ -311,7 +311,8 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
|
|||
{
|
||||
MeshMakeData mesh_make_data(client->ndef(), 1);
|
||||
MeshCollector collector(v3f(0.0f * BS), v3f());
|
||||
mesh_make_data.setSmoothLighting(false);
|
||||
mesh_make_data.m_smooth_lighting = false;
|
||||
mesh_make_data.m_enable_water_reflections = false;
|
||||
MapblockMeshGenerator gen(&mesh_make_data, &collector);
|
||||
|
||||
if (n.getParam2()) {
|
||||
|
|
|
@ -39,7 +39,8 @@ public:
|
|||
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true)
|
||||
{
|
||||
MeshMakeData data{ndef(), 1};
|
||||
data.setSmoothLighting(smooth_lighting);
|
||||
data.m_smooth_lighting = smooth_lighting;
|
||||
data.m_enable_water_reflections = false;
|
||||
data.m_blockpos = {0, 0, 0};
|
||||
for (s16 x = -1; x <= 1; x++)
|
||||
for (s16 y = -1; y <= 1; y++)
|
||||
|
|
Loading…
Add table
Reference in a new issue