Final VS fixes

Former-commit-id: 6da44f94127f61de39710a52b8b3b73ce19c1269
This commit is contained in:
Lynix 2015-06-14 16:18:37 +02:00
parent 32a217ea1b
commit f4c3ec51ed
24 changed files with 57 additions and 39 deletions

View File

@ -12,8 +12,8 @@
namespace Ndk
{
template<unsigned int N> ComponentId BuildComponentId(const char (&name)[N]);
template<typename ComponentType> constexpr ComponentIndex GetComponentIndex();
template<typename SystemType> constexpr SystemIndex GetSystemIndex();
template<typename ComponentType> ComponentIndex GetComponentIndex();
template<typename SystemType> SystemIndex GetSystemIndex();
template<typename ComponentType, unsigned int N> ComponentIndex InitializeComponent(const char (&name)[N]);
template<typename SystemType> SystemIndex InitializeSystem();
template<typename ComponentType, typename C> bool IsComponent(C& component);

View File

@ -20,13 +20,13 @@ namespace Ndk
}
template<typename ComponentType>
constexpr ComponentIndex GetComponentIndex()
ComponentIndex GetComponentIndex()
{
return ComponentType::componentIndex;
}
template<typename SystemType>
constexpr SystemIndex GetSystemIndex()
SystemIndex GetSystemIndex()
{
return SystemType::systemIndex;
}

View File

@ -45,7 +45,7 @@ namespace Ndk
template<typename ComponentType>
void BaseSystem::Excludes()
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value , "ComponentType is not a component");
ExcludesComponent(GetComponentIndex<ComponentType>());
}
@ -70,7 +70,7 @@ namespace Ndk
template<typename ComponentType>
void BaseSystem::Requires()
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
RequiresComponent(GetComponentIndex<ComponentType>());
}
@ -90,7 +90,7 @@ namespace Ndk
template<typename ComponentType>
void BaseSystem::RequiresAny()
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
RequiresAnyComponent(GetComponentIndex<ComponentType>());
}

View File

@ -140,7 +140,7 @@ namespace Ndk
{
m_target = renderTarget;
if (m_target)
m_targetReleaseSlot.Connect(m_target->OnRenderTargetRelease, this, OnRenderTargetRelease);
m_targetReleaseSlot.Connect(m_target->OnRenderTargetRelease, this, &CameraComponent::OnRenderTargetRelease);
else
m_targetReleaseSlot.Disconnect();
}

View File

