mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Fix cloud-related bugs
First, this reverts 56123b2fbe
,
which un-fixes #15031 but fixes #15798 and #15854.
Then we disable culling for the cloud scene node which fixes #15031 again.
This commit is contained in:
parent
68602b2eaf
commit
358658fa34
2 changed files with 28 additions and 5 deletions
src/client
|
@ -52,6 +52,13 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
|
|||
|
||||
updateBox();
|
||||
|
||||
// Neither EAC_BOX (the default) nor EAC_FRUSTUM_BOX will correctly cull
|
||||
// the clouds.
|
||||
// And yes, the bounding box is correct. You can check using the #if 0'd
|
||||
// code in render() and see for yourself.
|
||||
// So I give up and let's disable culling.
|
||||
setAutomaticCulling(scene::EAC_OFF);
|
||||
|
||||
m_meshbuffer.reset(new scene::SMeshBuffer());
|
||||
m_meshbuffer->setHardwareMappingHint(scene::EHM_DYNAMIC);
|
||||
}
|
||||
|
@ -366,6 +373,19 @@ void Clouds::render()
|
|||
if (SceneManager->getSceneNodeRenderPass() != scene::ESNRP_TRANSPARENT)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
{
|
||||
video::SMaterial tmp;
|
||||
tmp.Thickness = 1.f;
|
||||
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||
driver->setMaterial(tmp);
|
||||
aabb3f tmpbox = m_box;
|
||||
tmpbox.MinEdge.X = tmpbox.MinEdge.Z = -1000 * BS;
|
||||
tmpbox.MaxEdge.X = tmpbox.MaxEdge.Z = 1000 * BS;
|
||||
driver->draw3DBox(tmpbox, video::SColor(255, 255, 0x4d, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
updateMesh();
|
||||
|
||||
// Update position
|
||||
|
@ -425,14 +445,14 @@ void Clouds::update(const v3f &camera_p, const video::SColorf &color_diffuse)
|
|||
|
||||
// is the camera inside the cloud mesh?
|
||||
m_camera_pos = camera_p;
|
||||
m_camera_inside_cloud = false; // default
|
||||
m_camera_inside_cloud = false;
|
||||
if (is3D()) {
|
||||
float camera_height = camera_p.Y - BS * m_camera_offset.Y;
|
||||
if (camera_height >= m_box.MinEdge.Y &&
|
||||
camera_height <= m_box.MaxEdge.Y) {
|
||||
v2f camera_in_noise;
|
||||
camera_in_noise.X = floor((camera_p.X - m_origin.X) / cloud_size + 0.5);
|
||||
camera_in_noise.Y = floor((camera_p.Z - m_origin.Y) / cloud_size + 0.5);
|
||||
camera_in_noise.X = floorf((camera_p.X - m_origin.X) / cloud_size + 0.5f);
|
||||
camera_in_noise.Y = floorf((camera_p.Z - m_origin.Y) / cloud_size + 0.5f);
|
||||
bool filled = gridFilled(camera_in_noise.X, camera_in_noise.Y);
|
||||
m_camera_inside_cloud = filled;
|
||||
}
|
||||
|
|
|
@ -134,8 +134,11 @@ private:
|
|||
{
|
||||
float height_bs = m_params.height * BS;
|
||||
float thickness_bs = m_params.thickness * BS;
|
||||
m_box = aabb3f(-BS * 1000000.0f, height_bs, -BS * 1000000.0f,
|
||||
BS * 1000000.0f, height_bs + thickness_bs, BS * 1000000.0f);
|
||||
float far_bs = 1000000.0f * BS;
|
||||
m_box = aabb3f(-far_bs, height_bs, -far_bs,
|
||||
far_bs, height_bs + thickness_bs, far_bs);
|
||||
m_box.MinEdge -= v3f::from(m_camera_offset) * BS;
|
||||
m_box.MaxEdge -= v3f::from(m_camera_offset) * BS;
|
||||
}
|
||||
|
||||
void updateMesh();
|
||||
|
|
Loading…
Add table
Reference in a new issue