Minor - Adds dynamic screen depth and near controls - V14.4.0

Implements dynamic adjustment of screen depth and near clipping plane distances via the ImGui interface.

This allows users to modify the perspective projection in real-time, affecting the rendering of the scene.

The changes involve:
- Adding screen depth and near variables to the application class.
- Exposing these variables in the ImGui settings window.
- Adding functions to the application and d3d classes to update the projection matrix based on new screen depth and near values.
- Updates the sky sphere size to use world scale.
This commit is contained in:
2025-10-01 16:03:11 +02:00
parent 284e282679
commit e4836174b4
9 changed files with 147 additions and 15 deletions

View File

@@ -61,8 +61,8 @@
// GLOBALS //
/////////////
constexpr bool full_screen = false;
constexpr float screen_depth = 1000.0f;
constexpr float screen_near = 0.3f;
// constexpr float screen_depth = 1000.0f;
// constexpr float screen_near = 0.3f;
static std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
@@ -457,16 +457,32 @@ public:
*/
int get_sky_id() const { return sky_id_; }
/**
* Set the sky entity size.
* @return The sky entity size as a float.
/** Get the Sky entity as a shared pointer.
* @return A shared pointer to the sky entity.
*/
XMVECTOR get_sky_distance() const { return sky_distance_; };
std::shared_ptr<ecs::Entity> get_sky_entity_shared_ptr() const { return sky_entity_; }
/**
* Set the sky entity size.
* @param distance The new sky entity size as a float.
* Update the screen depth.
*/
void set_sky_distance(XMVECTOR distance);
bool update_screen_depth(float new_screen_depth);
/**
* Update the screen near.
*/
bool update_screen_near(float new_screen_near);
/**
* Get the screen depth.
* @return The screen depth as a float.
*/
float get_screen_depth() const { return screen_depth; }
/**
* Get the screen near.
* @return The screen near as a float.
*/
float get_screen_near() const { return screen_near; }
private:
/**
@@ -581,6 +597,9 @@ private :
HWND hwnd_;
bool windowed_;
float screen_depth = 1000.0f;
float screen_near = 0.3f;
// ------------------------------------- //
// ------------- RENDERING ------------- //
// ------------------------------------- //
@@ -612,7 +631,6 @@ private :
int sky_id_ = -1;
std::shared_ptr<ecs::Entity> sky_entity_;
XMVECTOR sky_distance_ = XMVectorSet(2.0f, 2.0f, 2.0f, 0.0f);
// ----------------------------------- //
// ------------- LIGHTS -------------- //