From 36b39ec868df49b69d297c86ebf18d701ee55d33 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Mar 2015 18:17:52 +0100 Subject: [PATCH] Alphabetical commit Former-commit-id: 4f1e73bd1228fefefd7f788adcd3ccb396d0b141 --- include/Nazara/Graphics/View.hpp | 2 +- src/Nazara/Graphics/View.cpp | 36 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Graphics/View.hpp b/include/Nazara/Graphics/View.hpp index b10b30cc0..30f8ba73c 100644 --- a/include/Nazara/Graphics/View.hpp +++ b/include/Nazara/Graphics/View.hpp @@ -46,8 +46,8 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget float GetZFar() const; float GetZNear() const; - NzVector2i MapWorldToPixel(const NzVector2f& coords); NzVector2f MapPixelToWorld(const NzVector2i& pixel); + NzVector2i MapWorldToPixel(const NzVector2f& coords); void SetSize(const NzVector2f& size); void SetSize(float width, float height); diff --git a/src/Nazara/Graphics/View.cpp b/src/Nazara/Graphics/View.cpp index 65c636f1c..b58e10ead 100644 --- a/src/Nazara/Graphics/View.cpp +++ b/src/Nazara/Graphics/View.cpp @@ -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);