diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp index f099bd3e..6bc26271 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/Core/FileSystem.cpp @@ -202,5 +202,7 @@ namespace Nuake } } } + + return nullptr; } } diff --git a/Nuake/src/Core/Logger.cpp b/Nuake/src/Core/Logger.cpp index be3fbd13..ec5ba39c 100644 --- a/Nuake/src/Core/Logger.cpp +++ b/Nuake/src/Core/Logger.cpp @@ -12,7 +12,9 @@ namespace Nuake { char buff[100]; time_t now = time(0); - strftime(buff, 100, "%H:%M:%S", localtime(&now)); + struct tm timeinfo; + localtime_s(&timeinfo, &now); + strftime(buff, 100, "%H:%M:%S", &timeinfo); LogEntry newLog = { type, diff --git a/Nuake/src/Core/OS.h b/Nuake/src/Core/OS.h index ec0649da..15430935 100644 --- a/Nuake/src/Core/OS.h +++ b/Nuake/src/Core/OS.h @@ -7,7 +7,7 @@ namespace Nuake public: static int GetTime() { - return std::chrono::system_clock::now().time_since_epoch().count(); + return static_cast(std::chrono::system_clock::now().time_since_epoch().count()); } }; } diff --git a/Nuake/src/Core/Physics/CharacterController.cpp b/Nuake/src/Core/Physics/CharacterController.cpp index 18e1eb1d..0957aad3 100644 --- a/Nuake/src/Core/Physics/CharacterController.cpp +++ b/Nuake/src/Core/Physics/CharacterController.cpp @@ -44,7 +44,7 @@ namespace Nuake if (m_hittingWall) { - for (unsigned int i = 0, size = m_surfaceHitNormals.size(); i < size; i++) + for (size_t i = 0, size = m_surfaceHitNormals.size(); i < size; i++) { // Cancel velocity across normal glm::vec3 velInNormalDir(glm::reflect(m_manualVelocity, m_surfaceHitNormals[i])); diff --git a/Nuake/src/Rendering/Buffers/VertexArray.cpp b/Nuake/src/Rendering/Buffers/VertexArray.cpp index 71168028..9c282cb2 100644 --- a/Nuake/src/Rendering/Buffers/VertexArray.cpp +++ b/Nuake/src/Rendering/Buffers/VertexArray.cpp @@ -23,7 +23,7 @@ namespace Nuake { { const auto& element = elements[i]; RenderCommand::EnableVertexAttribArray(i); - RenderCommand::VertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset); + RenderCommand::VertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)(uintptr_t)offset); offset += element.count * VertexBufferElement::GetSizeOfType(element.type); } } diff --git a/Nuake/src/Rendering/Camera.cpp b/Nuake/src/Rendering/Camera.cpp index 56a3360b..42557112 100644 --- a/Nuake/src/Rendering/Camera.cpp +++ b/Nuake/src/Rendering/Camera.cpp @@ -36,7 +36,7 @@ namespace Nuake m_Type = type; } - void Camera::OnWindowResize(int x, int y) + void Camera::OnWindowResize(float x, float y) { AspectRatio = (float)x / (float)y; float width = (float)y * (16.0f * 9.0f); diff --git a/Nuake/src/Rendering/Camera.h b/Nuake/src/Rendering/Camera.h index c15cd665..c52c9361 100644 --- a/Nuake/src/Rendering/Camera.h +++ b/Nuake/src/Rendering/Camera.h @@ -41,7 +41,7 @@ namespace Nuake Camera(CAMERA_TYPE type, Vector3 position); void SetType(CAMERA_TYPE type); - void OnWindowResize(int x, int y); + void OnWindowResize(float x, float y); void SetDirection(Vector3 direction); diff --git a/Nuake/src/Rendering/Mesh/Mesh.cpp b/Nuake/src/Rendering/Mesh/Mesh.cpp index a21ce6a1..be49bed1 100644 --- a/Nuake/src/Rendering/Mesh/Mesh.cpp +++ b/Nuake/src/Rendering/Mesh/Mesh.cpp @@ -97,7 +97,7 @@ namespace Nuake m_Material->Bind(shader); m_VertexArray->Bind(); - RenderCommand::DrawElements(RendererEnum::TRIANGLES, m_Indices.size(), RendererEnum::UINT, 0); + RenderCommand::DrawElements(RendererEnum::TRIANGLES, (int)m_Indices.size(), RendererEnum::UINT, 0); } void Mesh::DebugDraw() @@ -106,7 +106,7 @@ namespace Nuake Renderer::m_DebugShader->SetUniform4f("u_Color", 1.0f, 0.0f, 0.0f, 1.f); m_VertexArray->Bind(); - RenderCommand::DrawElements(RendererEnum::TRIANGLES, m_Indices.size(), RendererEnum::UINT, 0); + RenderCommand::DrawElements(RendererEnum::TRIANGLES, (int)m_Indices.size(), RendererEnum::UINT, 0); } json Mesh::Serialize() diff --git a/Nuake/src/Rendering/PostFX/Bloom.cpp b/Nuake/src/Rendering/PostFX/Bloom.cpp index a23ec225..477514c5 100644 --- a/Nuake/src/Rendering/PostFX/Bloom.cpp +++ b/Nuake/src/Rendering/PostFX/Bloom.cpp @@ -39,7 +39,7 @@ namespace Nuake m_VBlurFB = std::vector>(); Vector2 currentSize = m_Size / 2.0f; - for (int i = 0; i < m_Iteration; i++) + for (uint32_t i = 0; i < m_Iteration; i++) { Ref fb = CreateRef(false, currentSize); fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); @@ -48,7 +48,7 @@ namespace Nuake currentSize *= DownsamplingScale; } - for (int i = 0; i < m_Iteration; i++) + for (uint32_t i = 0; i < m_Iteration; i++) { Ref fb = CreateRef(false, currentSize); fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); @@ -86,7 +86,7 @@ namespace Nuake Renderer::DrawQuad(Matrix4()); } - for (int i = 0; i < m_Iteration; i++) + for (uint32_t i = 0; i < m_Iteration; i++) { m_DownSampleFB[i]->Bind(); m_DownSampleFB[i]->Clear(); @@ -103,7 +103,7 @@ namespace Nuake m_DownSampleFB[i]->Unbind(); } - for (int i = 0; i < m_Iteration; i++) + for (uint32_t i = 0; i < m_Iteration; i++) { // Horizontal blur m_HBlurFB[i]->Bind(); @@ -115,7 +115,7 @@ namespace Nuake Ref blurTexture = m_DownSampleFB[m_Iteration - i - 1]->GetTexture(); blurTexture->Bind(1); shader->SetUniform1i("u_Source", 1); - shader->SetUniform2f("u_SourceSize", blurTexture->GetWidth(), blurTexture->GetHeight()); + shader->SetUniform2f("u_SourceSize", (float)blurTexture->GetWidth(), (float)blurTexture->GetHeight()); Renderer::DrawQuad(Matrix4()); m_HBlurFB[i]->Unbind(); @@ -129,7 +129,7 @@ namespace Nuake m_HBlurFB[i]->GetTexture()->Bind(1); shader->SetUniform1i("u_Source", 1); - shader->SetUniform2f("u_SourceSize", m_HBlurFB[i]->GetTexture()->GetWidth(), m_HBlurFB[i]->GetTexture()->GetHeight()); + shader->SetUniform2f("u_SourceSize", (float)m_HBlurFB[i]->GetTexture()->GetWidth(), (float)m_HBlurFB[i]->GetTexture()->GetHeight()); Renderer::DrawQuad(Matrix4()); m_VBlurFB[i]->Unbind(); @@ -153,7 +153,7 @@ namespace Nuake m_UpSampleFB[i - 1]->GetTexture()->Bind(2); shader->SetUniform1i("u_Source2", 2); - shader->SetUniform2f("u_Source2Size", m_UpSampleFB[i]->GetTexture()->GetWidth(), m_UpSampleFB[i]->GetTexture()->GetHeight()); + shader->SetUniform2f("u_Source2Size", (float)m_UpSampleFB[i]->GetTexture()->GetWidth(), (float)m_UpSampleFB[i]->GetTexture()->GetHeight()); } Renderer::DrawQuad(Matrix4()); m_UpSampleFB[i]->Unbind(); diff --git a/Nuake/src/Rendering/Renderer.cpp b/Nuake/src/Rendering/Renderer.cpp index 541fcaec..b316d193 100644 --- a/Nuake/src/Rendering/Renderer.cpp +++ b/Nuake/src/Rendering/Renderer.cpp @@ -153,7 +153,7 @@ namespace Nuake deferredShader->Bind(); m_Lights.push_back({ transform , light }); - int idx = m_Lights.size(); + size_t idx = m_Lights.size(); Vector3 direction = light.GetDirection(); Vector3 pos = transform.GetGlobalPosition(); @@ -174,7 +174,7 @@ namespace Nuake shadowmapAmount += CSM_AMOUNT; } - deferredShader->SetUniform1i("LightCount", idx); + deferredShader->SetUniform1i("LightCount", (int)idx); deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].Type", light.Type); deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Position", pos.x, pos.y, pos.z); deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Direction", direction.x, direction.y, direction.z); @@ -200,7 +200,7 @@ namespace Nuake VertexArray lineVertexArray = VertexArray(); lineVertexArray.Bind(); - VertexBuffer lineVertexBuffer = VertexBuffer(&vertices, size(vertices)); + VertexBuffer lineVertexBuffer = VertexBuffer(&vertices, static_cast(size(vertices))); VertexBufferLayout vblayout = VertexBufferLayout(); vblayout.Push(3); diff --git a/Nuake/src/Rendering/Renderer2D.h b/Nuake/src/Rendering/Renderer2D.h index 92434751..ac7065a4 100644 --- a/Nuake/src/Rendering/Renderer2D.h +++ b/Nuake/src/Rendering/Renderer2D.h @@ -6,7 +6,7 @@ namespace Nuake { - class TextStyle; + struct TextStyle; class Renderer2D { private: diff --git a/Nuake/src/Rendering/Textures/Material.h b/Nuake/src/Rendering/Textures/Material.h index 29d2f811..9dd2e269 100644 --- a/Nuake/src/Rendering/Textures/Material.h +++ b/Nuake/src/Rendering/Textures/Material.h @@ -45,7 +45,7 @@ namespace Nuake 0, // Has metalness 0.f, // Metalness value 0, // u_HasRoughness - 0.f, // u_RoughnessValue + 1.f, // u_RoughnessValue 0, // u_HasAO 1.f, // u_AOValue 0, // u_HasNormal diff --git a/Nuake/src/Resource/FGD/FGDFile.h b/Nuake/src/Resource/FGD/FGDFile.h index 7d94fcff..592983ef 100644 --- a/Nuake/src/Resource/FGD/FGDFile.h +++ b/Nuake/src/Resource/FGD/FGDFile.h @@ -72,6 +72,8 @@ namespace Nuake { if (name == b.Name) return b; } + + assert(false && "Brush entity not found!"); } FGDPointEntity& GetPointEntity(const std::string& name) @@ -81,6 +83,8 @@ namespace Nuake { if (name == p.Name) return p; } + + assert(false && "Point entity not found!"); } EntityType GetTypeOfEntity(const std::string& className) diff --git a/Nuake/src/Resource/FGD/FGDSerializer.cpp b/Nuake/src/Resource/FGD/FGDSerializer.cpp index fbf61c23..c5b83cc3 100644 --- a/Nuake/src/Resource/FGD/FGDSerializer.cpp +++ b/Nuake/src/Resource/FGD/FGDSerializer.cpp @@ -84,6 +84,8 @@ namespace Nuake { line += "]"; FileSystem::WriteLine(line); + + return true; } bool FGDSerializer::SerializeBrush(FGDBrushEntity fgdClass) diff --git a/Nuake/src/Scene/Components/LightComponent.h b/Nuake/src/Scene/Components/LightComponent.h index ac6d92cc..32c4a110 100644 --- a/Nuake/src/Scene/Components/LightComponent.h +++ b/Nuake/src/Scene/Components/LightComponent.h @@ -156,7 +156,7 @@ namespace Nuake // Store SplitDistance and ViewProjection-Matrix mCascadeSplitDepth[cascade] = (nearClip + splitDist * clipRange) * 1.0f; - mViewProjections[cascade] = lightProjectionMatrix * lightViewMatrix; + mViewProjections[cascade] = shadowMatrix; lastSplitDist = mCascadeSplits[cascade]; // -----------------------Debug only----------------------- diff --git a/Nuake/src/Scene/Entities/ImGuiHelper.h b/Nuake/src/Scene/Entities/ImGuiHelper.h index 4c01dfb8..937b7ff8 100644 --- a/Nuake/src/Scene/Entities/ImGuiHelper.h +++ b/Nuake/src/Scene/Entities/ImGuiHelper.h @@ -13,7 +13,7 @@ public: ImGui::PushID(label.c_str()); - float availWidth = (ImGui::GetContentRegionAvailWidth() / 3.0) - 9.0; + float availWidth = (ImGui::GetContentRegionAvailWidth() / 3.0f) - 9.0f; ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 }); float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f; diff --git a/Nuake/src/Scene/Environment/ProceduralSky.h b/Nuake/src/Scene/Environment/ProceduralSky.h index bbe5bf32..829f319d 100644 --- a/Nuake/src/Scene/Environment/ProceduralSky.h +++ b/Nuake/src/Scene/Environment/ProceduralSky.h @@ -14,7 +14,7 @@ namespace Nuake float AtmosphereRadius = 6380e3f; Vector3 RayleighScattering = Vector3(58e-7f, 135e-7f, 331e-7f); Vector3 MieScattering = Vector3(2e-5f); - float SunIntensity = 100.0; + float SunIntensity = 10.0; Vector3 CenterPoint = Vector3(0.f, -SurfaceRadius, 0.f); Vector3 SunDirection = Vector3(0.20000f, 0.95917f, 0.20000f); diff --git a/Nuake/src/Scene/Environment/SkyboxHDR.cpp b/Nuake/src/Scene/Environment/SkyboxHDR.cpp index 754f5561..3e555a8f 100644 --- a/Nuake/src/Scene/Environment/SkyboxHDR.cpp +++ b/Nuake/src/Scene/Environment/SkyboxHDR.cpp @@ -294,8 +294,8 @@ namespace Nuake { for (unsigned int mip = 0; mip < maxMipLevels; ++mip) { // reisze framebuffer according to mip-level size. - unsigned int mipWidth = 1024 * std::pow(0.5, mip); - unsigned int mipHeight = 1024 * std::pow(0.5, mip); + unsigned int mipWidth = unsigned int(1024 * std::pow(0.5f, mip)); + unsigned int mipHeight = unsigned int(1024 * std::pow(0.5f, mip)); glBindRenderbuffer(GL_RENDERBUFFER, captureRBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight); glViewport(0, 0, mipWidth, mipHeight); diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 211c3850..53a89177 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -75,11 +75,14 @@ namespace Nuake { Entity Scene::GetEntityByID(int id) { auto idView = m_Registry.view(); - for (auto e : idView) { + for (auto e : idView) + { NameComponent& nameC = idView.get(e); if (nameC.ID == id) return Entity{ e, this }; } + + assert("Not found"); } diff --git a/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp b/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp index fbe84dc7..3dc71618 100644 --- a/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp +++ b/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp @@ -386,7 +386,7 @@ namespace Nuake { geo_generator_run(); DefaultMaterial = MaterialManager::Get()->GetMaterial("default"); - for (uint32_t e = 0; e < entity_count; ++e) + for (uint32_t e = 0; e < (uint32_t)entity_count; ++e) { entity* entity_inst = &entities[e]; entity_geometry* entity_geo_inst = &entity_geo[e]; @@ -598,7 +598,7 @@ namespace Nuake { for (auto& index : pm.Indices) batchedIndices.push_back(indexOffset + index); - indexOffset += pm.Vertices.size(); + indexOffset += static_cast(pm.Vertices.size()); } Ref mesh = CreateRef(); diff --git a/Nuake/src/Scripting/Modules/InputModule.h b/Nuake/src/Scripting/Modules/InputModule.h index 50d1fd84..468bb9d1 100644 --- a/Nuake/src/Scripting/Modules/InputModule.h +++ b/Nuake/src/Scripting/Modules/InputModule.h @@ -47,8 +47,8 @@ namespace Nuake { static void IsMouseButtonDown(WrenVM* vm) { - int key = wrenGetSlotDouble(vm, 1); - bool result = Input::IsMouseButtonDown(key); + double key = wrenGetSlotDouble(vm, 1); + bool result = Input::IsMouseButtonDown((int)key); wrenSetSlotBool(vm, 0, result); } @@ -61,28 +61,28 @@ namespace Nuake { static void IsMouseButtonReleased(WrenVM* vm) { - int key = wrenGetSlotDouble(vm, 1); + int key = (int)wrenGetSlotDouble(vm, 1); bool result = Input::IsMouseButtonReleased(key); wrenSetSlotBool(vm, 0, result); } static void IsKeyDown(WrenVM* vm) { - int key = wrenGetSlotDouble(vm, 1); + int key = (int)wrenGetSlotDouble(vm, 1); bool result = Input::IsKeyDown(key); wrenSetSlotBool(vm, 0, result); } static void IsKeyPressed(WrenVM* vm) { - int key = wrenGetSlotDouble(vm, 1); + int key = (int)wrenGetSlotDouble(vm, 1); bool result = Input::IsKeyPressed(key); wrenSetSlotBool(vm, 0, result); } static void IsKeyReleased(WrenVM* vm) { - int key = wrenGetSlotDouble(vm, 1); + int key = (int)wrenGetSlotDouble(vm, 1); bool result = Input::IsKeyReleased(key); wrenSetSlotBool(vm, 0, result); } diff --git a/Nuake/src/Scripting/Modules/MathModule.h b/Nuake/src/Scripting/Modules/MathModule.h index a34ae72f..5393ba42 100644 --- a/Nuake/src/Scripting/Modules/MathModule.h +++ b/Nuake/src/Scripting/Modules/MathModule.h @@ -32,38 +32,38 @@ namespace Nuake { static void Sqrt(WrenVM* vm) { - float x = wrenGetSlotDouble(vm, 1); - float y = wrenGetSlotDouble(vm, 2); - float z = wrenGetSlotDouble(vm, 3); - float result = glm::sqrt((x * x) + (y * y) + (z * z)); + double x = wrenGetSlotDouble(vm, 1); + double y = wrenGetSlotDouble(vm, 2); + double z = wrenGetSlotDouble(vm, 3); + double result = glm::sqrt((x * x) + (y * y) + (z * z)); wrenSetSlotDouble(vm, 0, result); } static void Cos(WrenVM* vm) { - float d = wrenGetSlotDouble(vm, 1); - float result = glm::cos(d); + double d = wrenGetSlotDouble(vm, 1); + double result = glm::cos(d); wrenSetSlotDouble(vm, 0, result); } static void Sin(WrenVM* vm) { - float d = wrenGetSlotDouble(vm, 1); - float result = glm::sin(d); + double d = wrenGetSlotDouble(vm, 1); + double result = glm::sin(d); wrenSetSlotDouble(vm, 0, result); } static void Radians(WrenVM* vm) { - float d = wrenGetSlotDouble(vm, 1); - float result = glm::radians(d); + double d = wrenGetSlotDouble(vm, 1); + double result = glm::radians(d); wrenSetSlotDouble(vm, 0, result); } static void Degrees(WrenVM* vm) { - float d = wrenGetSlotDouble(vm, 1); - float result = glm::degrees(d); + double d = wrenGetSlotDouble(vm, 1); + double result = glm::degrees(d); wrenSetSlotDouble(vm, 0, result); } diff --git a/Nuake/src/Scripting/Modules/SceneModule.h b/Nuake/src/Scripting/Modules/SceneModule.h index 4ad96008..8d92f39c 100644 --- a/Nuake/src/Scripting/Modules/SceneModule.h +++ b/Nuake/src/Scripting/Modules/SceneModule.h @@ -63,7 +63,7 @@ namespace Nuake { static void EntityHasComponent(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); std::string name = wrenGetSlotString(vm, 2); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); @@ -106,7 +106,7 @@ namespace Nuake { static void GetScript(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); if (ent.HasComponent()) @@ -117,18 +117,18 @@ namespace Nuake { static void SetLightIntensity(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); - float intensity = wrenGetSlotDouble(vm, 2); + double handle = wrenGetSlotDouble(vm, 1); + double intensity = wrenGetSlotDouble(vm, 2); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& light = ent.GetComponent(); - light.Strength = intensity; + light.Strength = static_cast(intensity); } static void GetLightIntensity(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); - float intensity = wrenGetSlotDouble(vm, 2); + double handle = wrenGetSlotDouble(vm, 1); + double intensity = wrenGetSlotDouble(vm, 2); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& light = ent.GetComponent(); @@ -137,10 +137,10 @@ namespace Nuake { static void SetCameraDirection(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); - float x = wrenGetSlotDouble(vm, 2); - float y = wrenGetSlotDouble(vm, 3); - float z = wrenGetSlotDouble(vm, 4); + double handle = wrenGetSlotDouble(vm, 1); + double x = wrenGetSlotDouble(vm, 2); + double y = wrenGetSlotDouble(vm, 3); + double z = wrenGetSlotDouble(vm, 4); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& cam = ent.GetComponent(); cam.CameraInstance->SetDirection(Vector3(x, y, z)); @@ -148,7 +148,7 @@ namespace Nuake { static void GetCameraDirection(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& cam = ent.GetComponent(); @@ -171,7 +171,7 @@ namespace Nuake { static void GetCameraRight(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& cam = ent.GetComponent(); @@ -192,7 +192,7 @@ namespace Nuake { static void IsCharacterControllerOnGround(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& characterController = ent.GetComponent(); bool result = characterController.CharacterController->IsOnGround; @@ -201,10 +201,10 @@ namespace Nuake { static void MoveAndSlide(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); - float x = wrenGetSlotDouble(vm, 2); - float y = wrenGetSlotDouble(vm, 3); - float z = wrenGetSlotDouble(vm, 4); + double handle = wrenGetSlotDouble(vm, 1); + double x = wrenGetSlotDouble(vm, 2); + double y = wrenGetSlotDouble(vm, 3); + double z = wrenGetSlotDouble(vm, 4); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& characterController = ent.GetComponent(); @@ -213,7 +213,7 @@ namespace Nuake { static void GetTranslation(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& transform = ent.GetComponent(); // set the slots @@ -231,7 +231,7 @@ namespace Nuake { static void GetRotation(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& transform = ent.GetComponent(); // set the slots @@ -248,33 +248,33 @@ namespace Nuake { static void SetRotation(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& transform = ent.GetComponent(); // set the slots - float x = wrenGetSlotDouble(vm, 2); - float y = wrenGetSlotDouble(vm, 3); - float z = wrenGetSlotDouble(vm, 4); + float x = (float)wrenGetSlotDouble(vm, 2); + float y = (float)wrenGetSlotDouble(vm, 3); + float z = (float)wrenGetSlotDouble(vm, 4); transform.SetLocalRotation(QuatFromEuler(x, y, z)); } static void SetTranslation(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& transform = ent.GetComponent(); // set the slots - float x = wrenGetSlotDouble(vm, 2); - float y = wrenGetSlotDouble(vm, 3); - float z = wrenGetSlotDouble(vm, 4); + double x = wrenGetSlotDouble(vm, 2); + double y = wrenGetSlotDouble(vm, 3); + double z = wrenGetSlotDouble(vm, 4); transform.SetGlobalPosition(Vector3(x, y, z)); } static void TriggerGetOverlappingBodyCount(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); TriggerZone trigger = ent.GetComponent(); @@ -286,14 +286,14 @@ namespace Nuake { static void TriggerGetOverlappingBodies(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); TriggerZone trigger = ent.GetComponent(); std::vector entities = trigger.GetOverlappingBodies(); - wrenEnsureSlots(vm, entities.size()); + wrenEnsureSlots(vm, static_cast(entities.size())); wrenSetSlotNewList(vm, 0); int idx = 1; @@ -307,11 +307,11 @@ namespace Nuake { static void BrushGetTargets(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); BSPBrushComponent& brush = ent.GetComponent(); - wrenEnsureSlots(vm, brush.Targets.size()); + wrenEnsureSlots(vm, static_cast(brush.Targets.size())); wrenSetSlotNewList(vm, 0); int idx = 1; @@ -324,11 +324,11 @@ namespace Nuake { } static void BrushGetTargetsCount(WrenVM* vm) { - int handle = wrenGetSlotDouble(vm, 1); + double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); BSPBrushComponent& brush = ent.GetComponent(); - wrenSetSlotDouble(vm, 0, brush.Targets.size()); + wrenSetSlotDouble(vm, 0, static_cast(brush.Targets.size())); } }; } diff --git a/Nuake/src/Scripting/ScriptingEngine.cpp b/Nuake/src/Scripting/ScriptingEngine.cpp index 7d69a124..0a95deb8 100644 --- a/Nuake/src/Scripting/ScriptingEngine.cpp +++ b/Nuake/src/Scripting/ScriptingEngine.cpp @@ -82,9 +82,7 @@ namespace Nuake { path += ".wren"; std::string str = FileSystem::ReadFile(path, true); - char* c = strcpy(new char[str.length() + 1], str.c_str()); - - result.source = c; + result.source = str.c_str(); return result; } @@ -173,7 +171,7 @@ namespace Nuake { wrenFreeVM(m_WrenVM); } - WrenForeignMethodFn ScriptingEngine::bindForeignMethod(WrenVM* vm, const char* module, const char* className, bool isStatic, const char* signature) + WrenForeignMethodFn ScriptingEngine::bindForeignMethod(WrenVM* vm, const char* modul, const char* className, bool isStatic, const char* signature) { if (Modules.find(className) != Modules.end()) { @@ -181,6 +179,8 @@ namespace Nuake { void* ptr = mod->GetMethodPointer(signature); return (WrenForeignMethodFn)ptr; } + + return nullptr; } WrenVM* ScriptingEngine::GetWrenVM() diff --git a/Nuake/src/UI/Font/Font.h b/Nuake/src/UI/Font/Font.h index 4902691e..c14816f4 100644 --- a/Nuake/src/UI/Font/Font.h +++ b/Nuake/src/UI/Font/Font.h @@ -9,10 +9,10 @@ namespace Nuake { struct CharPos { - double left; - double right; - double top; - double bottom; + float left; + float right; + float top; + float bottom; }; struct CharUV diff --git a/Nuake/src/UI/Font/FontLoader.h b/Nuake/src/UI/Font/FontLoader.h index bf1a7738..cd561d17 100644 --- a/Nuake/src/UI/Font/FontLoader.h +++ b/Nuake/src/UI/Font/FontLoader.h @@ -56,7 +56,7 @@ namespace Nuake // Setup generator settings generator.setAttributes(config.generatorAttributes); generator.setThreadCount(config.threadCount); - generator.generate(glyphs.data(), glyphs.size()); + generator.generate(glyphs.data(), static_cast(glyphs.size())); // Create bitmap msdfgen::BitmapConstRef bitmap = (msdfgen::BitmapConstRef) generator.atlasStorage(); @@ -120,11 +120,14 @@ namespace Nuake atlasPacker.setMiterLimit(config.miterLimit); // Pack atlas - if (int remaining = atlasPacker.pack(glyphs.data(), glyphs.size())) { - if (remaining < 0) { + if (int remaining = atlasPacker.pack(glyphs.data(), static_cast(glyphs.size()))) + { + if (remaining < 0) + { Logger::Log("Failed to pack atlas.", CRITICAL); } - else { + else + { printf("Error: Could not fit %d out of %d glyphs into the atlas.\n", remaining, (int)glyphs.size()); } @@ -145,30 +148,37 @@ namespace Nuake // glyph.edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed); //} - msdf_atlas::Workload([&glyphs, &config](int i, int threadNo) -> bool { + msdf_atlas::Workload([&glyphs, &config](int i, int threadNo) -> bool + { unsigned long long glyphSeed = (6364136223846793005ull * (config.coloringSeed ^ i) + 1442695040888963407ull) * !!config.coloringSeed; glyphs[i].edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed); return true; - }, glyphs.size()).finish(config.threadCount); + }, (int)glyphs.size()).finish(config.threadCount); // Create bitmap and char structure auto bitmap = makeAtlas(glyphs, fonts, config, font); for (auto& g : glyphs) { - CharPos plane = {}; - g.getQuadPlaneBounds(plane.left, plane.bottom, plane.right, plane.top); - - CharUV box = {}; + double planeLeft, planeBottom, planeRight, planeTop; + g.getQuadPlaneBounds(planeLeft, planeBottom, planeRight, planeTop); + CharPos plane { + static_cast(planeLeft), + static_cast(planeRight), + static_cast(planeTop), + static_cast(planeBottom) + }; double x2, y2, z2, w2; g.getQuadAtlasBounds(x2, y2, z2, w2); - box.Pos.x = x2; - box.Pos.y = y2; - box.Size.x = z2; - box.Size.y = w2; - font->AddChar(g.getCodepoint(), g.getAdvance(), plane, box); + + CharUV box { + Vector2{x2, y2}, + Vector2{z2, w2} + }; + + font->AddChar(g.getCodepoint(), static_cast(g.getAdvance()), plane, box); } return font; diff --git a/Nuake/src/UI/InterfaceParser.cpp b/Nuake/src/UI/InterfaceParser.cpp index 1ed0815e..a2e17640 100644 --- a/Nuake/src/UI/InterfaceParser.cpp +++ b/Nuake/src/UI/InterfaceParser.cpp @@ -166,6 +166,8 @@ namespace Nuake } } } + + return Layout::LayoutUnit{ 1.0f, Layout::Unit::AUTO }; } Layout::LayoutVec4 InterfaceParser::GetVec4Unit(const std::string& value) diff --git a/Nuake/src/UI/UserInterface.cpp b/Nuake/src/UI/UserInterface.cpp index 9bc30daa..88ca054b 100644 --- a/Nuake/src/UI/UserInterface.cpp +++ b/Nuake/src/UI/UserInterface.cpp @@ -56,7 +56,7 @@ namespace Nuake { void UserInterface::Calculate(int available_width, int available_height) { YGNodeRef root = Root->YogaNode; - YGNodeCalculateLayout(root, available_width, available_height, YGDirectionLTR); + YGNodeCalculateLayout(root, static_cast(available_width), static_cast(available_height), YGDirectionLTR); } void UserInterface::CreateYogaLayout() @@ -109,7 +109,7 @@ namespace Nuake { void UserInterface::Draw(Vector2 size) { - Calculate(size.x, size.y); + Calculate((int)size.x, (int)size.y); Renderer2D::BeginDraw(size); DrawRecursive(Root, 0); Renderer2D::EndDraw(); @@ -194,6 +194,8 @@ namespace Nuake { if (result) return result; } + + return nullptr; } Ref UserInterface::GetNodeByIDRecurse(Ref node, const std::string& id)