Matrix
produced by Camera::mvp_matrix
gamnit :: cameras_cache $ Camera
A camera with a point of view on the worldgamnit :: cameras_cache $ EulerCamera
Simple camera with perspective oriented with Euler angles (pitch, yaw, roll
)
gamnit :: cameras_cache $ UICamera
Orthogonal camera to draw UI objects with services to work with screens of different sizesgamnit :: cameras_cache $ Camera
A camera with a point of view on the worldgamnit :: cameras_cache $ EulerCamera
Simple camera with perspective oriented with Euler angles (pitch, yaw, roll
)
gamnit :: cameras_cache $ UICamera
Orthogonal camera to draw UI objects with services to work with screens of different sizesSerializable::inspect
to show more useful information
serialization :: serialization_core
Abstract services to serialize Nit objects to different formatscore :: union_find
union–find algorithm using an efficient disjoint-set data structureEulerCamera
and App::frame_core_draw
to get a stereoscopic view
# Cache the `Matrix` produced by `Camera::mvp_matrix`
module cameras_cache
import cameras
redef class Camera
private var mvp_matrix_cache: nullable Matrix = null
private var position_cache = new Point3d[Float](0.0, 0.0, 0.0)
# Has `position` changed from `position_cache`? Update the cache at the same time
private fun check_position_changed: Bool
do
if position.x != position_cache.x or
position.y != position_cache.y or
position.z != position_cache.z then
position_cache.x = position.x
position_cache.y = position.y
position_cache.z = position.z
return true
end
return false
end
end
redef class EulerCamera
# The returned matrix must not be modified as it is cached.
redef fun mvp_matrix
do
var m = mvp_matrix_cache
if m == null or check_position_changed then
m = super
mvp_matrix_cache = m
end
return m
end
redef fun pitch=(value)
do
super
mvp_matrix_cache = null
end
redef fun yaw=(value)
do
super
mvp_matrix_cache = null
end
redef fun roll=(value)
do
super
mvp_matrix_cache = null
end
redef fun field_of_view_y=(value)
do
super
mvp_matrix_cache = null
end
redef fun near=(value)
do
super
mvp_matrix_cache = null
end
redef fun far=(value)
do
super
mvp_matrix_cache = null
end
end
redef class UICamera
# The returned matrix must not be modified as it is cached.
redef fun mvp_matrix
do
var m = mvp_matrix_cache
if m == null or check_position_changed then
m = super
mvp_matrix_cache = m
end
return m
end
redef fun near=(value)
do
super
mvp_matrix_cache = null
end
redef fun far=(value)
do
super
mvp_matrix_cache = null
end
redef fun height=(value)
do
super
mvp_matrix_cache = null
end
end
lib/gamnit/cameras_cache.nit:15,1--118,3