diff --git a/modules/napparameter/src/parametergroup.h b/modules/napparameter/src/parametergroup.h index efdb76ebc9..1f56f95868 100644 --- a/modules/napparameter/src/parametergroup.h +++ b/modules/napparameter/src/parametergroup.h @@ -28,5 +28,5 @@ namespace nap // For backwards compatibility reasons, override the default 'Members' and 'Children' property names // of the 'nap::ParameterGroup' to the property names introduced before the arrival of the generic nap::Group. template<> - nap::Group::Group(); + NAPAPI nap::Group::Group(); } diff --git a/modules/naprender/src/perspcameracomponent.cpp b/modules/naprender/src/perspcameracomponent.cpp index 1638016994..3c6193b516 100644 --- a/modules/naprender/src/perspcameracomponent.cpp +++ b/modules/naprender/src/perspcameracomponent.cpp @@ -268,23 +268,37 @@ namespace nap } + float PerspCameraComponentInstance::getNearClippingPlane() const + { + return mProperties.mNearClippingPlane; + } + + + float PerspCameraComponentInstance::getFarClippingPlane() const + { + return mProperties.mFarClippingPlane; + } + + void PerspCameraComponentInstance::updateProjectionMatrices() const { - if (mDirty) - { - const float fov = glm::radians(mProperties.mFieldOfView); - const float near_plane = mProperties.mNearClippingPlane; - const float far_plane = mProperties.mFarClippingPlane; - const float aspect_ratio = ((float)(getRenderTargetSize().x * mProperties.mGridDimensions.x)) / ((float)(getRenderTargetSize().y * mProperties.mGridDimensions.y)); - - float left, right, top, bottom; - calculateCameraPlanes(fov, aspect_ratio, near_plane, mProperties.mGridDimensions.x, mProperties.mGridLocation.x, left, right); - calculateCameraPlanes(fov, 1.0f, near_plane, mProperties.mGridDimensions.y, mProperties.mGridLocation.y, bottom, top); - mRenderProjectionMatrix = createASymmetricProjection(near_plane, far_plane, left, right, top, bottom); - - mProjectionMatrix = glm::perspective(fov, aspect_ratio, near_plane, far_plane); - mDirty = false; - } + // Bail if there's nothing to update + if (!mDirty) + return; + + // Compute projection matrix + const float fov = glm::radians(mProperties.mFieldOfView); + const float near_plane = mProperties.mNearClippingPlane; + const float far_plane = mProperties.mFarClippingPlane; + const float aspect_ratio = ((float)(getRenderTargetSize().x * mProperties.mGridDimensions.x)) / ((float)(getRenderTargetSize().y * mProperties.mGridDimensions.y)); + + float left, right, top, bottom; + calculateCameraPlanes(fov, aspect_ratio, near_plane, mProperties.mGridDimensions.x, mProperties.mGridLocation.x, left, right); + calculateCameraPlanes(fov, 1.0f, near_plane, mProperties.mGridDimensions.y, mProperties.mGridLocation.y, bottom, top); + mRenderProjectionMatrix = createASymmetricProjection(near_plane, far_plane, left, right, top, bottom); + + mProjectionMatrix = glm::perspective(fov, aspect_ratio, near_plane, far_plane); + mDirty = false; } diff --git a/modules/naprender/src/perspcameracomponent.h b/modules/naprender/src/perspcameracomponent.h index 54c187df7b..a2b8c46617 100644 --- a/modules/naprender/src/perspcameracomponent.h +++ b/modules/naprender/src/perspcameracomponent.h @@ -103,10 +103,20 @@ namespace nap void setFieldOfView(float fov); /** - * @return current field of view + * @return camera field of view */ float getFieldOfView() const; + /** + * @return camera near clipping plane + */ + float getNearClippingPlane() const; + + /** + * @return camera far clipping plane + */ + float getFarClippingPlane() const; + /** * Returns the matrix that is used to transform a 3d scene in to a 2d projection by the renderer. * Vulkan uses a coordinate system where (-1, -1) is in the top left quadrant, instead of the bottom left quadrant.