Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/GLCamera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,16 @@ function imagespace(pos, camera)
Point2f0(pos[1], pos[2]) / pos[4]
end



function translate_cam(
translate, proj, view, window_size, prj_type,
eyepos_s, lookat_s, up_s,
)
translate::T,
proj::Signal{Mat4{Float32}},
view::Signal{Mat4{Float32}},
window_size::Signal{SimpleRectangle{Int}},
prj_type::Signal{Projection},
eyepos_s::Signal{T},
lookat_s::Signal{T},
up_s::Signal{T},
) where T<:Vec3
translate == Vec3f0(0) && return nothing # nothing to do

lookat, eyepos, up, prjt = map(value, (lookat_s, eyepos_s, up_s, prj_type))
Expand Down
28 changes: 28 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using GLAbstraction, GeometryTypes, ModernGL, FileIO, GLWindow
using ColorTypes
using Base.Test
import GLAbstraction: N0f8
import Reactive: Signal



Expand Down Expand Up @@ -58,4 +59,31 @@ while isopen(window) && i < 20
end
GLFW.DestroyWindow(window)

# test for type stability in translate_cam
translate = Vec3f0([1.0, 1.0, 1.0])
proj = Signal(Mat4{Float32}(eye(Float32,4)))
view_test = Signal(Mat4{Float32}(eye(Float32,4)))
window_size = Signal(SimpleRectangle(-1, -1, 1, 1)) #from DummyCamera
prj_type = Signal(PERSPECTIVE)
eyepos_s = Signal(Vec3f0([1.0, 0.0, 0.0]))
lookat_s = Signal(Vec3f0([0.0, 1.0, 0.0]))
up_s = Signal(Vec3f0([0.0, 0.0, 1.0]))
# Record original types
type_eyepos = typeof(eyepos_s)
type_lookat = typeof(lookat_s)

GLAbstraction.translate_cam(
translate,
proj,
view_test,
window_size,
prj_type,
eyepos_s,
lookat_s,
up_s
)

@test typeof(eyepos_s)==type_eyepos
@test typeof(lookat_s)==type_lookat

end