From fefc3610872ee1009a6d4e4cccc50739734e3ff3 Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Fri, 12 Jun 2020 22:09:04 +0100 Subject: [PATCH] improved cpp conformance --- Editor/Editor_Windows.vcxproj | 4 ++++ Editor/ModelImporter_GLTF.cpp | 24 +++++++++---------- Template_Windows/Template_Windows.vcxproj | 4 ++++ Tests/Tests.vcxproj | 4 ++++ WickedEngine/WickedEngine_Windows.vcxproj | 4 ++++ WickedEngine/wiGraphics.h | 4 +++- WickedEngine/wiGraphicsDevice_DX11.cpp | 2 +- WickedEngine/wiGraphicsDevice_DX12.cpp | 2 +- WickedEngine/wiIntersect.cpp | 2 +- WickedEngine/wiMath.h | 28 +++++++++++------------ WickedEngine/wiProfiler.cpp | 2 +- WickedEngine/wiRenderer.cpp | 6 ++--- WickedEngine/wiResourceManager.cpp | 2 +- WickedEngine/wiScene.cpp | 2 +- WickedEngine/wiScene_BindLua.cpp | 6 ++--- WickedEngine/wiVersion.cpp | 2 +- 16 files changed, 58 insertions(+), 40 deletions(-) diff --git a/Editor/Editor_Windows.vcxproj b/Editor/Editor_Windows.vcxproj index cb1645cd0..81c9d436c 100644 --- a/Editor/Editor_Windows.vcxproj +++ b/Editor/Editor_Windows.vcxproj @@ -107,6 +107,7 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) ../WickedEngine;%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pch + true Windows @@ -132,6 +133,7 @@ _DEBUG;_WINDOWS;%(PreprocessorDefinitions) ../WickedEngine;%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pch + true Windows @@ -165,6 +167,7 @@ Sync true $(IntDir)$(TargetName).pch + true Windows @@ -190,6 +193,7 @@ true MultiThreaded $(IntDir)$(TargetName).pch + true Windows diff --git a/Editor/ModelImporter_GLTF.cpp b/Editor/ModelImporter_GLTF.cpp index a7237adb8..0e7232423 100644 --- a/Editor/ModelImporter_GLTF.cpp +++ b/Editor/ModelImporter_GLTF.cpp @@ -421,19 +421,19 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene) material.reflectance = 0.02f; // metallic-roughness workflow: - auto& baseColorTexture = x.values.find("baseColorTexture"); - auto& metallicRoughnessTexture = x.values.find("metallicRoughnessTexture"); - auto& baseColorFactor = x.values.find("baseColorFactor"); - auto& roughnessFactor = x.values.find("roughnessFactor"); - auto& metallicFactor = x.values.find("metallicFactor"); + auto baseColorTexture = x.values.find("baseColorTexture"); + auto metallicRoughnessTexture = x.values.find("metallicRoughnessTexture"); + auto baseColorFactor = x.values.find("baseColorFactor"); + auto roughnessFactor = x.values.find("roughnessFactor"); + auto metallicFactor = x.values.find("metallicFactor"); // common workflow: - auto& normalTexture = x.additionalValues.find("normalTexture"); - auto& emissiveTexture = x.additionalValues.find("emissiveTexture"); - auto& occlusionTexture = x.additionalValues.find("occlusionTexture"); - auto& emissiveFactor = x.additionalValues.find("emissiveFactor"); - auto& alphaCutoff = x.additionalValues.find("alphaCutoff"); - auto& alphaMode = x.additionalValues.find("alphaMode"); + auto normalTexture = x.additionalValues.find("normalTexture"); + auto emissiveTexture = x.additionalValues.find("emissiveTexture"); + auto occlusionTexture = x.additionalValues.find("occlusionTexture"); + auto emissiveFactor = x.additionalValues.find("emissiveFactor"); + auto alphaCutoff = x.additionalValues.find("alphaCutoff"); + auto alphaMode = x.additionalValues.find("alphaMode"); if (baseColorTexture != x.values.end()) @@ -514,7 +514,7 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene) } // specular-glossiness workflow (todo): - auto& specularGlossinessWorkflow = x.extensions.find("KHR_materials_pbrSpecularGlossiness"); + auto specularGlossinessWorkflow = x.extensions.find("KHR_materials_pbrSpecularGlossiness"); if (specularGlossinessWorkflow != x.extensions.end()) { material.SetUseSpecularGlossinessWorkflow(true); diff --git a/Template_Windows/Template_Windows.vcxproj b/Template_Windows/Template_Windows.vcxproj index 44dbf687f..baee61686 100644 --- a/Template_Windows/Template_Windows.vcxproj +++ b/Template_Windows/Template_Windows.vcxproj @@ -101,6 +101,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreaded + true Windows @@ -118,6 +119,7 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true ../WickedEngine;%(AdditionalIncludeDirectories) + true Windows @@ -133,6 +135,7 @@ _DEBUG;_WINDOWS;%(PreprocessorDefinitions) true ../WickedEngine;%(AdditionalIncludeDirectories) + true Windows @@ -151,6 +154,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreaded + true Windows diff --git a/Tests/Tests.vcxproj b/Tests/Tests.vcxproj index ff0dcb7b5..a58f18e86 100644 --- a/Tests/Tests.vcxproj +++ b/Tests/Tests.vcxproj @@ -106,6 +106,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreaded + true Windows @@ -124,6 +125,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL + true Windows @@ -140,6 +142,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL + true Windows @@ -158,6 +161,7 @@ true ../WickedEngine;%(AdditionalIncludeDirectories) MultiThreaded + true Windows diff --git a/WickedEngine/WickedEngine_Windows.vcxproj b/WickedEngine/WickedEngine_Windows.vcxproj index ffeca45c5..c20bd30d1 100644 --- a/WickedEngine/WickedEngine_Windows.vcxproj +++ b/WickedEngine/WickedEngine_Windows.vcxproj @@ -105,6 +105,7 @@ Speed ProgramDatabase Default + true Windows @@ -137,6 +138,7 @@ Speed ProgramDatabase Default + true Windows @@ -169,6 +171,7 @@ true Speed true + true Windows @@ -197,6 +200,7 @@ true Speed true + true Windows diff --git a/WickedEngine/wiGraphics.h b/WickedEngine/wiGraphics.h index 7b2307508..ae6a284bb 100644 --- a/WickedEngine/wiGraphics.h +++ b/WickedEngine/wiGraphics.h @@ -1,7 +1,9 @@ #pragma once #include "CommonInclude.h" + #include #include +#include namespace wiGraphics { @@ -334,7 +336,7 @@ namespace wiGraphics { static const uint32_t APPEND_ALIGNED_ELEMENT = 0xffffffff; // automatically figure out AlignedByteOffset depending on Format - char* SemanticName = nullptr; + std::string SemanticName; uint32_t SemanticIndex = 0; FORMAT Format = FORMAT_UNKNOWN; uint32_t InputSlot = 0; diff --git a/WickedEngine/wiGraphicsDevice_DX11.cpp b/WickedEngine/wiGraphicsDevice_DX11.cpp index 5423340a7..2b255fd38 100644 --- a/WickedEngine/wiGraphicsDevice_DX11.cpp +++ b/WickedEngine/wiGraphicsDevice_DX11.cpp @@ -1572,7 +1572,7 @@ bool GraphicsDevice_DX11::CreateInputLayout(const InputLayoutDesc *pInputElement std::vector desc(NumElements); for (uint32_t i = 0; i < NumElements; ++i) { - desc[i].SemanticName = pInputElementDescs[i].SemanticName; + desc[i].SemanticName = pInputElementDescs[i].SemanticName.c_str(); desc[i].SemanticIndex = pInputElementDescs[i].SemanticIndex; desc[i].Format = _ConvertFormat(pInputElementDescs[i].Format); desc[i].InputSlot = pInputElementDescs[i].InputSlot; diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 854c3b374..fa42c392a 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -3652,7 +3652,7 @@ using namespace DX12_Internal; elements.resize(desc.InputLayout.NumElements); for (uint32_t i = 0; i < desc.InputLayout.NumElements; ++i) { - elements[i].SemanticName = pso->desc.il->desc[i].SemanticName; + elements[i].SemanticName = pso->desc.il->desc[i].SemanticName.c_str(); elements[i].SemanticIndex = pso->desc.il->desc[i].SemanticIndex; elements[i].Format = _ConvertFormat(pso->desc.il->desc[i].Format); elements[i].InputSlot = pso->desc.il->desc[i].InputSlot; diff --git a/WickedEngine/wiIntersect.cpp b/WickedEngine/wiIntersect.cpp index 0f5316eaa..89e8c28d8 100644 --- a/WickedEngine/wiIntersect.cpp +++ b/WickedEngine/wiIntersect.cpp @@ -62,7 +62,7 @@ float AABB::getArea() const return (_max.x - _min.x)*(_max.y - _min.y)*(_max.z - _min.z); } float AABB::getRadius() const { - XMFLOAT3& abc = getHalfWidth(); + XMFLOAT3 abc = getHalfWidth(); return std::max(std::max(abc.x, abc.y), abc.z); } AABB::INTERSECTION_TYPE AABB::intersects(const AABB& b) const { diff --git a/WickedEngine/wiMath.h b/WickedEngine/wiMath.h index a15563e03..2360ce779 100644 --- a/WickedEngine/wiMath.h +++ b/WickedEngine/wiMath.h @@ -17,8 +17,8 @@ namespace wiMath } inline float Distance(const XMVECTOR& v1, const XMVECTOR& v2) { - XMVECTOR& vectorSub = XMVectorSubtract(v1, v2); - XMVECTOR& length = XMVector3Length(vectorSub); + XMVECTOR vectorSub = XMVectorSubtract(v1, v2); + XMVECTOR length = XMVector3Length(vectorSub); float Distance = 0.0f; XMStoreFloat(&Distance, length); @@ -26,8 +26,8 @@ namespace wiMath } inline float DistanceSquared(const XMVECTOR& v1, const XMVECTOR& v2) { - XMVECTOR& vectorSub = XMVectorSubtract(v1, v2); - XMVECTOR& length = XMVector3LengthSq(vectorSub); + XMVECTOR vectorSub = XMVectorSubtract(v1, v2); + XMVECTOR length = XMVector3LengthSq(vectorSub); float Distance = 0.0f; XMStoreFloat(&Distance, length); @@ -35,8 +35,8 @@ namespace wiMath } inline float DistanceEstimated(const XMVECTOR& v1, const XMVECTOR& v2) { - XMVECTOR& vectorSub = XMVectorSubtract(v1, v2); - XMVECTOR& length = XMVector3LengthEst(vectorSub); + XMVECTOR vectorSub = XMVectorSubtract(v1, v2); + XMVECTOR length = XMVector3LengthEst(vectorSub); float Distance = 0.0f; XMStoreFloat(&Distance, length); @@ -44,26 +44,26 @@ namespace wiMath } inline float Distance(const XMFLOAT2& v1, const XMFLOAT2& v2) { - XMVECTOR& vector1 = XMLoadFloat2(&v1); - XMVECTOR& vector2 = XMLoadFloat2(&v2); + XMVECTOR vector1 = XMLoadFloat2(&v1); + XMVECTOR vector2 = XMLoadFloat2(&v2); return XMVectorGetX(XMVector2Length(vector2 - vector1)); } inline float Distance(const XMFLOAT3& v1, const XMFLOAT3& v2) { - XMVECTOR& vector1 = XMLoadFloat3(&v1); - XMVECTOR& vector2 = XMLoadFloat3(&v2); + XMVECTOR vector1 = XMLoadFloat3(&v1); + XMVECTOR vector2 = XMLoadFloat3(&v2); return Distance(vector1, vector2); } inline float DistanceSquared(const XMFLOAT3& v1, const XMFLOAT3& v2) { - XMVECTOR& vector1 = XMLoadFloat3(&v1); - XMVECTOR& vector2 = XMLoadFloat3(&v2); + XMVECTOR vector1 = XMLoadFloat3(&v1); + XMVECTOR vector2 = XMLoadFloat3(&v2); return DistanceSquared(vector1, vector2); } inline float DistanceEstimated(const XMFLOAT3& v1, const XMFLOAT3& v2) { - XMVECTOR& vector1 = XMLoadFloat3(&v1); - XMVECTOR& vector2 = XMLoadFloat3(&v2); + XMVECTOR vector1 = XMLoadFloat3(&v1); + XMVECTOR vector2 = XMLoadFloat3(&v2); return DistanceEstimated(vector1, vector2); } inline XMVECTOR ClosestPointOnLine(const XMVECTOR& A, const XMVECTOR& B, const XMVECTOR& Point) diff --git a/WickedEngine/wiProfiler.cpp b/WickedEngine/wiProfiler.cpp index bf43b1766..6af6d8f90 100644 --- a/WickedEngine/wiProfiler.cpp +++ b/WickedEngine/wiProfiler.cpp @@ -178,7 +178,7 @@ namespace wiProfiler lock.lock(); - auto& it = ranges.find(id); + auto it = ranges.find(id); if (it != ranges.end()) { if (it->second.IsCPURange()) diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 056046f29..80b916074 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -11446,9 +11446,9 @@ RAY GetPickRay(long cursorX, long cursorY) XMMATRIX V = camera.GetView(); XMMATRIX P = camera.GetProjection(); XMMATRIX W = XMMatrixIdentity(); - XMVECTOR& lineStart = XMVector3Unproject(XMVectorSet((float)cursorX, (float)cursorY, 1, 1), 0, 0, screenW, screenH, 0.0f, 1.0f, P, V, W); - XMVECTOR& lineEnd = XMVector3Unproject(XMVectorSet((float)cursorX, (float)cursorY, 0, 1), 0, 0, screenW, screenH, 0.0f, 1.0f, P, V, W); - XMVECTOR& rayDirection = XMVector3Normalize(XMVectorSubtract(lineEnd, lineStart)); + XMVECTOR lineStart = XMVector3Unproject(XMVectorSet((float)cursorX, (float)cursorY, 1, 1), 0, 0, screenW, screenH, 0.0f, 1.0f, P, V, W); + XMVECTOR lineEnd = XMVector3Unproject(XMVectorSet((float)cursorX, (float)cursorY, 0, 1), 0, 0, screenW, screenH, 0.0f, 1.0f, P, V, W); + XMVECTOR rayDirection = XMVector3Normalize(XMVectorSubtract(lineEnd, lineStart)); return RAY(lineStart, rayDirection); } diff --git a/WickedEngine/wiResourceManager.cpp b/WickedEngine/wiResourceManager.cpp index 011a1039f..c3292adb4 100644 --- a/WickedEngine/wiResourceManager.cpp +++ b/WickedEngine/wiResourceManager.cpp @@ -69,7 +69,7 @@ namespace wiResourceManager // dynamic type selection: { - auto& it = types.find(ext); + auto it = types.find(ext); if (it != types.end()) { type = it->second; diff --git a/WickedEngine/wiScene.cpp b/WickedEngine/wiScene.cpp index 33d5d25c6..fcc11b0aa 100644 --- a/WickedEngine/wiScene.cpp +++ b/WickedEngine/wiScene.cpp @@ -372,7 +372,7 @@ namespace wiScene for (size_t i = 0; i < vertices.size(); ++i) { const XMFLOAT3& pos = vertex_positions[i]; - XMFLOAT3& nor = vertex_normals.empty() ? XMFLOAT3(1, 1, 1) : vertex_normals[i]; + XMFLOAT3 nor = vertex_normals.empty() ? XMFLOAT3(1, 1, 1) : vertex_normals[i]; XMStoreFloat3(&nor, XMVector3Normalize(XMLoadFloat3(&nor))); const uint8_t wind = vertex_windweights.empty() ? 0xFF : vertex_windweights[i]; vertices[i].FromFULL(pos, nor, wind); diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 3cee76cb9..28fb8a48f 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -122,7 +122,7 @@ int Pick(lua_State* L) } } } - auto& pick = wiScene::Pick(ray->ray, renderTypeMask, layerMask, *scene); + auto pick = wiScene::Pick(ray->ray, renderTypeMask, layerMask, *scene); wiLua::SSetLongLong(L, pick.entity); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); @@ -172,7 +172,7 @@ int SceneIntersectSphere(lua_State* L) } } } - auto& pick = wiScene::SceneIntersectSphere(sphere->sphere, renderTypeMask, layerMask, *scene); + auto pick = wiScene::SceneIntersectSphere(sphere->sphere, renderTypeMask, layerMask, *scene); wiLua::SSetLongLong(L, pick.entity); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); @@ -222,7 +222,7 @@ int SceneIntersectCapsule(lua_State* L) } } } - auto& pick = wiScene::SceneIntersectCapsule(capsule->capsule, renderTypeMask, layerMask, *scene); + auto pick = wiScene::SceneIntersectCapsule(capsule->capsule, renderTypeMask, layerMask, *scene); wiLua::SSetLongLong(L, pick.entity); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position))); Luna::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal))); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 863aa8fe8..a3ffe88c8 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 42; // minor bug fixes, alterations, refactors, updates - const int revision = 7; + const int revision = 8; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);