Skip to content

Commit 6803811

Browse files
The engine now compiles and starts up
1 parent c294cc3 commit 6803811

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1457
-1584
lines changed

Engine/Scripts/Volt-ScriptCore.dll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:979f1d35c912936bd1a0c43327e04226f8908f4416b822f6ae12db2e73e55dcf
2+
oid sha256:627d95fa21447cab034cdb06a21c02f4fbd39739d1181077223662fb629accd9
33
size 101888

Volt/GraphKey/src/GraphKey/Nodes/CustomEventNode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace GraphKey
88
inputs =
99
{
1010
AttributeConfig("", AttributeDirection::Input, GK_BIND_FUNCTION(CallCustomEventNode::CallEvent)),
11-
AttributeConfigDefault<Volt::Entity>("Target", AttributeDirection::Input, Volt::Entity{ entt::null, {} })
11+
AttributeConfigDefault<Volt::Entity>("Target", AttributeDirection::Input, Volt::Entity::Null())
1212
};
1313

1414
outputs =

Volt/GraphKey/src/GraphKey/Nodes/Entity/TransformNodes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace GraphKey
99
{
1010
inputs =
1111
{
12-
AttributeConfigDefault<Volt::Entity>("Entity", AttributeDirection::Input, Volt::Entity{ entt::null, {} })
12+
AttributeConfigDefault<Volt::Entity>("Entity", AttributeDirection::Input, Volt::Entity::Null())
1313
};
1414

1515
outputs =

Volt/Sandbox/src/Sandbox/DebugRendering.cpp

+44-57
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <Volt/Rendering/DebugRenderer.h>
2121
#include <Volt/Rendering/SceneRenderer.h>
22+
#include <Volt/Rendering/Camera/Camera.h>
2223

2324
#include <NavigationEditor/Tools/NavMeshDebugDrawer.h>
2425
#include <NavigationEditor/Builder/RecastBuilder.h>
@@ -27,30 +28,30 @@ void Sandbox::RenderSelection(Ref<Volt::Camera> camera)
2728
{
2829
VT_PROFILE_FUNCTION();
2930

30-
auto& registry = myRuntimeScene->GetRegistry();
31-
32-
for (const auto& ent : SelectionManager::GetSelectedEntities())
31+
for (const auto& id : SelectionManager::GetSelectedEntities())
3332
{
34-
if (!registry.HasComponent<Volt::TransformComponent>(ent))
33+
Volt::Entity entity{ id, myRuntimeScene };
34+
35+
if (!entity.HasComponent<Volt::TransformComponent>())
3536
{
3637
continue;
3738
}
3839

39-
auto& transComp = registry.GetComponent<Volt::TransformComponent>(ent);
40+
auto& transComp = entity.GetComponent<Volt::TransformComponent>();
4041

41-
if (!transComp.visible || !registry.HasComponent<Volt::MeshComponent>(ent))
42+
if (!transComp.visible || !entity.HasComponent<Volt::MeshComponent>())
4243
{
4344
continue;
4445
}
4546

46-
auto& meshComp = registry.GetComponent<Volt::MeshComponent>(ent);
47+
auto& meshComp = entity.GetComponent<Volt::MeshComponent>();
4748
auto mesh = Volt::AssetManager::GetAsset<Volt::Mesh>(meshComp.handle);
4849
if (!mesh || !mesh->IsValid())
4950
{
5051
continue;
5152
}
5253

53-
mySceneRenderer->SubmitOutlineMesh(mesh, myRuntimeScene->GetWorldSpaceTransform(Volt::Entity{ent, myRuntimeScene.get()}));
54+
mySceneRenderer->SubmitOutlineMesh(mesh, entity.GetTransform());
5455
}
5556
}
5657

@@ -65,15 +66,15 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
6566
return;
6667
}
6768

68-
auto& registry = scene->GetRegistry();
69-
7069
Sandbox::Get().GetSceneRenderer()->SetHideStaticMeshes(settings.colliderViewMode == ColliderViewMode::AllHideMesh || settings.navMeshViewMode == NavMeshViewMode::Only);
7170

