Fix some warnings from MSVC

This commit is contained in:
Lynix 2016-11-10 16:44:29 +01:00
parent 8ed34d22fb
commit 7f445def13
19 changed files with 96 additions and 97 deletions

View File

@ -148,9 +148,11 @@ namespace Ndk
// We alert each system // We alert each system
for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index))
{ {
if (m_world->HasSystem(index)) auto sysIndex = static_cast<Ndk::SystemIndex>(index);
if (m_world->HasSystem(sysIndex))
{ {
BaseSystem& system = m_world->GetSystem(index); BaseSystem& system = m_world->GetSystem(sysIndex);
system.RemoveEntity(this); system.RemoveEntity(this);
} }
} }

View File

@ -174,7 +174,7 @@ namespace Ndk
case 16: case 16:
{ {
double values[16]; double values[16];
for (std::size_t i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
values[i] = lua.CheckNumber(i); values[i] = lua.CheckNumber(i);
Nz::PlacementNew(matrix, values); Nz::PlacementNew(matrix, values);

View File

@ -67,7 +67,7 @@ namespace Ndk
else else
{ {
// We allocate a new entity // We allocate a new entity
id = m_entities.size(); id = static_cast<Ndk::EntityId>(m_entities.size());
// We can't use emplace_back due to the scope // We can't use emplace_back due to the scope
m_entities.push_back(Entity(this, id)); m_entities.push_back(Entity(this, id));
@ -221,7 +221,7 @@ namespace Ndk
Nz::Bitset<>& removedComponents = entity->GetRemovedComponentBits(); Nz::Bitset<>& removedComponents = entity->GetRemovedComponentBits();
for (std::size_t j = removedComponents.FindFirst(); j != m_dirtyEntities.npos; j = removedComponents.FindNext(j)) for (std::size_t j = removedComponents.FindFirst(); j != m_dirtyEntities.npos; j = removedComponents.FindNext(j))
entity->DestroyComponent(j); entity->DestroyComponent(static_cast<Ndk::ComponentIndex>(j));
removedComponents.Reset(); removedComponents.Reset();
for (auto& system : m_orderedSystems) for (auto& system : m_orderedSystems)

View File

@ -87,7 +87,7 @@ namespace Nz
struct SpriteChain_XYZ_Color_UV struct SpriteChain_XYZ_Color_UV
{ {
const VertexStruct_XYZ_Color_UV* vertices; const VertexStruct_XYZ_Color_UV* vertices;
unsigned int spriteCount; std::size_t spriteCount;
}; };
struct BatchedSpriteEntry struct BatchedSpriteEntry
@ -160,7 +160,7 @@ namespace Nz
const Material* material; const Material* material;
}; };
typedef std::vector<unsigned int> TransparentModelContainer; typedef std::vector<std::size_t> TransparentModelContainer;
struct Layer struct Layer
{ {

View File

@ -36,10 +36,10 @@ namespace Nz
~ParticleDeclaration(); ~ParticleDeclaration();
void DisableComponent(ParticleComponent component); void DisableComponent(ParticleComponent component);
void EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset); void EnableComponent(ParticleComponent component, ComponentType type, std::size_t offset);
void GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const; void GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const;
unsigned int GetStride() const; std::size_t GetStride() const;
void SetStride(unsigned int stride); void SetStride(unsigned int stride);
@ -60,7 +60,7 @@ namespace Nz
{ {
ComponentType type; ComponentType type;
bool enabled = false; bool enabled = false;
unsigned int offset; std::size_t offset;
/* /*
** -Lynix: ** -Lynix:
@ -71,7 +71,7 @@ namespace Nz
}; };
std::array<Component, ParticleComponent_Max + 1> m_components; std::array<Component, ParticleComponent_Max + 1> m_components;
unsigned int m_stride; std::size_t m_stride;
static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations; static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations;
static ParticleDeclarationLibrary::LibraryMap s_library; static ParticleDeclarationLibrary::LibraryMap s_library;

View File

@ -28,12 +28,12 @@ namespace Nz
void EnableLagCompensation(bool enable); void EnableLagCompensation(bool enable);
unsigned int GetEmissionCount() const; std::size_t GetEmissionCount() const;
float GetEmissionRate() const; float GetEmissionRate() const;
bool IsLagCompensationEnabled() const; bool IsLagCompensationEnabled() const;
void SetEmissionCount(unsigned int count); void SetEmissionCount(std::size_t count);
void SetEmissionRate(float rate); void SetEmissionRate(float rate);
ParticleEmitter& operator=(const ParticleEmitter& emitter) = default; ParticleEmitter& operator=(const ParticleEmitter& emitter) = default;
@ -49,7 +49,7 @@ namespace Nz
bool m_lagCompensationEnabled; bool m_lagCompensationEnabled;
mutable float m_emissionAccumulator; mutable float m_emissionAccumulator;
float m_emissionRate; float m_emissionRate;
unsigned int m_emissionCount; std::size_t m_emissionCount;
}; };
} }

View File

@ -45,11 +45,11 @@ namespace Nz
void* GenerateParticles(unsigned int count); void* GenerateParticles(unsigned int count);
const ParticleDeclarationConstRef& GetDeclaration() const; const ParticleDeclarationConstRef& GetDeclaration() const;
unsigned int GetMaxParticleCount() const; std::size_t GetMaxParticleCount() const;
unsigned int GetParticleCount() const; std::size_t GetParticleCount() const;
unsigned int GetParticleSize() const; std::size_t GetParticleSize() const;
void KillParticle(unsigned int index); void KillParticle(std::size_t index);
void KillParticles(); void KillParticles();
void RemoveController(ParticleController* controller); void RemoveController(ParticleController* controller);
@ -81,6 +81,9 @@ namespace Nz
}; };
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles; std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
std::size_t m_maxParticleCount;
std::size_t m_particleCount;
std::size_t m_particleSize;
mutable std::vector<UInt8> m_buffer; mutable std::vector<UInt8> m_buffer;
std::vector<ParticleControllerRef> m_controllers; std::vector<ParticleControllerRef> m_controllers;
std::vector<EmitterEntry> m_emitters; std::vector<EmitterEntry> m_emitters;
@ -88,9 +91,6 @@ namespace Nz
ParticleDeclarationConstRef m_declaration; ParticleDeclarationConstRef m_declaration;
ParticleRendererRef m_renderer; ParticleRendererRef m_renderer;
bool m_processing; bool m_processing;
unsigned int m_maxParticleCount;
unsigned int m_particleCount;
unsigned int m_particleSize;
}; };
} }

View File

@ -29,7 +29,7 @@ namespace Nz
static AbstractRenderTechnique* GetByName(const String& name, int* techniqueRanking = nullptr); static AbstractRenderTechnique* GetByName(const String& name, int* techniqueRanking = nullptr);
static AbstractRenderTechnique* GetByRanking(int maxRanking, int* techniqueRanking = nullptr); static AbstractRenderTechnique* GetByRanking(int maxRanking, int* techniqueRanking = nullptr);
static unsigned int GetCount(); static std::size_t GetCount();
static void Register(const String& name, int ranking, RenderTechniqueFactory factory); static void Register(const String& name, int ranking, RenderTechniqueFactory factory);

View File

@ -159,13 +159,13 @@ namespace Nz
instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4));
const Matrix4f* instanceMatrices = &instances[0]; const Matrix4f* instanceMatrices = &instances[0];
unsigned int instanceCount = instances.size(); std::size_t instanceCount = instances.size();
unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer std::size_t maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer
while (instanceCount > 0) while (instanceCount > 0)
{ {
// We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size)
unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); std::size_t renderedInstanceCount = std::min(instanceCount, maxInstanceCount);
instanceCount -= renderedInstanceCount; instanceCount -= renderedInstanceCount;
// We fill the instancing buffer with our world matrices // We fill the instancing buffer with our world matrices

View File

@ -267,13 +267,13 @@ namespace Nz
const Texture* overlay = overlayIt.first; const Texture* overlay = overlayIt.first;
auto& spriteChainVector = overlayIt.second.spriteChains; auto& spriteChainVector = overlayIt.second.spriteChains;
unsigned int spriteChainCount = spriteChainVector.size(); std::size_t spriteChainCount = spriteChainVector.size();
if (spriteChainCount > 0) if (spriteChainCount > 0)
{ {
Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture);
unsigned int spriteChain = 0; // Which chain of sprites are we treating std::size_t spriteChain = 0; // Which chain of sprites are we treating
unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain std::size_t spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain
do do
{ {
@ -281,13 +281,13 @@ namespace Nz
BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite);
VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer()); VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
unsigned int spriteCount = 0; std::size_t spriteCount = 0;
unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); std::size_t maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4);
do do
{ {
ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain];
unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); std::size_t count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset);
std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV));
vertices += count * 4; vertices += count * 4;
@ -373,17 +373,17 @@ namespace Nz
auto& entry = matIt.second; auto& entry = matIt.second;
auto& billboardVector = entry.billboards; auto& billboardVector = entry.billboards;
unsigned int billboardCount = billboardVector.size(); std::size_t billboardCount = billboardVector.size();
if (billboardCount > 0) if (billboardCount > 0)
{ {
// We begin to apply the material (and get the shader activated doing so) // We begin to apply the material (and get the shader activated doing so)
material->Apply(pipelineInstance); material->Apply(pipelineInstance);
const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; const ForwardRenderQueue::BillboardData* data = &billboardVector[0];
unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); std::size_t maxBillboardPerDraw = instanceBuffer->GetVertexCount();
do do
{ {
unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); std::size_t renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw);
billboardCount -= renderedBillboardCount; billboardCount -= renderedBillboardCount;
instanceBuffer->Fill(data, 0, renderedBillboardCount, true); instanceBuffer->Fill(data, 0, renderedBillboardCount, true);
@ -435,12 +435,12 @@ namespace Nz
auto& billboardVector = entry.billboards; auto& billboardVector = entry.billboards;
const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; const ForwardRenderQueue::BillboardData* data = &billboardVector[0];
unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); std::size_t maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4);
unsigned int billboardCount = billboardVector.size(); std::size_t billboardCount = billboardVector.size();
do do
{ {
unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); std::size_t renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw);
billboardCount -= renderedBillboardCount; billboardCount -= renderedBillboardCount;
BufferMapper<VertexBuffer> vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); BufferMapper<VertexBuffer> vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4);
@ -584,13 +584,13 @@ namespace Nz
instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4));
const Matrix4f* instanceMatrices = &instances[0]; const Matrix4f* instanceMatrices = &instances[0];
unsigned int instanceCount = instances.size(); std::size_t instanceCount = instances.size();
unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch std::size_t maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch
while (instanceCount > 0) while (instanceCount > 0)
{ {
// We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size)
unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); std::size_t renderedInstanceCount = std::min(instanceCount, maxInstanceCount);
instanceCount -= renderedInstanceCount; instanceCount -= renderedInstanceCount;
// We fill the instancing buffer with our world matrices // We fill the instancing buffer with our world matrices

View File

@ -383,7 +383,7 @@ namespace Nz
auto& transparentModelData = currentLayer.transparentModelData; auto& transparentModelData = currentLayer.transparentModelData;
// The material is transparent, we must draw this mesh using another way (after the rendering of opages objects while sorting them) // The material is transparent, we must draw this mesh using another way (after the rendering of opages objects while sorting them)
unsigned int index = transparentModelData.size(); std::size_t index = transparentModelData.size();
transparentModelData.resize(index+1); transparentModelData.resize(index+1);
TransparentModelData& data = transparentModelData.back(); TransparentModelData& data = transparentModelData.back();
@ -603,7 +603,7 @@ namespace Nz
{ {
Layer& layer = pair.second; Layer& layer = pair.second;
std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (std::size_t index1, std::size_t index2)
{ {
const Spheref& sphere1 = layer.transparentModelData[index1].squaredBoundingSphere; const Spheref& sphere1 = layer.transparentModelData[index1].squaredBoundingSphere;
const Spheref& sphere2 = layer.transparentModelData[index2].squaredBoundingSphere; const Spheref& sphere2 = layer.transparentModelData[index2].squaredBoundingSphere;
@ -672,7 +672,7 @@ namespace Nz
BatchedBillboardEntry& entry = it->second; BatchedBillboardEntry& entry = it->second;
auto& billboardVector = entry.billboards; auto& billboardVector = entry.billboards;
unsigned int prevSize = billboardVector.size(); std::size_t prevSize = billboardVector.size();
billboardVector.resize(prevSize + count); billboardVector.resize(prevSize + count);
return &billboardVector[prevSize]; return &billboardVector[prevSize];

View File

@ -33,8 +33,8 @@ namespace Nz
Vector2f uv; Vector2f uv;
}; };
unsigned int s_maxQuads = std::numeric_limits<UInt16>::max() / 6; std::size_t s_maxQuads = std::numeric_limits<UInt16>::max() / 6;
unsigned int s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB std::size_t s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB
} }
/*! /*!
@ -347,13 +347,13 @@ namespace Nz
const Texture* overlay = overlayIt.first; const Texture* overlay = overlayIt.first;
auto& spriteChainVector = overlayIt.second.spriteChains; auto& spriteChainVector = overlayIt.second.spriteChains;
unsigned int spriteChainCount = spriteChainVector.size(); std::size_t spriteChainCount = spriteChainVector.size();
if (spriteChainCount > 0) if (spriteChainCount > 0)
{ {
Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture);
unsigned int spriteChain = 0; // Which chain of sprites are we treating std::size_t spriteChain = 0; // Which chain of sprites are we treating
unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain std::size_t spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain
do do
{ {
@ -361,13 +361,13 @@ namespace Nz
BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); BufferMapper<VertexBuffer> vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite);
VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer()); VertexStruct_XYZ_Color_UV* vertices = static_cast<VertexStruct_XYZ_Color_UV*>(vertexMapper.GetPointer());
unsigned int spriteCount = 0; std::size_t spriteCount = 0;
unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); std::size_t maxSpriteCount = std::min<std::size_t>(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4);
do do
{ {
ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain];
unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); std::size_t count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset);
std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV));
vertices += count * 4; vertices += count * 4;
@ -450,17 +450,17 @@ namespace Nz
auto& entry = matIt.second; auto& entry = matIt.second;
auto& billboardVector = entry.billboards; auto& billboardVector = entry.billboards;
unsigned int billboardCount = billboardVector.size(); std::size_t billboardCount = billboardVector.size();
if (billboardCount > 0) if (billboardCount > 0)
{ {
// We begin to apply the material (and get the shader activated doing so) // We begin to apply the material (and get the shader activated doing so)
material->Apply(pipelineInstance); material->Apply(pipelineInstance);
const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; const ForwardRenderQueue::BillboardData* data = &billboardVector[0];
unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); std::size_t maxBillboardPerDraw = instanceBuffer->GetVertexCount();
do do
{ {
unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); std::size_t renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw);
billboardCount -= renderedBillboardCount; billboardCount -= renderedBillboardCount;
instanceBuffer->Fill(data, 0, renderedBillboardCount, true); instanceBuffer->Fill(data, 0, renderedBillboardCount, true);
@ -512,12 +512,12 @@ namespace Nz
auto& billboardVector = entry.billboards; auto& billboardVector = entry.billboards;
const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; const ForwardRenderQueue::BillboardData* data = &billboardVector[0];
unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); std::size_t maxBillboardPerDraw = std::min<std::size_t>(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4);
unsigned int billboardCount = billboardVector.size(); std::size_t billboardCount = billboardVector.size();
do do
{ {
unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); std::size_t renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw);
billboardCount -= renderedBillboardCount; billboardCount -= renderedBillboardCount;
BufferMapper<VertexBuffer> vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); BufferMapper<VertexBuffer> vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4);
@ -666,16 +666,16 @@ namespace Nz
// With instancing, impossible to select the lights for each object // With instancing, impossible to select the lights for each object
// So, it's only activated for directional lights // So, it's only activated for directional lights
unsigned int lightCount = m_renderQueue.directionalLights.size(); std::size_t lightCount = m_renderQueue.directionalLights.size();
unsigned int lightIndex = 0; std::size_t lightIndex = 0;
RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); RendererComparison oldDepthFunc = Renderer::GetDepthFunc();
unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; std::size_t passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1;
for (unsigned int pass = 0; pass < passCount; ++pass) for (std::size_t pass = 0; pass < passCount; ++pass)
{ {
if (shaderUniforms->hasLightUniforms) if (shaderUniforms->hasLightUniforms)
{ {
unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); std::size_t renderedLightCount = std::min<std::size_t>(lightCount, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
lightCount -= renderedLightCount; lightCount -= renderedLightCount;
if (pass == 1) if (pass == 1)
@ -690,18 +690,18 @@ namespace Nz
} }
// Sends the uniforms // Sends the uniforms
for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) for (std::size_t i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i);
} }
const Matrix4f* instanceMatrices = &instances[0]; const Matrix4f* instanceMatrices = &instances[0];
unsigned int instanceCount = instances.size(); std::size_t instanceCount = instances.size();
unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch std::size_t maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch
while (instanceCount > 0) while (instanceCount > 0)
{ {
// We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size)
unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); std::size_t renderedInstanceCount = std::min(instanceCount, maxInstanceCount);
instanceCount -= renderedInstanceCount; instanceCount -= renderedInstanceCount;
// We fill the instancing buffer with our world matrices // We fill the instancing buffer with our world matrices
@ -726,16 +726,16 @@ namespace Nz
// Choose the lights depending on an object position and apparent radius // Choose the lights depending on an object position and apparent radius
ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius)); ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius));
unsigned int lightCount = m_lights.size(); std::size_t lightCount = m_lights.size();
Renderer::SetMatrix(MatrixType_World, matrix); Renderer::SetMatrix(MatrixType_World, matrix);
unsigned int lightIndex = 0; std::size_t lightIndex = 0;
RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it
unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; std::size_t passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1;
for (unsigned int pass = 0; pass < passCount; ++pass) for (std::size_t pass = 0; pass < passCount; ++pass)
{ {
lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); lightCount -= std::min<std::size_t>(lightCount, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
if (pass == 1) if (pass == 1)
{ {
@ -749,7 +749,7 @@ namespace Nz
} }
// Sends the light uniforms to the shader // Sends the light uniforms to the shader
for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) for (std::size_t i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i);
// And we draw // And we draw
@ -835,7 +835,7 @@ namespace Nz
{ {
lightCount = std::min(m_renderQueue.directionalLights.size(), static_cast<decltype(m_renderQueue.directionalLights.size())>(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS)); lightCount = std::min(m_renderQueue.directionalLights.size(), static_cast<decltype(m_renderQueue.directionalLights.size())>(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS));
for (unsigned int i = 0; i < lightCount; ++i) for (std::size_t i = 0; i < lightCount; ++i)
SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset * i, freeTextureUnit++); SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset * i, freeTextureUnit++);
} }
@ -874,7 +874,7 @@ namespace Nz
float radius = modelData.squaredBoundingSphere.radius; float radius = modelData.squaredBoundingSphere.radius;
ChooseLights(Spheref(position, radius), false); ChooseLights(Spheref(position, radius), false);
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) for (std::size_t i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset*i, freeTextureUnit++); SendLightUniforms(shader, shaderUniforms->lightUniforms, i, shaderUniforms->lightOffset*i, freeTextureUnit++);
} }

View File

@ -100,7 +100,7 @@ namespace Nz
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if type is not supported * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if type is not supported
*/ */
void ParticleDeclaration::EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset) void ParticleDeclaration::EnableComponent(ParticleComponent component, ComponentType type, std::size_t offset)
{ {
#ifdef NAZARA_DEBUG #ifdef NAZARA_DEBUG
if (component > ParticleComponent_Max) if (component > ParticleComponent_Max)
@ -145,7 +145,7 @@ namespace Nz
* \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused
*/ */
void ParticleDeclaration::GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const void ParticleDeclaration::GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const
{ {
#ifdef NAZARA_DEBUG #ifdef NAZARA_DEBUG
if (component > ParticleComponent_Max) if (component > ParticleComponent_Max)
@ -180,7 +180,7 @@ namespace Nz
* \return Stride of the declaration * \return Stride of the declaration
*/ */
unsigned int ParticleDeclaration::GetStride() const std::size_t ParticleDeclaration::GetStride() const
{ {
return m_stride; return m_stride;
} }

View File

@ -74,11 +74,11 @@ namespace Nz
if (emissionCount >= 1.f) if (emissionCount >= 1.f)
{ {
// We compute the maximum number of particles which can be emitted // We compute the maximum number of particles which can be emitted
unsigned int emissionCountInt = static_cast<unsigned int>(emissionCount); std::size_t emissionCountInt = static_cast<std::size_t>(emissionCount);
unsigned int maxParticleCount = emissionCountInt * m_emissionCount; std::size_t maxParticleCount = emissionCountInt * m_emissionCount;
// We get the number of particles that we are able to create (depending on the free space) // We get the number of particles that we are able to create (depending on the free space)
unsigned int particleCount = std::min(maxParticleCount, system.GetMaxParticleCount() - system.GetParticleCount()); std::size_t particleCount = std::min(maxParticleCount, system.GetMaxParticleCount() - system.GetParticleCount());
if (particleCount == 0) if (particleCount == 0)
return; return;
@ -115,7 +115,7 @@ namespace Nz
* \return Current emission count * \return Current emission count
*/ */
unsigned int ParticleEmitter::GetEmissionCount() const std::size_t ParticleEmitter::GetEmissionCount() const
{ {
return m_emissionCount; return m_emissionCount;
} }
@ -146,7 +146,7 @@ namespace Nz
* \param count Emission count * \param count Emission count
*/ */
void ParticleEmitter::SetEmissionCount(unsigned int count) void ParticleEmitter::SetEmissionCount(std::size_t count)
{ {
m_emissionCount = count; m_emissionCount = count;
} }

View File

@ -142,11 +142,10 @@ namespace Nz
* \remark Produces a NazaraAssert if renderQueue is invalid * \remark Produces a NazaraAssert if renderQueue is invalid
*/ */
void ParticleGroup::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const void ParticleGroup::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& /*transformMatrix*/) const
{ {
NazaraAssert(m_renderer, "Invalid particle renderer"); NazaraAssert(m_renderer, "Invalid particle renderer");
NazaraAssert(renderQueue, "Invalid renderqueue"); NazaraAssert(renderQueue, "Invalid renderqueue");
NazaraUnused(transformMatrix);
if (m_particleCount > 0) if (m_particleCount > 0)
{ {
@ -215,7 +214,7 @@ namespace Nz
if (m_particleCount + count > m_maxParticleCount) if (m_particleCount + count > m_maxParticleCount)
return nullptr; return nullptr;
unsigned int particlesIndex = m_particleCount; std::size_t particlesIndex = m_particleCount;
m_particleCount += count; m_particleCount += count;
return &m_buffer[particlesIndex * m_particleSize]; return &m_buffer[particlesIndex * m_particleSize];
@ -264,7 +263,7 @@ namespace Nz
* \return Current maximum number * \return Current maximum number
*/ */
unsigned int ParticleGroup::GetMaxParticleCount() const std::size_t ParticleGroup::GetMaxParticleCount() const
{ {
return m_maxParticleCount; return m_maxParticleCount;
} }
@ -274,7 +273,7 @@ namespace Nz
* \return Current number * \return Current number
*/ */
unsigned int ParticleGroup::GetParticleCount() const std::size_t ParticleGroup::GetParticleCount() const
{ {
return m_particleCount; return m_particleCount;
} }
@ -284,7 +283,7 @@ namespace Nz
* \return Current size * \return Current size
*/ */
unsigned int ParticleGroup::GetParticleSize() const std::size_t ParticleGroup::GetParticleSize() const
{ {
return m_particleSize; return m_particleSize;
} }
@ -295,7 +294,7 @@ namespace Nz
* \param index Index of the particle * \param index Index of the particle
*/ */
void ParticleGroup::KillParticle(unsigned int index) void ParticleGroup::KillParticle(std::size_t index)
{ {
///FIXME: Verify the index ///FIXME: Verify the index
@ -402,10 +401,8 @@ namespace Nz
* \param transformMatrix Matrix transformation for our bounding volume * \param transformMatrix Matrix transformation for our bounding volume
*/ */
void ParticleGroup::UpdateBoundingVolume(const Matrix4f& transformMatrix) void ParticleGroup::UpdateBoundingVolume(const Matrix4f& /*transformMatrix*/)
{ {
NazaraUnused(transformMatrix);
// Nothing to do here (our bounding volume is global) // Nothing to do here (our bounding volume is global)
} }

View File

@ -170,7 +170,7 @@ namespace Nz
* \return Number of techniques * \return Number of techniques
*/ */
unsigned int RenderTechniques::GetCount() std::size_t RenderTechniques::GetCount()
{ {
return s_renderTechniques.size(); return s_renderTechniques.size();
} }

View File

@ -24,7 +24,7 @@ namespace Nz
Vector2f PhysWorld2D::GetGravity() const Vector2f PhysWorld2D::GetGravity() const
{ {
cpVect gravity = cpSpaceGetGravity(m_handle); cpVect gravity = cpSpaceGetGravity(m_handle);
return Vector2f(gravity.x, gravity.y); return Vector2f(Vector2<cpFloat>(gravity.x, gravity.y));
} }
cpSpace* PhysWorld2D::GetHandle() const cpSpace* PhysWorld2D::GetHandle() const

View File

@ -1441,7 +1441,7 @@ namespace Nz
SharedImage::PixelContainer levels(m_sharedImage->levels.size()); SharedImage::PixelContainer levels(m_sharedImage->levels.size());
for (unsigned int i = 0; i < levels.size(); ++i) for (unsigned int i = 0; i < levels.size(); ++i)
{ {
unsigned int size = GetMemoryUsage(i); std::size_t size = GetMemoryUsage(i);
levels[i].reset(new UInt8[size]); levels[i].reset(new UInt8[size]);
std::memcpy(levels[i].get(), m_sharedImage->levels[i].get(), size); std::memcpy(levels[i].get(), m_sharedImage->levels[i].get(), size);
} }

View File

@ -45,7 +45,7 @@ namespace Nz
bool VertexBuffer::Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard) bool VertexBuffer::Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard)
{ {
unsigned int stride = m_vertexDeclaration->GetStride(); std::size_t stride = m_vertexDeclaration->GetStride();
return FillRaw(data, startVertex*stride, length*stride, forceDiscard); return FillRaw(data, startVertex*stride, length*stride, forceDiscard);
} }