1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Undo changes to the clouds

This commit is contained in:
Gefüllte Taubenbrust 2024-12-28 21:41:33 +01:00
parent ba31db3eef
commit 6b6baf3fd7

View file

@ -13,6 +13,7 @@
#include "settings.h" #include "settings.h"
#include <cmath> #include <cmath>
class Clouds;
scene::ISceneManager* g_menucloudsmgr = nullptr; scene::ISceneManager* g_menucloudsmgr = nullptr;
Clouds* g_menuclouds = nullptr; Clouds* g_menuclouds = nullptr;
@ -90,13 +91,16 @@ void Clouds::updateMesh()
if (!m_mesh_valid) { if (!m_mesh_valid) {
// mesh was never created or invalidated // mesh was never created or invalidated
} else if (m_mesh_origin.getDistanceFrom(m_origin) >= max_d) { }
else if (m_mesh_origin.getDistanceFrom(m_origin) >= max_d) {
// clouds moved // clouds moved
} else if (center_of_drawing_in_noise_i != m_last_noise_center) { }
else if (center_of_drawing_in_noise_i != m_last_noise_center) {
// noise offset changed // noise offset changed
// I think in practice this never happens due to the camera offset // I think in practice this never happens due to the camera offset
// being smaller than the cloud size.(?) // being smaller than the cloud size.(?)
} else { }
else {
return; return;
} }
@ -190,15 +194,6 @@ void Clouds::updateMesh()
v2f p0 = v2f(xi, zi) * cloud_size + world_center_of_drawing_in_noise_f; v2f p0 = v2f(xi, zi) * cloud_size + world_center_of_drawing_in_noise_f;
const f32 rx = cloud_size / 2.0f;
// if clouds are flat, the top layer should be at the given height
const f32 ry = is3D() ? m_params.thickness * BS : 0.0f;
const f32 rz = cloud_size / 2;
bool soft_clouds_enabled = g_settings->getBool("soft_clouds");
v3f pos(p0.X, m_params.height * BS, p0.Y);
video::S3DVertex v[4] = { video::S3DVertex v[4] = {
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1), video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1),
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1), video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1),
@ -206,6 +201,12 @@ void Clouds::updateMesh()
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 0) video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 0)
}; };
const f32 rx = cloud_size / 2.0f;
// if clouds are flat, the top layer should be at the given height
const f32 ry = is3D() ? m_params.thickness * BS : 0.0f;
const f32 rz = cloud_size / 2;
bool soft_clouds_enabled = g_settings->getBool("soft_clouds");
for (u32 i = 0; i < num_faces_to_draw; i++) for (u32 i = 0; i < num_faces_to_draw; i++)
{ {
switch (i) switch (i)
@ -327,6 +328,8 @@ void Clouds::updateMesh()
break; break;
} }
v3f pos(p0.X, m_params.height * BS, p0.Y);
for (video::S3DVertex& vertex : v) { for (video::S3DVertex& vertex : v) {
vertex.Pos += pos; vertex.Pos += pos;
vertices.push_back(vertex); vertices.push_back(vertex);
@ -341,7 +344,8 @@ void Clouds::updateMesh()
if (mb->getIndexCount() > index_count) { if (mb->getIndexCount() > index_count) {
indices.resize(index_count); indices.resize(index_count);
mb->setDirty(scene::EBT_INDEX); mb->setDirty(scene::EBT_INDEX);
} else if (mb->getIndexCount() < index_count) { }
else if (mb->getIndexCount() < index_count) {
const u32 start = mb->getIndexCount() / 6; const u32 start = mb->getIndexCount() / 6;
assert(start * 6 == mb->getIndexCount()); assert(start * 6 == mb->getIndexCount());
for (u32 k = start; k < quad_count; k++) { for (u32 k = start; k < quad_count; k++) {