Merge branch 'master' into NDK
Conflicts: src/Nazara/Physics/Geom.cpp Former-commit-id: 8fd71e34dbe105890042acc55e30b64e7c457ed4
This commit is contained in:
@@ -171,6 +171,10 @@ void NzCamera::SetTarget(const NzRenderTarget* renderTarget)
|
||||
m_target = renderTarget;
|
||||
if (m_target)
|
||||
m_target->AddListener(this);
|
||||
|
||||
m_frustumUpdated = false;
|
||||
m_projectionMatrixUpdated = false;
|
||||
m_viewportUpdated = false;
|
||||
}
|
||||
|
||||
void NzCamera::SetTarget(const NzRenderTarget& renderTarget)
|
||||
|
||||
@@ -127,8 +127,8 @@ bool NzDeferredPhongLightingPass::Process(const NzScene* scene, unsigned int fir
|
||||
NzRenderer::SetRenderStates(lightStates);
|
||||
|
||||
NzRenderer::SetShader(m_pointSpotLightShader);
|
||||
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderEyePositionLocation, scene->GetAmbientColor());
|
||||
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderSceneAmbientLocation, scene->GetViewer()->GetEyePosition());
|
||||
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderSceneAmbientLocation, scene->GetAmbientColor());
|
||||
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderEyePositionLocation, scene->GetViewer()->GetEyePosition());
|
||||
|
||||
NzMatrix4f lightMatrix;
|
||||
lightMatrix.MakeIdentity();
|
||||
|
||||
@@ -658,9 +658,12 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
||||
shader->SendVector(shaderUniforms->eyePosition, viewer->GetEyePosition());
|
||||
|
||||
// On envoie les lumières directionnelles s'il y a (Les mêmes pour tous)
|
||||
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
||||
for (unsigned int i = 0; i < lightCount; ++i)
|
||||
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
if (shaderUniforms->hasLightUniforms)
|
||||
{
|
||||
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
||||
for (unsigned int i = 0; i < lightCount; ++i)
|
||||
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
}
|
||||
|
||||
lastShader = shader;
|
||||
}
|
||||
@@ -690,21 +693,24 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
||||
NzRenderer::SetIndexBuffer(indexBuffer);
|
||||
NzRenderer::SetVertexBuffer(vertexBuffer);
|
||||
|
||||
// Calcul des lumières les plus proches
|
||||
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
||||
if (shaderUniforms->hasLightUniforms)
|
||||
{
|
||||
NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition();
|
||||
float radius = modelData.squaredBoundingSphere.radius;
|
||||
unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
|
||||
// Calcul des lumières les plus proches
|
||||
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
||||
{
|
||||
NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition();
|
||||
float radius = modelData.squaredBoundingSphere.radius;
|
||||
unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
|
||||
|
||||
unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount);
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++));
|
||||
unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount);
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++));
|
||||
}
|
||||
|
||||
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
||||
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
}
|
||||
|
||||
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
||||
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
|
||||
NzRenderer::SetMatrix(nzMatrixType_World, matrix);
|
||||
drawFunc(meshData.primitiveMode, 0, indexCount);
|
||||
}
|
||||
|
||||
@@ -170,6 +170,24 @@ float NzView::GetZNear() const
|
||||
return m_zNear;
|
||||
}
|
||||
|
||||
NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel)
|
||||
{
|
||||
if (!m_invViewProjMatrixUpdated)
|
||||
UpdateInvViewProjMatrix();
|
||||
|
||||
if (!m_viewportUpdated)
|
||||
UpdateViewport();
|
||||
|
||||
// Conversion du viewport en flottant
|
||||
NzRectf viewport(m_viewport);
|
||||
|
||||
NzVector2f normalized;
|
||||
normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width;
|
||||
normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height;
|
||||
|
||||
return m_invViewProjMatrix.Transform(normalized);
|
||||
}
|
||||
|
||||
NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
||||
{
|
||||
if (!m_viewProjMatrixUpdated)
|
||||
@@ -190,24 +208,6 @@ NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
||||
return pixel;
|
||||
}
|
||||
|
||||
NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel)
|
||||
{
|
||||
if (!m_invViewProjMatrixUpdated)
|
||||
UpdateInvViewProjMatrix();
|
||||
|
||||
if (!m_viewportUpdated)
|
||||
UpdateViewport();
|
||||
|
||||
// Conversion du viewport en flottant
|
||||
NzRectf viewport(m_viewport);
|
||||
|
||||
NzVector2f normalized;
|
||||
normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width;
|
||||
normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height;
|
||||
|
||||
return m_invViewProjMatrix.Transform(normalized);
|
||||
}
|
||||
|
||||
void NzView::SetSize(const NzVector2f& size)
|
||||
{
|
||||
SetSize(size.x, size.y);
|
||||
|
||||
Reference in New Issue
Block a user