Skip to content

Commit

Permalink
Implemented some base support for large worlds (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkTreasure1 authored Dec 15, 2023
2 parents e81a60b + 918e2eb commit 3c81ff7
Show file tree
Hide file tree
Showing 72 changed files with 1,373 additions and 180 deletions.
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Capsule.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 7368991460119830626
assetHandle: 6283149130508796929
filePath: Engine/Meshes/Primitives/SM_Capsule.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
4 changes: 2 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Capsule.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Capsule.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 18411356710391823355
assetHandle: 10117410387453422377
filePath: Engine/Meshes/Primitives/SM_Capsule.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cone.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 5244042238809914408
assetHandle: 4608470111307946929
filePath: Engine/Meshes/Primitives/SM_Cone.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
2 changes: 1 addition & 1 deletion Engine/Engine/Meshes/Primitives/SM_Cone.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cone.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 10242065537839545921
assetHandle: 6968151257201624914
filePath: Engine/Meshes/Primitives/SM_Cone.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
4 changes: 2 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cube.fbx
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cube.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 6184134929358402430
assetHandle: 16422502198230809186
filePath: Engine/Meshes/Primitives/SM_Cube.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
2 changes: 1 addition & 1 deletion Engine/Engine/Meshes/Primitives/SM_Cube.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cube.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 10149696181569838305
assetHandle: 7235711071482003307
filePath: Engine/Meshes/Primitives/SM_Cube.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cylinder.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 9963684909373996543
assetHandle: 6095984363745051238
filePath: Engine/Meshes/Primitives/SM_Cylinder.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
4 changes: 2 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cylinder.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Cylinder.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 2900881217054044389
assetHandle: 9258625515238793615
filePath: Engine/Meshes/Primitives/SM_Cylinder.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Plane.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 13661243206498577773
assetHandle: 15731543908010069181
filePath: Engine/Meshes/Primitives/SM_Plane.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
2 changes: 1 addition & 1 deletion Engine/Engine/Meshes/Primitives/SM_Plane.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Plane.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 3087037750680072373
assetHandle: 7102265901469832403
filePath: Engine/Meshes/Primitives/SM_Plane.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Sphere.fbx.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 16599656187294192819
assetHandle: 11824673864998436943
filePath: Engine/Meshes/Primitives/SM_Sphere.fbx
type: 2
Dependencies:
[]
[]
Properties:
{}
4 changes: 2 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Sphere.vtmesh
Git LFS file not shown
6 changes: 4 additions & 2 deletions Engine/Engine/Meshes/Primitives/SM_Sphere.vtmesh.vtmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Metadata:
assetHandle: 12441354821563457429
assetHandle: 11830290587447924398
filePath: Engine/Meshes/Primitives/SM_Sphere.vtmesh
type: 1
Dependencies:
[]
[]
Properties:
{}
6 changes: 3 additions & 3 deletions Engine/Engine/Shaders/Source/HLSL/Editor/Grid_ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ float4 Grid(float3 position, float scale)
float4 color = float4(0.2f, 0.2f, 0.2f, 1.f - min(lin, 1.f));

// Z axis
if (position.x > -100.f * minX && position.x < 100.f * minX)
if (position.x > -1.f * minX && position.x < 1.f * minX)
{
color.z = 1.f;
}

// X axis
if (position.z > -100.f * minZ && position.z < 100.f * minZ)
if (position.z > -1.f * minZ && position.z < 1.f * minZ)
{
color.x = 1.f;
}
Expand Down Expand Up @@ -66,7 +66,7 @@ Output main(Input input)
const float fading = max(0.f, (0.5f - linearDepth));

Output output;
output.color = Grid(position, 0.01f) * float(t > 0);
output.color = Grid(position, 1.f) * float(t > 0);
output.color.a *= fading;
output.depth = ComputeDepth(position);

Expand Down
4 changes: 2 additions & 2 deletions Engine/Launcher.exe
Git LFS file not shown
4 changes: 2 additions & 2 deletions Engine/Sandbox.exe
Git LFS file not shown
4 changes: 2 additions & 2 deletions Engine/Scripts/Volt-ScriptCore.dll
Git LFS file not shown
4 changes: 2 additions & 2 deletions Engine/Scripts/Volt-ScriptCore.pdb
Git LFS file not shown
6 changes: 4 additions & 2 deletions Volt/Sandbox/src/Sandbox/Camera/EditorCameraController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EditorCameraController::EditorCameraController(float fov, float nearPlane, float farPlane)
: m_fov(fov), m_nearPlane(nearPlane), m_farPlane(farPlane)
{
const glm::vec3 startPosition = { 500.f, 500.f, 500.f };
const glm::vec3 startPosition = { 5.f, 5.f, 5.f };
m_focalDistance = glm::distance(startPosition, m_focalPoint);
m_rotation = { 45.f, 135.f, 0.f };
m_position = startPosition;
Expand Down Expand Up @@ -111,10 +111,12 @@ void EditorCameraController::ArcBall(const glm::vec2& deltaPos)

void EditorCameraController::ArcZoom(float deltaPos)
{
constexpr float MAX_SPEED = 0.1f;

float distance = m_focalDistance * 0.2f;
distance = glm::max(distance, 0.0f);
float speed = distance * distance;
speed = glm::min(speed, 10.f); // max speed = 50
speed = glm::min(speed, MAX_SPEED); // max speed = 50

m_focalDistance -= deltaPos * speed;
m_position = m_focalPoint - m_camera->GetForward() * m_focalDistance;
Expand Down
16 changes: 8 additions & 8 deletions Volt/Sandbox/src/Sandbox/Camera/EditorCameraController.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ class EditorCameraController
float m_yawDelta = 0.f;

glm::vec3 m_focalPoint = { 0.f, 0.f, 0.f };
float m_focalDistance = 100.f;
float m_minFocalDistance = 10000.f;
float m_focalDistance = 1.f;
float m_minFocalDistance = 100.f;

float m_fov = 45.f;
float m_nearPlane = 0.1f;
float m_farPlane = 10000.f;
float m_nearPlane = 0.01f;
float m_farPlane = 1000.f;

float m_translationSpeed = 100.f;
float m_scrollTranslationSpeed = 100.f;
float m_translationSpeed = 5.f;

float m_maxTranslationSpeed = 100000.f;
float m_sensitivity = 0.12f;
const float m_scrollTranslationSpeed = 1.f;
const float m_maxTranslationSpeed = 40.f;
const float m_sensitivity = 0.12f;

bool m_isControllable = false;
bool m_isViewportHovered = false;
Expand Down
12 changes: 6 additions & 6 deletions Volt/Sandbox/src/Sandbox/DebugRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)

glm::vec3 p = entity.GetPosition();

const float maxDist = 5000.f * 5000.f;
const float lerpStartDist = 4000.f * 4000.f;
const float maxDist = 50.f * 50.f;
const float lerpStartDist = 40.f * 40.f;
const float maxScale = 1.f;
const float minScale = 0.3f;
const float distance = glm::distance2(camera->GetPosition(), p);
Expand Down Expand Up @@ -124,8 +124,8 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)

glm::vec3 p = entity.GetPosition();

const float maxDist = 5000.f;
const float lerpStartDist = 4000.f;
const float maxDist = 50.f;
const float lerpStartDist = 40.f;
const float maxScale = 1.f;
const float distance = glm::distance(camera->GetPosition(), p);

Expand Down Expand Up @@ -154,8 +154,8 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)

