Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERA-4] preview fixes #19

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/EraEditor/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int main(int argc, char** argv)
using namespace era_engine;

#ifndef _DEBUG || DEBUG
::ShowWindow(::GetConsoleWindow(), SW_SHOW);
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
#endif

try
Expand Down
82 changes: 24 additions & 58 deletions modules/core/src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace era_engine
for (size_t i = 0; i < mat_size; i++)
ptr[i] = mat.m[i];
data.core->process_trs(reinterpret_cast<uintptr_t>(ptr), (int)entityHandle);
delete[] ptr;
//delete[] ptr; //CLR clear's it
}
data.core->update(data.deltaTime);
}
Expand Down Expand Up @@ -239,20 +239,20 @@ namespace era_engine
}

static entity_handle sphere{};
static entity_handle ragdoll{};
//static entity_handle ragdoll{};

static void initTestScene(escene& scene)
{
#ifndef ERA_RUNTIME
//if (auto mesh = loadMeshFromFileAsync(getAssetPath("/resources/assets/Sponza/sponza.obj")))
//{
// model_asset ass = load3DModelFromFile(getAssetPath("/resources/assets/Sponza/sponza.obj"));
// const auto& sponza = scene.createEntity("Sponza")
// .addComponent<transform_component>(vec3(0.f, 0.f, 0.f), quat::identity, 0.01f)
// .addComponent<mesh_component>(mesh);
if (auto mesh = loadMeshFromFileAsync(getAssetPath("/resources/assets/Sponza/sponza.obj")))
{
model_asset ass = load3DModelFromFile(getAssetPath("/resources/assets/Sponza/sponza.obj"));
const auto& sponza = scene.createEntity("Sponza")
.addComponent<transform_component>(vec3(5.0f, -3.75f, 35.0f), quat::identity, 0.01f)
.addComponent<mesh_component>(mesh);

// addRaytracingComponentAsync(sponza, mesh);
//}
addRaytracingComponentAsync(sponza, mesh);
}
#endif

#if 0
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace era_engine
// addRaytracingComponentAsync(en, mesh);
//}

if (auto mesh = loadAnimatedMeshFromFileAsync(getAssetPath("/resources/assets/resident-evil-tyrant/source/UmodelExport.fbx")))
/*if (auto mesh = loadAnimatedMeshFromFileAsync(getAssetPath("/resources/assets/resident-evil-tyrant/source/UmodelExport.fbx")))
{
auto& en = scene.createEntity("Ragdoll")
.addComponent<transform_component>(vec3(0.0f), quat::identity, vec3(0.1f))
Expand All @@ -341,7 +341,7 @@ namespace era_engine
addRaytracingComponentAsync(en, mesh);

ragdoll = en.handle;
}
}*/


#if PX_BLAST_ENABLE
Expand Down Expand Up @@ -420,7 +420,7 @@ namespace era_engine
// .addComponent<physics::px_cloth_component>(100, 100, vec3(0.f, 15.0f, 0.0f));

scene.createEntity("Platform")
.addComponent<transform_component>(vec3(10, -9.f, 0.f), quat(vec3(1.f, 0.f, 0.f), deg2rad(0.f)))
.addComponent<transform_component>(vec3(10, -9.f, 0.f), quat(vec3(1.f, 0.f, 0.f), deg2rad(0.f)), vec3(5.0f, 1.0f, 5.0f))
.addComponent<physics::px_plane_collider_component>(vec3(0.f, -5.0, 0.0f))
.addComponent<mesh_component>(groundMesh);

Expand Down Expand Up @@ -766,40 +766,6 @@ namespace era_engine
for (auto [entityHandle, cgm, _] : scene.group(component_group<physics::chunk_graph_manager, transform_component>).each())
{
cgm.update();
//for (auto&[handle, joints] : cgm.joints)
//{
// if (joints.empty())
// continue;
// //if (selectedEntity != handle)
// //continue;
// for (auto& joint : joints)
// {
// entity_handle h = *(entity_handle*)joint->second->userData;
// eentity entity{ h, &scene.registry };
// if (physics::px_convex_mesh_collider_component* cm = entity.getComponentIfExists<physics::px_convex_mesh_collider_component>())
// {
// physics::px_body_component* body = physics::getBodyComponent(entity);

// ASSERT(body != nullptr);

// physics::physics_lock_read lock{};

// physx::PxShape* shape[1];
// body->getRigidActor()->getShapes(shape, 1);
// auto geom = (physx::PxConvexMeshGeometry*)cm->getGeometry();
// auto mesh = geom->convexMesh;

// auto vertices = mesh->getVertices();
// auto nbv = mesh->getNbVertices();

// for (size_t i = 0; i < nbv; i++)
// {
// vec3 a = physx::createVec3(vertices[i] + shape[0]->getLocalPose().p) + entity.getComponent<transform_component>().position;
// renderPoint(a, vec4(1, 0, 0, 1), &ldrRenderPass, true);
// }
// }
// }
//}
}
}
#endif
Expand Down Expand Up @@ -926,20 +892,20 @@ namespace era_engine
renderer->setSun(sun);
renderer->setCamera(camera);

