From a3d4eb65d5f67eb672cc178ea8221cb25b6e6a74 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 1 Feb 2016 17:53:01 +0100 Subject: [PATCH] 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;