7271
if (settings.showEntityGizmos)
7372
{
74-
registry.ForEach<Volt::TransformComponent>([&](entt::entity id, const Volt::TransformComponent& transformComp)
73+
myRuntimeScene->ForEachWithComponents<const Volt::TransformComponent>([&](entt::entity id, const Volt::TransformComponent& transformComp)
7574
{
76-
if (registry.HasComponent<Volt::CameraComponent>(id) || registry.HasComponent<Volt::PointLightComponent>(id) || registry.HasComponent<Volt::SpotLightComponent>(id))
75+
Volt::Entity entity{ id, myRuntimeScene };
76+
77+
if (entity.HasComponent<Volt::CameraComponent>() || entity.HasComponent<Volt::PointLightComponent>() || entity.HasComponent<Volt::SpotLightComponent>())
7778
{
7879
return;
7980
}
@@ -83,8 +84,6 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
8384
return;
8485
}
8586

86-
Volt::Entity entity{ id, myRuntimeScene.get() };
87-
8887
glm::vec3 p = entity.GetPosition();
8988

9089
const float maxDist = 5000.f * 5000.f;
@@ -103,14 +102,14 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
103102
if (distance < maxDist)
104103
{
105104
float scale = glm::max(glm::min(distance / maxDist * 2.f, maxScale), minScale);
106-
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::EntityGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, id);
105+
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::EntityGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID());
107106
}
108107
});
109108
}
110109

