Draw actor to selection values

Property definitions

gamnit :: selection $ Material :: draw_selection
	# Draw `actor` to selection values
	protected fun draw_selection(actor: Actor, model: LeafModel, id: Int)
	do
		var program = app.selection_program
		var mesh = model.mesh

		draw_selection_texture(actor, model)

		program.translation.uniform(actor.center.x, actor.center.y, actor.center.z, 0.0)
		program.scale.uniform actor.scale

		program.coord.array_enabled = true
		program.coord.array(mesh.vertices, 3)
		program.rotation.uniform new Matrix.gamnit_euler_rotation(actor.pitch, actor.yaw, actor.roll)

		var display = app.display
		assert display != null
		var r = display.red_bits
		var g = display.green_bits
		var b = display.blue_bits

		# Build ID as a color
		var p1 = id & ((2**r)-1)
		var p2 = id >> r & ((2**g)-1)
		var p3 = id >> (r+g) & ((2**b)-1)
		program.color_id.uniform(
			p1.to_f/((2**r)-1).to_f,
			p2.to_f/((2**g)-1).to_f,
			p3.to_f/((2**b)-1).to_f, 1.0)

		if mesh.indices.is_empty then
			glDrawArrays(mesh.draw_mode, 0, mesh.vertices.length/3)
		else
			glDrawElements(mesh.draw_mode, mesh.indices.length, gl_UNSIGNED_SHORT, mesh.indices_c.native_array)
		end
	end
lib/gamnit/depth/selection.nit:147,2--182,4