Daniele Bartolini 11 лет назад
Родитель
Сommit
7afd7b015d
3 измененных файлов с 12 добавлено и 2 удалено
  1. 7 0
      engine/world/camera.cpp
  2. 3 0
      engine/world/camera.h
  3. 2 2
      engine/world/world.cpp

+ 7 - 0
engine/world/camera.cpp

@@ -108,6 +108,13 @@ const Matrix4x4& Camera::projection_matrix() const
 	return _projection;
 }
 
+Matrix4x4 Camera::view_matrix() const
+{
+	Matrix4x4 view = camera->world_pose();
+	matrix4x4::invert(view);
+	return view;
+}
+
 float Camera::fov() const
 {
 	return _FOV;

+ 3 - 0
engine/world/camera.h

@@ -87,6 +87,9 @@ struct Camera
 	/// Returns the projection matrix of the camera.
 	const Matrix4x4& projection_matrix() const;
 
+	/// Returns the view matrix of the camera.
+	Matrix4x4 view_matrix() const;
+
 	/// Returns the field-of-view of the camera in degrees.
 	float fov() const;
 

+ 2 - 2
engine/world/world.cpp

@@ -166,8 +166,8 @@ void World::update(float dt)
 
 void World::render(Camera* camera)
 {
-	m_render_world.update(camera->world_pose(), camera->m_projection, camera->m_view_x, camera->m_view_y,
-							camera->m_view_width, camera->m_view_height, device()->last_delta_time());
+	m_render_world.update(camera->view_matrix(), camera->projection_matrix(), camera->_view_x, camera->_view_y,
+							camera->_view_width, camera->_view_height, device()->last_delta_time());
 
 	m_physics_world.draw_debug();
 }