From 4b7613a659c31aa7b1fc0fb34dec5bfd4c8f0257 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 27 Jan 2016 17:07:48 +0100 Subject: [PATCH 01/43] Sorted editor component dropdown and made it always be fully expanded to show as many components as possible --- include/Engine/Editor/EditorGUI.h | 2 ++ src/Engine/Editor/EditorGUI.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 973f6a90..c2cd1001 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "../Common.h" #include "../GLM.h" #include @@ -118,6 +119,7 @@ private: const std::string formatEntityName(EntityWrapper entity); GLuint tryLoadTexture(std::string filePath); void openModal(const std::string& modal); + static bool compareCharArray(const char* c1, const char* c2); // Entity file handling methods void entityImport(World* world); diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 1200ce34..0d747b86 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -234,10 +234,12 @@ void EditorGUI::drawComponents(EntityWrapper entity) componentTypes.push_back(pair.first.c_str()); } } + // Sort components in alphabetical order + std::sort(componentTypes.begin(), componentTypes.end(), compareCharArray); // Draw combo box ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() - 10.f); int selectedItem = -1; - if (ImGui::Combo("", &selectedItem, componentTypes.data(), componentTypes.size())) { + if (ImGui::Combo("", &selectedItem, componentTypes.data(), componentTypes.size(), componentTypes.size())) { if (selectedItem != -1) { if (m_OnComponentAttach != nullptr) { std::string chosenComponentType(componentTypes.at(selectedItem)); @@ -644,6 +646,11 @@ void EditorGUI::openModal(const std::string& modal) m_ModalsToOpen.insert(modal); } +bool EditorGUI::compareCharArray(const char* c1, const char* c2) +{ + return strcmp(c1, c2) < 0; +} + void EditorGUI::SetDirty(EntityWrapper entity) { EntityWrapper baseParent = entity; From c519ba2536247a36ad41f7b59eaeb1807bf0d03d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 27 Jan 2016 17:12:07 +0100 Subject: [PATCH 02/43] Component fields in the editor are now sorted in the order they're defined --- src/Engine/Editor/EditorGUI.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 0d747b86..01f15da9 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -285,9 +285,8 @@ bool EditorGUI::drawComponentNode(EntityWrapper entity, const ComponentInfo& ci) // Draw component fields ComponentWrapper& component = entity.World->GetComponent(entity.ID, ci.Name); - for (auto& kv : ci.Fields) { - const std::string& fieldName = kv.first; - const ComponentInfo::Field_t& field = kv.second; + for (auto& fieldName : ci.FieldsInOrder) { + const ComponentInfo::Field_t& field = ci.Fields.at(fieldName); // Draw the field widget based on its type bool dirty = drawComponentField(component, field); From 97cbc55223c7a12be33f13c13500031c949b06c7 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 27 Jan 2016 17:21:00 +0100 Subject: [PATCH 03/43] Some debug features for color corrections and glow strength fix. --- .../Rendering/DrawColorCorrectionPass.h | 4 +- resources/Schema/Entities/EditorTestWorld.xml | 149 ++++++++++-------- .../Shaders/DrawColorCorrection.frag.glsl | 4 +- resources/Shaders/ForwardPlus.frag.glsl | 2 +- .../Rendering/DrawColorCorrectionPass.cpp | 6 +- 5 files changed, 92 insertions(+), 73 deletions(-) diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index e9a7e281..f507b53c 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -7,6 +7,7 @@ #include "ShaderProgram.h" //#include "Util/UnorderedMapVec2.h" #include "Texture.h" +#include "imgui/imgui.h" class DrawColorCorrectionPass { @@ -23,7 +24,8 @@ private: ShaderProgram* m_ColorCorrectionProgram; Model* m_ScreenQuad; - GLfloat m_Exposure; + GLfloat m_Exposure = 1; + GLfloat m_Gamma = 2.2; }; #endif \ No newline at end of file diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 9565e2d4..b7baea28 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -43,7 +43,7 @@ - + @@ -85,7 +85,7 @@ Run - + 1 @@ -101,7 +101,7 @@ Walk - + 1 @@ -147,70 +147,6 @@ - - - - Models/NormalMapSphere.mesh - - - - - - - - - - - Models/SpecularMapSphere.mesh - - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - - - - - Models/IncandescenceMapSphere.mesh - - - - - - - @@ -227,7 +163,7 @@ - + @@ -284,6 +220,83 @@ + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 8d13992a..91ace0c7 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -3,6 +3,7 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; uniform float Exposure; +uniform float Gamma; in VertexData{ vec2 TextureCoordinate; @@ -12,7 +13,6 @@ out vec4 fragmentColor; void main() { - const float gamma = 2.2; vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); hdrColor += bloomColor; @@ -21,7 +21,7 @@ void main() vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); //gamme correction - result = pow(result, vec3(1.0 / gamma)); + result = pow(result, vec3(1.0 / Gamma)); fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index de672dd1..16dca034 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -160,7 +160,7 @@ void main() color_result += FillColor; } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - color_result += glowTexel; + color_result += glowTexel*3; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index ba9efe3e..0e3d3db5 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -5,7 +5,8 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer) m_Renderer = renderer; m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); - m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. + + //m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. InitializeShaderPrograms(); } @@ -21,6 +22,8 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) { + ImGui::DragFloat("Exposure", &m_Exposure, 0.01f, 0.f, 10.f, "%.2f", 1.f); + ImGui::DragFloat("Gamma", &m_Gamma, 0.01f, 0.f, 50.f, "%.2f", 1.f); //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); @@ -28,6 +31,7 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) m_ColorCorrectionProgram->Bind(); glClear(GL_COLOR_BUFFER_BIT); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), m_Gamma); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sceneTexture); From 65da634c71301458264d6cb34321634e43c05626 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 27 Jan 2016 17:45:25 +0100 Subject: [PATCH 04/43] File dropping into resource paths in the editor --- include/Engine/Editor/EditorGUI.h | 6 ++++- src/Engine/Editor/EditorGUI.cpp | 38 ++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index c2cd1001..00c823e9 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "../Common.h" #include "../GLM.h" #include @@ -19,6 +19,7 @@ #include "../Core/ResourceManager.h" #include "../Core/EPause.h" #include "../Core/EKeyDown.h" +#include "../Core/EFileDropped.h" #include "../Rendering/Texture.h" class EditorGUI @@ -96,6 +97,7 @@ private: WidgetMode m_CurrentWidgetMode = WidgetMode::Translate; std::set m_ModalsToOpen; std::map m_ModalData; + std::string m_DroppedFile = ""; // Callbacks OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; @@ -112,6 +114,8 @@ private: // Events EventRelay m_EKeyDown; bool OnKeyDown(const Events::KeyDown& e); + EventRelay m_EFileDropped; + bool OnFileDropped(const Events::FileDropped& e); // Utility functions boost::filesystem::path fileOpenDialog(); diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 01f15da9..a1791d4f 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -6,6 +6,7 @@ EditorGUI::EditorGUI(World* world, EventBroker* eventBroker) , m_EventBroker(eventBroker) { EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &EditorGUI::OnKeyDown); + EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorGUI::OnFileDropped); } void EditorGUI::Draw() @@ -168,10 +169,7 @@ bool EditorGUI::drawEntityNode(EntityWrapper entity) ImGui::Text(formatEntityName(entity).c_str()); ImGui::End(); } - }/* else if (m_CurrentlyDragging == entity) { - LOG_DEBUG("Stopped dragging %i", entity.ID); - m_CurrentlyDragging = EntityWrapper::Invalid; - }*/ + } // Entity context menu std::string contextMenuUniqueID = std::string("EntityContextMenu") + std::to_string(entity.ID); if (hovered && ImGui::IsMouseClicked(1)) { @@ -436,18 +434,31 @@ bool EditorGUI::drawComponentField_bool(ComponentWrapper &c, const ComponentInfo bool EditorGUI::drawComponentField_string(ComponentWrapper &c, const ComponentInfo::Field_t &field) { + bool result = false; + auto& val = c.Field(field.Name); + char tempString[1024]; // Let's just hope this is an sufficiently large buffer for strings :) tempString[1023] = '\0'; // Null terminator just in case the string is larger than the buffer // Copy the string into the buffer, taking the null terminator into account memcpy(tempString, val.c_str(), std::min(val.length() + 1, sizeof(tempString) - 1)); if (ImGui::InputText("", tempString, sizeof(tempString))) { val = std::string(tempString); - return true; - } else { - return false; + result = true; } - // TODO: Handle drag and drop of files + + // Handle file drag and drop + if (ImGui::IsItemHovered() && !m_DroppedFile.empty()) { + // Unset potential input focus or our newly set value will be overwritten! + if (ImGui::IsItemActive()) { + ImGui::SetActiveID(0, nullptr); + } + // Set the actual dropped value + val = m_DroppedFile; + m_DroppedFile = ""; + } + + return result; } void EditorGUI::drawModals() @@ -574,6 +585,17 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e) return true; } +bool EditorGUI::OnFileDropped(const Events::FileDropped& e) +{ + // Make a best effort to make the path relative to the working directory of the executable + m_DroppedFile = boost::filesystem::path(e.Path).lexically_relative(boost::filesystem::current_path()).string(); + // Compensate for Windows retardedness + std::replace(m_DroppedFile.begin(), m_DroppedFile.end(), '\\', '/'); + // Special case for when people drop from the asset folder instead of from the symlink to the asset folders in bin + boost::algorithm::replace_first(m_DroppedFile, "../assets/", ""); + return true; +} + boost::filesystem::path EditorGUI::fileOpenDialog() { namespace bfs = boost::filesystem; From 8bcafc1151d786b3fdedcb477e660cae8cbf204b Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 27 Jan 2016 18:07:05 +0100 Subject: [PATCH 05/43] WIP --- include/Engine/Rendering/IRenderer.h | 3 --- resources/Schema/Components.xsd | 1 + resources/Schema/Components/SceneLight.xml | 7 ++++++ resources/Schema/Components/SceneLight.xsd | 25 +++++++++++++++++++ resources/Schema/Types/Entity.xsd | 1 + .../Rendering/DrawColorCorrectionPass.cpp | 2 -- src/Engine/Rendering/RenderSystem.cpp | 10 ++++++++ 7 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 resources/Schema/Components/SceneLight.xml create mode 100644 resources/Schema/Components/SceneLight.xsd diff --git a/include/Engine/Rendering/IRenderer.h b/include/Engine/Rendering/IRenderer.h index 811ecd28..708b87a6 100644 --- a/include/Engine/Rendering/IRenderer.h +++ b/include/Engine/Rendering/IRenderer.h @@ -40,9 +40,6 @@ public: virtual void Draw(RenderFrame& rq) = 0; virtual PickData Pick(glm::vec2 screenCord) = 0; - - World* m_World; //Temp world, untill viktor merge. - protected: Rectangle m_Resolution = Rectangle::Rectangle(1280, 720); Rectangle m_ViewPortWidth = Rectangle::Rectangle(1280, 720); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index ab46b0ea..bb1fd770 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -11,6 +11,7 @@ + diff --git a/resources/Schema/Components/SceneLight.xml b/resources/Schema/Components/SceneLight.xml new file mode 100644 index 00000000..80b6b9f4 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xml @@ -0,0 +1,7 @@ + + + + true + 2.2 + 1 + \ No newline at end of file diff --git a/resources/Schema/Components/SceneLight.xsd b/resources/Schema/Components/SceneLight.xsd new file mode 100644 index 00000000..9f8a9705 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xsd @@ -0,0 +1,25 @@ + + + + + + Some settings for the scene lighting + + + + + Color of the ambient light + + + Wether the ambient light should be applied or not + + + Gamma correction for the scene + + + The exposure of the camera + + + + + \ No newline at end of file diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 99b90caa..028af9e6 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -31,6 +31,7 @@ + diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 0e3d3db5..9b9e2236 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -22,8 +22,6 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) { - ImGui::DragFloat("Exposure", &m_Exposure, 0.01f, 0.f, 10.f, "%.2f", 1.f); - ImGui::DragFloat("Gamma", &m_Gamma, 0.01f, 0.f, 50.f, "%.2f", 1.f); //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index a0912a45..98373a61 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -244,6 +244,16 @@ void RenderSystem::Update(double dt) RenderScene scene; scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); + + //auto cSceneLight = m_Renderer->m_World->GetComponents("SceneLight"); + //if (cSceneLight != nullptr) { + // m_Gamma = (double)(*cSceneLight->begin())["Gamma"]; + // m_Exposure = (double)(*cSceneLight->begin())["Exposure"]; + //} + + //scene.ambient + //scene.gamma + //scene.exponent fillModels(scene.OpaqueObjects, scene.TransparentObjects); fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); From 13f020ddf57378e378ae8c4c1b947d4b49dcd128 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 27 Jan 2016 18:06:33 +0100 Subject: [PATCH 06/43] Fixed #49 being able to parent an entity to itself, which resulted in infinite infinite loops everywhere! D: --- src/Engine/Core/World.cpp | 7 +++++++ src/Engine/Editor/EditorGUI.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 8b212d31..69c25f61 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -96,6 +96,13 @@ EntityID World::GetParent(EntityID entity) void World::SetParent(EntityID entity, EntityID parent) { + // Don't allow an entity to be a child to itself! + if (entity == parent) { + // HACK: We purposely don't check the whole hierarchy of children here, since it would be way too slow. + // This might result in infinite loops if an entity somehow ends up as a child. + return; + } + EntityID lastParent = m_EntityParents.at(entity); auto parentChildren = m_EntityChildren.equal_range(lastParent); for (auto it = parentChildren.first; it != parentChildren.second; it++) { diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index a1791d4f..c1f1683d 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -759,7 +759,7 @@ void EditorGUI::entityDelete(EntityWrapper entity) void EditorGUI::entityChangeParent(EntityWrapper entity, EntityWrapper parent) { - if (entity == parent) { + if (entity == parent || parent.IsChildOf(entity)) { return; } From 0c97ce7a4a29d84c2ec87d0ea8a29008757d0c40 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Fri, 29 Jan 2016 10:12:49 +0100 Subject: [PATCH 07/43] You can now DoubleJump! --- include/Game/Systems/PlayerMovementSystem.h | 2 ++ src/Game/Systems/PlayerMovementSystem.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index f39740ec..4fbb2c79 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -20,4 +20,6 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); + + bool m_DoubleJumped = false; }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 6eab02c5..868751f7 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -76,7 +76,13 @@ void PlayerMovementSystem::Update(double dt) ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } - if (controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { + if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !m_DoubleJumped)) { + if (velocity.y == 0.f) { + m_DoubleJumped = false; + } + else { + m_DoubleJumped = true; + } velocity.y += 4.f; } From 7987d4b27cabe927d75da234a0e201ec502b66ac Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Fri, 29 Jan 2016 12:06:14 +0100 Subject: [PATCH 08/43] Added AssaultDash and all its logic, including a doubletapkey. Doubletapkey could be made more generic. --- include/Game/Systems/PlayerMovementSystem.h | 16 +++++++ src/Game/Systems/PlayerMovementSystem.cpp | 52 +++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index f39740ec..554d174e 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -20,4 +20,20 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); + + double m_AssaultDashDoubleTapDeltaTime = 0.0f; + double m_AssaultDashCoolDownTimer = 0.0f; + double m_AssaultDashCoolDownMaxTimer = 3.0f; + ImGuiKey m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; + const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; + enum class AssaultDashDirection { + Left, + Right, + None + }; + AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + bool m_AssaultDashDoubleTapped = false; + bool m_PlayerIsDashing = false; + + void assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping); }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 6eab02c5..fe28ff8e 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -1,6 +1,6 @@ #include "Systems/PlayerMovementSystem.h" -PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) +PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) : System(world, eventBroker) , PureSystem("Player") { @@ -41,7 +41,9 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; - + //Assault Dash Check - + //TODO: check if playerclass is assault! + assaultDashCheck(controller->Movement(), dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); float wishSpeed; if (controller->Crouching()) { @@ -71,12 +73,15 @@ void PlayerMovementSystem::Update(double dt) static float surfaceFriction = 5.f; ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; - accelerationSpeed = glm::min(accelerationSpeed, addSpeed); + //if doubleTapped do Assault Dash - but only boost maximum 50.0f + float doubleTapDashBoost = m_AssaultDashDoubleTapped ? 20.0f : 1.0f; + accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } - if (controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { + //you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air + if (!m_PlayerIsDashing && controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { velocity.y += 4.f; } @@ -95,6 +100,7 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cAnimation = playerModel["Animation"]; float movementLength = glm::length(groundVelocity); + //TODO: add assault dash animation here if (glm::length(controller->Movement()) > 0.f) { if (controller->Crouching()) { cAnimation["Name"] = "Crouch Walk"; @@ -158,3 +164,41 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) return true; } +void PlayerMovementSystem::assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping) { + m_AssaultDashDoubleTapDeltaTime += dt; + m_AssaultDashCoolDownTimer -= dt; + //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + m_PlayerIsDashing = true; + } else { + m_PlayerIsDashing = false; + } + //reset the DoubleTapped state in case we recently doubleTapped + if (m_AssaultDashDoubleTapped) { + m_AssaultDashDoubleTapped = false; + } + //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash + if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != ImGuiKey_RightArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = ImGuiKey_RightArrow; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Right; + } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != ImGuiKey_LeftArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = ImGuiKey_LeftArrow; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Left; + } else { + m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; + } +} From d3b1053f21cd522f39fa2e68e938b6be22dad6ed Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 10:29:59 +0100 Subject: [PATCH 09/43] Fixes #59 --- src/Engine/Editor/EditorSystem.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 6ffd0e24..16023b18 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -82,11 +82,17 @@ void EditorSystem::Update(double dt) void EditorSystem::Enable() { m_EditorCameraInputController->Enable(); + m_EventBroker->Publish(Events::UnlockMouse()); - Events::SetCamera e; - e.CameraEntity = m_EditorCamera; - m_EventBroker->Publish(e); - (glm::vec3&)m_EditorCamera["Transform"]["Position"] = Transform::AbsolutePosition(m_ActualCamera); + + // Enable editor camera + Events::SetCamera eSetCamera; + eSetCamera.CameraEntity = m_EditorCamera; + m_EventBroker->Publish(eSetCamera); + if (m_ActualCamera.Valid()) { + (glm::vec3&)m_EditorCamera["Transform"]["Position"] = Transform::AbsolutePosition(m_ActualCamera); + } + m_Enabled = true; } From ee922003005b56917d14fa33dceb153ef2bd1314 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 10:30:34 +0100 Subject: [PATCH 10/43] Improved editor pause logic. Editor now pauses when it's enabled and makes sure UI is up to date with the current state. --- include/Engine/Editor/EditorGUI.h | 5 +++++ src/Engine/Editor/EditorGUI.cpp | 24 ++++++++++++++++++++---- src/Engine/Editor/EditorSystem.cpp | 5 +++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 00c823e9..8bd9bbab 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -98,6 +98,7 @@ private: std::set m_ModalsToOpen; std::map m_ModalData; std::string m_DroppedFile = ""; + bool m_Paused = false; // Callbacks OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; @@ -116,6 +117,10 @@ private: bool OnKeyDown(const Events::KeyDown& e); EventRelay m_EFileDropped; bool OnFileDropped(const Events::FileDropped& e); + EventRelay m_EPause; + bool OnPause(const Events::Pause& e); + EventRelay m_EResume; + bool OnResume(const Events::Resume& e); // Utility functions boost::filesystem::path fileOpenDialog(); diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index c1f1683d..007e845d 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -7,6 +7,8 @@ EditorGUI::EditorGUI(World* world, EventBroker* eventBroker) { EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &EditorGUI::OnKeyDown); EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorGUI::OnFileDropped); + EVENT_SUBSCRIBE_MEMBER(m_EPause, &EditorGUI::OnPause); + EVENT_SUBSCRIBE_MEMBER(m_EResume, &EditorGUI::OnResume); } void EditorGUI::Draw() @@ -58,19 +60,17 @@ void EditorGUI::drawTools() // Play button ImGui::SameLine(); static bool paused = false; - if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { + if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { Events::Resume e; e.World = m_World; m_EventBroker->Publish(e); - paused = false; } // Pause button ImGui::SameLine(); - if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Pause.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { + if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Pause.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { Events::Pause e; e.World = m_World; m_EventBroker->Publish(e); - paused = true; } ImGui::End(); @@ -596,6 +596,22 @@ bool EditorGUI::OnFileDropped(const Events::FileDropped& e) return true; } +bool EditorGUI::OnPause(const Events::Pause& e) +{ + if (e.World == m_World) { + m_Paused = true; + } + return true; +} + +bool EditorGUI::OnResume(const Events::Resume& e) +{ + if (e.World == m_World) { + m_Paused = false; + } + return true; +} + boost::filesystem::path EditorGUI::fileOpenDialog() { namespace bfs = boost::filesystem; diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 16023b18..83963531 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -93,6 +93,11 @@ void EditorSystem::Enable() (glm::vec3&)m_EditorCamera["Transform"]["Position"] = Transform::AbsolutePosition(m_ActualCamera); } + // Pause the world we're editing + Events::Pause ePause; + ePause.World = m_World; + m_EventBroker->Publish(ePause); + m_Enabled = true; } From 7054822be20f1ff83f0693e2c944aaa82df0f18a Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 11:12:03 +0100 Subject: [PATCH 11/43] SceneLight component now working --- .../Rendering/DrawColorCorrectionPass.h | 4 +--- include/Engine/Rendering/RenderQueue.h | 4 ++++ resources/Schema/Entities/EditorTestWorld.xml | 21 ++++++++++++------- resources/Shaders/ForwardPlus.frag.glsl | 5 ++--- .../Rendering/DrawColorCorrectionPass.cpp | 6 +++--- src/Engine/Rendering/DrawFinalPass.cpp | 9 ++++++++ src/Engine/Rendering/RenderSystem.cpp | 15 ++++++------- src/Engine/Rendering/Renderer.cpp | 4 ++-- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index f507b53c..fcde73d7 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -17,15 +17,13 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; ShaderProgram* m_ColorCorrectionProgram; Model* m_ScreenQuad; - GLfloat m_Exposure = 1; - GLfloat m_Gamma = 2.2; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 57371146..af9d928e 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -26,6 +26,7 @@ struct RenderScene std::list> DirectionalLightJobs; Rectangle Viewport; bool ClearDepth = false; + glm::vec4 AmbientColor; void Clear() { @@ -40,6 +41,9 @@ struct RenderScene struct RenderFrame { public: + //TODO: Getters + GLfloat Gamma = 2.2f; + GLfloat Exposure = 1.f; void Add(RenderScene &scene) { diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index b7baea28..de65f736 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -18,7 +18,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -85,7 +85,7 @@ Run - + 1 @@ -101,7 +101,7 @@ Walk - + 1 @@ -163,7 +163,7 @@ - + @@ -227,7 +227,7 @@ - + @@ -259,7 +259,7 @@ - + @@ -299,6 +299,13 @@ + + + + + + + diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 16dca034..d9a2f7d5 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -7,6 +7,7 @@ uniform vec4 Color; uniform vec4 DiffuseColor; uniform vec2 ScreenDimensions; uniform vec4 FillColor; +uniform vec4 AmbientColor; uniform float FillPercentage; layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; @@ -60,8 +61,6 @@ in VertexData{ out vec4 sceneColor; out vec4 bloomColor; -vec4 scene_ambient = vec4(0.3,0.3,0.3,1); - struct LightResult { vec4 Diffuse; vec4 Specular; @@ -128,7 +127,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = scene_ambient; + totalLighting.Diffuse = AmbientColor; int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 9b9e2236..95de26e2 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -20,7 +20,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); @@ -28,8 +28,8 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); glClear(GL_COLOR_BUFFER_BIT); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), m_Gamma); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sceneTexture); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 48ea4144..89538c9a 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -141,18 +141,22 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); + GLERROR("DrawFinalPass::Model: 1"); } else { auto modelJob = std::dynamic_pointer_cast(job); if (modelJob) { //bind forward program m_ForwardPlusProgram->Bind(); + GLERROR("DrawFinalPass::Model: 2"); //bind uniforms BindModelUniforms(forwardHandle, modelJob, scene); + GLERROR("DrawFinalPass::Model: 3"); //bind textures BindModelTextures(modelJob); + GLERROR("DrawFinalPass::Model: 4"); if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -161,6 +165,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } + GLERROR("DrawFinalPass::Model: 5"); //draw glBindVertexArray(modelJob->Model->VAO); @@ -175,6 +180,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, GL_FALSE, glm::value_ptr(scene.AmbientColor)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); @@ -196,8 +202,10 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); @@ -205,6 +213,7 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrDiffuseColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + } diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 98373a61..b51ab7f8 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -240,20 +240,17 @@ void RenderSystem::Update(double dt) m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera)); } - RenderScene scene; scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); - //auto cSceneLight = m_Renderer->m_World->GetComponents("SceneLight"); - //if (cSceneLight != nullptr) { - // m_Gamma = (double)(*cSceneLight->begin())["Gamma"]; - // m_Exposure = (double)(*cSceneLight->begin())["Exposure"]; - //} + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr) { + m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; + m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; + scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; + } - //scene.ambient - //scene.gamma - //scene.exponent fillModels(scene.OpaqueObjects, scene.TransparentObjects); fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 55cd8b03..0ec593df 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -120,8 +120,8 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); - if(m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture()); + if (m_DebugTextureToDraw == 0) { + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); From 5bfcffc142e753b7cfb92b735b294ac8d33067de Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 11:56:21 +0100 Subject: [PATCH 12/43] Fixed widget movement calculations going weird when world origin wasn't on screen --- src/Engine/Editor/EditorWidgetSystem.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Engine/Editor/EditorWidgetSystem.cpp b/src/Engine/Editor/EditorWidgetSystem.cpp index 8352c5c1..286aff97 100644 --- a/src/Engine/Editor/EditorWidgetSystem.cpp +++ b/src/Engine/Editor/EditorWidgetSystem.cpp @@ -23,14 +23,17 @@ void EditorWidgetSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper Events::WidgetDelta e; + // Widget axes should have a common parent EntityWrapper moveEntity = entity.Parent(); if (!moveEntity.Valid()) { moveEntity = entity; } + glm::vec3 moveEntityPos = moveEntity["Transform"]["Position"]; auto camera = m_PickData.Camera; - glm::vec3 axis = cEditorWidget["Axis"]; - glm::vec2 axisScreen = camera->WorldToScreen(axis, m_Renderer->GetViewPortSize()) - camera->WorldToScreen(glm::vec3(0, 0, 0), m_Renderer->GetViewPortSize()); + glm::vec3 axis = (glm::vec3)cEditorWidget["Axis"]; + glm::vec2 axisScreen = camera->WorldToScreen(moveEntityPos + axis, m_Renderer->GetViewPortSize()) - camera->WorldToScreen(moveEntityPos, m_Renderer->GetViewPortSize()); + ImGui::Text("axisScreen: (%f, %f)", axisScreen.x, axisScreen.y); float dot = glm::dot(m_MouseDelta, glm::normalize(axisScreen)) / glm::length(axisScreen); glm::vec3 worldMovement = dot * axis; From a22bc00d46d4cf1dee4481edab3cfc36b4ac9961 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 12:01:24 +0100 Subject: [PATCH 13/43] *cough* --- include/Engine/Rendering/IRenderer.h | 18 +++++++----------- src/Engine/Editor/EditorWidgetSystem.cpp | 2 +- src/Engine/Rendering/DrawBloomPass.cpp | 4 ++-- src/Engine/Rendering/DrawFinalPass.cpp | 8 ++++---- src/Engine/Rendering/LightCullingPass.cpp | 10 +++++----- src/Engine/Rendering/PickingPass.cpp | 4 ++-- src/Engine/Rendering/Renderer.cpp | 7 +++---- src/Game/Systems/WeaponSystem.cpp | 2 +- 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/include/Engine/Rendering/IRenderer.h b/include/Engine/Rendering/IRenderer.h index 811ecd28..b399aefa 100644 --- a/include/Engine/Rendering/IRenderer.h +++ b/include/Engine/Rendering/IRenderer.h @@ -25,27 +25,23 @@ class IRenderer { public: GLFWwindow* Window() const { return m_Window; } - //Returns screensize including window border and header + //Returns screen size including window border and header Rectangle Resolution() const { return m_Resolution; } - void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; } + virtual void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; } bool Fullscreen() { return m_Fullscreen; } - void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; } + virtual void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; } bool VSYNC() const { return m_VSYNC; } - void SetVSYNC(bool vsync) { m_VSYNC = vsync; } - //Returns screensize excluding window border and header - Rectangle GetViewPortSize() const { return m_ViewPortWidth; } - void SetViewPortSize(const Rectangle& viewportWidth) { m_ViewPortWidth = viewportWidth; } + virtual void SetVSYNC(bool vsync) { m_VSYNC = vsync; } + //Returns screen size excluding window border and header + Rectangle GetViewportSize() const { return m_ViewportSize; } virtual void Initialize() = 0; virtual void Update(double dt) = 0; virtual void Draw(RenderFrame& rq) = 0; virtual PickData Pick(glm::vec2 screenCord) = 0; - - World* m_World; //Temp world, untill viktor merge. - protected: Rectangle m_Resolution = Rectangle::Rectangle(1280, 720); - Rectangle m_ViewPortWidth = Rectangle::Rectangle(1280, 720); + Rectangle m_ViewportSize = Rectangle::Rectangle(1280, 720); bool m_Fullscreen = false; bool m_VSYNC = false; int m_GLVersion[2]; diff --git a/src/Engine/Editor/EditorWidgetSystem.cpp b/src/Engine/Editor/EditorWidgetSystem.cpp index 286aff97..44d3796a 100644 --- a/src/Engine/Editor/EditorWidgetSystem.cpp +++ b/src/Engine/Editor/EditorWidgetSystem.cpp @@ -32,7 +32,7 @@ void EditorWidgetSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper auto camera = m_PickData.Camera; glm::vec3 axis = (glm::vec3)cEditorWidget["Axis"]; - glm::vec2 axisScreen = camera->WorldToScreen(moveEntityPos + axis, m_Renderer->GetViewPortSize()) - camera->WorldToScreen(moveEntityPos, m_Renderer->GetViewPortSize()); + glm::vec2 axisScreen = camera->WorldToScreen(moveEntityPos + axis, m_Renderer->GetViewportSize()) - camera->WorldToScreen(moveEntityPos, m_Renderer->GetViewportSize()); ImGui::Text("axisScreen: (%f, %f)", axisScreen.x, axisScreen.y); float dot = glm::dot(m_MouseDelta, glm::normalize(axisScreen)) / glm::length(axisScreen); glm::vec3 worldMovement = dot * axis; diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index efd206d3..c5c4060c 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -34,12 +34,12 @@ void DrawBloomPass::InitializeShaderPrograms() void DrawBloomPass::InitializeBuffers() { - GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); m_GaussianFrameBuffer_horiz.Generate(); - GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); m_GaussianFrameBuffer_vert.Generate(); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index ee40eb24..a8a87dbd 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -19,11 +19,11 @@ void DrawFinalPass::InitializeFrameBuffers() { glGenRenderbuffers(1, &m_DepthBuffer); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); @@ -125,7 +125,7 @@ void DrawFinalPass::Draw(RenderScene& scene) glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height); + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); //TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); diff --git a/src/Engine/Rendering/LightCullingPass.cpp b/src/Engine/Rendering/LightCullingPass.cpp index 46a17286..5e6da64d 100644 --- a/src/Engine/Rendering/LightCullingPass.cpp +++ b/src/Engine/Rendering/LightCullingPass.cpp @@ -25,8 +25,8 @@ void LightCullingPass::GenerateNewFrustum(RenderScene& scene) glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO); glUniformMatrix4fv(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "P"), 1, false, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height); - glDispatchCompute((int)(m_Renderer->GetViewPortSize().Width/(TILE_SIZE*TILE_SIZE) + 1), (int)(m_Renderer->GetViewPortSize().Height/(TILE_SIZE*TILE_SIZE) + 1), 1); + glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + glDispatchCompute((int)(m_Renderer->GetViewportSize().Width/(TILE_SIZE*TILE_SIZE) + 1), (int)(m_Renderer->GetViewportSize().Height/(TILE_SIZE*TILE_SIZE) + 1), 1); GLERROR("CalculateFrustum Error: End"); } @@ -40,7 +40,7 @@ void LightCullingPass::OnResolutionChange() void LightCullingPass::SetSSBOSizes() { - m_NumberOfTiles = (int)(m_Renderer->GetViewPortSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewPortSize().Height/TILE_SIZE); + m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE); m_Frustums = new Frustum[m_NumberOfTiles]; m_LightGrid = new LightGrid[m_NumberOfTiles]; @@ -67,14 +67,14 @@ void LightCullingPass::CullLights(RenderScene& scene) glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); m_LightCullProgram->Bind(); - glUniform2f(glGetUniformLocation(m_LightCullProgram->GetHandle(), "ScreenDimensions"), m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height); + glUniform2f(glGetUniformLocation(m_LightCullProgram->GetHandle(), "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glUniformMatrix4fv(glGetUniformLocation(m_LightCullProgram->GetHandle(), "V"), 1, false, glm::value_ptr(scene.Camera->ViewMatrix())); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightGridSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, m_LightOffsetSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightIndexSSBO); - glDispatchCompute(glm::ceil(m_Renderer->GetViewPortSize().Width/ TILE_SIZE), glm::ceil(m_Renderer->GetViewPortSize().Height / TILE_SIZE), 1); + glDispatchCompute(glm::ceil(m_Renderer->GetViewportSize().Width/ TILE_SIZE), glm::ceil(m_Renderer->GetViewportSize().Height / TILE_SIZE), 1); GLERROR("CullLights Error: End"); } diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 3a7d5bfd..aaaf9678 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -18,14 +18,14 @@ PickingPass::~PickingPass() void PickingPass::InitializeTextures() { GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, - glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); } void PickingPass::InitializeFrameBuffers() { glGenRenderbuffers(1, &m_DepthBuffer); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_PickingBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 08b30afa..741d2b0a 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -59,10 +59,9 @@ void Renderer::InitializeWindow() exit(EXIT_FAILURE); } - int res[2]; - glfwGetWindowSize(m_Window, &res[0], &res[1]); - SetViewPortSize(Rectangle::Rectangle(res[0], res[1])); - + int windowSize[2]; + glfwGetWindowSize(m_Window, &windowSize[0], &windowSize[1]); + m_ViewportSize = Rectangle(windowSize[0], windowSize[1]); } void Renderer::InitializeShaders() diff --git a/src/Game/Systems/WeaponSystem.cpp b/src/Game/Systems/WeaponSystem.cpp index 4b4b8da2..1613cb7a 100644 --- a/src/Game/Systems/WeaponSystem.cpp +++ b/src/Game/Systems/WeaponSystem.cpp @@ -104,7 +104,7 @@ bool WeaponSystem::OnShoot(Events::Shoot& eShoot) // Screen center, based on current resolution! // TODO: check if player has enough ammo and if weapon has a cooldown or not - Rectangle screenResolution = m_Renderer->GetViewPortSize(); + Rectangle screenResolution = m_Renderer->GetViewportSize(); glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2); // TODO: check if player has enough ammo and if weapon has a cooldown or not From 65f5bc673fdfe8856eb58137272b90cf8c6b5d02 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 15:47:56 +0100 Subject: [PATCH 14/43] Functional translation widget in global and local space --- assets | 2 +- include/Engine/Editor/EditorGUI.h | 19 ++++++ include/Engine/Editor/EditorSystem.h | 2 + resources/DefaultInput.ini | 4 -- src/Engine/Editor/EditorGUI.cpp | 87 +++++++++++++++++++++--- src/Engine/Editor/EditorSystem.cpp | 29 ++++++-- src/Engine/Editor/EditorWidgetSystem.cpp | 13 ++-- 7 files changed, 131 insertions(+), 25 deletions(-) diff --git a/assets b/assets index e4dc9529..091ad5c0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit e4dc9529f2178d373808ddf487165fa50a641a78 +Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 8bd9bbab..7a0289c6 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -19,6 +19,7 @@ #include "../Core/ResourceManager.h" #include "../Core/EPause.h" #include "../Core/EKeyDown.h" +#include "../Core/ELockMouse.h" #include "../Core/EFileDropped.h" #include "../Rendering/Texture.h" @@ -34,6 +35,12 @@ public: Scale }; + enum class WidgetSpace + { + Global, + Local + }; + void Draw(); void SelectEntity(EntityWrapper entity); @@ -75,6 +82,9 @@ public: // Called when the user selects a widget mode. typedef std::function OnWidgetMode_t; void SetWidgetModeCallback(OnWidgetMode_t f) { m_OnWidgetMode = f; } + // Called when the user selects a widget space. + typedef std::function OnWidgetSpace_t; + void SetWidgetSpaceCallback(OnWidgetSpace_t f) { m_OnWidgetSpace = f; } private: World* m_World; @@ -95,10 +105,12 @@ private: EntityWrapper m_CurrentlyDragging = EntityWrapper::Invalid; std::string m_LastErrorMessage; WidgetMode m_CurrentWidgetMode = WidgetMode::Translate; + WidgetSpace m_CurrentWidgetSpace = WidgetSpace::Global; std::set m_ModalsToOpen; std::map m_ModalData; std::string m_DroppedFile = ""; bool m_Paused = false; + bool m_MouseLocked = false; // Callbacks OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; @@ -111,6 +123,7 @@ private: OnComponentAttach_t m_OnComponentAttach = nullptr; OnComponentDelete_t m_OnComponentDelete = nullptr; OnWidgetMode_t m_OnWidgetMode = nullptr; + OnWidgetSpace_t m_OnWidgetSpace = nullptr; // Events EventRelay m_EKeyDown; @@ -121,6 +134,10 @@ private: bool OnPause(const Events::Pause& e); EventRelay m_EResume; bool OnResume(const Events::Resume& e); + EventRelay m_ELockMouse; + bool OnLockMouse(const Events::LockMouse& e); + EventRelay m_EUnlockMouse; + bool OnUnlockMouse(const Events::UnlockMouse& e); // Utility functions boost::filesystem::path fileOpenDialog(); @@ -128,6 +145,8 @@ private: const std::string formatEntityName(EntityWrapper entity); GLuint tryLoadTexture(std::string filePath); void openModal(const std::string& modal); + void setWidgetMode(WidgetMode mode); + void toggleWidgetSpace(); static bool compareCharArray(const char* c1, const char* c2); // Entity file handling methods diff --git a/include/Engine/Editor/EditorSystem.h b/include/Engine/Editor/EditorSystem.h index 2db24ba3..accf66e4 100644 --- a/include/Engine/Editor/EditorSystem.h +++ b/include/Engine/Editor/EditorSystem.h @@ -41,6 +41,7 @@ private: double m_LastTime = 0.f; bool m_Enabled = true; EditorGUI::WidgetMode m_WidgetMode = EditorGUI::WidgetMode::Translate; + EditorGUI::WidgetSpace m_WidgetSpace = EditorGUI::WidgetSpace::Global; EntityWrapper m_Widget = EntityWrapper::Invalid; EntityWrapper m_CurrentSelection = EntityWrapper::Invalid; @@ -57,6 +58,7 @@ private: void OnEntityChangeName(EntityWrapper entity, const std::string& name); void OnComponentAttach(EntityWrapper entity, const std::string& componentType); void OnComponentDelete(EntityWrapper entity, const std::string& componentType); + void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace); // Events EventRelay m_EMousePress; diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index d07ed6a3..a3f7d166 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -15,10 +15,6 @@ Space=Jump LeftControl=Crouch LeftShift=Sprint F1=ToggleEditor -1=EditorToolMove -2=EditorToolRotate -3=EditorToolScale -X=EditorToggleTransformSpace C=ConnectToServer N=SwitchToServer M=SwitchToClient diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 007e845d..06938064 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -9,6 +9,8 @@ EditorGUI::EditorGUI(World* world, EventBroker* eventBroker) EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorGUI::OnFileDropped); EVENT_SUBSCRIBE_MEMBER(m_EPause, &EditorGUI::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &EditorGUI::OnResume); + EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &EditorGUI::OnLockMouse); + EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &EditorGUI::OnUnlockMouse); } void EditorGUI::Draw() @@ -40,26 +42,49 @@ void EditorGUI::drawTools() return; } + // Widget modes createWidgetToolButton(WidgetMode::Translate); if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Translate"); + ImGui::SetTooltip("Translate (W)"); } ImGui::SameLine(); createWidgetToolButton(WidgetMode::Rotate); if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Rotate"); + ImGui::SetTooltip("Rotate (E)"); } ImGui::SameLine(); createWidgetToolButton(WidgetMode::Scale); if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("Scale"); + ImGui::SetTooltip("Scale (R)"); } + + ImGui::SameLine(); + ImGui::ItemSize(ImVec2(5, 0)); + + // Widget space + ImGui::SameLine(); + GLuint spaceTexture = 0; + if (m_CurrentWidgetSpace == WidgetSpace::Global) { + spaceTexture = tryLoadTexture("Textures/Icons/Global.png"); + } else if (m_CurrentWidgetSpace == WidgetSpace::Local) { + spaceTexture = tryLoadTexture("Textures/Icons/Local.png"); + } + if (ImGui::ImageButton((void*)spaceTexture, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { + toggleWidgetSpace(); + } + if (ImGui::IsItemHovered()) { + if (m_CurrentWidgetSpace == WidgetSpace::Global) { + ImGui::SetTooltip("Widget space: Global (X)"); + } else if (m_CurrentWidgetSpace == WidgetSpace::Local) { + ImGui::SetTooltip("Widget space: Local (X)"); + } + } + ImGui::SameLine(); ImGui::ItemSize(ImVec2(5, 0)); // Play button ImGui::SameLine(); - static bool paused = false; if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { Events::Resume e; e.World = m_World; @@ -549,10 +574,7 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode) (m_CurrentWidgetMode == mode) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1) ) ) { - if (m_OnWidgetMode != nullptr) { - m_OnWidgetMode(mode); - } - m_CurrentWidgetMode = mode; + setWidgetMode(mode); } } @@ -582,6 +604,22 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e) } } + if (!m_MouseLocked) { + if (e.KeyCode == GLFW_KEY_W) { + setWidgetMode(WidgetMode::Translate); + } + if (e.KeyCode == GLFW_KEY_E) { + setWidgetMode(WidgetMode::Rotate); + } + if (e.KeyCode == GLFW_KEY_R) { + setWidgetMode(WidgetMode::Scale); + } + + if (e.KeyCode == GLFW_KEY_X) { + toggleWidgetSpace(); + } + } + return true; } @@ -612,6 +650,18 @@ bool EditorGUI::OnResume(const Events::Resume& e) return true; } +bool EditorGUI::OnLockMouse(const Events::LockMouse& e) +{ + m_MouseLocked = true; + return true; +} + +bool EditorGUI::OnUnlockMouse(const Events::UnlockMouse& e) +{ + m_MouseLocked = false; + return true; +} + boost::filesystem::path EditorGUI::fileOpenDialog() { namespace bfs = boost::filesystem; @@ -683,6 +733,27 @@ void EditorGUI::openModal(const std::string& modal) m_ModalsToOpen.insert(modal); } +void EditorGUI::setWidgetMode(WidgetMode mode) +{ + if (m_OnWidgetMode != nullptr) { + m_OnWidgetMode(mode); + } + m_CurrentWidgetMode = mode; +} + +void EditorGUI::toggleWidgetSpace() +{ + if (m_CurrentWidgetSpace == WidgetSpace::Global) { + m_CurrentWidgetSpace = WidgetSpace::Local; + } else if (m_CurrentWidgetSpace == WidgetSpace::Local) { + m_CurrentWidgetSpace = WidgetSpace::Global; + } + + if (m_OnWidgetSpace != nullptr) { + m_OnWidgetSpace(m_CurrentWidgetSpace); + } +} + bool EditorGUI::compareCharArray(const char* c1, const char* c2) { return strcmp(c1, c2) < 0; diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 83963531..ccbc1b48 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -31,6 +31,7 @@ EditorSystem::EditorSystem(World* world, EventBroker* eventBroker, IRenderer* re m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1)); + m_EditorGUI->SetWidgetSpaceCallback(std::bind(&EditorSystem::OnWidgetSpace, this, std::placeholders::_1)); EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorSystem::OnMousePress); EVENT_SUBSCRIBE_MEMBER(m_EWidgetDelta, &EditorSystem::OnWidgetDelta); @@ -65,7 +66,12 @@ void EditorSystem::Update(double dt) m_EditorStats->Draw(actualDelta); if (m_CurrentSelection.Valid() && m_Widget.Valid()) { - (glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID); + (glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection); + if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) { + (glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection); + } else { + (glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0); + } } m_EditorWorldSystemPipeline->Update(actualDelta); @@ -165,6 +171,11 @@ void EditorSystem::OnComponentDelete(EntityWrapper entity, const std::string& co } } +void EditorSystem::OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace) +{ + m_WidgetSpace = widgetSpace; +} + bool EditorSystem::OnMousePress(const Events::MousePress& e) { ImGuiIO& io = ImGui::GetIO(); @@ -181,12 +192,18 @@ bool EditorSystem::OnMousePress(const Events::MousePress& e) bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e) { if (m_CurrentSelection.Valid()) { - glm::quat parentOrientation; - EntityWrapper parent = m_CurrentSelection.Parent(); - if (parent.Valid()) { - parentOrientation = glm::inverse(Transform::AbsoluteOrientation(parent.World, parent.ID)); + if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) { + glm::quat parentOrientation; + EntityWrapper parent = m_CurrentSelection.Parent(); + if (parent.Valid()) { + parentOrientation = glm::inverse(Transform::AbsoluteOrientation(parent)); + } + (glm::vec3&)m_CurrentSelection["Transform"]["Position"] += parentOrientation * e.Translation; + } else if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) { + glm::quat selectionOri = glm::quat((glm::vec3)m_CurrentSelection["Transform"]["Orientation"]); + glm::vec3 localTranslation = selectionOri * e.Translation; + (glm::vec3&)m_CurrentSelection["Transform"]["Position"] += localTranslation; } - (glm::vec3&)m_CurrentSelection["Transform"]["Position"] += parentOrientation * e.Translation; m_EditorGUI->SetDirty(m_CurrentSelection); } return true; diff --git a/src/Engine/Editor/EditorWidgetSystem.cpp b/src/Engine/Editor/EditorWidgetSystem.cpp index 44d3796a..7c20a7c7 100644 --- a/src/Engine/Editor/EditorWidgetSystem.cpp +++ b/src/Engine/Editor/EditorWidgetSystem.cpp @@ -24,16 +24,17 @@ void EditorWidgetSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper Events::WidgetDelta e; // Widget axes should have a common parent - EntityWrapper moveEntity = entity.Parent(); - if (!moveEntity.Valid()) { - moveEntity = entity; + EntityWrapper widgetBase = entity.Parent(); + if (!widgetBase.Valid()) { + widgetBase = entity; } - glm::vec3 moveEntityPos = moveEntity["Transform"]["Position"]; + glm::vec3 widgetBasePos = widgetBase["Transform"]["Position"]; + glm::quat widgetBaseOri = glm::quat((glm::vec3)widgetBase["Transform"]["Orientation"]); auto camera = m_PickData.Camera; glm::vec3 axis = (glm::vec3)cEditorWidget["Axis"]; - glm::vec2 axisScreen = camera->WorldToScreen(moveEntityPos + axis, m_Renderer->GetViewportSize()) - camera->WorldToScreen(moveEntityPos, m_Renderer->GetViewportSize()); - ImGui::Text("axisScreen: (%f, %f)", axisScreen.x, axisScreen.y); + glm::vec3 axisOriented = widgetBaseOri * axis; + glm::vec2 axisScreen = camera->WorldToScreen(widgetBasePos + axisOriented, m_Renderer->GetViewportSize()) - camera->WorldToScreen(widgetBasePos, m_Renderer->GetViewportSize()); float dot = glm::dot(m_MouseDelta, glm::normalize(axisScreen)) / glm::length(axisScreen); glm::vec3 worldMovement = dot * axis; From 0a43f8104e73ab3962dcd4bec4f7ae7a052b42bb Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 16:31:01 +0100 Subject: [PATCH 15/43] Added _CRT_SECURE_NO_WARNINGS definition compiling with MSVC --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43286658..b97bf8df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") elseif(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() #set(BUILD_SHARED_LIBS FALSE) From 53cae25eb2e23a209c821b53854ea3861ddca45b Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 16:56:55 +0100 Subject: [PATCH 16/43] WIP on widget fuckery --- include/Engine/Rendering/Util/GLError.h | 2 +- resources/Shaders/ExplosionEffect.geom.glsl | 12 ++- resources/Shaders/ForwardPlus.frag.glsl | 6 +- resources/Shaders/ForwardPlus.vert.glsl | 2 +- src/Engine/Editor/EditorRenderSystem.cpp | 2 +- .../Rendering/DrawColorCorrectionPass.cpp | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 75 +++++++++++++++---- src/Engine/Rendering/FrameBuffer.cpp | 7 -- 8 files changed, 76 insertions(+), 32 deletions(-) diff --git a/include/Engine/Rendering/Util/GLError.h b/include/Engine/Rendering/Util/GLError.h index 754623d1..2b244e1c 100644 --- a/include/Engine/Rendering/Util/GLError.h +++ b/include/Engine/Rendering/Util/GLError.h @@ -9,7 +9,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig GLenum error = glGetError(); if (error != GL_NO_ERROR) { - _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s, %i, %s", info, error, gluErrorString(error)); + _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s\nError code: %i, %s\n", info, error, gluErrorString(error)); return true; } diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index cb91b545..34e6230d 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -17,6 +17,8 @@ uniform bool ExponentialAccelaration; in VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; }Input[]; @@ -24,6 +26,8 @@ in VertexData{ out VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; }Output; @@ -132,6 +136,8 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -154,7 +160,7 @@ void main() // if explosion color should be affected by distance instead of time... if (ColorByDistance == true) { - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = vec4(1.0); } else { @@ -168,7 +174,9 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; - + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; + // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; EmitVertex(); diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d9a2f7d5..025068f7 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -14,7 +14,6 @@ layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; - #define TILE_SIZE 16 struct LightSource { @@ -149,8 +148,9 @@ void main() totalLighting.Specular += light_result.Specular; } - - vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; + vec4 color_result = Color * diffuseTexel * DiffuseColor * Input.ExplosionColor; + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 1a7cca12..4e1f8734 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -41,5 +41,5 @@ void main() Output.Normal = vec3(M * vec4(Normal, 0.0)); Output.Tangent = vec3(M * vec4(Tangent, 0.0)); Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = vec4(1.0); } \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 898eac9d..d1b9083c 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -49,7 +49,7 @@ void EditorRenderSystem::Update(double dt) glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); for (auto matGroup : model->MaterialGroups()) { std::shared_ptr modelJob = std::make_shared(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f); - if(cModel["Transparent"]) { + if (cModel["Transparent"]) { scene.TransparentObjects.push_back(modelJob); } else { scene.OpaqueObjects.push_back(modelJob); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 95de26e2..45401bce 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -27,7 +27,7 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - glClear(GL_COLOR_BUFFER_BIT); + //glClear(GL_COLOR_BUFFER_BIT); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 89538c9a..4fde4eae 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -44,6 +44,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor"); m_ForwardPlusProgram->Link(); + GLERROR("Creating forward+ program"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); @@ -53,11 +54,12 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor"); m_ExplosionEffectProgram->Link(); + GLERROR("Creating explosion program"); } void DrawFinalPass::Draw(RenderScene& scene) { - GLERROR("DrawFinalPass::Draw: Pre"); + GLERROR("Pre"); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { @@ -65,12 +67,12 @@ void DrawFinalPass::Draw(RenderScene& scene) } DrawModelRenderQueues(scene.OpaqueObjects, scene); - GLERROR("DrawFinalPass::Draw: OpaqueObjects"); + GLERROR("OpaqueObjects"); DrawModelRenderQueues(scene.TransparentObjects, scene); - GLERROR("DrawFinalPass::Draw: TransparentObjects"); + GLERROR("TransparentObjects"); - GLERROR("DrawFinalPass::Draw: END"); delete state; + GLERROR("END"); } @@ -111,7 +113,9 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: void DrawFinalPass::DrawModelRenderQueues(std::list>& job, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); + GLERROR("forwardHandle"); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); + GLERROR("explosionHandle"); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); @@ -122,10 +126,21 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& auto explosionEffectJob = std::dynamic_pointer_cast(job); if(explosionEffectJob) { //Bind program + if(GLERROR("Prebind")) { + continue; + } m_ExplosionEffectProgram->Bind(); + if(GLERROR("BindProgram")) { + continue; + } + + //glDisable(GL_CULL_FACE); //Bind uniforms BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + if(GLERROR("BindExplosionUniforms")) { + continue; + } if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -134,29 +149,35 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } + if(GLERROR("Animation")) { + continue; + } //bind textures BindExplosionTextures(explosionEffectJob); + if(GLERROR("BindExplosionTextures")) { + continue; + } //draw glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); - GLERROR("DrawFinalPass::Model: 1"); + //glEnable(GL_CULL_FACE); + if(GLERROR("explosion effect end")) { + continue; + } } else { auto modelJob = std::dynamic_pointer_cast(job); if (modelJob) { //bind forward program m_ForwardPlusProgram->Bind(); - GLERROR("DrawFinalPass::Model: 2"); //bind uniforms BindModelUniforms(forwardHandle, modelJob, scene); - GLERROR("DrawFinalPass::Model: 3"); //bind textures BindModelTextures(modelJob); - GLERROR("DrawFinalPass::Model: 4"); if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -165,13 +186,14 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } - GLERROR("DrawFinalPass::Model: 5"); //draw glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int))); - GLERROR("DrawFinalPass::Model: END"); + if(GLERROR("models end")) { + continue; + } } } } @@ -180,40 +202,46 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, GL_FALSE, glm::value_ptr(scene.AmbientColor)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); - glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin)); glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath); glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration); glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor)); glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness); + glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar); glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity)); glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance); glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration); + + glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); - glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); + glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); + glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + GLERROR("END"); } void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + GLERROR("END"); } @@ -225,7 +253,22 @@ void DrawFinalPass::BindExplosionTextures(std::shared_ptr& j } else { glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); } + glActiveTexture(GL_TEXTURE1); + if (job->NormalTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->NormalTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE2); + if (job->SpecularTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->SpecularTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE3); if (job->IncandescenceTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture); } else { diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index b7e908cc..9677f50e 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -54,13 +54,6 @@ void FrameBuffer::Generate() case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); - if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 || - (*it)->m_Attachment != GL_COLOR_ATTACHMENT1 || - (*it)->m_Attachment != GL_DEPTH_ATTACHMENT || - (*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta - { - LOG_ERROR("RenderBuffer Attachment not valid."); - } break; } From 5474a18753391660b1a709f74c959eaf5e59fbea Mon Sep 17 00:00:00 2001 From: stiffly Date: Mon, 1 Feb 2016 17:15:51 +0100 Subject: [PATCH 17/43] #68 Fixed warning in SoundSystem.cpp --- src/Engine/Sound/SoundSystem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Engine/Sound/SoundSystem.cpp b/src/Engine/Sound/SoundSystem.cpp index a55c1fee..cd83d9c6 100644 --- a/src/Engine/Sound/SoundSystem.cpp +++ b/src/Engine/Sound/SoundSystem.cpp @@ -116,7 +116,11 @@ void SoundSystem::updateEmitters(double dt) setSourcePos(it->second->ALsource, nextPos); setSourceVel(it->second->ALsource, velocity); float gain; - (bool)(it->second->Type) ? gain = m_SFXVolumeChannel : gain = m_BGMVolumeChannel; + if (it->second->Type == SoundType::SFX) { + gain = m_SFXVolumeChannel; + } else if (it->second->Type == SoundType::BGM) { + gain = m_BGMVolumeChannel; + } auto emitter = m_World->GetComponent(it->first, "SoundEmitter"); setSoundProperties(it->second->ALsource, &emitter); From a3d4eb65d5f67eb672cc178ea8221cb25b6e6a74 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 17:53:01 +0100 Subject: [PATCH 18/43] Fixes #66 warnings --- include/Engine/Core/ComponentWrapper.h | 2 +- include/Engine/Core/EntityFile.h | 2 +- include/Engine/Core/Util/FileWatcher.h | 4 +- .../Editor/EditorCameraInputController.h | 6 +-- include/Engine/Rendering/RawModelCustom.h | 22 ++++----- src/Engine/Core/EntityFile.cpp | 4 +- src/Engine/Core/EntityFilePreprocessor.cpp | 2 +- src/Engine/Core/InputManager.cpp | 2 +- src/Engine/Editor/EditorGUI.cpp | 10 ++-- src/Engine/Editor/EditorRenderSystem.cpp | 6 +-- src/Engine/Input/MouseInputHandler.cpp | 4 +- src/Engine/Rendering/ImGuiRenderPass.cpp | 8 +-- src/Engine/Rendering/PNG.cpp | 4 +- src/Engine/Rendering/RawModelCustom.cpp | 49 ++++++++++--------- src/Engine/Rendering/ShaderProgram.cpp | 2 +- src/Engine/Rendering/Skeleton.cpp | 4 +- src/Game/Systems/CapturePointSystem.cpp | 4 +- src/Game/Systems/SpawnerSystem.cpp | 2 +- 18 files changed, 69 insertions(+), 68 deletions(-) diff --git a/include/Engine/Core/ComponentWrapper.h b/include/Engine/Core/ComponentWrapper.h index f09bbfe3..1dc131d2 100644 --- a/include/Engine/Core/ComponentWrapper.h +++ b/include/Engine/Core/ComponentWrapper.h @@ -81,7 +81,7 @@ class ComponentWrapperFactory { public: ComponentWrapperFactory() = default; - ComponentWrapperFactory(std::string componentTypeName, std::size_t allocation = 0) + ComponentWrapperFactory(std::string componentTypeName, unsigned int allocation = 0) { m_ComponentInfo.Name = componentTypeName; m_ComponentInfo.Meta->Allocation = allocation; diff --git a/include/Engine/Core/EntityFile.h b/include/Engine/Core/EntityFile.h index 2549ed06..538e9047 100644 --- a/include/Engine/Core/EntityFile.h +++ b/include/Engine/Core/EntityFile.h @@ -143,7 +143,7 @@ private: ~EntityFile(); public: - static std::size_t GetTypeStride(std::string typeName); + static unsigned int GetTypeStride(std::string typeName); static void WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map& attributes); static void WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData); diff --git a/include/Engine/Core/Util/FileWatcher.h b/include/Engine/Core/Util/FileWatcher.h index 01b4157d..e7f207eb 100644 --- a/include/Engine/Core/Util/FileWatcher.h +++ b/include/Engine/Core/Util/FileWatcher.h @@ -42,7 +42,7 @@ enum class FileWatcher::FileEventFlags }; inline FileWatcher::FileEventFlags operator|(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast(static_cast(a) | static_cast(b)); } -inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast(a)& static_cast(b); } +inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return (static_cast(a) & static_cast(b)) != 0; } class FileWatcher::Worker { @@ -54,7 +54,7 @@ public: private: struct FileInfo { - int Size; + std::size_t Size; std::time_t Timestamp; }; diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 66c7952a..4c139e01 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -23,7 +23,7 @@ public: m_SpeedMultiplier = m_Config->Get("Editor.CameraSpeed", 3.f); } - virtual const glm::vec3 Movement() const override { return m_Movement * m_SpeedMultiplier; } + virtual const glm::vec3 Movement() const override { return m_Movement * static_cast(m_SpeedMultiplier); } void Enable() { m_Enabled = true; } void Disable() { m_Enabled = false; } @@ -69,7 +69,7 @@ public: protected: ConfigFile* m_Config; bool m_Enabled = false; - float m_SpeedMultiplier = 1.f; + double m_SpeedMultiplier = 1.f; EventRelay m_EMousePress; bool OnMousePress(const Events::MousePress& e) @@ -105,7 +105,7 @@ protected: return false; } - m_SpeedMultiplier += e.DeltaY * (0.1f * m_SpeedMultiplier); + m_SpeedMultiplier += e.DeltaY * (0.1 * m_SpeedMultiplier); m_Config->Set("Editor.CameraSpeed", m_SpeedMultiplier); m_Config->SaveToDisk(); return true; diff --git a/include/Engine/Rendering/RawModelCustom.h b/include/Engine/Rendering/RawModelCustom.h index f1bc0e24..e903f49f 100644 --- a/include/Engine/Rendering/RawModelCustom.h +++ b/include/Engine/Rendering/RawModelCustom.h @@ -75,21 +75,21 @@ private: void ReadMeshFile(std::string filePath); - void ReadMeshFileHeader(unsigned int& offset, char* fileData, unsigned int& fileByteSize); - void ReadMesh(unsigned int& offset, char* fileData, unsigned int& fileByteSize); - void ReadVertices(unsigned int& offset, char* fileData, unsigned int& fileByteSize); - void ReadIndices(unsigned int& offset, char* fileData, unsigned int& fileByteSize); + void ReadMeshFileHeader(std::size_t& offset, char* fileData); + void ReadMesh(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); + void ReadVertices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); + void ReadIndices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); void ReadMaterialFile(std::string filePath); - void ReadMaterials(unsigned int &offset, char* fileData, unsigned int& fileByteSize); - void ReadMaterialSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize); + void ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); + void ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); void ReadAnimationFile(std::string filePath); - void ReadAnimationBindPoses(unsigned int &offset, char* fileData, unsigned int& fileByteSize); - void ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize); - void ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips); - void ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex); - void ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation); + void ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); + void ReadAnimationJoint(std::size_t& offset, char* fileData, const unsigned int& fileByteSize); + void ReadAnimationClips(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfClips); + void ReadAnimationClipSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int clipIndex); + void ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation); //void CreateSkeleton(std::vector> &boneInfo, std::map &boneNameMapping, aiNode* node, int parentID); }; diff --git a/src/Engine/Core/EntityFile.cpp b/src/Engine/Core/EntityFile.cpp index d5585317..0d97d4ae 100644 --- a/src/Engine/Core/EntityFile.cpp +++ b/src/Engine/Core/EntityFile.cpp @@ -40,9 +40,9 @@ void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader) reader->setFeature(XMLUni::fgXercesCalculateSrcOfs, true); } -std::size_t EntityFile::GetTypeStride(std::string typeName) +unsigned int EntityFile::GetTypeStride(std::string typeName) { - std::map typeStrides{ + std::map typeStrides{ { "bool", sizeof(bool) }, { "int", sizeof(int) }, { "float", sizeof(float) }, diff --git a/src/Engine/Core/EntityFilePreprocessor.cpp b/src/Engine/Core/EntityFilePreprocessor.cpp index 2a1d22d6..3d5e9e41 100644 --- a/src/Engine/Core/EntityFilePreprocessor.cpp +++ b/src/Engine/Core/EntityFilePreprocessor.cpp @@ -114,7 +114,7 @@ void EntityFilePreprocessor::parseComponentInfo() std::string baseType = XS::ToString(elementDeclaration->getTypeDefinition()->getBaseType()->getName()); std::string effectiveType = type; - size_t stride = EntityFile::GetTypeStride(type); + unsigned int stride = EntityFile::GetTypeStride(type); if (stride == 0) { stride = EntityFile::GetTypeStride(baseType); if (stride == 0) { diff --git a/src/Engine/Core/InputManager.cpp b/src/Engine/Core/InputManager.cpp index 941cc223..b75809b1 100644 --- a/src/Engine/Core/InputManager.cpp +++ b/src/Engine/Core/InputManager.cpp @@ -218,7 +218,7 @@ void InputManager::PublishGamepadAxisIfChanged(int gamepadID, Gamepad::Axis axis void InputManager::PublishGamepadButtonIfChanged(int gamepadID, Gamepad::Button button) { bool currentState = m_CurrentGamepadButtonState[gamepadID][static_cast(button)]; - float lastState = m_LastGamepadButtonState[gamepadID][static_cast(button)]; + bool lastState = m_LastGamepadButtonState[gamepadID][static_cast(button)]; if (currentState != lastState) { if (currentState == true) { Events::GamepadButtonDown e; diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 06938064..70775a2b 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -69,7 +69,7 @@ void EditorGUI::drawTools() } else if (m_CurrentWidgetSpace == WidgetSpace::Local) { spaceTexture = tryLoadTexture("Textures/Icons/Local.png"); } - if (ImGui::ImageButton((void*)spaceTexture, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { + if (ImGui::ImageButton(reinterpret_cast(spaceTexture), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { toggleWidgetSpace(); } if (ImGui::IsItemHovered()) { @@ -85,14 +85,14 @@ void EditorGUI::drawTools() // Play button ImGui::SameLine(); - if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { + if (ImGui::ImageButton(reinterpret_cast(tryLoadTexture("Textures/Icons/Play.png")), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { Events::Resume e; e.World = m_World; m_EventBroker->Publish(e); } // Pause button ImGui::SameLine(); - if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Pause.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { + if (ImGui::ImageButton(reinterpret_cast(tryLoadTexture("Textures/Icons/Pause.png")), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { Events::Pause e; e.World = m_World; m_EventBroker->Publish(e); @@ -262,7 +262,7 @@ void EditorGUI::drawComponents(EntityWrapper entity) // Draw combo box ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() - 10.f); int selectedItem = -1; - if (ImGui::Combo("", &selectedItem, componentTypes.data(), componentTypes.size(), componentTypes.size())) { + if (ImGui::Combo("", &selectedItem, componentTypes.data(), static_cast(componentTypes.size()), static_cast(componentTypes.size()))) { if (selectedItem != -1) { if (m_OnComponentAttach != nullptr) { std::string chosenComponentType(componentTypes.at(selectedItem)); @@ -565,7 +565,7 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode) break; } if (ImGui::ImageButton( - (void*)texture, + reinterpret_cast(texture), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 898eac9d..67b09a21 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -80,9 +80,9 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e) { ComponentWrapper cTransform = e.CameraEntity["Transform"]; ComponentWrapper cCamera = e.CameraEntity["Camera"]; - m_EditorCamera->SetFOV((double)cCamera["FOV"]); - m_EditorCamera->SetNearClip((double)cCamera["NearClip"]); - m_EditorCamera->SetFarClip((double)cCamera["FarClip"]); + m_EditorCamera->SetFOV(static_cast((double)cCamera["FOV"])); + m_EditorCamera->SetNearClip(static_cast((double)cCamera["NearClip"])); + m_EditorCamera->SetFarClip(static_cast((double)cCamera["FarClip"])); m_EditorCamera->SetPosition(cTransform["Position"]); m_EditorCamera->SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"])); m_CurrentCamera = e.CameraEntity; diff --git a/src/Engine/Input/MouseInputHandler.cpp b/src/Engine/Input/MouseInputHandler.cpp index 5996b43d..9346f627 100644 --- a/src/Engine/Input/MouseInputHandler.cpp +++ b/src/Engine/Input/MouseInputHandler.cpp @@ -98,7 +98,7 @@ bool MouseInputHandler::OnMouseMove(const Events::MouseMove& e) Events::InputCommand ic; ic.PlayerID = -1; std::tie(ic.Command, ic.Value) = it->second; - ic.Value *= e.DeltaX; + ic.Value *= static_cast(e.DeltaX); m_InputProxy->Publish(ic); } } @@ -109,7 +109,7 @@ bool MouseInputHandler::OnMouseMove(const Events::MouseMove& e) Events::InputCommand ic; ic.PlayerID = -1; std::tie(ic.Command, ic.Value) = it->second; - ic.Value *= e.DeltaY; + ic.Value *= static_cast(e.DeltaY); m_InputProxy->Publish(ic); } } diff --git a/src/Engine/Rendering/ImGuiRenderPass.cpp b/src/Engine/Rendering/ImGuiRenderPass.cpp index e67eea71..e0e7347f 100644 --- a/src/Engine/Rendering/ImGuiRenderPass.cpp +++ b/src/Engine/Rendering/ImGuiRenderPass.cpp @@ -134,8 +134,8 @@ bool ImGuiRenderPass::OnMouseRelease(const Events::MouseRelease& e) bool ImGuiRenderPass::OnMouseMove(const Events::MouseMove& e) { ImGuiIO& io = ImGui::GetIO(); - io.MousePos.x = e.X; - io.MousePos.y = e.Y; + io.MousePos.x = static_cast(e.X); + io.MousePos.y = static_cast(e.Y); return true; } @@ -271,7 +271,7 @@ bool ImGuiRenderPass::createFontsTexture() glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Store our identifier - io.Fonts->TexID = (void*)g_FontTexture; + io.Fonts->TexID = reinterpret_cast(g_FontTexture); // Restore state glBindTexture(GL_TEXTURE_2D, last_texture); @@ -291,7 +291,7 @@ void ImGuiRenderPass::newFrame() io.DisplaySize = ImVec2((float)w, (float)h); io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); - io.DeltaTime = g_DeltaTime; + io.DeltaTime = static_cast(g_DeltaTime); io.KeyCtrl = glfwGetKey(g_Window, GLFW_KEY_LEFT_CONTROL) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_CONTROL); io.KeyShift = glfwGetKey(g_Window, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_SHIFT); diff --git a/src/Engine/Rendering/PNG.cpp b/src/Engine/Rendering/PNG.cpp index f1e7b06d..7ffd5c20 100644 --- a/src/Engine/Rendering/PNG.cpp +++ b/src/Engine/Rendering/PNG.cpp @@ -71,12 +71,12 @@ PNG::PNG(std::string path) png_read_update_info(png_ptr, info_ptr); } - unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr); + std::size_t row_bytes = png_get_rowbytes(png_ptr, info_ptr); this->Data = new unsigned char[height * row_bytes]; png_bytep* row_pointers = new png_bytep[height]; // Point each row to the continuous data array - for (int i = 0; i < height; ++i) { + for (unsigned int i = 0; i < height; ++i) { // Invert Y for OpenGL row_pointers[height - 1 - i] = this->Data + i * row_bytes; } diff --git a/src/Engine/Rendering/RawModelCustom.cpp b/src/Engine/Rendering/RawModelCustom.cpp index 83f6e703..59634625 100644 --- a/src/Engine/Rendering/RawModelCustom.cpp +++ b/src/Engine/Rendering/RawModelCustom.cpp @@ -22,42 +22,42 @@ void RawModelCustom::ReadMeshFile(std::string filePath) if (!in.is_open()) { throw Resource::FailedLoadingException("Open mesh file failed"); } - unsigned int fileByteSize = in.tellg(); + unsigned int fileByteSize = static_cast(in.tellg()); in.seekg(0, std::ios_base::beg); fileData = new char[fileByteSize]; in.read(fileData, fileByteSize); in.close(); - unsigned int offset = 0; + std::size_t offset = 0; if (fileByteSize > 0) { - ReadMeshFileHeader(offset, fileData, fileByteSize); + ReadMeshFileHeader(offset, fileData); ReadMesh(offset, fileData, fileByteSize); } delete fileData; } -void RawModelCustom::ReadMeshFileHeader(unsigned int& offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadMeshFileHeader(std::size_t& offset, char* fileData) { #ifdef BOOST_LITTLE_ENDIAN - m_Vertices.resize(*(unsigned int*)(fileData + offset)); + m_Vertices.resize(static_cast(*(unsigned int*)(fileData + offset))); offset += sizeof(unsigned int); - m_Indices.resize(*(unsigned int*)(fileData + offset)); + m_Indices.resize(static_cast(*(unsigned int*)(fileData + offset))); offset += sizeof(unsigned int); #else #endif } -void RawModelCustom::ReadMesh(unsigned int& offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadMesh(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { ReadVertices(offset, fileData, fileByteSize); ReadIndices(offset, fileData, fileByteSize); } -void RawModelCustom::ReadVertices(unsigned int& offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadVertices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { #ifdef BOOST_LITTLE_ENDIAN - if (offset + m_Vertices.size() * sizeof(Vertex) > fileByteSize) { + if (offset + m_Vertices.size() * sizeof(Vertex) > fileByteSize) { throw Resource::FailedLoadingException("Reading vertices failed"); } @@ -67,7 +67,7 @@ void RawModelCustom::ReadVertices(unsigned int& offset, char* fileData, unsigned #endif } -void RawModelCustom::ReadIndices(unsigned int& offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadIndices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { #ifdef BOOST_LITTLE_ENDIAN if (offset + m_Indices.size() * sizeof(unsigned int) > fileByteSize) { @@ -90,35 +90,36 @@ void RawModelCustom::ReadMaterialFile(std::string filePath) if (!in.is_open()) { throw Resource::FailedLoadingException("Open material file failed"); } - unsigned int fileByteSize = in.tellg(); + + unsigned int fileByteSize = static_cast(in.tellg()); in.seekg(0, std::ios_base::beg); fileData = new char[fileByteSize]; in.read(fileData, fileByteSize); in.close(); - unsigned int offset = 0; + std::size_t offset = 0; if (fileByteSize > 0) { ReadMaterials(offset, fileData, fileByteSize); } delete fileData; } -void RawModelCustom::ReadMaterials(unsigned int& offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { #ifdef BOOST_LITTLE_ENDIAN unsigned int* numMaterials = (unsigned int*)(fileData); MaterialGroups.reserve(*numMaterials); offset += sizeof(unsigned int); - for (int i = 0; i < *numMaterials; i++) { + for (unsigned int i = 0; i < *numMaterials; i++) { ReadMaterialSingle(offset, fileData, fileByteSize); } #else #endif } -void RawModelCustom::ReadMaterialSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { MaterialGroup newMaterial; @@ -210,14 +211,14 @@ void RawModelCustom::ReadAnimationFile(std::string filePath) return; } - unsigned int fileByteSize = in.tellg(); + unsigned int fileByteSize = static_cast(in.tellg()); in.seekg(0, std::ios_base::beg); fileData = new char[fileByteSize]; in.read(fileData, fileByteSize); in.close(); - unsigned int offset = 0; + std::size_t offset = 0; if (fileByteSize > 0) { m_Skeleton = new Skeleton(); @@ -235,7 +236,7 @@ void RawModelCustom::ReadAnimationFile(std::string filePath) delete fileData; } -void RawModelCustom::ReadAnimationBindPoses(unsigned int &offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { #ifdef BOOST_LITTLE_ENDIAN unsigned int* numBones = (unsigned int*)(fileData + offset); @@ -248,7 +249,7 @@ void RawModelCustom::ReadAnimationBindPoses(unsigned int &offset, char* fileData #endif } -void RawModelCustom::ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize) +void RawModelCustom::ReadAnimationJoint(std::size_t& offset, char* fileData, const unsigned int& fileByteSize) { #ifdef BOOST_LITTLE_ENDIAN if (offset + sizeof(unsigned int) > fileByteSize) { @@ -290,14 +291,14 @@ void RawModelCustom::ReadAnimationJoint(unsigned int &offset, char* fileData, un #endif } -void RawModelCustom::ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips) +void RawModelCustom::ReadAnimationClips(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfClips) { for (unsigned int i = 0; i < numberOfClips; i++) { ReadAnimationClipSingle(offset, fileData, fileByteSize, i); } } -void RawModelCustom::ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex) +void RawModelCustom::ReadAnimationClipSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int clipIndex) { #ifdef BOOST_LITTLE_ENDIAN Skeleton::Animation newAnimation; @@ -342,7 +343,7 @@ void RawModelCustom::ReadAnimationClipSingle(unsigned int &offset, char* fileDat #endif } -void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int nrOfJoints, Skeleton::Animation& animation) +void RawModelCustom::ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation) { Skeleton::Animation::Keyframe newKeyFrame; @@ -358,12 +359,12 @@ void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData, newKeyFrame.Time = *(float*)(fileData + offset); offset += sizeof(float); - if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * nrOfJoints> fileByteSize) { + if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * numberOfJoints> fileByteSize) { throw Resource::FailedLoadingException("Reading AnimationKeyFrame joints failed"); } Skeleton::Animation::Keyframe::BoneProperty newBone; - for (unsigned int i = 0; i < nrOfJoints; i++) { + for (unsigned int i = 0; i < numberOfJoints; i++) { memcpy(&newBone, (fileData + offset), sizeof(Skeleton::Animation::Keyframe::BoneProperty)); offset += sizeof(Skeleton::Animation::Keyframe::BoneProperty); newKeyFrame.BoneProperties[newBone.ID] = newBone; diff --git a/src/Engine/Rendering/ShaderProgram.cpp b/src/Engine/Rendering/ShaderProgram.cpp index f713cd03..9c26c15c 100644 --- a/src/Engine/Rendering/ShaderProgram.cpp +++ b/src/Engine/Rendering/ShaderProgram.cpp @@ -21,7 +21,7 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName) return 0; const GLchar* shaderFiles = shaderFile.c_str(); - const GLint length = shaderFile.length(); + const GLint length = static_cast(shaderFile.length()); glShaderSource(shader, 1, &shaderFiles, &length); if (GLERROR("glShaderSource")) return 0; diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index cebabb67..851408a4 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -53,11 +53,11 @@ std::vector Skeleton::GetFrameBones(const Animation& animation, doubl const Animation::Keyframe& currentFrame = animation.Keyframes[currentKeyframeIndex]; const Animation::Keyframe& nextFrame = animation.Keyframes[(currentKeyframeIndex + 1) % animation.Keyframes.size()]; - float alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); + double alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); //auto animationFrame = Animations[""].Keyframes[frame]; std::map frameBones; - AccumulateBoneTransforms(noRootMotion, currentFrame, nextFrame, alpha, frameBones, RootBone, glm::mat4(1)); + AccumulateBoneTransforms(noRootMotion, currentFrame, nextFrame, static_cast(alpha), frameBones, RootBone, glm::mat4(1)); std::vector finalMatrices; for (auto &kv : frameBones) { diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 43876822..1de21858 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -64,7 +64,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp std::map nextPossibleCapturePoint; nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Blue"] = -1; - for (size_t i = 0; i < m_NumberOfCapturePoints; i++) + for (int i = 0; i < m_NumberOfCapturePoints; i++) { if (m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; @@ -93,7 +93,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //reset timers and reset the bool that triggers this if (m_ResetTimers) { - for (size_t i = 0; i < m_NumberOfCapturePoints; i++) + for (int i = 0; i < m_NumberOfCapturePoints; i++) { ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index f9357113..7a0a13c9 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -30,7 +30,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / if (spawnPoints.size() > 1) { static std::random_device randomDevice; static std::mt19937 randomGenerator(randomDevice()); - std::uniform_int_distribution<> distribution(0, std::distance(spawnPoints.begin(), spawnPoints.end()) - 1); + std::uniform_int_distribution<> distribution(0, static_cast(std::distance(spawnPoints.begin(), spawnPoints.end())) - 1); auto randomSpawnPointIt = spawnPoints.begin(); std::advance(randomSpawnPointIt, distribution(randomGenerator)); spawnPoint = *randomSpawnPointIt; From ed7d00c1d821fb77e674281c894759da3627d689 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 18:19:38 +0100 Subject: [PATCH 19/43] Bug where widgets did not get their ambient light now fixed. --- resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Editor/EditorRenderSystem.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 025068f7..d2c1c628 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -126,7 +126,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = AmbientColor; + totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index d1b9083c..ef1a33ce 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -23,6 +23,16 @@ void EditorRenderSystem::Update(double dt) scene.Camera = m_EditorCamera; scene.Viewport = Rectangle(1920, 1080); + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr) { + //m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; + //m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; + //scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; + m_RenderFrame->Gamma = 2.2; + m_RenderFrame->Exposure = 1.0; + scene.AmbientColor = glm::vec4(0.6, 0.5, 0.5, 1.0); + } + auto models = m_World->GetComponents("Model"); if (models != nullptr) { for (auto& cModel : *models) { From a188a3f7faaab87c03876dde9011943cbd510a36 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 18:22:36 +0100 Subject: [PATCH 20/43] Removed widget pointlight since it is now redundant --- resources/Schema/Entities/EditorWidgetTranslate.xml | 9 --------- src/Engine/Editor/EditorRenderSystem.cpp | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/resources/Schema/Entities/EditorWidgetTranslate.xml b/resources/Schema/Entities/EditorWidgetTranslate.xml index d4ed5e76..c6dba4d9 100644 --- a/resources/Schema/Entities/EditorWidgetTranslate.xml +++ b/resources/Schema/Entities/EditorWidgetTranslate.xml @@ -84,15 +84,6 @@ - - - - - - - - - diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index ef1a33ce..de783f66 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -30,7 +30,7 @@ void EditorRenderSystem::Update(double dt) //scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; m_RenderFrame->Gamma = 2.2; m_RenderFrame->Exposure = 1.0; - scene.AmbientColor = glm::vec4(0.6, 0.5, 0.5, 1.0); + scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); } auto models = m_World->GetComponents("Model"); From 782c1a388a1fddb3c9b64b239689bb2d168a5856 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 18:23:40 +0100 Subject: [PATCH 21/43] Comment --- src/Engine/Editor/EditorRenderSystem.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index de783f66..572dd83d 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -25,9 +25,7 @@ void EditorRenderSystem::Update(double dt) auto cSceneLight = m_World->GetComponents("SceneLight"); if (cSceneLight != nullptr) { - //m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; - //m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; - //scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; + //these are hardcoded since they want special light treatment and a component just for widgets is stupid. m_RenderFrame->Gamma = 2.2; m_RenderFrame->Exposure = 1.0; scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); From 8299b99e2f33ed24b20b04eef98d4b0d4c6998e8 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 1 Feb 2016 19:08:46 +0100 Subject: [PATCH 22/43] Test world changes and some other small fixes --- assets | 2 +- resources/Schema/Entities/EditorTestWorld.xml | 44 ++++++++++++++----- src/Engine/Editor/EditorRenderSystem.cpp | 2 - src/Engine/Rendering/DrawFinalPass.cpp | 4 +- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/assets b/assets index 091ad5c0..01a73005 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea +Subproject commit 01a73005d45c1d5574428536be88f085f4f844ce diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index de65f736..6ffbad89 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -38,12 +38,12 @@ Models/DirectionalLightWidget.mesh - 1.0499999523162842 + 1 - + @@ -62,11 +62,31 @@ - Models/SecondaryWeapon.mesh + Models/DefenderGunBlue.mesh - - + + + + + + + + + + true + + 0.33345697685444975 + + + + Models/DefenderGunRed.mesh + true + false + + + + @@ -85,7 +105,7 @@ Run - + 1 @@ -101,7 +121,7 @@ Walk - + 1 @@ -163,7 +183,7 @@ - + @@ -227,7 +247,7 @@ - + @@ -259,7 +279,7 @@ - + @@ -301,7 +321,9 @@ - + + 2 + diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 572dd83d..374704dc 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -26,8 +26,6 @@ void EditorRenderSystem::Update(double dt) auto cSceneLight = m_World->GetComponents("SceneLight"); if (cSceneLight != nullptr) { //these are hardcoded since they want special light treatment and a component just for widgets is stupid. - m_RenderFrame->Gamma = 2.2; - m_RenderFrame->Exposure = 1.0; scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index ae2ebefc..8247797e 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -134,7 +134,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& continue; } - //glDisable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); //Bind uniforms BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); @@ -162,7 +162,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); - //glEnable(GL_CULL_FACE); + glEnable(GL_CULL_FACE); if(GLERROR("explosion effect end")) { continue; } From 9c2e459e0c35867f19bb50d87e4b22c1c3df1a56 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 10:58:00 +0100 Subject: [PATCH 23/43] Deatheffect color now correctly calculated --- assets | 2 +- resources/Schema/Entities/EditorTestWorld.xml | 34 +++++++++++-------- resources/Shaders/ExplosionEffect.geom.glsl | 18 +++++++--- resources/Shaders/ForwardPlus.frag.glsl | 3 +- resources/Shaders/ForwardPlus.vert.glsl | 2 ++ 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/assets b/assets index 01a73005..763d7c5c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 01a73005d45c1d5574428536be88f085f4f844ce +Subproject commit 763d7c5c0dcb84722221490b5ef9ed0aad18be06 diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 6ffbad89..3c521e3f 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -43,15 +43,25 @@ - + + + true + + + 0.9332666733480437 + 5 + + 3 + Models/Assault.mesh + true @@ -62,23 +72,17 @@ - Models/DefenderGunBlue.mesh + Models/AssaultWeapon.mesh + true - - - true - - 0.33345697685444975 - - Models/DefenderGunRed.mesh true @@ -105,7 +109,7 @@ Run - + 1 @@ -121,7 +125,7 @@ Walk - + 1 @@ -183,7 +187,7 @@ - + @@ -247,7 +251,7 @@ - + @@ -279,7 +283,7 @@ - + @@ -322,7 +326,7 @@ - 2 + 1.3999999761581421 diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index 34e6230d..44b44aa6 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -21,6 +21,7 @@ in VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input[]; out VertexData{ @@ -30,6 +31,7 @@ out VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; layout(triangles) in; @@ -118,12 +120,17 @@ void main() { // calculate the max distance (s) the triangle will move float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2)); + float te = (length(triangleCenter2ExplosionRadius) / s); - Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = te; + } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... @@ -160,11 +167,14 @@ void main() // if explosion color should be affected by distance instead of time... if (ColorByDistance == true) { - Output.ExplosionColor = vec4(1.0); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = 0.0; } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d2c1c628..3431ed6b 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -55,6 +55,7 @@ in VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input; out vec4 sceneColor; @@ -148,7 +149,7 @@ void main() totalLighting.Specular += light_result.Specular; } - vec4 color_result = Color * diffuseTexel * DiffuseColor * Input.ExplosionColor; + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 4e1f8734..3b3e931c 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -20,6 +20,7 @@ out VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; void main() @@ -42,4 +43,5 @@ void main() Output.Tangent = vec3(M * vec4(Tangent, 0.0)); Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); + Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file From 42b52a6766c4718ac456e1f1b5879e12f76f384d Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 2 Feb 2016 11:37:22 +0100 Subject: [PATCH 24/43] Several changes/fixes based on the latest broken refactoring. Fixed Simon's mistake in CapturePointLogic. William fixed so TriggerSystem works again with CapturePoints. --- .../Engine/Collision/CollidableOctreeSystem.h | 4 +- include/Engine/Core/Octree.h | 2 +- include/Game/Game.h | 1 + resources/Schema/Components/CapturePoint.xsd | 2 +- resources/Schema/Entities/CapturePoint.xml | 17 ++ .../Schema/Entities/CaptureTestState5.xml | 173 ++++++++++++++++++ src/Engine/Collision/TriggerSystem.cpp | 6 +- src/Game/Game.cpp | 7 +- src/Game/Systems/CapturePointSystem.cpp | 3 +- 9 files changed, 205 insertions(+), 10 deletions(-) create mode 100644 resources/Schema/Entities/CapturePoint.xml create mode 100644 resources/Schema/Entities/CaptureTestState5.xml diff --git a/include/Engine/Collision/CollidableOctreeSystem.h b/include/Engine/Collision/CollidableOctreeSystem.h index 39aea979..0aa01d2e 100644 --- a/include/Engine/Collision/CollidableOctreeSystem.h +++ b/include/Engine/Collision/CollidableOctreeSystem.h @@ -9,9 +9,9 @@ class CollidableOctreeSystem : public ImpureSystem, public PureSystem { public: - CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree* octree) + CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree* octree, const std::string& componentType) : System(world, eventBroker) - , PureSystem("Collidable") + , PureSystem(componentType) , m_Octree(octree) { } diff --git a/include/Engine/Core/Octree.h b/include/Engine/Core/Octree.h index 72825c3c..8bac5503 100644 --- a/include/Engine/Core/Octree.h +++ b/include/Engine/Core/Octree.h @@ -149,7 +149,7 @@ template template void Octree::ObjectsInSameRegion(const Box& box, std::vector& outObjects) { - //static_assert(std::is_base_of::value, "template argument type Box in Octree::ObjectsInSameRegion must be a subclass of AABB."); + static_assert(std::is_base_of::value, "template argument type Box in Octree::ObjectsInSameRegion must be a subclass of AABB."); falsifyObjectChecks(); m_Root->ObjectsInSameRegion(box, outObjects); } diff --git a/include/Game/Game.h b/include/Game/Game.h index 671edfc5..37267a68 100644 --- a/include/Game/Game.h +++ b/include/Game/Game.h @@ -51,6 +51,7 @@ private: GUI::Frame* m_FrameStack; World* m_World; Octree* m_OctreeCollision; + Octree* m_OctreeTrigger; Octree* m_OctreeFrustrumCulling; SystemPipeline* m_SystemPipeline; RenderFrame* m_RenderFrame; diff --git a/resources/Schema/Components/CapturePoint.xsd b/resources/Schema/Components/CapturePoint.xsd index 91afd366..fbdb3568 100644 --- a/resources/Schema/Components/CapturePoint.xsd +++ b/resources/Schema/Components/CapturePoint.xsd @@ -6,7 +6,7 @@ - A Capture Point. Add a Team Component to specify who currently owns it + A Capture Point. Make sure to update the HomePoint,CapturePointNumber,Team for each diff --git a/resources/Schema/Entities/CapturePoint.xml b/resources/Schema/Entities/CapturePoint.xml new file mode 100644 index 00000000..9b3c5036 --- /dev/null +++ b/resources/Schema/Entities/CapturePoint.xml @@ -0,0 +1,17 @@ + + + + + + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + diff --git a/resources/Schema/Entities/CaptureTestState5.xml b/resources/Schema/Entities/CaptureTestState5.xml new file mode 100644 index 00000000..f1b07a7b --- /dev/null +++ b/resources/Schema/Entities/CaptureTestState5.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + + + + + + + + + + + 1 + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + + + + + + + 2 + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + + + + + + + + + + + 3 + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + + + + + + + + + + + + + + 4 + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh + + + + + + + + + + + + + + + + + + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitCube.mesh + + + + + + + + + + + + + + + + + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitCube.mesh + + + + + + + + + + + + + + + + + C:\Users\123456\Workspace\TacticalZ\assets\Models\DummyScene.mesh + + + + + + + + + + diff --git a/src/Engine/Collision/TriggerSystem.cpp b/src/Engine/Collision/TriggerSystem.cpp index dc7c77ff..410a7fa1 100644 --- a/src/Engine/Collision/TriggerSystem.cpp +++ b/src/Engine/Collision/TriggerSystem.cpp @@ -76,18 +76,18 @@ bool TriggerSystem::throwLeaveIfWasInTrigger(std::unordered_set& bool TriggerSystem::OnTouch(const Events::TriggerTouch &event) { - LOG_INFO("Player entity %i touched trigger entity %i.", event.Entity, event.Trigger); + LOG_INFO("Player entity %i touched trigger entity %i.", event.Entity.ID, event.Trigger.ID); return true; } bool TriggerSystem::OnEnter(const Events::TriggerEnter &event) { - LOG_INFO("Player entity %i entered trigger entity %i.", event.Entity, event.Trigger); + LOG_INFO("Player entity %i entered trigger entity %i.", event.Entity.ID, event.Trigger.ID); return true; } bool TriggerSystem::OnLeave(const Events::TriggerLeave &event) { - LOG_INFO("Player entity %i left trigger entity %i.", event.Entity, event.Trigger); + LOG_INFO("Player entity %i left trigger entity %i.", event.Entity.ID, event.Trigger.ID); return true; } \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 515540bf..f5afcaeb 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -74,6 +74,7 @@ Game::Game(int argc, char* argv[]) // Create Octrees m_OctreeCollision = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4); + m_OctreeTrigger = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4); m_OctreeFrustrumCulling = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4); // Create system pipeline m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker); @@ -92,14 +93,15 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; - m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); + m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); + m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger, "Player"); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); // Collision and TriggerSystem should update after player. ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); - m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); + m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger); ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_RenderFrame); ++updateOrderLevel; @@ -123,6 +125,7 @@ Game::~Game() delete m_SoundSystem; delete m_OctreeFrustrumCulling; delete m_OctreeCollision; + delete m_OctreeTrigger; delete m_World; delete m_FrameStack; delete m_InputProxy; diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 43876822..a10c0287 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -66,7 +66,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp nextPossibleCapturePoint["Blue"] = -1; for (size_t i = 0; i < m_NumberOfCapturePoints; i++) { - if (m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { + if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; } ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; @@ -119,6 +119,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp if (std::get<1>(triggerTouched) == capturePointEntity) { //some player has touched this - lets figure out: what team, health EntityWrapper player = std::get<0>(triggerTouched); + //check if its really a player that has triggered the touch if (!player.HasComponent("Player")) { //if a non-player has entered the capturePoint, just erase that event and continue m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); From 28d412f5c7ce64ec35d13c662e61a72868b9b004 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 13:24:18 +0100 Subject: [PATCH 25/43] Some small changes to test world and assets --- assets | 2 +- resources/Schema/Entities/EditorTestWorld.xml | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/assets b/assets index 763d7c5c..415bbd54 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 763d7c5c0dcb84722221490b5ef9ed0aad18be06 +Subproject commit 415bbd5409174bdd1257db57326f3e1ff66d7faf diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 3c521e3f..4727c777 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -2,7 +2,9 @@ - + + + @@ -43,7 +45,7 @@ - + @@ -54,14 +56,13 @@ true - 0.9332666733480437 + 5.0498686575577523 5 3 Models/Assault.mesh - true @@ -72,11 +73,12 @@ - Models/AssaultWeapon.mesh + Models/AssaultWeaponRed.mesh true - + + @@ -109,7 +111,7 @@ Run - + 1 @@ -125,7 +127,7 @@ Walk - + 1 @@ -187,7 +189,7 @@ - + @@ -251,7 +253,7 @@ - + @@ -283,7 +285,7 @@ - + From 6a3f585fb921e10f23513cebf98de645822115d7 Mon Sep 17 00:00:00 2001 From: Jocke Date: Tue, 2 Feb 2016 13:26:15 +0100 Subject: [PATCH 26/43] Fixed warnings associated with Network.cpp, Client.cpp, Server.cpp and Packet.cpp. BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition was fixed by https://svn.boost.org/trac/boost/ticket/11539 --- include/Engine/Network/Client.h | 4 ++-- include/Engine/Network/Network.h | 2 +- include/Engine/Network/NetworkData.h | 16 ++++++++-------- include/Engine/Network/Packet.h | 18 +++++++++--------- include/Engine/Network/Server.h | 8 ++++---- include/Game/Systems/InterpolationSystem.h | 2 +- src/Engine/Network/Client.cpp | 6 +++--- src/Engine/Network/Network.cpp | 10 +++++----- src/Engine/Network/Packet.cpp | 6 +++--- src/Engine/Network/Server.cpp | 16 ++++++++-------- src/Game/Systems/InterpolationSystem.cpp | 6 +++--- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 4f1baa67..7d1d5bba 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -36,7 +36,7 @@ private: boost::asio::ip::udp::socket m_Socket; // Sending message to server logic - int bytesRead = -1; + size_t bytesRead = 0; char readBuf[INPUTSIZE] = { 0 }; // Packet loss logic @@ -69,7 +69,7 @@ private: // Private member functions void readFromServer(); - int receive(char* data); + size_t receive(char* data); void send(Packet& packet); void connect(); void disconnect(); diff --git a/include/Engine/Network/Network.h b/include/Engine/Network/Network.h index e1e64fc1..874e3377 100644 --- a/include/Engine/Network/Network.h +++ b/include/Engine/Network/Network.h @@ -29,7 +29,7 @@ protected: unsigned int m_SaveDataIntervalMs = 1000; std::clock_t m_SaveDataTimer; unsigned int m_MaxConnections; - unsigned int m_TimeoutMs; + double m_TimeoutMs; void saveToFile(); void updateNetworkData(); void initialize(); diff --git a/include/Engine/Network/NetworkData.h b/include/Engine/Network/NetworkData.h index 87f7a215..85db36de 100644 --- a/include/Engine/Network/NetworkData.h +++ b/include/Engine/Network/NetworkData.h @@ -3,16 +3,16 @@ #include struct NetworkData { - unsigned int TotalTime = 0; - unsigned int TotalDataReceived = 0; - unsigned int TotalDataSent = 0; - unsigned int AmountOfMessagesReceived = 0; + double TotalTime = 0; + size_t TotalDataReceived = 0; + size_t TotalDataSent = 0; + size_t AmountOfMessagesReceived = 0; unsigned int AmountOfMessagesSent = 0; // Interval based - unsigned int DataReceivedThisInterval = 0; - unsigned int DataSentThisInterval = 0; + size_t DataReceivedThisInterval = 0; + size_t DataSentThisInterval = 0; // pair: first=reveived, second=send - std::vector> BandwidthBytes; + std::vector> BandwidthBytes; }; -#endif +#endif \ No newline at end of file diff --git a/include/Engine/Network/Packet.h b/include/Engine/Network/Packet.h index d38ddf58..009d8563 100644 --- a/include/Engine/Network/Packet.h +++ b/include/Engine/Network/Packet.h @@ -13,7 +13,7 @@ public: // arg2: PacketID for identifying packet loss. Packet(MessageType type, unsigned int& packetID); // Used to create packet from already existing data buffer. - Packet(char* data, const int sizeOfPacket); + Packet(char* data, const size_t sizeOfPacket); Packet(MessageType type); ~Packet(); void Init(MessageType type, unsigned int& packetID); @@ -51,18 +51,18 @@ public: std::string ReadString(); char* ReadData(int SizeOfData); void ChangePacketID(unsigned int& packetID); - int Size() { return m_Offset; }; + size_t Size() { return m_Offset; }; char* Data() { return m_Data; }; - unsigned int DataReadSize() { return m_ReturnDataOffset; } - unsigned int MaxSize() { return m_MaxPacketSize; } - unsigned int HeaderSize() { return m_HeaderSize; } + size_t DataReadSize() { return m_ReturnDataOffset; } + size_t MaxSize() { return m_MaxPacketSize; } + size_t HeaderSize() { return m_HeaderSize; } private: char* m_Data; - unsigned int m_ReturnDataOffset = 0; - int m_Offset = 0; - unsigned int m_MaxPacketSize = 512; - unsigned int m_HeaderSize = 0; + size_t m_ReturnDataOffset = 0; + size_t m_Offset = 0; + size_t m_MaxPacketSize = 512; + size_t m_HeaderSize = 0; void resizeData(); }; diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 11f983a9..90b9e922 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -36,14 +36,14 @@ private: std::map m_ConnectedPlayers; // HACK: Fix INPUTSIZE char readBuffer[INPUTSIZE] = { 0 }; - int bytesRead = 0; + size_t bytesRead = 0; // time for previouse message std::clock_t previousePingMessage = std::clock(); std::clock_t previousSnapshotMessage = std::clock(); std::clock_t timOutTimer = std::clock(); // How often we send messages (milliseconds) - int pingIntervalMs; - int snapshotInterval; + float pingIntervalMs; + float snapshotInterval; int checkTimeOutInterval = 100; int m_NextPlayerID = 0; @@ -59,7 +59,7 @@ private: PacketID m_PreviousPacketID = 0; // Private member functions - int receive(char* data); + size_t receive(char* data); void readFromClients(); void send(PlayerID player, Packet& packet); void send(Packet& packet); diff --git a/include/Game/Systems/InterpolationSystem.h b/include/Game/Systems/InterpolationSystem.h index 1e345c91..96236f62 100644 --- a/include/Game/Systems/InterpolationSystem.h +++ b/include/Game/Systems/InterpolationSystem.h @@ -23,7 +23,7 @@ class InterpolationSystem : public PureSystem glm::vec3 Position; glm::vec3 Scale; glm::quat Orientation; - double interpolationTime; + float interpolationTime; }; public: InterpolationSystem(World* world, EventBroker* eventBroker); diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index 6c43cc8b..f4631e98 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -258,11 +258,11 @@ void Client::parseSnapshot(Packet& packet) } } -int Client::receive(char* data) +size_t Client::receive(char* data) { boost::system::error_code error; - int bytesReceived = m_Socket.receive_from(boost + size_t bytesReceived = m_Socket.receive_from(boost ::asio::buffer((void*)data, INPUTSIZE), m_ReceiverEndpoint, 0, error); @@ -390,7 +390,7 @@ void Client::identifyPacketLoss() bool Client::hasServerTimedOut() { // Time in ms - float timeSincePing = 1000 * (std::clock() - m_StartPingTime) / static_cast(CLOCKS_PER_SEC); + double timeSincePing = 1000 * (std::clock() - m_StartPingTime) / static_cast(CLOCKS_PER_SEC); if (timeSincePing > m_TimeoutMs) { // Clear everything and go to menu. LOG_INFO("Server has timed out, returning to menu, Beep Boop."); diff --git a/src/Engine/Network/Network.cpp b/src/Engine/Network/Network.cpp index f4dcd1a2..f43e5d83 100644 --- a/src/Engine/Network/Network.cpp +++ b/src/Engine/Network/Network.cpp @@ -26,10 +26,10 @@ void Network::saveToFile() outfile << "Total messages received," + std::to_string(m_NetworkData.AmountOfMessagesReceived) + "\n"; outfile << "Total messages sent," + std::to_string(m_NetworkData.AmountOfMessagesSent) + "\n"; - float messagesReceivedPerSec = (float)m_NetworkData.AmountOfMessagesReceived / (m_NetworkData.TotalTime / 1000); - float messagesSentPerSec = (float)m_NetworkData.AmountOfMessagesSent / (m_NetworkData.TotalTime / 1000); - float dataReceivedPerSec = (float)m_NetworkData.TotalDataReceived / (m_NetworkData.TotalTime / 1000); - float dataSentPerSec = (float)m_NetworkData.TotalDataSent / (m_NetworkData.TotalTime / 1000); + double messagesReceivedPerSec = m_NetworkData.AmountOfMessagesReceived / (m_NetworkData.TotalTime / 1000); + double messagesSentPerSec = m_NetworkData.AmountOfMessagesSent / (m_NetworkData.TotalTime / 1000); + double dataReceivedPerSec = m_NetworkData.TotalDataReceived / (m_NetworkData.TotalTime / 1000); + double dataSentPerSec = m_NetworkData.TotalDataSent / (m_NetworkData.TotalTime / 1000); outfile << "Avarage messages received / s: " + std::to_string(messagesReceivedPerSec) + "\n"; outfile << "Avarage messages sents / s: " + std::to_string(messagesSentPerSec) + "\n"; outfile << "Avarage data received B/s: " + std::to_string(dataReceivedPerSec) + "\n"; @@ -52,7 +52,7 @@ void Network::updateNetworkData() if (m_SaveDataIntervalMs < (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC)) { // Set values m_NetworkData.TotalTime += (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC); - m_NetworkData.BandwidthBytes.push_back(std::pair(m_NetworkData.DataReceivedThisInterval, m_NetworkData.DataSentThisInterval)); + m_NetworkData.BandwidthBytes.push_back(std::pair(m_NetworkData.DataReceivedThisInterval, m_NetworkData.DataSentThisInterval)); // Reset interval stuff m_SaveDataTimer = std::clock(); m_NetworkData.DataSentThisInterval = 0; diff --git a/src/Engine/Network/Packet.cpp b/src/Engine/Network/Packet.cpp index d40a1b32..21226a07 100644 --- a/src/Engine/Network/Packet.cpp +++ b/src/Engine/Network/Packet.cpp @@ -7,7 +7,7 @@ Packet::Packet(MessageType type, unsigned int& packetID) } // Create message -Packet::Packet(char* data, const int sizeOfPacket) +Packet::Packet(char* data, const size_t sizeOfPacket) { // Resize message m_MaxPacketSize = sizeOfPacket; @@ -45,7 +45,7 @@ void Packet::Init(MessageType type, unsigned int & packetID) void Packet::WriteString(const std::string& str) { // Message, add one extra byte for null terminator - int sizeOfString = str.size() + 1; + size_t sizeOfString = str.size() + 1; if (m_Offset + sizeOfString > m_MaxPacketSize) { //LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2); resizeData(); @@ -82,7 +82,7 @@ char * Packet::ReadData(int SizeOfData) //LOG_WARNING("packet ReadData(): Oh no! You are trying to remove things outside my memory kingdom"); return nullptr; } - unsigned int oldReturnDataOffset = m_ReturnDataOffset; + size_t oldReturnDataOffset = m_ReturnDataOffset; m_ReturnDataOffset += SizeOfData; return (m_Data + oldReturnDataOffset); } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index adf810aa..962081cc 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -4,7 +4,7 @@ Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::a { Network::initialize(); ConfigFile* config = ResourceManager::Load("Config.ini"); - snapshotInterval = 1000 * config->Get("Networking.SnapshotInterval", 0.05); + snapshotInterval = 1000 * config->Get("Networking.SnapshotInterval", 0.05f); pingIntervalMs = config->Get("Networking.PingIntervalMs", 1000); } @@ -43,7 +43,7 @@ void Server::readFromClients() bytesRead = receive(readBuffer); Packet packet(readBuffer, bytesRead); parseMessageType(packet); - } catch (const std::exception& err) { + } catch (const std::exception&) { //LOG_ERROR("%i: Read from client crashed %s", m_PacketID, err.what()); } } @@ -103,9 +103,9 @@ void Server::parseMessageType(Packet& packet) } } -int Server::receive(char * data) +size_t Server::receive(char * data) { - unsigned int length = m_Socket.receive_from( + size_t length = m_Socket.receive_from( boost::asio::buffer((void*)data , INPUTSIZE) , m_ReceiverEndpoint, 0); @@ -121,7 +121,7 @@ int Server::receive(char * data) void Server::send(PlayerID player, Packet& packet) { try { - int bytesSent = m_Socket.send_to( + size_t bytesSent = m_Socket.send_to( boost::asio::buffer(packet.Data(), packet.Size()), m_ConnectedPlayers[player].Endpoint, 0); @@ -131,7 +131,7 @@ void Server::send(PlayerID player, Packet& packet) m_NetworkData.DataSentThisInterval += packet.Size(); m_NetworkData.AmountOfMessagesSent++; } - } catch (const boost::system::system_error& e) { + } catch (const boost::system::system_error&) { // TODO: Clean up invalid endpoints out of m_ConnectedPlayers later m_ConnectedPlayers[player].Endpoint = boost::asio::ip::udp::endpoint(); } @@ -231,12 +231,12 @@ void Server::sendPing() void Server::checkForTimeOuts() { - int startPing = 1000 * m_StartPingTime + double startPing = 1000 * m_StartPingTime / static_cast(CLOCKS_PER_SEC); for (int i = 0; i < m_ConnectedPlayers.size(); i++) { if (m_ConnectedPlayers[i].Endpoint.address() != boost::asio::ip::address()) { - int stopPing = 1000 * m_ConnectedPlayers[i].StopTime / + double stopPing = 1000 * m_ConnectedPlayers[i].StopTime / static_cast(CLOCKS_PER_SEC); if (startPing > stopPing + m_TimeoutMs) { LOG_INFO("User %i timed out!", i); diff --git a/src/Game/Systems/InterpolationSystem.cpp b/src/Game/Systems/InterpolationSystem.cpp index bfb6952a..f2de710d 100644 --- a/src/Game/Systems/InterpolationSystem.cpp +++ b/src/Game/Systems/InterpolationSystem.cpp @@ -5,7 +5,7 @@ InterpolationSystem::InterpolationSystem(World* world, EventBroker* eventBroker) , PureSystem("Transform") { ConfigFile* config = ResourceManager::Load("Config.ini"); - m_SnapshotInterval = config->Get("Networking.SnapshotInterval", 0.05); + m_SnapshotInterval = config->Get("Networking.SnapshotInterval", 0.05f); EVENT_SUBSCRIBE_MEMBER(m_EInterpolate, &InterpolationSystem::OnInterpolate); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &InterpolationSystem::OnPlayerSpawned); } @@ -18,9 +18,9 @@ void InterpolationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrappe } if (m_NextTransform.find(transform.EntityID) != m_NextTransform.end()) { // Exists in map - m_NextTransform[transform.EntityID].interpolationTime += dt; + m_NextTransform[transform.EntityID].interpolationTime += static_cast(dt); Transform sTransform = m_NextTransform[transform.EntityID]; - double time = sTransform.interpolationTime; + float time = sTransform.interpolationTime; if (time > m_SnapshotInterval) { if (m_LastReceivedTransform.find(transform.EntityID) != m_LastReceivedTransform.end()) { m_NextTransform[transform.EntityID] = m_LastReceivedTransform[transform.EntityID]; From 45a92b362f6877695715566e9ef22b42b493c5a8 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 2 Feb 2016 15:10:11 +0100 Subject: [PATCH 27/43] DoubleJumping now in InputController instead. --- include/Engine/Input/FirstPersonInputController.h | 15 ++++++++++----- include/Game/Systems/PlayerMovementSystem.h | 2 -- src/Game/Systems/PlayerMovementSystem.cpp | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 426670c4..d4c9071c 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -15,7 +15,11 @@ public: virtual const glm::vec3 Rotation() const { return m_Rotation; } virtual bool Jumping() const { return m_Jumping; } virtual bool Crouching() const { return m_Crouching; } - + virtual bool DoubleJumping() const { return m_DoubleJumping; } + virtual void SetDoubleJumping(bool isDoubleJumping) { + m_DoubleJumping = isDoubleJumping; + } + void LockMouse(); void UnlockMouse(); virtual bool OnCommand(const Events::InputCommand& e) override; @@ -27,8 +31,9 @@ protected: glm::vec3 m_Rotation; glm::vec3 m_Movement; bool m_Jumping = false; + bool m_DoubleJumping = false; bool m_Crouching = false; - + EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); EventRelay m_EUnlockMouse; @@ -36,7 +41,7 @@ protected: }; template -FirstPersonInputController::FirstPersonInputController(EventBroker* eventBroker, int playerID) +FirstPersonInputController::FirstPersonInputController(EventBroker* eventBroker, int playerID) : InputController(eventBroker) , m_PlayerID(playerID) { @@ -113,14 +118,14 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm template bool FirstPersonInputController::OnUnlockMouse(const Events::UnlockMouse& e) { - m_MouseLocked = false; + m_MouseLocked = false; return true; } template bool FirstPersonInputController::OnLockMouse(const Events::LockMouse& e) { - m_MouseLocked = true; + m_MouseLocked = true; return true; } diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 4fbb2c79..f39740ec 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -20,6 +20,4 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); - - bool m_DoubleJumped = false; }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 868751f7..72900d7a 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -76,12 +76,12 @@ void PlayerMovementSystem::Update(double dt) ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } - if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !m_DoubleJumped)) { + if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { - m_DoubleJumped = false; + controller->SetDoubleJumping(false); } else { - m_DoubleJumped = true; + controller->SetDoubleJumping(true); } velocity.y += 4.f; } From b131f56f5e4b96d5c180abd43fe54614f6228370 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 16:06:42 +0100 Subject: [PATCH 28/43] Made a quality assurance world that will need to be used before creating a pull request --- assets | 2 +- resources/Schema/Entities/AssetPedistal.xml | 51 + .../Schema/Entities/QualityAssurance.xml | 1230 +++++++++++++++++ .../Entities/SpawnPointClusterWithModels.xml | 68 + .../Entities/SpawnerWithPlayerModel.xml | 16 + src/Engine/Rendering/RenderSystem.cpp | 2 +- 6 files changed, 1367 insertions(+), 2 deletions(-) create mode 100644 resources/Schema/Entities/AssetPedistal.xml create mode 100644 resources/Schema/Entities/QualityAssurance.xml create mode 100644 resources/Schema/Entities/SpawnPointClusterWithModels.xml create mode 100644 resources/Schema/Entities/SpawnerWithPlayerModel.xml diff --git a/assets b/assets index 415bbd54..c4898d82 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 415bbd5409174bdd1257db57326f3e1ff66d7faf +Subproject commit c4898d8281b5584d89b1caf14dab8e5fac120321 diff --git a/resources/Schema/Entities/AssetPedistal.xml b/resources/Schema/Entities/AssetPedistal.xml new file mode 100644 index 00000000..728a3028 --- /dev/null +++ b/resources/Schema/Entities/AssetPedistal.xml @@ -0,0 +1,51 @@ + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml new file mode 100644 index 00000000..018e1121 --- /dev/null +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -0,0 +1,1230 @@ + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + Audio/crosscounter.wav + true + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Sound Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + 0.80000001192092896 + + + Models/DirectionalLightWidget.mesh + + + 1 + + + + + + + + + + + + + + + + + + + + + Run + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + + + Walk + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + Animation test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Run + + 1 + + + Models/AssaultAnimated.mesh + + + + + + + + + + + + + + + + + + + + + + + + models/NormSpecIncdMapSphere.mesh + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 5.0100002288818359 + 0.69999998807907104 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 4 + 0.80000001192092896 + + + + + + + + + + + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + + + + + TextureMap's Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1.3999999761581421 + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + Spawn Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + Models/Core/UnitRaptor.mesh + + true + + + + + + + + + + + Models/Assault.mesh + + true + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + Transparency Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponRed.mesh + + + + + + + + + + + + + + + + Asset Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/SecondaryWeapon.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssualtSoft.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunRed.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/Assualt.mesh + + + + + + + + + + + + + + + + + + + + + + + + CapturePoint Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Red team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + 1 + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Free capture point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + + 3 + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Blue team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Test/ObstacleCourse.mesh + + + + + + + + + + + Collision Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnPointClusterWithModels.xml b/resources/Schema/Entities/SpawnPointClusterWithModels.xml new file mode 100644 index 00000000..9c42d0e4 --- /dev/null +++ b/resources/Schema/Entities/SpawnPointClusterWithModels.xml @@ -0,0 +1,68 @@ + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnerWithPlayerModel.xml b/resources/Schema/Entities/SpawnerWithPlayerModel.xml new file mode 100644 index 00000000..1274eefa --- /dev/null +++ b/resources/Schema/Entities/SpawnerWithPlayerModel.xml @@ -0,0 +1,16 @@ + + + + + + + Models/Assault.mesh + + + + + + + + + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index b51ab7f8..eaecf99e 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -245,7 +245,7 @@ void RenderSystem::Update(double dt) scene.Viewport = Rectangle(1280, 720); auto cSceneLight = m_World->GetComponents("SceneLight"); - if (cSceneLight != nullptr) { + if (cSceneLight != nullptr && cSceneLight->begin() != cSceneLight->end()) { m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; From 12a181c1ff5848831df5b9f4bdf9d32e4c05cdae Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 16:11:03 +0100 Subject: [PATCH 29/43] Fixed a bug where normals scaled with model scale. Again. --- .../Schema/Entities/QualityAssurance.xml | 48 ++++++++++--------- resources/Shaders/ForwardPlus.frag.glsl | 1 + 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 018e1121..cef0582b 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -20,12 +20,14 @@ - + - + + 90 + - + @@ -37,7 +39,7 @@ - + @@ -96,7 +98,7 @@ - + @@ -113,7 +115,7 @@ Run - + 1 @@ -129,7 +131,7 @@ Walk - + 1 @@ -179,7 +181,7 @@ - + @@ -187,7 +189,7 @@ Run - + 1 @@ -208,7 +210,7 @@ - + @@ -228,7 +230,7 @@ - + @@ -292,7 +294,7 @@ - + @@ -324,7 +326,7 @@ - + @@ -673,7 +675,7 @@ - + @@ -720,7 +722,7 @@ - + @@ -780,7 +782,7 @@ - + @@ -827,7 +829,7 @@ - + @@ -873,7 +875,7 @@ - + @@ -920,7 +922,7 @@ - + @@ -967,7 +969,7 @@ - + @@ -991,7 +993,7 @@ - + @@ -1015,7 +1017,7 @@ - + @@ -1102,7 +1104,7 @@ - + diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 3431ed6b..c09e0438 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -119,6 +119,7 @@ void main() vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); vec4 position = V * M * vec4(Input.Position, 1.0); vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture); + normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); From eba36b84929f178cce18844acb615de429fce201 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 17:12:14 +0100 Subject: [PATCH 30/43] Some QA-map fixes --- .../Schema/Entities/QualityAssurance.xml | 405 +++++++++++++++--- resources/Schema/Entities/SoundEmitter.xml | 24 ++ 2 files changed, 378 insertions(+), 51 deletions(-) create mode 100644 resources/Schema/Entities/SoundEmitter.xml diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index cef0582b..b01d21ce 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -10,12 +10,13 @@ + + Models/Core/UnitPlane.mesh - @@ -39,7 +40,7 @@ - + @@ -50,7 +51,7 @@ true - + @@ -66,6 +67,12 @@ + + + + + + @@ -98,7 +105,7 @@ - + @@ -106,8 +113,8 @@ - - + + @@ -115,7 +122,7 @@ Run - + 1 @@ -131,7 +138,7 @@ Walk - + 1 @@ -181,7 +188,7 @@ - + @@ -189,7 +196,7 @@ Run - + 1 @@ -210,7 +217,7 @@ - + @@ -230,7 +237,7 @@ - + @@ -294,7 +301,7 @@ - + @@ -326,7 +333,7 @@ - + @@ -364,7 +371,7 @@ - + TextureMap's Test @@ -372,7 +379,7 @@ - + @@ -391,7 +398,7 @@ - + @@ -473,7 +480,7 @@ - + @@ -554,7 +561,7 @@ - + @@ -580,6 +587,7 @@ + @@ -626,7 +634,7 @@ - + Transparency Test @@ -634,7 +642,7 @@ - + @@ -644,7 +652,7 @@ - + @@ -675,7 +683,7 @@ - + @@ -722,7 +730,7 @@ - + @@ -782,7 +790,7 @@ - + @@ -829,7 +837,7 @@ - + @@ -875,7 +883,7 @@ - + @@ -922,7 +930,7 @@ - + @@ -969,7 +977,7 @@ - + @@ -993,7 +1001,7 @@ - + @@ -1014,14 +1022,13 @@ Models/CapturePoint.mesh - - + - + @@ -1031,16 +1038,23 @@ Models/Core/UnitCube.mesh - + true - - + + + + + + + + + - + Red team home point @@ -1056,6 +1070,51 @@ + + + + Models/CapturePoint.mesh + + + + + + + + + + + 1 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + RedMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + @@ -1064,27 +1123,29 @@ - + - 1 + 2 Models/Core/UnitCube.mesh - true - + + + + - + - Free capture point + Middle Point Fonts/DroidSans.ttf,64 @@ -1097,38 +1158,90 @@ + + + + Models/CapturePoint.mesh + + + + + + + + + + + -12.033302729641917 + 3 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + BlueMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + Models/CapturePoint.mesh - - + - + - 3 + 4 Models/Core/UnitCube.mesh - + true - - + + + + + + + + + - + Blue team home point @@ -1227,6 +1340,196 @@ + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + true + + 0.66670660122008485 + 3.7999999523162842 + + true + + + Models/AssaultWeaponBlue.mesh + true + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + + + 0.20002680222910385 + + + Models/Assault.mesh + true + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Walk + + 1 + + + true + + + 1.4833885697323694 + + true + + + Models/AssaultAnimated.mesh + true + + + + + + + + + + + + + + + ExplosionEffect Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + diff --git a/resources/Schema/Entities/SoundEmitter.xml b/resources/Schema/Entities/SoundEmitter.xml new file mode 100644 index 00000000..39b4c750 --- /dev/null +++ b/resources/Schema/Entities/SoundEmitter.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + From 11025b5466e79397ddaa0e7c7f3abffa6d787592 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 17:19:58 +0100 Subject: [PATCH 31/43] QA-map stuff --- .../Schema/Entities/QualityAssurance.xml | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index b01d21ce..c711d5dd 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -122,7 +122,7 @@ Run - + 1 @@ -138,7 +138,7 @@ Walk - + 1 @@ -188,7 +188,7 @@ - + @@ -196,7 +196,7 @@ Run - + 1 @@ -237,7 +237,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -333,7 +333,7 @@ - + @@ -683,7 +683,7 @@ - + @@ -730,7 +730,7 @@ - + @@ -790,7 +790,7 @@ - + @@ -837,7 +837,7 @@ - + @@ -883,7 +883,7 @@ - + @@ -930,7 +930,7 @@ - + @@ -977,7 +977,7 @@ - + @@ -1374,7 +1374,7 @@ - + @@ -1383,7 +1383,7 @@ true - 0.66670660122008485 + 2.6005657651057277 3.7999999523162842 true @@ -1430,7 +1430,7 @@ - + @@ -1439,7 +1439,7 @@ - 0.20002680222910385 + 1.1504741652238408 Models/Assault.mesh @@ -1482,7 +1482,7 @@ - + @@ -1490,14 +1490,14 @@ Walk - + 1 true - 1.4833885697323694 + 0.43378409460495959 true From a3b7bd7df54ffa92ff2dd7c20d8bc7386d217e88 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 17:39:57 +0100 Subject: [PATCH 32/43] Fix in picking pass, QA map fix. Blue and red ray change. Player weapon change. --- resources/Schema/Entities/Player.xml | 17 +++++-- .../Schema/Entities/QualityAssurance.xml | 50 +++++++++---------- resources/Schema/Entities/RayBlue.xml | 3 +- resources/Schema/Entities/RayRed.xml | 3 +- src/Engine/Rendering/PickingPass.cpp | 8 +-- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e81ec5aa..d365c0ee 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -2,12 +2,12 @@ - + @@ -20,7 +20,7 @@ - + @@ -101,12 +101,19 @@ + + true + + 3.7999999523162842 + + true + - Models/AssaultWeapon.mesh + Models/AssaultWeaponRed.mesh - + @@ -141,7 +148,7 @@ Hold Pos - + 1 diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index c711d5dd..55e67c9b 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -122,7 +122,7 @@ Run - + 1 @@ -138,7 +138,7 @@ Walk - + 1 @@ -188,7 +188,7 @@ - + @@ -196,7 +196,7 @@ Run - + 1 @@ -237,7 +237,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -333,7 +333,7 @@ - + @@ -683,7 +683,7 @@ - + @@ -730,7 +730,7 @@ - + @@ -790,7 +790,7 @@ - + @@ -837,7 +837,7 @@ - + @@ -883,7 +883,7 @@ - + @@ -930,7 +930,7 @@ - + @@ -977,7 +977,7 @@ - + @@ -1304,7 +1304,7 @@ Models/Core/UnitCube.mesh - + @@ -1332,7 +1332,7 @@ Models/Core/UnitCube.mesh - + @@ -1374,7 +1374,7 @@ - + @@ -1383,7 +1383,7 @@ true - 2.6005657651057277 + 0.016748705294958199 3.7999999523162842 true @@ -1430,7 +1430,7 @@ - + @@ -1439,7 +1439,7 @@ - 1.1504741652238408 + 0.96672645330102114 Models/Assault.mesh @@ -1482,7 +1482,7 @@ - + @@ -1490,14 +1490,14 @@ Walk - + 1 true - 0.43378409460495959 + 0.51665750859842774 true diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 3b985a7e..4a0bb9d4 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml index df563476..e69df489 100644 --- a/resources/Schema/Entities/RayRed.xml +++ b/resources/Schema/Entities/RayRed.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 792539f8..3a86dd60 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -75,9 +75,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } @@ -121,9 +121,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } From 73716c28e225d57c9bd1d15f56b92dd975af9b2e Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 2 Feb 2016 17:40:22 +0100 Subject: [PATCH 33/43] pickpass fix --- src/Engine/Rendering/PickingPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 3a86dd60..abc79f2e 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -77,7 +77,7 @@ void PickingPass::Draw(RenderScene& scene) m_ColorCounter[0] = 0; m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 1; + m_ColorCounter[0] += 1; } } From 51a588657efdf1df96d126d15fd25ccd8518c392 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 3 Feb 2016 10:11:53 +0100 Subject: [PATCH 34/43] QA map change --- .../Schema/Entities/QualityAssurance.xml | 69 ++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 55e67c9b..e057cf38 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -122,7 +122,7 @@ Run - + 1 @@ -138,7 +138,7 @@ Walk - + 1 @@ -188,7 +188,7 @@ - + @@ -196,7 +196,7 @@ Run - + 1 @@ -237,7 +237,7 @@ - + @@ -301,7 +301,7 @@ - + @@ -333,7 +333,7 @@ - + @@ -683,7 +683,7 @@ - + @@ -730,7 +730,7 @@ - + @@ -790,7 +790,7 @@ - + @@ -837,7 +837,7 @@ - + @@ -883,7 +883,7 @@ - + @@ -930,7 +930,7 @@ - + @@ -977,7 +977,7 @@ - + @@ -1374,7 +1374,7 @@ - + @@ -1383,7 +1383,7 @@ true - 0.016748705294958199 + 0.75008034908941568 3.7999999523162842 true @@ -1430,7 +1430,7 @@ - + @@ -1439,7 +1439,7 @@ - 0.96672645330102114 + 1.1999860997035228 Models/Assault.mesh @@ -1482,7 +1482,7 @@ - + @@ -1490,14 +1490,14 @@ Walk - + 1 true - 0.51665750859842774 + 0.68343188336345406 true @@ -1530,6 +1530,29 @@ + + + + + + + + + + + Remember to pick random entities. + Fonts/DroidSans.ttf,64 + + + + + + + + + + + From 9d3171540df1d0acd04174a564459ab13b4ae4b6 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 11:54:14 +0100 Subject: [PATCH 35/43] AssaultDashCheck is now in FirstPersonInputController instead. TODO: config option, shift button, forward/backward dash --- .../Engine/Input/FirstPersonInputController.h | 62 +++++++++++++++++++ include/Game/Systems/PlayerMovementSystem.h | 15 ----- src/Game/Systems/PlayerMovementSystem.cpp | 44 +------------ 3 files changed, 65 insertions(+), 56 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index d4c9071c..1efe4b75 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -25,6 +25,10 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); + void AssaultDashCheck(double dt, bool isJumping); + virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } + virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } + protected: const int m_PlayerID; bool m_MouseLocked = false; @@ -33,6 +37,23 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; + //assault dash enum + enum class AssaultDashDirection { + Left, + Right, + Forward, + Backward, + None + }; + //assault dash membervariables + double m_AssaultDashDoubleTapDeltaTime = 0.0f; + double m_AssaultDashCoolDownTimer = 0.0f; + double m_AssaultDashCoolDownMaxTimer = 3.0f; + AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; + AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + bool m_AssaultDashDoubleTapped = false; + bool m_PlayerIsDashing = false; EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -129,4 +150,45 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou return true; } +template +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { + auto controllerMovement = Movement(); + m_AssaultDashDoubleTapDeltaTime += dt; + m_AssaultDashCoolDownTimer -= dt; + //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + m_PlayerIsDashing = true; + } else { + m_PlayerIsDashing = false; + } + //reset the DoubleTapped state in case we recently doubleTapped + if (m_AssaultDashDoubleTapped) { + m_AssaultDashDoubleTapped = false; + } + //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash + if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Right && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Right; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Right; + } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Left && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Left; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Left; + } else { + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + } +} + #endif \ No newline at end of file diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 554d174e..34862e90 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -21,19 +21,4 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); - double m_AssaultDashDoubleTapDeltaTime = 0.0f; - double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 3.0f; - ImGuiKey m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; - const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; - enum class AssaultDashDirection { - Left, - Right, - None - }; - AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; - bool m_AssaultDashDoubleTapped = false; - bool m_PlayerIsDashing = false; - - void assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping); }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index c3eb1c84..70bbafb0 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,7 +43,7 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - //TODO: check if playerclass is assault! - assaultDashCheck(controller->Movement(), dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); float wishSpeed; if (controller->Crouching()) { @@ -74,14 +74,14 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; //if doubleTapped do Assault Dash - but only boost maximum 50.0f - float doubleTapDashBoost = m_AssaultDashDoubleTapped ? 20.0f : 1.0f; + float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 20.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } //you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air - if (!m_PlayerIsDashing && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { + if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { controller->SetDoubleJumping(false); } @@ -170,41 +170,3 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) return true; } -void PlayerMovementSystem::assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping) { - m_AssaultDashDoubleTapDeltaTime += dt; - m_AssaultDashCoolDownTimer -= dt; - //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) - if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { - m_PlayerIsDashing = true; - } else { - m_PlayerIsDashing = false; - } - //reset the DoubleTapped state in case we recently doubleTapped - if (m_AssaultDashDoubleTapped) { - m_AssaultDashDoubleTapped = false; - } - //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash - if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != ImGuiKey_RightArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = ImGuiKey_RightArrow; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Right; - } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != ImGuiKey_LeftArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = ImGuiKey_LeftArrow; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Left; - } else { - m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; - } -} From b56824786ce1c01f429b9f2309423bb1021a929e Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 3 Feb 2016 16:16:06 +0100 Subject: [PATCH 36/43] Revert "Merge pull request #75 from teamfisk/NormalSpecularMapping" This reverts commit 192de8078250ffc612c3d3642c484579959315bf, reversing changes made to 24aac6a00d27940de6a596ef0360f1ae9271aa78. --- assets | 2 +- .../Rendering/DrawColorCorrectionPass.h | 4 +- include/Engine/Rendering/RenderQueue.h | 4 - include/Engine/Rendering/Util/GLError.h | 2 +- resources/Schema/Components.xsd | 1 - resources/Schema/Components/SceneLight.xml | 7 - resources/Schema/Components/SceneLight.xsd | 25 - resources/Schema/Entities/AssetPedistal.xml | 51 - resources/Schema/Entities/EditorTestWorld.xml | 196 +-- .../Schema/Entities/EditorWidgetTranslate.xml | 9 + resources/Schema/Entities/Player.xml | 17 +- .../Schema/Entities/QualityAssurance.xml | 1558 ----------------- resources/Schema/Entities/RayBlue.xml | 3 +- resources/Schema/Entities/RayRed.xml | 3 +- resources/Schema/Entities/SoundEmitter.xml | 24 - .../Entities/SpawnPointClusterWithModels.xml | 68 - .../Entities/SpawnerWithPlayerModel.xml | 16 - resources/Schema/Types/Entity.xsd | 1 - .../Shaders/DrawColorCorrection.frag.glsl | 4 +- resources/Shaders/ExplosionEffect.geom.glsl | 28 +- resources/Shaders/ForwardPlus.frag.glsl | 15 +- resources/Shaders/ForwardPlus.vert.glsl | 4 +- src/Engine/Editor/EditorRenderSystem.cpp | 8 +- .../Rendering/DrawColorCorrectionPass.cpp | 10 +- src/Engine/Rendering/DrawFinalPass.cpp | 70 +- src/Engine/Rendering/FrameBuffer.cpp | 7 + src/Engine/Rendering/PickingPass.cpp | 8 +- src/Engine/Rendering/RenderSystem.cpp | 9 +- src/Engine/Rendering/Renderer.cpp | 4 +- 29 files changed, 137 insertions(+), 2021 deletions(-) delete mode 100644 resources/Schema/Components/SceneLight.xml delete mode 100644 resources/Schema/Components/SceneLight.xsd delete mode 100644 resources/Schema/Entities/AssetPedistal.xml delete mode 100644 resources/Schema/Entities/QualityAssurance.xml delete mode 100644 resources/Schema/Entities/SoundEmitter.xml delete mode 100644 resources/Schema/Entities/SpawnPointClusterWithModels.xml delete mode 100644 resources/Schema/Entities/SpawnerWithPlayerModel.xml diff --git a/assets b/assets index c4898d82..091ad5c0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c4898d8281b5584d89b1caf14dab8e5fac120321 +Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index fcde73d7..e9a7e281 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -7,7 +7,6 @@ #include "ShaderProgram.h" //#include "Util/UnorderedMapVec2.h" #include "Texture.h" -#include "imgui/imgui.h" class DrawColorCorrectionPass { @@ -17,13 +16,14 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure); + void Draw(GLuint sceneTexture, GLuint bloomTexture); private: const IRenderer* m_Renderer; ShaderProgram* m_ColorCorrectionProgram; Model* m_ScreenQuad; + GLfloat m_Exposure; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index af9d928e..57371146 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -26,7 +26,6 @@ struct RenderScene std::list> DirectionalLightJobs; Rectangle Viewport; bool ClearDepth = false; - glm::vec4 AmbientColor; void Clear() { @@ -41,9 +40,6 @@ struct RenderScene struct RenderFrame { public: - //TODO: Getters - GLfloat Gamma = 2.2f; - GLfloat Exposure = 1.f; void Add(RenderScene &scene) { diff --git a/include/Engine/Rendering/Util/GLError.h b/include/Engine/Rendering/Util/GLError.h index 2b244e1c..754623d1 100644 --- a/include/Engine/Rendering/Util/GLError.h +++ b/include/Engine/Rendering/Util/GLError.h @@ -9,7 +9,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig GLenum error = glGetError(); if (error != GL_NO_ERROR) { - _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s\nError code: %i, %s\n", info, error, gluErrorString(error)); + _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s, %i, %s", info, error, gluErrorString(error)); return true; } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index bb1fd770..ab46b0ea 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -11,7 +11,6 @@ - diff --git a/resources/Schema/Components/SceneLight.xml b/resources/Schema/Components/SceneLight.xml deleted file mode 100644 index 80b6b9f4..00000000 --- a/resources/Schema/Components/SceneLight.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - true - 2.2 - 1 - \ No newline at end of file diff --git a/resources/Schema/Components/SceneLight.xsd b/resources/Schema/Components/SceneLight.xsd deleted file mode 100644 index 9f8a9705..00000000 --- a/resources/Schema/Components/SceneLight.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - Some settings for the scene lighting - - - - - Color of the ambient light - - - Wether the ambient light should be applied or not - - - Gamma correction for the scene - - - The exposure of the camera - - - - - \ No newline at end of file diff --git a/resources/Schema/Entities/AssetPedistal.xml b/resources/Schema/Entities/AssetPedistal.xml deleted file mode 100644 index 728a3028..00000000 --- a/resources/Schema/Entities/AssetPedistal.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/AssaultWeaponBlue.mesh - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 4727c777..9565e2d4 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -2,9 +2,7 @@ - - - + @@ -20,7 +18,7 @@ - + @@ -40,27 +38,18 @@ Models/DirectionalLightWidget.mesh - 1 + 1.0499999523162842 - + - - true - - - 5.0498686575577523 - 5 - - 3 - Models/Assault.mesh @@ -73,26 +62,11 @@ - Models/AssaultWeaponRed.mesh - true + Models/SecondaryWeapon.mesh - - - - - - - - - - Models/DefenderGunRed.mesh - true - false - - - - + + @@ -111,7 +85,7 @@ Run - + 1 @@ -127,7 +101,7 @@ Walk - + 1 @@ -173,6 +147,70 @@ + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + @@ -189,7 +227,7 @@ - + @@ -246,94 +284,8 @@ - - - - 1 - - - - - - - - - - - Models/NormalMapSphere.mesh - - - - - - - - - - - Models/SpecularMapSphere.mesh - - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - - - - - Models/IncandescenceMapSphere.mesh - - - - - - - - - - - - - 1.3999999761581421 - - - - - diff --git a/resources/Schema/Entities/EditorWidgetTranslate.xml b/resources/Schema/Entities/EditorWidgetTranslate.xml index c6dba4d9..d4ed5e76 100644 --- a/resources/Schema/Entities/EditorWidgetTranslate.xml +++ b/resources/Schema/Entities/EditorWidgetTranslate.xml @@ -84,6 +84,15 @@ + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d365c0ee..e81ec5aa 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -2,12 +2,12 @@ + - @@ -20,7 +20,7 @@ - + @@ -101,19 +101,12 @@ - - true - - 3.7999999523162842 - - true - - Models/AssaultWeaponRed.mesh + Models/AssaultWeapon.mesh - + @@ -148,7 +141,7 @@ Hold Pos - + 1 diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml deleted file mode 100644 index e057cf38..00000000 --- a/resources/Schema/Entities/QualityAssurance.xml +++ /dev/null @@ -1,1558 +0,0 @@ - - - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - - - - - - - - - - 90 - - - - - - - - - - - - 1 - - - - - - - - - - - Audio/crosscounter.wav - true - - - - - - - - - - SoundEmitter - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - Sound Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - 0.80000001192092896 - - - Models/DirectionalLightWidget.mesh - - - 1 - - - - - - - - - - - - - - - - - - - - - Run - - 1 - - - models/AssaultAnimated.mesh - - - - - - - - - - - Walk - - 1 - - - models/AssaultAnimated.mesh - - - - - - - - - Animation test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Run - - 1 - - - Models/AssaultAnimated.mesh - - - - - - - - - - - - - - - - - - - - - - - - models/NormSpecIncdMapSphere.mesh - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 5.0100002288818359 - 0.69999998807907104 - - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 4 - 0.80000001192092896 - - - - - - - - - - - - - - 1 - - - - - - - - - - - Models/NormalMapSphere.mesh - - - - - - - - - - - Models/SpecularMapSphere.mesh - - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - - - - - Models/IncandescenceMapSphere.mesh - - - - - - - - - - - - - TextureMap's Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - 1.3999999761581421 - - - - - - - - - - - - - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - - - Spawn Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - true - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - Models/Core/UnitRaptor.mesh - - true - - - - - - - - - - - Models/Assault.mesh - - true - - - - - - - - - - - - Models/Core/UnitCube.mesh - - true - - - - - - - - - - - - - Transparency Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/AssaultWeaponBlue.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/AssaultWeaponRed.mesh - - - - - - - - - - - - - - - - Asset Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/SecondaryWeapon.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/AssualtSoft.mesh - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/DefenderGunBlue.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/DefenderGunRed.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/Assualt.mesh - - - - - - - - - - - - - - - - - - - - - - - - CapturePoint Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Models/CapturePoint.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - true - - - - - - - - - - - - - - - - - - Red team home point - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - Models/CapturePoint.mesh - - - - - - - - - - - 1 - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - RedMiddle Point - Fonts/DroidSans.ttf - - - - - - - - - - - - - - - Models/CapturePoint.mesh - - - - - - - - - 2 - - - Models/Core/UnitCube.mesh - true - - - - - - - - - - - - - - Middle Point - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - Models/CapturePoint.mesh - - - - - - - - - - - -12.033302729641917 - 3 - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - BlueMiddle Point - Fonts/DroidSans.ttf - - - - - - - - - - - - - - - Models/CapturePoint.mesh - - - - - - - - - - - - - - 4 - - - Models/Core/UnitCube.mesh - - true - - - - - - - - - - - - - - - - - - Blue team home point - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Models/Test/ObstacleCourse.mesh - - - - - - - - - - - Collision Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - true - - 0.75008034908941568 - 3.7999999523162842 - - true - - - Models/AssaultWeaponBlue.mesh - true - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - 1.1999860997035228 - - - Models/Assault.mesh - true - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Walk - - 1 - - - true - - - 0.68343188336345406 - - true - - - Models/AssaultAnimated.mesh - true - - - - - - - - - - - - - - - ExplosionEffect Test - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - Remember to pick random entities. - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 4a0bb9d4..3b985a7e 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -7,8 +7,7 @@ Models/CylinderBullet.mesh - - true + diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml index e69df489..df563476 100644 --- a/resources/Schema/Entities/RayRed.xml +++ b/resources/Schema/Entities/RayRed.xml @@ -7,8 +7,7 @@ Models/CylinderBullet.mesh - - true + diff --git a/resources/Schema/Entities/SoundEmitter.xml b/resources/Schema/Entities/SoundEmitter.xml deleted file mode 100644 index 39b4c750..00000000 --- a/resources/Schema/Entities/SoundEmitter.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - SoundEmitter - Fonts/DroidSans.ttf,64 - - - - - - - - - - diff --git a/resources/Schema/Entities/SpawnPointClusterWithModels.xml b/resources/Schema/Entities/SpawnPointClusterWithModels.xml deleted file mode 100644 index 9c42d0e4..00000000 --- a/resources/Schema/Entities/SpawnPointClusterWithModels.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - - - Models/Assault.mesh - - - - - - - - - - diff --git a/resources/Schema/Entities/SpawnerWithPlayerModel.xml b/resources/Schema/Entities/SpawnerWithPlayerModel.xml deleted file mode 100644 index 1274eefa..00000000 --- a/resources/Schema/Entities/SpawnerWithPlayerModel.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Models/Assault.mesh - - - - - - - - - diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 028af9e6..99b90caa 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -31,7 +31,6 @@ - diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 91ace0c7..8d13992a 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -3,7 +3,6 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; uniform float Exposure; -uniform float Gamma; in VertexData{ vec2 TextureCoordinate; @@ -13,6 +12,7 @@ out vec4 fragmentColor; void main() { + const float gamma = 2.2; vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); hdrColor += bloomColor; @@ -21,7 +21,7 @@ void main() vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); //gamme correction - result = pow(result, vec3(1.0 / Gamma)); + result = pow(result, vec3(1.0 / gamma)); fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index 44b44aa6..cb91b545 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -17,21 +17,15 @@ uniform bool ExponentialAccelaration; in VertexData{ vec3 Position; vec3 Normal; - vec3 Tangent; - vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; - float ExplosionPercentageElapsed; }Input[]; out VertexData{ vec3 Position; vec3 Normal; - vec3 Tangent; - vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; - float ExplosionPercentageElapsed; }Output; layout(triangles) in; @@ -120,17 +114,12 @@ void main() { // calculate the max distance (s) the triangle will move float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2)); - float te = (length(triangleCenter2ExplosionRadius) / s); - Output.ExplosionColor = EndColor; - Output.ExplosionPercentageElapsed = te; - + Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s); } else { - Output.ExplosionColor = EndColor; - Output.ExplosionPercentageElapsed = timePercetage; - + Output.ExplosionColor = EndColor * timePercetage; } // for every vertex on the triangle... @@ -143,8 +132,6 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; - Output.Tangent = Input[i].Tangent; - Output.BiTangent = Input[i].BiTangent; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -167,14 +154,11 @@ void main() // if explosion color should be affected by distance instead of time... if (ColorByDistance == true) { - Output.ExplosionColor = EndColor; - Output.ExplosionPercentageElapsed = 0.0; + Output.ExplosionColor = vec4(0.0); } else { - Output.ExplosionColor = EndColor; - Output.ExplosionPercentageElapsed = timePercetage; - + Output.ExplosionColor = EndColor * timePercetage; } // for every vertex on the triangle... @@ -184,9 +168,7 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; - Output.Tangent = Input[i].Tangent; - Output.BiTangent = Input[i].BiTangent; - + // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; EmitVertex(); diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index c09e0438..de672dd1 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -7,13 +7,13 @@ uniform vec4 Color; uniform vec4 DiffuseColor; uniform vec2 ScreenDimensions; uniform vec4 FillColor; -uniform vec4 AmbientColor; uniform float FillPercentage; layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; + #define TILE_SIZE 16 struct LightSource { @@ -55,12 +55,13 @@ in VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; - float ExplosionPercentageElapsed; }Input; out vec4 sceneColor; out vec4 bloomColor; +vec4 scene_ambient = vec4(0.3,0.3,0.3,1); + struct LightResult { vec4 Diffuse; vec4 Specular; @@ -119,7 +120,6 @@ void main() vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); vec4 position = V * M * vec4(Input.Position, 1.0); vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture); - normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); @@ -128,7 +128,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); + totalLighting.Diffuse = scene_ambient; int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); @@ -150,9 +150,8 @@ void main() totalLighting.Specular += light_result.Specular; } - vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); - color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; + + vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; @@ -161,7 +160,7 @@ void main() color_result += FillColor; } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - color_result += glowTexel*3; + color_result += glowTexel; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 3b3e931c..1a7cca12 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -20,7 +20,6 @@ out VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; - float ExplosionPercentageElapsed; }Output; void main() @@ -42,6 +41,5 @@ void main() Output.Normal = vec3(M * vec4(Normal, 0.0)); Output.Tangent = vec3(M * vec4(Tangent, 0.0)); Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); - Output.ExplosionColor = vec4(1.0); - Output.ExplosionPercentageElapsed = 0.0; + Output.ExplosionColor = vec4(0.0); } \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 4d65e9d3..67b09a21 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -23,12 +23,6 @@ void EditorRenderSystem::Update(double dt) scene.Camera = m_EditorCamera; scene.Viewport = Rectangle(1920, 1080); - auto cSceneLight = m_World->GetComponents("SceneLight"); - if (cSceneLight != nullptr) { - //these are hardcoded since they want special light treatment and a component just for widgets is stupid. - scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); - } - auto models = m_World->GetComponents("Model"); if (models != nullptr) { for (auto& cModel : *models) { @@ -55,7 +49,7 @@ void EditorRenderSystem::Update(double dt) glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); for (auto matGroup : model->MaterialGroups()) { std::shared_ptr modelJob = std::make_shared(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f); - if (cModel["Transparent"]) { + if(cModel["Transparent"]) { scene.TransparentObjects.push_back(modelJob); } else { scene.OpaqueObjects.push_back(modelJob); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 45401bce..ba9efe3e 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -5,8 +5,7 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer) m_Renderer = renderer; m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); - - //m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. + m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. InitializeShaderPrograms(); } @@ -20,16 +19,15 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - //glClear(GL_COLOR_BUFFER_BIT); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma); + glClear(GL_COLOR_BUFFER_BIT); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sceneTexture); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 8247797e..aa9da9a1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -44,7 +44,6 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor"); m_ForwardPlusProgram->Link(); - GLERROR("Creating forward+ program"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); @@ -54,12 +53,11 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor"); m_ExplosionEffectProgram->Link(); - GLERROR("Creating explosion program"); } void DrawFinalPass::Draw(RenderScene& scene) { - GLERROR("Pre"); + GLERROR("DrawFinalPass::Draw: Pre"); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { @@ -67,12 +65,12 @@ void DrawFinalPass::Draw(RenderScene& scene) } DrawModelRenderQueues(scene.OpaqueObjects, scene); - GLERROR("OpaqueObjects"); + GLERROR("DrawFinalPass::Draw: OpaqueObjects"); DrawModelRenderQueues(scene.TransparentObjects, scene); - GLERROR("TransparentObjects"); + GLERROR("DrawFinalPass::Draw: TransparentObjects"); + GLERROR("DrawFinalPass::Draw: END"); delete state; - GLERROR("END"); } @@ -113,9 +111,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: void DrawFinalPass::DrawModelRenderQueues(std::list>& job, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); - GLERROR("forwardHandle"); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); - GLERROR("explosionHandle"); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); @@ -126,21 +122,10 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& auto explosionEffectJob = std::dynamic_pointer_cast(job); if(explosionEffectJob) { //Bind program - if(GLERROR("Prebind")) { - continue; - } m_ExplosionEffectProgram->Bind(); - if(GLERROR("BindProgram")) { - continue; - } - - glDisable(GL_CULL_FACE); //Bind uniforms BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); - if(GLERROR("BindExplosionUniforms")) { - continue; - } if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -149,23 +134,13 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } - if(GLERROR("Animation")) { - continue; - } //bind textures BindExplosionTextures(explosionEffectJob); - if(GLERROR("BindExplosionTextures")) { - continue; - } //draw glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); - glEnable(GL_CULL_FACE); - if(GLERROR("explosion effect end")) { - continue; - } } else { auto modelJob = std::dynamic_pointer_cast(job); @@ -192,9 +167,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int))); - if(GLERROR("models end")) { - continue; - } + GLERROR("DrawFinalPass::Model: END"); } } } @@ -203,46 +176,36 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); + glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin)); glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath); glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration); glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor)); glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness); - glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar); glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity)); glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance); glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration); - - glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); - glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); - glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); - glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); - GLERROR("END"); + glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); } void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); - glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); - - GLERROR("END"); } @@ -254,22 +217,7 @@ void DrawFinalPass::BindExplosionTextures(std::shared_ptr& j } else { glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); } - glActiveTexture(GL_TEXTURE1); - if (job->NormalTexture != nullptr) { - glBindTexture(GL_TEXTURE_2D, job->NormalTexture->m_Texture); - } else { - glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); - } - - glActiveTexture(GL_TEXTURE2); - if (job->SpecularTexture != nullptr) { - glBindTexture(GL_TEXTURE_2D, job->SpecularTexture->m_Texture); - } else { - glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture); - } - - glActiveTexture(GL_TEXTURE3); if (job->IncandescenceTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture); } else { diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 9677f50e..b7e908cc 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -54,6 +54,13 @@ void FrameBuffer::Generate() case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); + if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 || + (*it)->m_Attachment != GL_COLOR_ATTACHMENT1 || + (*it)->m_Attachment != GL_DEPTH_ATTACHMENT || + (*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta + { + LOG_ERROR("RenderBuffer Attachment not valid."); + } break; } diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index abc79f2e..792539f8 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -75,9 +75,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 1; + m_ColorCounter[1] += 5; } else { - m_ColorCounter[0] += 1; + m_ColorCounter[0] += 50; } } @@ -121,9 +121,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 1; + m_ColorCounter[1] += 5; } else { - m_ColorCounter[0] += 1; + m_ColorCounter[0] += 50; } } diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index eaecf99e..a0912a45 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -240,17 +240,10 @@ void RenderSystem::Update(double dt) m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera)); } + RenderScene scene; scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); - - auto cSceneLight = m_World->GetComponents("SceneLight"); - if (cSceneLight != nullptr && cSceneLight->begin() != cSceneLight->end()) { - m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; - m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; - scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; - } - fillModels(scene.OpaqueObjects, scene.TransparentObjects); fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index a63e02a0..bec86b4a 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -119,8 +119,8 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); - if (m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure); + if(m_DebugTextureToDraw == 0) { + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture()); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); From bd2da7bc9f88f8e9f27bfbeaa2c1cff210e0cdb4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 3 Feb 2016 16:30:00 +0100 Subject: [PATCH 37/43] Revert "Revert "Merge pull request #75 from teamfisk/NormalSpecularMapping"" This reverts commit b56824786ce1c01f429b9f2309423bb1021a929e. --- assets | 2 +- .../Rendering/DrawColorCorrectionPass.h | 4 +- include/Engine/Rendering/RenderQueue.h | 4 + include/Engine/Rendering/Util/GLError.h | 2 +- resources/Schema/Components.xsd | 1 + resources/Schema/Components/SceneLight.xml | 7 + resources/Schema/Components/SceneLight.xsd | 25 + resources/Schema/Entities/AssetPedistal.xml | 51 + resources/Schema/Entities/EditorTestWorld.xml | 196 ++- .../Schema/Entities/EditorWidgetTranslate.xml | 9 - resources/Schema/Entities/Player.xml | 17 +- .../Schema/Entities/QualityAssurance.xml | 1558 +++++++++++++++++ resources/Schema/Entities/RayBlue.xml | 3 +- resources/Schema/Entities/RayRed.xml | 3 +- resources/Schema/Entities/SoundEmitter.xml | 24 + .../Entities/SpawnPointClusterWithModels.xml | 68 + .../Entities/SpawnerWithPlayerModel.xml | 16 + resources/Schema/Types/Entity.xsd | 1 + .../Shaders/DrawColorCorrection.frag.glsl | 4 +- resources/Shaders/ExplosionEffect.geom.glsl | 28 +- resources/Shaders/ForwardPlus.frag.glsl | 15 +- resources/Shaders/ForwardPlus.vert.glsl | 4 +- src/Engine/Editor/EditorRenderSystem.cpp | 8 +- .../Rendering/DrawColorCorrectionPass.cpp | 10 +- src/Engine/Rendering/DrawFinalPass.cpp | 86 +- src/Engine/Rendering/FrameBuffer.cpp | 7 - src/Engine/Rendering/PickingPass.cpp | 8 +- src/Engine/Rendering/RenderSystem.cpp | 9 +- src/Engine/Rendering/Renderer.cpp | 4 +- 29 files changed, 2029 insertions(+), 145 deletions(-) create mode 100644 resources/Schema/Components/SceneLight.xml create mode 100644 resources/Schema/Components/SceneLight.xsd create mode 100644 resources/Schema/Entities/AssetPedistal.xml create mode 100644 resources/Schema/Entities/QualityAssurance.xml create mode 100644 resources/Schema/Entities/SoundEmitter.xml create mode 100644 resources/Schema/Entities/SpawnPointClusterWithModels.xml create mode 100644 resources/Schema/Entities/SpawnerWithPlayerModel.xml diff --git a/assets b/assets index 091ad5c0..c4898d82 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea +Subproject commit c4898d8281b5584d89b1caf14dab8e5fac120321 diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index e9a7e281..fcde73d7 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -7,6 +7,7 @@ #include "ShaderProgram.h" //#include "Util/UnorderedMapVec2.h" #include "Texture.h" +#include "imgui/imgui.h" class DrawColorCorrectionPass { @@ -16,14 +17,13 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; ShaderProgram* m_ColorCorrectionProgram; Model* m_ScreenQuad; - GLfloat m_Exposure; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 57371146..af9d928e 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -26,6 +26,7 @@ struct RenderScene std::list> DirectionalLightJobs; Rectangle Viewport; bool ClearDepth = false; + glm::vec4 AmbientColor; void Clear() { @@ -40,6 +41,9 @@ struct RenderScene struct RenderFrame { public: + //TODO: Getters + GLfloat Gamma = 2.2f; + GLfloat Exposure = 1.f; void Add(RenderScene &scene) { diff --git a/include/Engine/Rendering/Util/GLError.h b/include/Engine/Rendering/Util/GLError.h index 754623d1..2b244e1c 100644 --- a/include/Engine/Rendering/Util/GLError.h +++ b/include/Engine/Rendering/Util/GLError.h @@ -9,7 +9,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig GLenum error = glGetError(); if (error != GL_NO_ERROR) { - _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s, %i, %s", info, error, gluErrorString(error)); + _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s\nError code: %i, %s\n", info, error, gluErrorString(error)); return true; } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index ab46b0ea..bb1fd770 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -11,6 +11,7 @@ + diff --git a/resources/Schema/Components/SceneLight.xml b/resources/Schema/Components/SceneLight.xml new file mode 100644 index 00000000..80b6b9f4 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xml @@ -0,0 +1,7 @@ + + + + true + 2.2 + 1 + \ No newline at end of file diff --git a/resources/Schema/Components/SceneLight.xsd b/resources/Schema/Components/SceneLight.xsd new file mode 100644 index 00000000..9f8a9705 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xsd @@ -0,0 +1,25 @@ + + + + + + Some settings for the scene lighting + + + + + Color of the ambient light + + + Wether the ambient light should be applied or not + + + Gamma correction for the scene + + + The exposure of the camera + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/AssetPedistal.xml b/resources/Schema/Entities/AssetPedistal.xml new file mode 100644 index 00000000..728a3028 --- /dev/null +++ b/resources/Schema/Entities/AssetPedistal.xml @@ -0,0 +1,51 @@ + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 9565e2d4..4727c777 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -2,7 +2,9 @@ - + + + @@ -18,7 +20,7 @@ - + @@ -38,18 +40,27 @@ Models/DirectionalLightWidget.mesh - 1.0499999523162842 + 1 - + + + true + + + 5.0498686575577523 + 5 + + 3 + Models/Assault.mesh @@ -62,11 +73,26 @@ - Models/SecondaryWeapon.mesh + Models/AssaultWeaponRed.mesh + true - - + + + + + + + + + + Models/DefenderGunRed.mesh + true + false + + + + @@ -85,7 +111,7 @@ Run - + 1 @@ -101,7 +127,7 @@ Walk - + 1 @@ -147,70 +173,6 @@ - - - - Models/NormalMapSphere.mesh - - - - - - - - - - - Models/SpecularMapSphere.mesh - - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - - - - - Models/IncandescenceMapSphere.mesh - - - - - - - @@ -227,7 +189,7 @@ - + @@ -284,8 +246,94 @@ + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + + + + + 1.3999999761581421 + + + + + diff --git a/resources/Schema/Entities/EditorWidgetTranslate.xml b/resources/Schema/Entities/EditorWidgetTranslate.xml index d4ed5e76..c6dba4d9 100644 --- a/resources/Schema/Entities/EditorWidgetTranslate.xml +++ b/resources/Schema/Entities/EditorWidgetTranslate.xml @@ -84,15 +84,6 @@ - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e81ec5aa..d365c0ee 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -2,12 +2,12 @@ - + @@ -20,7 +20,7 @@ - + @@ -101,12 +101,19 @@ + + true + + 3.7999999523162842 + + true + - Models/AssaultWeapon.mesh + Models/AssaultWeaponRed.mesh - + @@ -141,7 +148,7 @@ Hold Pos - + 1 diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml new file mode 100644 index 00000000..e057cf38 --- /dev/null +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -0,0 +1,1558 @@ + + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + 90 + + + + + + + + + + + + 1 + + + + + + + + + + + Audio/crosscounter.wav + true + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Sound Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + 0.80000001192092896 + + + Models/DirectionalLightWidget.mesh + + + 1 + + + + + + + + + + + + + + + + + + + + + Run + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + + + Walk + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + Animation test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Run + + 1 + + + Models/AssaultAnimated.mesh + + + + + + + + + + + + + + + + + + + + + + + + models/NormSpecIncdMapSphere.mesh + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 5.0100002288818359 + 0.69999998807907104 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 4 + 0.80000001192092896 + + + + + + + + + + + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + + + + + TextureMap's Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1.3999999761581421 + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + Spawn Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + Models/Core/UnitRaptor.mesh + + true + + + + + + + + + + + Models/Assault.mesh + + true + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + Transparency Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponRed.mesh + + + + + + + + + + + + + + + + Asset Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/SecondaryWeapon.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssualtSoft.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunRed.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/Assualt.mesh + + + + + + + + + + + + + + + + + + + + + + + + CapturePoint Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + + + + + + Red team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + 1 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + RedMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + 2 + + + Models/Core/UnitCube.mesh + true + + + + + + + + + + + + + + Middle Point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + -12.033302729641917 + 3 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + BlueMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + 4 + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + + + + + + Blue team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Test/ObstacleCourse.mesh + + + + + + + + + + + Collision Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + true + + 0.75008034908941568 + 3.7999999523162842 + + true + + + Models/AssaultWeaponBlue.mesh + true + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + + + 1.1999860997035228 + + + Models/Assault.mesh + true + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Walk + + 1 + + + true + + + 0.68343188336345406 + + true + + + Models/AssaultAnimated.mesh + true + + + + + + + + + + + + + + + ExplosionEffect Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Remember to pick random entities. + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 3b985a7e..4a0bb9d4 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml index df563476..e69df489 100644 --- a/resources/Schema/Entities/RayRed.xml +++ b/resources/Schema/Entities/RayRed.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/resources/Schema/Entities/SoundEmitter.xml b/resources/Schema/Entities/SoundEmitter.xml new file mode 100644 index 00000000..39b4c750 --- /dev/null +++ b/resources/Schema/Entities/SoundEmitter.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnPointClusterWithModels.xml b/resources/Schema/Entities/SpawnPointClusterWithModels.xml new file mode 100644 index 00000000..9c42d0e4 --- /dev/null +++ b/resources/Schema/Entities/SpawnPointClusterWithModels.xml @@ -0,0 +1,68 @@ + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnerWithPlayerModel.xml b/resources/Schema/Entities/SpawnerWithPlayerModel.xml new file mode 100644 index 00000000..1274eefa --- /dev/null +++ b/resources/Schema/Entities/SpawnerWithPlayerModel.xml @@ -0,0 +1,16 @@ + + + + + + + Models/Assault.mesh + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 99b90caa..028af9e6 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -31,6 +31,7 @@ + diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 8d13992a..91ace0c7 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -3,6 +3,7 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; uniform float Exposure; +uniform float Gamma; in VertexData{ vec2 TextureCoordinate; @@ -12,7 +13,6 @@ out vec4 fragmentColor; void main() { - const float gamma = 2.2; vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); hdrColor += bloomColor; @@ -21,7 +21,7 @@ void main() vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); //gamme correction - result = pow(result, vec3(1.0 / gamma)); + result = pow(result, vec3(1.0 / Gamma)); fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index cb91b545..44b44aa6 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -17,15 +17,21 @@ uniform bool ExponentialAccelaration; in VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input[]; out VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; layout(triangles) in; @@ -114,12 +120,17 @@ void main() { // calculate the max distance (s) the triangle will move float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2)); + float te = (length(triangleCenter2ExplosionRadius) / s); - Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = te; + } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... @@ -132,6 +143,8 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -154,11 +167,14 @@ void main() // if explosion color should be affected by distance instead of time... if (ColorByDistance == true) { - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = 0.0; } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... @@ -168,7 +184,9 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; - + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; + // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; EmitVertex(); diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index de672dd1..c09e0438 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -7,13 +7,13 @@ uniform vec4 Color; uniform vec4 DiffuseColor; uniform vec2 ScreenDimensions; uniform vec4 FillColor; +uniform vec4 AmbientColor; uniform float FillPercentage; layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; - #define TILE_SIZE 16 struct LightSource { @@ -55,13 +55,12 @@ in VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input; out vec4 sceneColor; out vec4 bloomColor; -vec4 scene_ambient = vec4(0.3,0.3,0.3,1); - struct LightResult { vec4 Diffuse; vec4 Specular; @@ -120,6 +119,7 @@ void main() vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); vec4 position = V * M * vec4(Input.Position, 1.0); vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture); + normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); @@ -128,7 +128,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = scene_ambient; + totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); @@ -150,8 +150,9 @@ void main() totalLighting.Specular += light_result.Specular; } - - vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; @@ -160,7 +161,7 @@ void main() color_result += FillColor; } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - color_result += glowTexel; + color_result += glowTexel*3; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 1a7cca12..3b3e931c 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -20,6 +20,7 @@ out VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; void main() @@ -41,5 +42,6 @@ void main() Output.Normal = vec3(M * vec4(Normal, 0.0)); Output.Tangent = vec3(M * vec4(Tangent, 0.0)); Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = vec4(1.0); + Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 67b09a21..4d65e9d3 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -23,6 +23,12 @@ void EditorRenderSystem::Update(double dt) scene.Camera = m_EditorCamera; scene.Viewport = Rectangle(1920, 1080); + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr) { + //these are hardcoded since they want special light treatment and a component just for widgets is stupid. + scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); + } + auto models = m_World->GetComponents("Model"); if (models != nullptr) { for (auto& cModel : *models) { @@ -49,7 +55,7 @@ void EditorRenderSystem::Update(double dt) glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); for (auto matGroup : model->MaterialGroups()) { std::shared_ptr modelJob = std::make_shared(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f); - if(cModel["Transparent"]) { + if (cModel["Transparent"]) { scene.TransparentObjects.push_back(modelJob); } else { scene.OpaqueObjects.push_back(modelJob); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index ba9efe3e..45401bce 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -5,7 +5,8 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer) m_Renderer = renderer; m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); - m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. + + //m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. InitializeShaderPrograms(); } @@ -19,15 +20,16 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - glClear(GL_COLOR_BUFFER_BIT); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure); + //glClear(GL_COLOR_BUFFER_BIT); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sceneTexture); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index aa9da9a1..8247797e 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -44,6 +44,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor"); m_ForwardPlusProgram->Link(); + GLERROR("Creating forward+ program"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); @@ -53,11 +54,12 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor"); m_ExplosionEffectProgram->Link(); + GLERROR("Creating explosion program"); } void DrawFinalPass::Draw(RenderScene& scene) { - GLERROR("DrawFinalPass::Draw: Pre"); + GLERROR("Pre"); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { @@ -65,12 +67,12 @@ void DrawFinalPass::Draw(RenderScene& scene) } DrawModelRenderQueues(scene.OpaqueObjects, scene); - GLERROR("DrawFinalPass::Draw: OpaqueObjects"); + GLERROR("OpaqueObjects"); DrawModelRenderQueues(scene.TransparentObjects, scene); - GLERROR("DrawFinalPass::Draw: TransparentObjects"); + GLERROR("TransparentObjects"); - GLERROR("DrawFinalPass::Draw: END"); delete state; + GLERROR("END"); } @@ -111,7 +113,9 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: void DrawFinalPass::DrawModelRenderQueues(std::list>& job, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); + GLERROR("forwardHandle"); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); + GLERROR("explosionHandle"); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); @@ -122,10 +126,21 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& auto explosionEffectJob = std::dynamic_pointer_cast(job); if(explosionEffectJob) { //Bind program + if(GLERROR("Prebind")) { + continue; + } m_ExplosionEffectProgram->Bind(); + if(GLERROR("BindProgram")) { + continue; + } + + glDisable(GL_CULL_FACE); //Bind uniforms BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + if(GLERROR("BindExplosionUniforms")) { + continue; + } if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -134,13 +149,23 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } + if(GLERROR("Animation")) { + continue; + } //bind textures BindExplosionTextures(explosionEffectJob); + if(GLERROR("BindExplosionTextures")) { + continue; + } //draw glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); + glEnable(GL_CULL_FACE); + if(GLERROR("explosion effect end")) { + continue; + } } else { auto modelJob = std::dynamic_pointer_cast(job); @@ -167,7 +192,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int))); - GLERROR("DrawFinalPass::Model: END"); + if(GLERROR("models end")) { + continue; + } } } } @@ -176,36 +203,46 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); - glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin)); glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath); glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration); glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor)); glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness); + glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar); glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity)); glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance); glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration); - glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); - glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); -} -void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) -{ - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + GLERROR("END"); +} + +void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) +{ + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); + + glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); + glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); + glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); + glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + + GLERROR("END"); } @@ -217,7 +254,22 @@ void DrawFinalPass::BindExplosionTextures(std::shared_ptr& j } else { glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); } + glActiveTexture(GL_TEXTURE1); + if (job->NormalTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->NormalTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE2); + if (job->SpecularTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->SpecularTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE3); if (job->IncandescenceTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture); } else { diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index b7e908cc..9677f50e 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -54,13 +54,6 @@ void FrameBuffer::Generate() case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); - if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 || - (*it)->m_Attachment != GL_COLOR_ATTACHMENT1 || - (*it)->m_Attachment != GL_DEPTH_ATTACHMENT || - (*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta - { - LOG_ERROR("RenderBuffer Attachment not valid."); - } break; } diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 792539f8..abc79f2e 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -75,9 +75,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } @@ -121,9 +121,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index a0912a45..eaecf99e 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -240,10 +240,17 @@ void RenderSystem::Update(double dt) m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera)); } - RenderScene scene; scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); + + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr && cSceneLight->begin() != cSceneLight->end()) { + m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; + m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; + scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; + } + fillModels(scene.OpaqueObjects, scene.TransparentObjects); fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index bec86b4a..a63e02a0 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -119,8 +119,8 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); - if(m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture()); + if (m_DebugTextureToDraw == 0) { + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); From 7b5a2a538815c632da5713ba3a68c5861d2f97df Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 17:30:46 +0100 Subject: [PATCH 38/43] Dashing now works great both with shift and doubletap. Added Dash Component. Changed default Player.xml to have a Dash Component. Disabled Sprint. You can now disable DoubleTapToDash in Input.Ini. Added command "SpecialAbility". --- .../Editor/EditorCameraInputController.h | 7 +- .../Engine/Input/FirstPersonInputController.h | 98 ++++++++++++++----- resources/Schema/Components.xsd | 1 + resources/Schema/Components/Dash.xml | 4 + resources/Schema/Components/Dash.xsd | 18 ++++ resources/Schema/Entities/Player.xml | 1 + src/Game/Systems/PlayerMovementSystem.cpp | 13 ++- 7 files changed, 108 insertions(+), 34 deletions(-) create mode 100644 resources/Schema/Components/Dash.xml create mode 100644 resources/Schema/Components/Dash.xsd diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 4c139e01..6c5e8b14 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -55,11 +55,12 @@ public: } } - if (e.Command == "Sprint") { + //this is just temp here, the sprint ability. it will have a component check later + if (e.Command == "SpecialAbility") { if (e.Value > 0) { - m_SpeedMultiplier *= 2.f; + //m_SpeedMultiplier *= 2.f; } else { - m_SpeedMultiplier /= 2.f; + //m_SpeedMultiplier /= 2.f; } } diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 1efe4b75..4e964d19 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -4,6 +4,7 @@ #include "../GLM.h" #include "../Core/InputController.h" #include "../Core/ELockMouse.h" +#include "InputHandler.h" template class FirstPersonInputController : public InputController @@ -48,12 +49,18 @@ protected: //assault dash membervariables double m_AssaultDashDoubleTapDeltaTime = 0.0f; double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 3.0f; + double m_AssaultDashCoolDownMaxTimer = 2.0f; AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; - AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; + bool m_ShiftDashing = true; + bool m_ValidDoubleTap = false; + + //specialabilitys + bool m_MovementKeyDown = false; + bool m_SpecialAbilityKeyDown = false; EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -125,6 +132,22 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } + if (e.Command == "Forward" || e.Command == "Right") { + //if value = 0 then you have just released this key + if (e.Value > 0 || e.Value < 0) { + m_MovementKeyDown = true; + //if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it + if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == e.Command) { + m_ValidDoubleTap = true; + } + } else { + m_MovementKeyDown = false; + //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer + m_AssaultDashTapDirection = e.Command; + m_AssaultDashDoubleTapDeltaTime = 0.f; + } + } + if (e.Command == "Jump") { m_Jumping = e.Value > 0; } @@ -133,6 +156,19 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm m_Crouching = e.Value > 0; } + if (e.Command == "SpecialAbility") { + if (e.Value > 0) { + m_SpecialAbilityKeyDown = true; + } else { + m_SpecialAbilityKeyDown = false; + } + } + if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { + m_ShiftDashing = true; + } else { + m_ShiftDashing = false; + } + return true; } @@ -152,7 +188,6 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou template void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { - auto controllerMovement = Movement(); m_AssaultDashDoubleTapDeltaTime += dt; m_AssaultDashCoolDownTimer -= dt; //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) @@ -161,34 +196,43 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool } else { m_PlayerIsDashing = false; } - //reset the DoubleTapped state in case we recently doubleTapped + + //dashing with shift + if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + //player is dashing with shift + //the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in! + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + //moving to the side has priority + return; + } + + //dashing with doubletap - check if doubletap to dash enabled + if (ResourceManager::Load("Input.ini")->Get("Keyboard.DoubleTapToDash", false)) { + return; + } + + //reset the DoubleTapped state in case we recently doubleTapped (doubletap will only happen during 1 frame) if (m_AssaultDashDoubleTapped) { m_AssaultDashDoubleTapped = false; } - //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash - if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Right && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Right; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Right; - } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Left && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Left; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Left; - } else { - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + + //check if we have received a valid doubletap + if (!m_ValidDoubleTap) { + return; } + m_ValidDoubleTap = false; + + if (!(m_AssaultDashCoolDownTimer <= 0.0f && !isJumping)) { + //if we cant dash at the moment, then just reset the tap-sensitivity-timer + m_AssaultDashDoubleTapDeltaTime = 0.f; + return; + } + //ok, we have a valid tap, lets do it + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; } #endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index bb1fd770..17278f14 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -30,4 +30,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/Dash.xml new file mode 100644 index 00000000..084f9620 --- /dev/null +++ b/resources/Schema/Components/Dash.xml @@ -0,0 +1,4 @@ + + + true + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/Dash.xsd new file mode 100644 index 00000000..68b64b0c --- /dev/null +++ b/resources/Schema/Components/Dash.xsd @@ -0,0 +1,18 @@ + + + + + + + + A dash component for one of the classes + + + + + Yada + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d365c0ee..3029e9f7 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,6 +6,7 @@ + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 70bbafb0..4fe3da2d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,8 +43,14 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - //TODO: check if playerclass is assault! - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + if (player.HasComponent("Dash")) { + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); + //this makes sure you can only dash in the 4 directions: forw,backw,left,right + if (controller->AssaultDashDoubleTapped() && controller->Movement().z != 0 && controller->Movement().x != 0) { + wishDirection = glm::vec3(controller->Movement().x, 0, 0)* glm::inverse(glm::quat(ori)); + } float wishSpeed; if (controller->Crouching()) { wishSpeed = playerCrouchSpeed; @@ -74,7 +80,7 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; //if doubleTapped do Assault Dash - but only boost maximum 50.0f - float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 20.0f : 1.0f; + float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); @@ -84,8 +90,7 @@ void PlayerMovementSystem::Update(double dt) if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { controller->SetDoubleJumping(false); - } - else { + } else { controller->SetDoubleJumping(true); } velocity.y += 4.f; From 1bd4aa91ff70275f1a3cd38e66c184841617f985 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 17:45:37 +0100 Subject: [PATCH 39/43] Oops! Readded "Sprint" command. Removed some unnecessary variables in FirstPersonInputController. Fixed bug where you couldnt dash right away as the game started. --- .../Engine/Editor/EditorCameraInputController.h | 7 +++---- .../Engine/Input/FirstPersonInputController.h | 17 ++++------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 6c5e8b14..4c139e01 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -55,12 +55,11 @@ public: } } - //this is just temp here, the sprint ability. it will have a component check later - if (e.Command == "SpecialAbility") { + if (e.Command == "Sprint") { if (e.Value > 0) { - //m_SpeedMultiplier *= 2.f; + m_SpeedMultiplier *= 2.f; } else { - //m_SpeedMultiplier /= 2.f; + m_SpeedMultiplier /= 2.f; } } diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 4e964d19..de4f1226 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -38,24 +38,15 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; - //assault dash enum - enum class AssaultDashDirection { - Left, - Right, - Forward, - Backward, - None - }; //assault dash membervariables - double m_AssaultDashDoubleTapDeltaTime = 0.0f; - double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 2.0f; - AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + double m_AssaultDashDoubleTapDeltaTime = 0.0; + double m_AssaultDashCoolDownTimer = 0.0; + double m_AssaultDashCoolDownMaxTimer = 2.0; const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; - bool m_ShiftDashing = true; + bool m_ShiftDashing = false; bool m_ValidDoubleTap = false; //specialabilitys From 03a16b46b568ee8079c615559b1a3e2d311855cf Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 10:28:28 +0100 Subject: [PATCH 40/43] Dash component now has the dash-maxCoolDownVariable in it. --- .../Engine/Input/FirstPersonInputController.h | 17 +++++++++-------- resources/Schema/Components/Dash.xml | 2 +- resources/Schema/Components/Dash.xsd | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 5 ++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index de4f1226..fa9af852 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -26,7 +26,7 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); - void AssaultDashCheck(double dt, bool isJumping); + void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -38,10 +38,11 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; - //assault dash membervariables + //assault dash membervariables - needed to calculate the doubletap- and dashlogic double m_AssaultDashDoubleTapDeltaTime = 0.0; double m_AssaultDashCoolDownTimer = 0.0; - double m_AssaultDashCoolDownMaxTimer = 2.0; + //i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable), + //and its very unlikely that someone wants to change that value const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; @@ -178,11 +179,11 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou } template -void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) { m_AssaultDashDoubleTapDeltaTime += dt; m_AssaultDashCoolDownTimer -= dt; - //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) - if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { m_PlayerIsDashing = true; } else { m_PlayerIsDashing = false; @@ -192,7 +193,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { //player is dashing with shift //the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in! - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; //moving to the side has priority @@ -223,7 +224,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool //ok, we have a valid tap, lets do it m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; } #endif \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/Dash.xml index 084f9620..fbd255a6 100644 --- a/resources/Schema/Components/Dash.xml +++ b/resources/Schema/Components/Dash.xml @@ -1,4 +1,4 @@ - true + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/Dash.xsd index 68b64b0c..ca6fc366 100644 --- a/resources/Schema/Components/Dash.xsd +++ b/resources/Schema/Components/Dash.xsd @@ -9,8 +9,8 @@ - - Yada + + This is the cooldown on dash diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 4fe3da2d..c65a961e 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -41,10 +41,9 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; - //Assault Dash Check - - //TODO: check if playerclass is assault! + //Assault Dash Check if (player.HasComponent("Dash")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]); } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right From 035c79564b2e129e16cefef4c6d527bb9cf75b98 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 11:41:21 +0100 Subject: [PATCH 41/43] Changed Dash name to DashAbility. Fixed dash bug where you could do two different keys to dash. --- include/Engine/Input/FirstPersonInputController.h | 11 ++++++++--- resources/Schema/Components.xsd | 2 +- .../Schema/Components/{Dash.xml => DashAbility.xml} | 2 +- .../Schema/Components/{Dash.xsd => DashAbility.xsd} | 2 +- resources/Schema/Entities/Player.xml | 4 +++- src/Game/Systems/PlayerMovementSystem.cpp | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) rename resources/Schema/Components/{Dash.xml => DashAbility.xml} (78%) rename resources/Schema/Components/{Dash.xsd => DashAbility.xsd} (94%) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index fa9af852..2bbd768d 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -45,6 +45,7 @@ protected: //and its very unlikely that someone wants to change that value const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; + std::string m_CurrentDirectionVector = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; bool m_ShiftDashing = false; @@ -125,17 +126,21 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } if (e.Command == "Forward" || e.Command == "Right") { + if (e.Value != 0) { + m_CurrentDirectionVector = e.Command == "Right" ? (e.Value > 0 ? "Right" : "Left") : (e.Value > 0 ? "Forward" : "Backward"); + } //if value = 0 then you have just released this key - if (e.Value > 0 || e.Value < 0) { + if (e.Value != 0) { m_MovementKeyDown = true; //if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it - if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == e.Command) { + if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == m_CurrentDirectionVector) { m_ValidDoubleTap = true; } } else { + //== 0 m_MovementKeyDown = false; //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer - m_AssaultDashTapDirection = e.Command; + m_AssaultDashTapDirection = m_CurrentDirectionVector; m_AssaultDashDoubleTapDeltaTime = 0.f; } } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 17278f14..265a3cc5 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -30,5 +30,5 @@ - + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/DashAbility.xml similarity index 78% rename from resources/Schema/Components/Dash.xml rename to resources/Schema/Components/DashAbility.xml index fbd255a6..25b9e19a 100644 --- a/resources/Schema/Components/Dash.xml +++ b/resources/Schema/Components/DashAbility.xml @@ -1,4 +1,4 @@ - + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/DashAbility.xsd similarity index 94% rename from resources/Schema/Components/Dash.xsd rename to resources/Schema/Components/DashAbility.xsd index ca6fc366..4273cc71 100644 --- a/resources/Schema/Components/Dash.xsd +++ b/resources/Schema/Components/DashAbility.xsd @@ -3,7 +3,7 @@ - + A dash component for one of the classes diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 3029e9f7..fe24adcc 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,7 +6,9 @@ - + + 2.0 + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index c65a961e..3224f579 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -42,8 +42,8 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - if (player.HasComponent("Dash")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]); + if (player.HasComponent("DashAbility")) { + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]); } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right From c87e4d4fd6f05d8e257da9588836d0252c59a5e4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 4 Feb 2016 11:53:11 +0100 Subject: [PATCH 42/43] Added mutex to resource manager cache reading to avoid a potential race condition. We hope this is the actual bug we saw. --- include/Engine/Core/ResourceManager.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/Engine/Core/ResourceManager.h b/include/Engine/Core/ResourceManager.h index 10529819..b994b5cf 100644 --- a/include/Engine/Core/ResourceManager.h +++ b/include/Engine/Core/ResourceManager.h @@ -200,13 +200,16 @@ static T* ResourceManager::Load(const std::string& resourceName, Resource* paren } //If resource has already been cached and completely loaded. - it = m_ResourceCache.find(cacheKey); - if (it != m_ResourceCache.end()) { - if (it->second != nullptr) { - return static_cast(it->second); - } else { - //Don't return null on failure, exception instead. - throw Resource::FailedLoadingException(); + { + boost::lock_guard guard(m_Mutex); + it = m_ResourceCache.find(cacheKey); + if (it != m_ResourceCache.end()) { + if (it->second != nullptr) { + return static_cast(it->second); + } else { + //Don't return null on failure, exception instead. + throw Resource::FailedLoadingException(); + } } } From 6990e473b3c2d481cee2cd4b5a784051eb386603 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 4 Feb 2016 11:53:35 +0100 Subject: [PATCH 43/43] Adding a clear here makes AMD drivers NOT crash for some reason. We're fixing the symptom but not the underlying cause. --- src/Engine/Rendering/DrawColorCorrectionPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 45401bce..95de26e2 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -27,7 +27,7 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - //glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma);