Ver Fonte

Draw sprite OBB when object is selected

Daniele Bartolini há 8 anos atrás
pai
commit
b60bfbe0a6
1 ficheiros alterados com 10 adições e 0 exclusões
  1. 10 0
      samples/core/editors/level_editor/level_editor.lua

+ 10 - 0
samples/core/editors/level_editor/level_editor.lua

@@ -105,6 +105,11 @@ function draw_mesh_obb(render_world, unit_id, lines)
 	DebugLine.add_obb(lines, tm, hext, Color4.red())
 	DebugLine.add_obb(lines, tm, hext, Color4.red())
 end
 end
 
 
+function draw_sprite_obb(render_world, unit_id, lines)
+	local tm, hext = RenderWorld.sprite_obb(render_world, unit_id)
+	DebugLine.add_obb(lines, tm, hext, Color4.red())
+end
+
 function raycast(objects, pos, dir)
 function raycast(objects, pos, dir)
 	local nearest = math.huge
 	local nearest = math.huge
 	local hit = nil
 	local hit = nil
@@ -335,6 +340,11 @@ function UnitBox:draw()
 		if mesh_component then
 		if mesh_component then
 			draw_mesh_obb(LevelEditor._rw, self._unit_id, LevelEditor._lines)
 			draw_mesh_obb(LevelEditor._rw, self._unit_id, LevelEditor._lines)
 		end
 		end
+
+		local sprite = RenderWorld.sprite_instances(LevelEditor._rw, self._unit_id)
+		if sprite then
+			draw_sprite_obb(LevelEditor._rw, self._unit_id, LevelEditor._lines)
+		end
 	end
 	end
 end
 end