Просмотр исходного кода

samples/core: parameterize gizmo size

Daniele Bartolini 5 лет назад
Родитель
Сommit
50714456e4
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      samples/core/editors/level_editor/level_editor.lua

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

@@ -1,7 +1,7 @@
 require "core/editors/level_editor/camera"
 require "core/lua/class"
 
-Colors = {
+Colors = Colors or {
 	grid          = function() return Color4(102, 102, 102, 255) end,
 	grid_disabled = function() return Color4(102, 102, 102, 102) end,
 	axis_x        = function() return Color4(217,   0,   0, 255) end,
@@ -10,6 +10,10 @@ Colors = {
 	axis_selected = function() return Color4(217, 217,   0, 255) end,
 }
 
+Gizmo = Gizmo or {
+	size = 85,
+}
+
 -- From Bitsquid's grid_plane.lua
 function snap_vector(tm, vector, size)
 	if size == 0 then return vector end
@@ -757,7 +761,7 @@ function MoveTool:update(dt, x, y)
 
 	local tm = self:pose()
 	local p  = self:position()
-	local l  = LevelEditor:camera():screen_length_to_world_length(self:position(), 85)
+	local l  = LevelEditor:camera():screen_length_to_world_length(self:position(), Gizmo.size)
 
 	local function transform(tm, offset)
 		local m = Matrix4x4.copy(tm)
@@ -984,7 +988,7 @@ function RotateTool:update(dt, x, y)
 
 	local tm = self:pose()
 	local p  = self:position()
-	local l  = LevelEditor:camera():screen_length_to_world_length(self:position(), 85)
+	local l  = LevelEditor:camera():screen_length_to_world_length(self:position(), Gizmo.size)
 
 	-- Select axis
 	if self:is_idle() and selected then
@@ -1204,7 +1208,7 @@ function ScaleTool:update(dt, x, y)
 
 	self:set_pose(selected:world_pose())
 
-	local l = LevelEditor:camera():screen_length_to_world_length(self:position(), 85)
+	local l = LevelEditor:camera():screen_length_to_world_length(self:position(), Gizmo.size)
 
 	-- Select axis
 	if self:is_idle() then