1
0
鏡像自 https://github.com/luanti-org/luanti.git 已同步 2025-11-01 15:55:26 +01:00

Fix distorted Sun, Moon and Star visuals based on Orbit Tilt (#15459)

此提交包含在:
veprogames
2024-12-06 22:00:06 +01:00
提交者 GitHub
父節點 5a8412dd23
當前提交 b857798848

查看文件

@@ -661,7 +661,9 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day)
return;
m_materials[0].ColorParam = color.toSColor();
auto sky_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f));
auto day_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f));
auto orbit_rotation = core::matrix4().setRotationAxisRadians(m_sky_params.body_orbit_tilt * M_PI / 180.0, v3f(1.0f, 0.0f, 0.0f));
auto sky_rotation = orbit_rotation * day_rotation;
auto world_matrix = driver->getTransform(video::ETS_WORLD);
driver->setTransform(video::ETS_WORLD, world_matrix * sky_rotation);
driver->setMaterial(m_materials[0]);
@@ -695,13 +697,11 @@ void Sky::place_sky_body(
* day_position: turn the body around the Z axis, to place it depending of the time of the day
*/
{
v3f centrum = getSkyBodyPosition(horizon_position, day_position, m_sky_params.body_orbit_tilt);
v3f untilted_centrum = getSkyBodyPosition(horizon_position, day_position, 0.f);
for (video::S3DVertex &vertex : vertices) {
// Body is directed to -Z (south) by default
vertex.Pos.rotateXZBy(horizon_position);
vertex.Pos.rotateXYBy(day_position);
vertex.Pos += centrum - untilted_centrum;
vertex.Pos.rotateYZBy(m_sky_params.body_orbit_tilt);
}
}