111110
if (settings.showEntityGizmos || settings.showLightSpheres)
112111
{
113-
registry.ForEach<Volt::PointLightComponent, Volt::TransformComponent>([&](entt::entity id, const Volt::PointLightComponent& lightComp, const Volt::TransformComponent& transformComp)
112+
myRuntimeScene->ForEachWithComponents<const Volt::PointLightComponent, const Volt::TransformComponent>([&](entt::entity id, const Volt::PointLightComponent& lightComp, const Volt::TransformComponent& transformComp)
114113
{
115114
if (!transformComp.visible)
116115
{
@@ -136,11 +135,11 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
136135
if (distance < maxDist)
137136
{
138137
float scale = glm::min(distance / maxDist, maxScale);
139-
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, id);
138+
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID());
140139
}
141140
});
142141

143-
registry.ForEach<Volt::SpotLightComponent, Volt::TransformComponent>([&](entt::entity id, const Volt::SpotLightComponent& lightComp, const Volt::TransformComponent& transformComp)
142+
myRuntimeScene->ForEachWithComponents<const Volt::SpotLightComponent, const Volt::TransformComponent>([&](entt::entity id, const Volt::SpotLightComponent& lightComp, const Volt::TransformComponent& transformComp)
144143
{
145144
if (!transformComp.visible)
146145
{
@@ -166,13 +165,13 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
166165
if (distance < maxDist)
167166
{
168167
float scale = glm::min(distance / maxDist, maxScale);
169-
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, id);
168+
Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID());
170169
}
171170
});
172171

173172
if (settings.showLightSpheres)
174173
{
175-
registry.ForEach<Volt::PointLightComponent>([&](entt::entity id, const Volt::PointLightComponent& comp)
174+
myRuntimeScene->ForEachWithComponents<const Volt::PointLightComponent>([&](entt::entity id, const Volt::PointLightComponent& comp)
176175
{
177176
Volt::Entity entity{ id, myRuntimeScene.get() };
178177
Volt::DebugRenderer::DrawLineSphere(entity.GetPosition(), comp.radius);
@@ -182,7 +181,7 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
182181
///// Sphere Bounds Visualization /////
183182
if (settings.showBoundingSpheres)
184183
{
185-
registry.ForEach<Volt::MeshComponent>([&](entt::entity id, const Volt::MeshComponent& comp)
184+
myRuntimeScene->ForEachWithComponents<const Volt::MeshComponent>([&](entt::entity id, const Volt::MeshComponent& comp)
186185
{
187186
if (comp.handle == Volt::Asset::Null())
188187
{
@@ -198,7 +197,7 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
198197
Volt::Entity entity{ id, myRuntimeScene.get() };
199198

200199
const auto& boundingSphere = mesh->GetBoundingSphere();
201-
const auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
200+
const auto transform = entity.GetTransform();
202201

203202
const glm::vec3 globalScale = { glm::length(transform[0]), glm::length(transform[1]), glm::length(transform[2]) };
204203
const float maxScale = std::max(std::max(globalScale.x, globalScale.y), globalScale.z);
@@ -226,20 +225,17 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
226225
// Draw NavLinks
227226
{
228227
std::vector<Volt::AI::NavLinkConnection> links;
229-
auto entitiesWithNavLink = myRuntimeScene->GetRegistry().GetComponentView<Volt::NavLinkComponent>();
230-
231-
for (auto ent : entitiesWithNavLink)
228+
myRuntimeScene->ForEachWithComponents<const Volt::NavLinkComponent>([&](const entt::entity id, const Volt::NavLinkComponent& comp)
232229
{
230+
Volt::Entity entity{ id, myRuntimeScene.get() };
233231
Volt::AI::NavLinkConnection link;
234-
auto& transformComp = myRuntimeScene->GetRegistry().GetComponent<Volt::TransformComponent>(ent);
235-
auto& linkComp = myRuntimeScene->GetRegistry().GetComponent<Volt::NavLinkComponent>(ent);
236232

237-
link.start = transformComp.position + linkComp.start;
238-
link.end = transformComp.position + linkComp.end;
239-
link.bidirectional = linkComp.bidirectional;
233+
link.start = entity.GetPosition() + comp.start;
234+
link.end = entity.GetPosition() + comp.end;
235+
link.bidirectional = comp.bidirectional;
240236

241237
links.emplace_back(link);
242-
}
238+
});
243239

244240
NavMeshDebugDrawer::DrawLinks(links);
245241
}
@@ -250,9 +246,11 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
250246
///////////////////////////////////////
251247

252248
///// Camera Gizmo /////
253-
registry.ForEach<Volt::CameraComponent, Volt::TransformComponent>([&](entt::entity id, const Volt::CameraComponent& cameraComponent, const Volt::TransformComponent& transComp)
249+
myRuntimeScene->ForEachWithComponents<Volt::CameraComponent>([&](entt::entity id, const Volt::CameraComponent& cameraComponent)
254250
{
255-
if (!transComp.visible)
251+
Volt::Entity entity{ id, myRuntimeScene.get() };
252+
253+
if (!entity.IsVisible())
256254
{
257255
return;
258256
}
@@ -265,8 +263,7 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
265263
return;
266264
}
267265

268-
const auto transform = myRuntimeScene->GetWorldSpaceTransform(Volt::Entity{ id, myRuntimeScene.get() });
269-
Volt::DebugRenderer::DrawMesh(cameraMesh, material, transform);
266+
Volt::DebugRenderer::DrawMesh(cameraMesh, material, entity.GetTransform());
270267

271268
// Frustums
272269
{
@@ -288,43 +285,39 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
288285
case ColliderViewMode::All:
289286
{
290287
auto collisionMaterial = Volt::AssetManager::GetAsset<Volt::Material>("Editor/Materials/M_ColliderDebug.vtmat");
291-
registry.ForEach<Volt::BoxColliderComponent>([&](entt::entity id, const Volt::BoxColliderComponent& collider)
288+
myRuntimeScene->ForEachWithComponents<const Volt::BoxColliderComponent>([&](entt::entity id, const Volt::BoxColliderComponent& collider)
292289
{
293290
Volt::Entity entity{ id, myRuntimeScene.get() };
294-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
295291

296292
auto cubeMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Cube.vtmesh");
297293

298294
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), collider.halfSize * 2.f * 0.01f);
299-
Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, transform * colliderTransform, id);
295+
Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
300296
});
301297

302-
registry.ForEach<Volt::SphereColliderComponent>([&](entt::entity id, const Volt::SphereColliderComponent& collider)
298+
myRuntimeScene->ForEachWithComponents<const Volt::SphereColliderComponent>([&](entt::entity id, const Volt::SphereColliderComponent& collider)
303299
{
304300
Volt::Entity entity{ id, myRuntimeScene.get() };
305-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
306301

307302
auto sphereMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Sphere.vtmesh");
308303

309304
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f });
310-
Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, transform * colliderTransform, id);
305+
Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
311306
});
312307

313-
registry.ForEach<Volt::CapsuleColliderComponent>([&](entt::entity id, const Volt::CapsuleColliderComponent& collider)
308+
myRuntimeScene->ForEachWithComponents<const Volt::CapsuleColliderComponent>([&](entt::entity id, const Volt::CapsuleColliderComponent& collider)
314309
{
315310
Volt::Entity entity{ id, myRuntimeScene.get() };
316-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
317311

318312
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f, collider.height * 0.01f, collider.radius * 2.f * 0.01f });
319313
auto capsuleMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Capsule.vtmesh");
320314

321-
Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, transform * colliderTransform, id);
315+
Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
322316
});
323317

324-
registry.ForEach<Volt::MeshColliderComponent>([&](entt::entity id, const Volt::MeshColliderComponent& collider)
318+
myRuntimeScene->ForEachWithComponents<const Volt::MeshColliderComponent>([&](entt::entity id, const Volt::MeshColliderComponent& collider)
325319
{
326320
Volt::Entity entity{ id, myRuntimeScene.get() };
327-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
328321

329322
Ref<Volt::Mesh> debugMesh;
330323

@@ -335,7 +328,7 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
335328
return;
336329
}
337330

338-
Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, transform, id);
331+
Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetUIntID());
339332
});
340333

341334
break;
@@ -352,40 +345,34 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
352345
if (entity.HasComponent<Volt::BoxColliderComponent>())
353346
{
354347
const auto& collider = entity.GetComponent<Volt::BoxColliderComponent>();
355-
356-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
357348
auto cubeMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Cube.vtmesh");
358349

359350
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), collider.halfSize * 2.f * 0.01f);
360-
Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, transform * colliderTransform, id);
351+
Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
361352
}
362353

363354
if (entity.HasComponent<Volt::SphereColliderComponent>())
364355
{
365356
const auto& collider = entity.GetComponent<Volt::SphereColliderComponent>();
366-
367-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
368357
auto sphereMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Sphere.vtmesh");
369358

370359
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f });
371-
Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, transform * colliderTransform, id);
360+
Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
372361
}
373362

