From e073562f80121ced07db38716e996c32b0c01a45 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 10 Apr 2015 15:52:40 +0500 Subject: [PATCH] Cycles: Make transform from viewplane a generic utility function --- intern/cycles/render/camera.cpp | 11 ----------- intern/cycles/render/camera.h | 1 - intern/cycles/util/util_transform.cpp | 16 ++++++++++++++-- intern/cycles/util/util_transform.h | 3 +++ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 80101a81bfd..9e3a17bf792 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -409,15 +409,4 @@ BoundBox Camera::viewplane_bounds_get() return bounds; } -Transform Camera::transform_from_viewplane(BoundBox2D &viewplane) -{ - return - transform_scale(1.0f / (viewplane.right - viewplane.left), - 1.0f / (viewplane.top - viewplane.bottom), - 1.0f) * - transform_translate(-viewplane.left, - -viewplane.bottom, - 0.0f); -} - CCL_NAMESPACE_END diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index e1faee3543d..31240f6813e 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -125,7 +125,6 @@ public: BoundBox viewplane_bounds_get(); float3 transform_raster_to_world(float raster_x, float raster_y); - Transform transform_from_viewplane(BoundBox2D &viewplane); }; CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp index 0a1c09ae3d5..acaca69464c 100644 --- a/intern/cycles/util/util_transform.cpp +++ b/intern/cycles/util/util_transform.cpp @@ -46,9 +46,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "util_math.h" #include "util_transform.h" +#include "util_boundbox.h" +#include "util_math.h" + CCL_NAMESPACE_BEGIN /* Transform Inverse */ @@ -271,5 +273,15 @@ void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTrans decomp->post_y = post.y; } -CCL_NAMESPACE_END +Transform transform_from_viewplane(BoundBox2D& viewplane) +{ + return + transform_scale(1.0f / (viewplane.right - viewplane.left), + 1.0f / (viewplane.top - viewplane.bottom), + 1.0f) * + transform_translate(-viewplane.left, + -viewplane.bottom, + 0.0f); +} +CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index ac97fa53084..1829ad29df3 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -449,6 +449,8 @@ ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionT #ifndef __KERNEL_GPU__ +class BoundBox2D; + ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransform& B) { return (A.pre == B.pre && A.post == B.post); @@ -456,6 +458,7 @@ ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransfor float4 transform_to_quat(const Transform& tfm); void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTransform *motion, const Transform *mid); +Transform transform_from_viewplane(BoundBox2D& viewplane); #endif