mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 09:20:23 +02:00
Meshgen: Handle enable_water_reflections like smooth_lighting
This commit is contained in:
@ -63,8 +63,7 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector
|
|||||||
data(input),
|
data(input),
|
||||||
collector(output),
|
collector(output),
|
||||||
nodedef(data->nodedef),
|
nodedef(data->nodedef),
|
||||||
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE),
|
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE)
|
||||||
smooth_liquids(g_settings->getBool("enable_water_reflections"))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +732,7 @@ void MapblockMeshGenerator::drawLiquidTop()
|
|||||||
int u = corner_resolve[i][0];
|
int u = corner_resolve[i][0];
|
||||||
int w = corner_resolve[i][1];
|
int w = corner_resolve[i][1];
|
||||||
|
|
||||||
if (smooth_liquids) {
|
if (data->m_enable_water_reflections) {
|
||||||
int x = vertices[i].Pos.X > 0;
|
int x = vertices[i].Pos.X > 0;
|
||||||
int z = vertices[i].Pos.Z > 0;
|
int z = vertices[i].Pos.Z > 0;
|
||||||
|
|
||||||
@ -785,7 +784,7 @@ void MapblockMeshGenerator::drawLiquidTop()
|
|||||||
|
|
||||||
vertex.TCoords += tcoord_translate;
|
vertex.TCoords += tcoord_translate;
|
||||||
|
|
||||||
if (!smooth_liquids) {
|
if (!data->m_enable_water_reflections) {
|
||||||
vertex.Normal = v3f(dx, 1., dz).normalize();
|
vertex.Normal = v3f(dx, 1., dz).normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,6 @@ private:
|
|||||||
f32 corner_levels[2][2];
|
f32 corner_levels[2][2];
|
||||||
};
|
};
|
||||||
LiquidData cur_liquid;
|
LiquidData cur_liquid;
|
||||||
bool smooth_liquids = false;
|
|
||||||
|
|
||||||
void prepareLiquidNodeDrawing();
|
void prepareLiquidNodeDrawing();
|
||||||
void getLiquidNeighborhood();
|
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;
|
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
|
Light and vertex color functions
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,7 @@ struct MeshMakeData
|
|||||||
v3s16 m_blockpos = v3s16(-1337,-1337,-1337);
|
v3s16 m_blockpos = v3s16(-1337,-1337,-1337);
|
||||||
v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337);
|
v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337);
|
||||||
bool m_smooth_lighting = false;
|
bool m_smooth_lighting = false;
|
||||||
|
bool m_enable_water_reflections = false;
|
||||||
u16 side_length;
|
u16 side_length;
|
||||||
|
|
||||||
const NodeDefManager *nodedef;
|
const NodeDefManager *nodedef;
|
||||||
@ -55,11 +56,6 @@ struct MeshMakeData
|
|||||||
Set the (node) position of a crack
|
Set the (node) position of a crack
|
||||||
*/
|
*/
|
||||||
void setCrack(int crack_level, v3s16 crack_pos);
|
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
|
// represents a triangle as indexes into the vertex buffer in SMeshBuffer
|
||||||
|
@ -40,6 +40,7 @@ MeshUpdateQueue::MeshUpdateQueue(Client *client):
|
|||||||
m_client(client)
|
m_client(client)
|
||||||
{
|
{
|
||||||
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
|
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
|
||||||
|
m_cache_enable_water_reflections = g_settings->getBool("enable_water_reflections");
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshUpdateQueue::~MeshUpdateQueue()
|
MeshUpdateQueue::~MeshUpdateQueue()
|
||||||
@ -191,7 +192,8 @@ void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data->setCrack(q->crack_level, q->crack_pos);
|
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::unordered_set<v3s16> m_inflight_blocks;
|
||||||
std::mutex m_mutex;
|
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_smooth_lighting;
|
||||||
|
bool m_cache_enable_water_reflections;
|
||||||
|
|
||||||
void fillDataFromMapBlocks(QueuedMeshUpdate *q);
|
void fillDataFromMapBlocks(QueuedMeshUpdate *q);
|
||||||
};
|
};
|
||||||
|
@ -311,7 +311,8 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
|
|||||||
{
|
{
|
||||||
MeshMakeData mesh_make_data(client->ndef(), 1);
|
MeshMakeData mesh_make_data(client->ndef(), 1);
|
||||||
MeshCollector collector(v3f(0.0f * BS), v3f());
|
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);
|
MapblockMeshGenerator gen(&mesh_make_data, &collector);
|
||||||
|
|
||||||
if (n.getParam2()) {
|
if (n.getParam2()) {
|
||||||
|
@ -39,7 +39,8 @@ public:
|
|||||||
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true)
|
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true)
|
||||||
{
|
{
|
||||||
MeshMakeData data{ndef(), 1};
|
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};
|
data.m_blockpos = {0, 0, 0};
|
||||||
for (s16 x = -1; x <= 1; x++)
|
for (s16 x = -1; x <= 1; x++)
|
||||||
for (s16 y = -1; y <= 1; y++)
|
for (s16 y = -1; y <= 1; y++)
|
||||||
|
Reference in New Issue
Block a user