From 31b448220869391f01aedbd32e6ee96205a2e332 Mon Sep 17 00:00:00 2001 From: Gabriel Rilling Date: Mon, 12 Oct 2020 23:50:32 +0200 Subject: [PATCH] added a project(::Scene,::T) where T<:StaticVector to mirror the to_world method --- src/camera/projection_math.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/camera/projection_math.jl b/src/camera/projection_math.jl index 73f5c172e..0d8ae3c11 100644 --- a/src/camera/projection_math.jl +++ b/src/camera/projection_math.jl @@ -307,6 +307,16 @@ function to_world( to_world(zeros(Point{N, T}), prj_view_inv, cam_res) end +function project(scene::Scene,point::T) where T<:StaticVector + cam = scene.camera + project( + cam.projection[] * + cam.view[] * + transformationmatrix(scene)[], + Vec2(scene.resolution[]), point + ) +end + function project(matrix::Mat4f0, p::T, dim4 = 1.0) where T <: VecTypes p = to_ndim(Vec4f0, to_ndim(Vec3f0, p, 0.0), dim4) p = matrix * p