Bläddra i källkod

samples: core: fix camera dx/dy

Daniele Bartolini 7 år sedan
förälder
incheckning
d7347a0720

+ 4 - 4
samples/core/editors/level_editor/camera.lua

@@ -83,8 +83,8 @@ function FPSCamera:update(dt, dx, dy, keyboard)
 	if dx ~= 0 or dy ~= 0 then
 		if not self:is_orthographic() then
 			local rotation_speed = self._rotation_speed * dt
-			local rotation_around_world_up = Quaternion(Vector3(0, 1, 0), -dx * rotation_speed)
-			local rotation_around_camera_right = Quaternion(camera_right_vector, -dy * rotation_speed)
+			local rotation_around_world_up = Quaternion(Vector3(0, 1, 0), dx * rotation_speed)
+			local rotation_around_camera_right = Quaternion(camera_right_vector, dy * rotation_speed)
 			local rotation = Quaternion.multiply(rotation_around_world_up, rotation_around_camera_right)
 
 			local old_rotation = Matrix4x4.from_quaternion(camera_rotation)
@@ -107,8 +107,8 @@ function FPSCamera:update(dt, dx, dy, keyboard)
 		if keyboard.dkey then camera_position = camera_position + camera_right_vector * translation_speed end
 	else
 		if keyboard.wkey then camera_position = camera_position + camera_view_vector * translation_speed end
-		if keyboard.skey then camera_position = camera_position + camera_view_vector * -translation_speed end
-		if keyboard.akey then camera_position = camera_position + camera_right_vector * -translation_speed end
+		if keyboard.skey then camera_position = camera_position - camera_view_vector * translation_speed end
+		if keyboard.akey then camera_position = camera_position - camera_right_vector * translation_speed end
 		if keyboard.dkey then camera_position = camera_position + camera_right_vector * translation_speed end
 	end
 	SceneGraph.set_local_position(sg, self._unit, camera_position)

+ 1 - 1
samples/core/editors/level_editor/level_editor.lua

@@ -1357,7 +1357,7 @@ function LevelEditor:update(dt)
 	end
 
 	self._fpscamera:mouse_wheel(self._mouse.wheel.delta)
-	self._fpscamera:update(dt, -delta.x, -delta.y, self._keyboard)
+	self._fpscamera:update(dt, delta.x, delta.y, self._keyboard)
 
 	self.tool:update(dt, self._mouse.x, self._mouse.y)