if (ImGui::Begin("Ragdoll"))
{
static bool init = false;
//if (ImGui::Begin("Ragdoll"))
//{
// static bool init = false;

if (ImGui::Checkbox("Build", &init))
{
init = false;
// if (ImGui::Checkbox("Build", &init))
// {
// init = false;

eentity rag{ ragdoll, &scene.registry };
// eentity rag{ ragdoll, &scene.registry };

rag.getComponent<physics::px_ragdoll_component>().initRagdoll(make_ref<animation::animation_skeleton>(rag.getComponent<mesh_component>().mesh->skeleton));
}
ImGui::End();
}
// rag.getComponent<physics::px_ragdoll_component>().initRagdoll(make_ref<animation::animation_skeleton>(rag.getComponent<mesh_component>().mesh->skeleton));
// }
// ImGui::End();
//}

//if (running)
// physics::physics_holder::physicsRef->endSimulation(dt);
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/asset/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace era_engine
{
sized_string lib = readString(file);
auto libMaterials = loadMaterialLibrary(relativeFilepath(lib, path));
for (auto [name, mat] : libMaterials)
for (auto& [name, mat] : libMaterials)
{
nameToMaterialIndex[std::move(name)] = (int32)materials.size();
materials.push_back(std::move(mat));
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/audio/sound_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
namespace era_engine
{
static std::unordered_map<uint64, sound_spec> soundRegistry;
static const fs::path registryPath = fs::path(L"resources/sounds.yaml").lexically_normal();
static const fs::path soundRegistryPath = fs::path(L"resources/sounds.yaml").lexically_normal();

void loadSoundRegistry()
{
std::ifstream stream(registryPath);
std::ifstream stream(soundRegistryPath);
YAML::Node n = YAML::Load(stream);

for (auto entryNode : n)
Expand Down Expand Up @@ -49,10 +49,10 @@ namespace era_engine
out.push_back(n);
}

fs::create_directories(registryPath.parent_path());
fs::create_directories(soundRegistryPath.parent_path());

LOG_MESSAGE("Rewriting sound registry");
std::ofstream fout(registryPath);
std::ofstream fout(soundRegistryPath);
fout << out;
}

Expand Down
22 changes: 22 additions & 0 deletions modules/core/src/core/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ namespace era_engine
#endif
}

inline std::string convertPath(const std::string& inputPath)
{
std::filesystem::path path(inputPath);
std::filesystem::path newPath;

for (const auto& part : path)
{
if (part == "..")
{
continue;
}
newPath /= part;
}

if (!newPath.empty())
{
newPath = newPath.relative_path();
}

return '/' + newPath.string();
}

inline constexpr std::string getAssetPath(std::string_view path)
{
#ifdef ERA_RUNTIME
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3112,7 +3112,7 @@ namespace era_engine
{
fs::path path = getPathFromAssetHandle(asset);
fs::path relative = fs::relative(path, fs::current_path());
if (auto newTex = loadTextureFromFileAsync(relative.string(), loadFlags))
if (auto newTex = loadTextureFromFileAsync(path, loadFlags))
{
tex = newTex;
}
Expand All @@ -3131,7 +3131,7 @@ namespace era_engine
{
fs::path path = getPathFromAssetHandle(asset);
fs::path relative = fs::relative(path, fs::current_path());
if (auto newMesh = loadMeshFromFile(relative.string(), loadFlags))
if (auto newMesh = loadMeshFromFile(path, loadFlags))
{
mesh = newMesh;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace era_engine

system_info systemInfo;

bool renderPhysicsShapes = true;
bool renderPhysicsShapes = false;

friend struct selection_undo;
friend struct application;
Expand Down
15 changes: 14 additions & 1 deletion modules/core/src/geometry/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "rendering/pbr.h"

#include "core/hash.h"
#include "core/string.h"

#include "asset/file_registry.h"
#include "asset/model_asset.h"
Expand Down Expand Up @@ -47,7 +48,19 @@ namespace era_engine
{
for (auto& sub : mesh.submeshes)
{
const pbr_material_desc& materialDesc = asset.materials[sub.materialIndex];
pbr_material_desc& materialDesc = asset.materials[sub.materialIndex];

{
if (!materialDesc.albedo.empty() && *materialDesc.albedo.c_str() != 'F')
materialDesc.albedo = getAssetPath(convertPath(materialDesc.albedo.string()));
if (!materialDesc.normal.empty() && *materialDesc.normal.c_str() != 'F')
materialDesc.normal = getAssetPath(convertPath(materialDesc.normal.string()));
if (!materialDesc.roughness.empty() && *materialDesc.roughness.c_str() != 'F')
materialDesc.roughness = getAssetPath(convertPath(materialDesc.roughness.string()));
if (!materialDesc.metallic.empty() && *materialDesc.metallic.c_str() != 'F')
materialDesc.metallic = getAssetPath(convertPath(materialDesc.metallic.string()));
}

ref<pbr_material> material;
if (!async)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj": {}
"E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj": {}
},
"projects": {
"E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj": {
"E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectUniqueName": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectName": "EraEngineDomain",
"projectPath": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectPath": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"packagesPath": "C:\\Users\\Эльдар\\.nuget\\packages\\",
"outputPath": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\obj\\",
"outputPath": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Эльдар\\AppData\\Roaming\\NuGet\\NuGet.Config",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("EraEngineDomain")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+34e9afbe20dfdba8865be91a526645aa46ef5b85")]
[assembly: System.Reflection.AssemblyProductAttribute("EraEngineDomain")]
[assembly: System.Reflection.AssemblyTitleAttribute("EraEngineDomain")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
df6b73febfb1a844ebf5eea8386905bfc69349e449658d27ece4d339294689ed
0817fae0291c940a3244afda4e41994762fe675f953073f6f83d08743cc42ea6
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = EraEngineDomain
build_property.ProjectDir = E:\EraEngine\modules\dotnet\EraEngineDomain\
build_property.ProjectDir = E:\Era Engine\modules\dotnet\EraEngineDomain\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop = false
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ E:\EraEngine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.d
E:\EraEngine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\refint\EraEngineDomain.dll
E:\EraEngine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.pdb
E:\EraEngine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\ref\EraEngineDomain.dll
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.csproj.AssemblyReference.cache
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.GeneratedMSBuildEditorConfig.editorconfig
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.AssemblyInfoInputs.cache
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.AssemblyInfo.cs
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.csproj.CoreCompileInputs.cache
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.sourcelink.json
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.dll
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\refint\EraEngineDomain.dll
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\EraEngineDomain.pdb
E:\Era Engine\modules\dotnet\EraEngineDomain\obj\Release\net8.0\ref\EraEngineDomain.dll
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"E:\\Era Engine\\*":"https://raw.githubusercontent.com/EldarMuradov/EraEngine/34e9afbe20dfdba8865be91a526645aa46ef5b85/*"}}
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions modules/dotnet/EraEngineDomain/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectUniqueName": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectName": "EraEngineDomain",
"projectPath": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectPath": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"packagesPath": "C:\\Users\\Эльдар\\.nuget\\packages\\",
"outputPath": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\obj\\",
"outputPath": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Эльдар\\AppData\\Roaming\\NuGet\\NuGet.Config",
Expand Down
4 changes: 2 additions & 2 deletions modules/dotnet/EraEngineDomain/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 2,
"dgSpecHash": "EbOhZ4OB2A9sKKsp3eKL8BWNYL9XHGffELRyzRM4KpJkkN3J6nTARgdH8qjur7A+3NWywRS8aCCudVe25+3+ZQ==",
"dgSpecHash": "6+XRLJKykCTyJ5Jy7Pm5PUwrhIJEDeo3lzr5Lj7/LSKl8u6+XXLZfffxV8V9vVs5V9IcnHtpqhXuE/ayAfmSfw==",
"success": true,
"projectFilePath": "E:\\EraEngine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"projectFilePath": "E:\\Era Engine\\modules\\dotnet\\EraEngineDomain\\EraEngineDomain.csproj",
"expectedPackageFiles": [
"C:\\Users\\Эльдар\\.nuget\\packages\\microsoft.dotnet.ilcompiler\\8.0.4\\microsoft.dotnet.ilcompiler.8.0.4.nupkg.sha512",
"C:\\Users\\Эльдар\\.nuget\\packages\\microsoft.net.illink.tasks\\8.0.4\\microsoft.net.illink.tasks.8.0.4.nupkg.sha512",
Expand Down
2 changes: 1 addition & 1 deletion modules/dotnet/EraScriptingCore/Runtime/ELevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void Update(float dt)
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Debug.LogError(ex.Message);
}
}

Expand Down
Loading