374363
if (entity.HasComponent<Volt::CapsuleColliderComponent>())
375364
{
376365
const auto& collider = entity.GetComponent<Volt::CapsuleColliderComponent>();
377-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
378366

379367
const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f, collider.height * 0.01f, collider.radius * 2.f * 0.01f });
380368
auto capsuleMesh = Volt::AssetManager::GetAsset<Volt::Mesh>("Engine/Meshes/Primitives/SM_Capsule.vtmesh");
381369

382-
Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, transform * colliderTransform, id);
370+
Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID());
383371
}
384372

385373
if (entity.HasComponent<Volt::MeshColliderComponent>())
386374
{
387375
const auto& collider = entity.GetComponent<Volt::MeshColliderComponent>();
388-
auto transform = myRuntimeScene->GetWorldSpaceTransform(entity);
389376

390377
Ref<Volt::Mesh> debugMesh;
391378

@@ -396,7 +383,7 @@ void Sandbox::RenderGizmos(Ref<Volt::Scene> scene, Ref<Volt::Camera> camera)
396383
return;
397384
}
398385

399-
Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, transform, id);
386+
Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetUIntID());
400387
}
401388
}
402389

Volt/Sandbox/src/Sandbox/EditorCommandStack.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#pragma once
22

33
#include <Volt/Core/Base.h>
4+
#include <Volt/Components/CoreComponents.h>
5+
46
#include <stack>
57
#include "EditorCommand.h"
68
#include "Volt/Scene/Entity.h"
79

10+
811
#include <tuple>
912

1013
class EditorCommandStack
@@ -265,7 +268,7 @@ struct ObjectStateCommand : EditorCommand
265268

266269
EditorCommandStack::PushUndo(command, true);
267270

268-
for (int i = 0; i < myEntities.size(); i++)§
271+
for (int i = 0; i < myEntities.size(); i++)
269272
{
270273
myEntities[i].GetScene()->RemoveEntity(myEntities[i]);
271274
}

Volt/Sandbox/src/Sandbox/GameBuilder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void GameBuilder::Thread_BuildGame(const BuildInfo& buildInfo)
350350
Ref<Volt::Scene> scene = Volt::AssetManager::GetAsset<Volt::Scene>(sceneHandle);
351351
std::set<Volt::AssetHandle> sceneDependencies;
352352

353-
auto& registry = scene->GetRegistry();
353+
/*auto& registry = scene->GetRegistry();
354354
for (const auto& ent : registry.GetAllEntities())
355355
{
356356
for (const auto& [guid, pool] : registry.GetPools())
@@ -373,7 +373,7 @@ void GameBuilder::Thread_BuildGame(const BuildInfo& buildInfo)
373373
}
374374
}
375375
}
376-
}
376+
}*/
377377

378378
for (const auto& [instanceId, fieldMap] : scene->GetScriptFieldCache().GetCache())
379379
{

0 commit comments

Comments
 (0)