@ -37,7 +37,7 @@ namespace Ndk
m_renderables.emplace_back(m_transformMatrix);
Renderable& r = m_renderables.back();
r.renderable = std::move(renderable);
r.renderableInvalidationSlot.Connect(r.renderable->OnRenderableInvalidateInstanceData, std::bind(InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
r.renderableInvalidationSlot.Connect(r.renderable->OnRenderableInvalidateInstanceData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
}
inline void GraphicsComponent::EnsureTransformMatrixUpdate() const

View File

@ -12,7 +12,7 @@ namespace Ndk
template<typename ComponentType, typename... Args>
ComponentType& Entity::AddComponent(Args&&... args)
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
// Allocation et affectation du component
std::unique_ptr<ComponentType> ptr(new ComponentType(std::forward<Args>(args)...));
@ -34,7 +34,7 @@ namespace Ndk
ComponentType& Entity::GetComponent()
{
///DOC: Le component doit être présent
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
ComponentIndex index = GetComponentIndex<ComponentType>();
return static_cast<ComponentType&>(GetComponent(index));
@ -68,7 +68,7 @@ namespace Ndk
template<typename ComponentType>
bool Entity::HasComponent() const
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
ComponentIndex index = GetComponentIndex<ComponentType>();
return HasComponent(index);

View File

@ -35,7 +35,7 @@ namespace Ndk
template<typename SystemType, typename... Args>
SystemType& World::AddSystem(Args&&... args)
{
static_assert(std::is_base_of<BaseSystem, SystemType>(), "SystemType is not a component");
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a component");
// Allocation et affectation du component
std::unique_ptr<SystemType> ptr(new SystemType(std::forward(args)...));
@ -73,7 +73,7 @@ namespace Ndk
SystemType& World::GetSystem()
{
///DOC: Le système doit être présent
static_assert(std::is_base_of<BaseSystem, SystemType>(), "SystemType is not a system");
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a system");
SystemIndex index = GetSystemIndex<SystemType>();
return static_cast<SystemType&>(GetSystem(index));

View File

@ -47,7 +47,7 @@ namespace Ndk
void CameraComponent::OnAttached()
{
if (m_entity->HasComponent<NodeComponent>())
m_nodeInvalidationSlot.Connect(m_entity->GetComponent<NodeComponent>().OnNodeInvalidation, this, OnNodeInvalidated);
m_nodeInvalidationSlot.Connect(m_entity->GetComponent<NodeComponent>().OnNodeInvalidation, this, &CameraComponent::OnNodeInvalidated);
InvalidateViewMatrix();
}
@ -57,7 +57,7 @@ namespace Ndk
if (IsComponent<NodeComponent>(component))
{
NodeComponent& nodeComponent = static_cast<NodeComponent&>(component);
m_nodeInvalidationSlot.Connect(nodeComponent.OnNodeInvalidation, this, OnNodeInvalidated);
m_nodeInvalidationSlot.Connect(nodeComponent.OnNodeInvalidation, this, &CameraComponent::OnNodeInvalidated);
InvalidateViewMatrix();
}

View File

@ -21,7 +21,7 @@ namespace Ndk
void GraphicsComponent::OnAttached()
{
if (m_entity->HasComponent<NodeComponent>())
m_nodeInvalidationSlot.Connect(m_entity->GetComponent<NodeComponent>().OnNodeInvalidation, this, OnNodeInvalidated);
m_nodeInvalidationSlot.Connect(m_entity->GetComponent<NodeComponent>().OnNodeInvalidation, this, &GraphicsComponent::OnNodeInvalidated);
InvalidateTransformMatrix();
}
@ -31,7 +31,7 @@ namespace Ndk
if (IsComponent<NodeComponent>(component))
{
NodeComponent& nodeComponent = static_cast<NodeComponent&>(component);
m_nodeInvalidationSlot.Connect(nodeComponent.OnNodeInvalidation, this, OnNodeInvalidated);
m_nodeInvalidationSlot.Connect(nodeComponent.OnNodeInvalidation, this, &GraphicsComponent::OnNodeInvalidated);
InvalidateTransformMatrix();
}

View File

@ -57,7 +57,7 @@ int main()
while (sound.GetStatus() == nzSoundStatus_Playing)
{
// Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
int sleepTime = 1000/60 - clock.GetMilliseconds(); // 60 FPS
int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS
if (sleepTime > 0)
NzThread::Sleep(sleepTime);

View File

@ -4,6 +4,7 @@
#include <Nazara/Utility/Animation.hpp>
#include <Nazara/Utility/Mesh.hpp>
#include <Nazara/Utility/Utility.hpp>
#include <cctype>
#include <iostream>
#include <limits>

View File

@ -17,7 +17,7 @@ class NzAbstractHash;
template<typename Block = nzUInt32, class Allocator = std::allocator<Block>>
class NzBitset
{
static_assert(std::is_integral<Block>() && std::is_unsigned<Block>(), "Block must be a unsigned integral type");
static_assert(std::is_integral<Block>::value && std::is_unsigned<Block>::value, "Block must be a unsigned integral type");
public:
class Bit;

View File

@ -8,6 +8,12 @@
#include <utility>
#include <Nazara/Core/Debug.hpp>
#ifdef NAZARA_COMPILER_MSVC
// Bits tricks require us to disable some warnings under VS
#pragma warning(disable: 4146)
#pragma warning(disable: 4804)
#endif
template<typename Block, class Allocator>
NzBitset<Block, Allocator>::NzBitset() :
m_bitCount(0)
@ -305,7 +311,7 @@ bool NzBitset<Block, Allocator>::Test(unsigned int bit) const
{
NazaraAssert(bit < m_bitCount, "Bit index out of range");
return m_blocks[GetBlockIndex(bit)] & (Block(1U) << GetBitIndex(bit));
return (m_blocks[GetBlockIndex(bit)] & (Block(1U) << GetBitIndex(bit))) != 0;
}
template<typename Block, class Allocator>
@ -754,4 +760,10 @@ namespace std
}
}
#ifdef NAZARA_COMPILER_MSVC
// Reenable those warnings
#pragma warning(default: 4146)
#pragma warning(default: 4804)
#endif
#include <Nazara/Core/DebugOff.hpp>

View File

@ -23,7 +23,7 @@ class NzMaterial;
class NzTexture;
struct NzMeshData;
class NAZARA_GRAPHICS_API NzAbstractRenderQueue : NzNonCopyable
class NAZARA_GRAPHICS_API NzAbstractRenderQueue
{
public:
struct DirectionalLight;
@ -31,6 +31,7 @@ class NAZARA_GRAPHICS_API NzAbstractRenderQueue : NzNonCopyable
struct SpotLight;
NzAbstractRenderQueue() = default;
NzAbstractRenderQueue(const NzAbstractRenderQueue&) = delete;
virtual ~NzAbstractRenderQueue();
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
@ -53,6 +54,7 @@ class NAZARA_GRAPHICS_API NzAbstractRenderQueue : NzNonCopyable
virtual void Clear(bool fully = false);
NzAbstractRenderQueue& operator=(const NzAbstractRenderQueue&) = delete;
struct DirectionalLight
{

View File

@ -19,10 +19,11 @@ class NzAbstractViewer;
class NzBackground;
struct SceneData;
class NAZARA_GRAPHICS_API NzAbstractRenderTechnique : NzNonCopyable
class NAZARA_GRAPHICS_API NzAbstractRenderTechnique
{
public:
NzAbstractRenderTechnique();
NzAbstractRenderTechnique(const NzAbstractRenderTechnique&) = delete;
virtual ~NzAbstractRenderTechnique();
virtual bool Draw(const NzSceneData& sceneData) const = 0;
@ -35,6 +36,8 @@ class NAZARA_GRAPHICS_API NzAbstractRenderTechnique : NzNonCopyable
virtual bool IsInstancingEnabled() const;
NzAbstractRenderTechnique& operator=(const NzAbstractRenderTechnique&) = delete;
protected:
bool m_instancingEnabled;
};

View File

@ -44,7 +44,7 @@ class NAZARA_GRAPHICS_API NzDeferredRenderQueue : public NzAbstractRenderQueue
struct MeshDataComparator
{
bool operator()(const NzMeshData& data1, const NzMeshData& data2);
bool operator()(const NzMeshData& data1, const NzMeshData& data2) const;
};
struct MeshInstanceEntry
@ -59,7 +59,7 @@ class NAZARA_GRAPHICS_API NzDeferredRenderQueue : public NzAbstractRenderQueue
struct BatchedModelMaterialComparator
{
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2) const;
};
struct BatchedModelEntry

View File

@ -60,7 +60,7 @@ class NAZARA_GRAPHICS_API NzDeferredRenderTechnique : public NzAbstractRenderTec
struct RenderPassComparator
{
bool operator()(nzRenderPassType pass1, nzRenderPassType pass2);
bool operator()(nzRenderPassType pass1, nzRenderPassType pass2) const;
};
std::map<nzRenderPassType, std::map<int, std::unique_ptr<NzDeferredRenderPass>>, RenderPassComparator> m_passes;

View File

@ -57,7 +57,7 @@ class NAZARA_GRAPHICS_API NzForwardRenderQueue : public NzAbstractRenderQueue
struct BatchedBillboardComparator
{
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2) const;
};
struct BatchedBillboardEntry
@ -103,7 +103,7 @@ class NAZARA_GRAPHICS_API NzForwardRenderQueue : public NzAbstractRenderQueue
/// Meshes
struct MeshDataComparator
{
bool operator()(const NzMeshData& data1, const NzMeshData& data2);
bool operator()(const NzMeshData& data1, const NzMeshData& data2) const;
};
struct MeshInstanceEntry
@ -119,7 +119,7 @@ class NAZARA_GRAPHICS_API NzForwardRenderQueue : public NzAbstractRenderQueue
struct BatchedModelMaterialComparator
{
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2) const;
};
struct BatchedModelEntry

View File

@ -278,7 +278,7 @@ int NzLuaClass<T>::MethodProxy(lua_State* state)
NzLuaInstance& lua = *NzLuaInstance::GetInstance(state);
ClassInfo* info = *static_cast<ClassInfo**>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
int index = lua.ToInteger(lua.GetIndexOfUpValue(2));
unsigned int index = static_cast<unsigned int>(lua.ToInteger(lua.GetIndexOfUpValue(2)));
ClassFunc method = info->methods[index];
T& instance = *(*static_cast<T**>(lua.CheckUserdata(1, info->name)));
@ -334,7 +334,7 @@ int NzLuaClass<T>::StaticMethodProxy(lua_State* state)
NzLuaInstance& lua = *NzLuaInstance::GetInstance(state);
ClassInfo* info = *static_cast<ClassInfo**>(lua.ToUserdata(lua.GetIndexOfUpValue(1)));
int index = lua.ToInteger(lua.GetIndexOfUpValue(2));
unsigned int index = static_cast<unsigned int>(lua.ToInteger(lua.GetIndexOfUpValue(2)));
StaticFunc method = info->staticMethods[index];
return method(lua);

View File

@ -81,7 +81,7 @@ namespace
{
// Le masque 32 bits sur la partie du nombre qu'on traite actuellement
T mask = T(std::numeric_limits<nzUInt32>::max()) << i*8;
T val = (number & mask) >> i*8; // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits)
nzUInt32 val = nzUInt32((number & mask) >> i*8); // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits)
// Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse
unsigned int log2 = NzImplIntegralLog2Pot<nzUInt32>(val);

View File

@ -160,7 +160,7 @@ void NzDeferredRenderQueue::OnVertexBufferInvalidation(const NzVertexBuffer* ver
}
}
bool NzDeferredRenderQueue::BatchedModelMaterialComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2)
bool NzDeferredRenderQueue::BatchedModelMaterialComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2) const
{
const NzUberShader* uberShader1 = mat1->GetShader();
const NzUberShader* uberShader2 = mat2->GetShader();
@ -180,7 +180,7 @@ bool NzDeferredRenderQueue::BatchedModelMaterialComparator::operator()(const NzM
return mat1 < mat2;
}
bool NzDeferredRenderQueue::MeshDataComparator::operator()(const NzMeshData& data1, const NzMeshData& data2)
bool NzDeferredRenderQueue::MeshDataComparator::operator()(const NzMeshData& data1, const NzMeshData& data2) const
{
const NzBuffer* buffer1;
const NzBuffer* buffer2;

View File

@ -569,7 +569,7 @@ void NzDeferredRenderTechnique::Uninitialize()
NzShaderLibrary::Unregister("DeferredGaussianBlur");
}
bool NzDeferredRenderTechnique::RenderPassComparator::operator()(nzRenderPassType pass1, nzRenderPassType pass2)
bool NzDeferredRenderTechnique::RenderPassComparator::operator()(nzRenderPassType pass1, nzRenderPassType pass2) const
{
return RenderPassPriority[pass1] < RenderPassPriority[pass2];
}

View File

@ -560,7 +560,7 @@ void NzForwardRenderQueue::OnVertexBufferInvalidation(const NzVertexBuffer* vert
}
}
bool NzForwardRenderQueue::BatchedBillboardComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2)
bool NzForwardRenderQueue::BatchedBillboardComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2) const
{
const NzUberShader* uberShader1 = mat1->GetShader();
const NzUberShader* uberShader2 = mat2->GetShader();
@ -580,7 +580,7 @@ bool NzForwardRenderQueue::BatchedBillboardComparator::operator()(const NzMateri
return mat1 < mat2;
}
bool NzForwardRenderQueue::BatchedModelMaterialComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2)
bool NzForwardRenderQueue::BatchedModelMaterialComparator::operator()(const NzMaterial* mat1, const NzMaterial* mat2) const
{
const NzUberShader* uberShader1 = mat1->GetShader();
const NzUberShader* uberShader2 = mat2->GetShader();
@ -620,7 +620,7 @@ bool NzForwardRenderQueue::BatchedSpriteMaterialComparator::operator()(const NzM
return mat1 < mat2;
}
bool NzForwardRenderQueue::MeshDataComparator::operator()(const NzMeshData& data1, const NzMeshData& data2)
bool NzForwardRenderQueue::MeshDataComparator::operator()(const NzMeshData& data1, const NzMeshData& data2) const
{
const NzBuffer* buffer1;
const NzBuffer* buffer2;

View File

@ -15,7 +15,7 @@ nzUInt32 NzGuillotineTextureAtlas::GetStorage() const
NzAbstractImage* NzGuillotineTextureAtlas::ResizeImage(NzAbstractImage* oldImage, const NzVector2ui& size) const
{
std::unique_ptr<NzTexture> newTexture(new NzTexture);
if (newTexture->Create(nzImageType_2D, nzPixelFormat_A8, size.x, size.y, 1, 0xFF))
if (newTexture->Create(nzImageType_2D, nzPixelFormat_A8, size.x, size.y, 1))
{
if (oldImage)
{