adspartan : noggit: ui: settings: unify render distance and far z settings

aedf0f1bd3
noggit: ui: settings: add fov
5fb49d7242
This commit is contained in:
T1ti
2024-09-01 03:36:01 +02:00
parent f9007a2b08
commit 2e0e840a91
10 changed files with 38 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
#include <glm/gtx/quaternion.hpp>
#include <noggit/Camera.hpp>
#include <QSettings>
namespace Noggit
{
@@ -17,6 +18,9 @@ namespace Noggit
//! \note ensure ranges
yaw (yaw_);
pitch (pitch_);
QSettings settings;
_fov = math::degrees(settings.value("fov", 54.f).toFloat());
}
math::degrees Camera::yaw() const
@@ -64,6 +68,13 @@ namespace Noggit
return _fov;
}
math::degrees Camera::fov(math::degrees value)
{
_fov = math::degrees(std::max(10.f, std::min(90.f, value._)));
return _fov;
}
glm::vec3 Camera::look_at() const
{
return position + direction();

View File

@@ -24,6 +24,7 @@ namespace Noggit
void add_to_pitch (math::degrees);
math::radians fov() const;
math::degrees fov(math::degrees);
glm::vec3 look_at() const;
glm::vec3 direction() const;

View File

@@ -59,6 +59,8 @@ inline constexpr float UNITSIZE = (CHUNKSIZE / 8.0f);
inline constexpr float MINICHUNKSIZE = (CHUNKSIZE / 4.0f);
inline constexpr float TEXDETAILSIZE = (CHUNKSIZE / 64.0f);
inline constexpr float ZEROPOINT = (32.0f * (TILESIZE));
static constexpr double TILE_RADIUS = 754.24723326565069269423398624517; //sqrt(2 * (533.33333)^2)
inline constexpr double MAPCHUNK_RADIUS = 47.140452079103168293389624140323; //sqrt((533.33333/16)^2 + (533.33333/16)^2)
struct MHDR

View File

@@ -433,7 +433,7 @@ void MapTile::convert_alphamap(bool to_big_alpha)
}
bool MapTile::intersect (math::ray const& ray, selection_result* results) const
bool MapTile::intersect (math::ray const& ray, selection_result* results)
{
if (!finished)
{

View File

@@ -4896,7 +4896,7 @@ glm::mat4x4 MapView::model_view(bool use_debug_cam) const
glm::mat4x4 MapView::projection() const
{
float far_z = _settings->value("farZ", 2048).toFloat();
float far_z = _settings->value("view_distance", 2000.f).toFloat() + 1.f;
if (_display_mode == display_mode::in_2D)
{
@@ -6072,12 +6072,15 @@ void MapView::onSettingsSave()
_world->renderer()->markTerrainParamsUniformBlockDirty();
_world->renderer()->setViewDistance(_settings->value("view_distance", 1000.f).toFloat());
_world->renderer()->setViewDistance(_settings->value("view_distance", 2000.f).toFloat());
_world.get()->mapIndex.setLoadingRadius(_settings->value("loading_radius", 2).toInt());
_world.get()->mapIndex.setUnloadDistance(_settings->value("unload_dist", 5).toInt());
_world.get()->mapIndex.setUnloadInterval(_settings->value("unload_interval", 30).toInt());
_camera.fov(math::degrees(_settings->value("fov", 54.f).toFloat()));
_debug_cam.fov(math::degrees(_settings->value("fov", 54.f).toFloat()));
}
void MapView::ShowContextMenu(QPoint pos)

View File

@@ -18,7 +18,7 @@ WorldRender::WorldRender(World* world)
: BaseRender()
, _world(world)
, _liquid_texture_manager(world->_context)
, _view_distance(world->_settings->value("view_distance", 1000.f).toFloat())
, _view_distance(world->_settings->value("view_distance", 2000.f).toFloat()) // + TILE_RADIUS) // add adt radius to make sure tiles aren't culled too soon, todo: improve adt culling to prevent that from happening
, _cull_distance(0.f)
{
}

View File

@@ -133,7 +133,7 @@ glm::mat4x4 ModelViewer::world_model_view() const
glm::mat4x4 ModelViewer::world_projection() const
{
float far_z = _settings->value("farZ", 2048).toFloat();
float far_z = _settings->value("view_distance", 2000.f).toFloat();
return glm::perspective(_camera.fov()._, aspect_ratio(), 1.f, far_z);
}

View File

@@ -371,7 +371,7 @@ glm::mat4x4 PreviewRenderer::model_view() const
glm::mat4x4 PreviewRenderer::projection() const
{
float far_z = _settings->value("farZ", 2048).toFloat();
float far_z = _settings->value("view_distance", 2000.f).toFloat();
return glm::perspective(_camera.fov()._, aspect_ratio(), 1.f, far_z);
}

View File

@@ -197,8 +197,8 @@ namespace Noggit
{
ui->importPathField->setText(_settings->value("project/import_file", "import.txt").toString());
ui->wmvLogPathField->setText(_settings->value("project/wmv_log_file").toString());
ui->viewDistanceField->setValue(_settings->value("view_distance", 1000.f).toFloat());
ui->farZField->setValue(_settings->value("farZ", 2048.f).toFloat());
ui->_view_distance->setValue(_settings->value("view_distance", 2000.f).toFloat());
ui->_fov->setValue(_settings->value("fov", 54.f).toFloat());
ui->_undock_tool_properties->setChecked(
_settings->value("undock_tool_properties/enabled", true).toBool());
ui->_undock_small_texture_palette->setChecked(
@@ -286,8 +286,8 @@ namespace Noggit
{
_settings->setValue("project/import_file", ui->importPathField->text());
_settings->setValue("project/wmv_log_file", ui->wmvLogPathField->text());
_settings->setValue("farZ", ui->farZField->value());
_settings->setValue("view_distance", ui->viewDistanceField->value());
_settings->setValue("view_distance", ui->_view_distance->value());
_settings->setValue("fov", ui->_fov->value());
_settings->setValue("undock_tool_properties/enabled", ui->_undock_tool_properties->isChecked());
_settings->setValue("undock_small_texture_palette/enabled",
ui->_undock_small_texture_palette->isChecked());

View File

@@ -344,10 +344,13 @@
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="viewDistanceField">
<widget class="QDoubleSpinBox" name="_view_distance">
<property name="maximum">
<double>1048576.000000000000000</double>
</property>
<property name="singleStep">
<double>100.000000000000000</double>
</property>
<property name="value">
<double>2000.000000000000000</double>
</property>
@@ -360,7 +363,7 @@
<item>
<widget class="QLabel" name="label_36">
<property name="text">
<string>FarZ</string>
<string>Field Of View (FOV)</string>
</property>
</widget>
</item>
@@ -378,12 +381,15 @@
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="farZField">
<widget class="QDoubleSpinBox" name="_fov">
<property name="minimum">
<double>10.000000000000000</double>
</property>
<property name="maximum">
<double>1048576.000000000000000</double>
<double>90.000000000000000</double>
</property>
<property name="value">
<double>2048.000000000000000</double>
<double>54.000000000000000</double>
</property>
</widget>
</item>