Minor - Improves engine settings and sky sphere - V14.3.0
Refactors the Engine Settings window into a tabbed interface, enhancing usability. Updates the sky sphere implementation to use a configurable distance. Adjusts ImGui layout for better docking and window arrangement.
This commit is contained in:
@@ -451,7 +451,22 @@ public:
|
||||
*/
|
||||
std::map<std::string, std::shared_ptr<model_class>>& get_model_cache() { return g_model_cache; }
|
||||
|
||||
/**
|
||||
* Get the sky entity ID.
|
||||
* @return The sky entity ID as an integer.
|
||||
*/
|
||||
int get_sky_id() const { return sky_id_; }
|
||||
|
||||
/**
|
||||
* Set the sky entity size.
|
||||
* @return The sky entity size as a float.
|
||||
*/
|
||||
XMVECTOR get_sky_distance() const { return sky_distance_; };
|
||||
/**
|
||||
* Set the sky entity size.
|
||||
* @param distance The new sky entity size as a float.
|
||||
*/
|
||||
void set_sky_distance(XMVECTOR distance);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -594,9 +609,10 @@ private :
|
||||
float speed_ = 0.1f; // speed for the demo spinning object
|
||||
std::vector<object*> imported_object_;
|
||||
int object_id_ = 0;
|
||||
//std::vector<object*> skybox_;
|
||||
|
||||
int sky_id_ = -1;
|
||||
std::shared_ptr<ecs::Entity> sky_entity_;
|
||||
XMVECTOR sky_distance_ = XMVectorSet(2.0f, 2.0f, 2.0f, 0.0f);
|
||||
|
||||
// ----------------------------------- //
|
||||
// ------------- LIGHTS -------------- //
|
||||
|
||||
@@ -2110,7 +2110,7 @@ bool application_class::create_skysphere()
|
||||
|
||||
auto transform = sky_entity_->AddComponent<ecs::TransformComponent>();
|
||||
transform->SetPosition(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
transform->SetScale(XMVectorSet(2.0f, 2.0f, 2.0f, 0.0f));
|
||||
transform->SetScale(sky_distance_);
|
||||
transform->UpdateWorldMatrix();
|
||||
|
||||
auto render = sky_entity_->AddComponent<ecs::RenderComponent>();
|
||||
|
||||
@@ -762,16 +762,6 @@ bool imguiManager::ImGuiWidgetRenderer()
|
||||
SetupDockspace();
|
||||
|
||||
//ImGui Widget
|
||||
ImGui::Begin("Khaotic Engine", NULL);
|
||||
|
||||
float speed = app_->get_speed();
|
||||
|
||||
WidgetSpeedSlider(&speed);
|
||||
app_->set_speed(speed);
|
||||
WidgetButton();
|
||||
WidgetAddObject();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Read the widget list and call the function if the show variable is true
|
||||
for (const auto& entry : widgets_)
|
||||
@@ -854,47 +844,72 @@ void imguiManager::WidgetEngineSettingsWindow()
|
||||
{
|
||||
ImGui::Begin("Engine Settings", &showEngineSettingsWindow);
|
||||
|
||||
// Begining Of General Setting
|
||||
ImGui::Text("General");
|
||||
|
||||
// Checkbox for toggling vsync globally in the application class by calling the set_vsync function in the application class when the checkbox state changes
|
||||
bool vsync = app_->get_vsync();
|
||||
if (ImGui::Checkbox("Vsync", &vsync))
|
||||
if (ImGui::BeginTabBar("Engine Settings"))
|
||||
{
|
||||
app_->set_vsync(vsync);
|
||||
}
|
||||
if (ImGui::BeginTabItem("General"))
|
||||
{
|
||||
bool v_sync = app_->get_vsync();
|
||||
if (ImGui::Checkbox("Vsync", &v_sync))
|
||||
{
|
||||
app_->set_vsync(v_sync);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("Enable or disable Vsync");
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Culling Settings"))
|
||||
{
|
||||
float frustumTolerance = app_->get_frustum_tolerance();
|
||||
if (ImGui::DragFloat("Frustum Tolerance", &frustumTolerance, 0.1f, 0.0f, 100.0f))
|
||||
{
|
||||
app_->set_frustum_tolerance(frustumTolerance);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("Set the frustum tolerance for culling");
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// End Of General Setting
|
||||
ImGui::Separator();
|
||||
// culling section
|
||||
ImGui::Text("Culling");
|
||||
if (ImGui::BeginTabItem("Physics Settings"))
|
||||
{
|
||||
int physics_tick_rate = app_->get_physics_tick_rate();
|
||||
XMVECTOR gravity = app_->get_physics()->GetGravity();
|
||||
float gravity_values[3] = { XMVectorGetX(gravity), XMVectorGetY(gravity), XMVectorGetZ(gravity) };
|
||||
|
||||
if (ImGui::InputInt("Physics Tick Rate", &physics_tick_rate))
|
||||
{
|
||||
app_->set_physics_tick_rate(physics_tick_rate);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("Set the physics tick rate (Fixed Update Interval)");
|
||||
}
|
||||
|
||||
// float input for frustum tolerance
|
||||
float frustumTolerance = app_->get_frustum_tolerance();
|
||||
if (ImGui::DragFloat("Frustum Tolerance", &frustumTolerance, 0.1f, 0.0f, 100.0f))
|
||||
{
|
||||
app_->set_frustum_tolerance(frustumTolerance);
|
||||
}
|
||||
if (ImGui::DragFloat3("Gravity", gravity_values))
|
||||
{
|
||||
app_->get_physics()->SetGravity(XMVectorSet(gravity_values[0], gravity_values[1], gravity_values[2], 0.0f));
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("Set the gravity vector for the physics engine");
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// End Of Culling Setting
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTabItem("Skysphere Settings"))
|
||||
{
|
||||
|
||||
// physics section
|
||||
ImGui::Text("physics");
|
||||
|
||||
// Input To set the Fixed Update Interval
|
||||
int physicsInterval = app_->get_physics_tick_rate();
|
||||
if (ImGui::InputInt("physics Tick Rate", &physicsInterval))
|
||||
{
|
||||
app_->set_physics_tick_rate(physicsInterval);
|
||||
}
|
||||
|
||||
// Input to change the gravity on same line
|
||||
XMVECTOR gravity = app_->get_physics()->GetGravity();
|
||||
float gravityValues[3] = { XMVectorGetX(gravity), XMVectorGetY(gravity), XMVectorGetZ(gravity) };
|
||||
if (ImGui::DragFloat3("Gravity", gravityValues))
|
||||
{
|
||||
app_->get_physics()->SetGravity(XMVectorSet(gravityValues[0], gravityValues[1], gravityValues[2], 0.0f));
|
||||
//float skysphere_size = app_->get_sky()->
|
||||
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
Reference in New Issue
Block a user