glm::vec3 p = entity.GetPosition();

const float maxDist = 5000.f;
const float lerpStartDist = 4000.f;
const float maxDist = 50.f;
const float lerpStartDist = 40.f;
const float maxScale = 1.f;
const float distance = glm::distance(camera->GetPosition(), p);

Expand Down
58 changes: 58 additions & 0 deletions Volt/Sandbox/src/Sandbox/Modals/ConvertToWorldEngineModal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "sbpch.h"
#include "ConvertToWorldEngineModal.h"

#include <Volt/Asset/AssetManager.h>
#include <Volt/Scene/Scene.h>

#include <Volt/Utility/FileSystem.h>

#include <imgui.h>

ConvertToWorldEngineModal::ConvertToWorldEngineModal(const std::string& stringId)
: Modal(stringId)
{
}

ConvertToWorldEngineModal::~ConvertToWorldEngineModal()
{
}

void ConvertToWorldEngineModal::DrawModalContent()
{
ImGui::Text("Are you sure you want to convert to WorldEngine?");

ImGui::SameLine();

if (ImGui::Button("Convert"))
{
m_scene->GetSceneSettingsMutable().useWorldEngine = true;

const auto& metadata = Volt::AssetManager::GetMetadataFromHandle(m_scene->handle);
if (metadata.IsValid())
{
const std::filesystem::path directoryPath = Volt::AssetManager::GetFilesystemPath(metadata.filePath);
const std::filesystem::path layersPath = directoryPath / "Layers";

if (std::filesystem::exists(directoryPath) && std::filesystem::exists(layersPath))
{
FileSystem::MoveToRecycleBin(layersPath);
}
}

Volt::AssetManager::SaveAsset(m_scene.GetSharedPtr());
Close();
}

ImGui::SameLine();

if (ImGui::Button("Cancel"))
{
m_scene->GetSceneSettingsMutable().useWorldEngine = false;
Close();
}
}

void ConvertToWorldEngineModal::OnClose()
{
m_scene.Reset();
}
Loading

0 comments on commit 3c81ff7

Please sign in to comment.