From b2ccbf51e41b5e9fd6d5b9b6d1ebf82ee465b3e4 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Mon, 17 Feb 2020 19:02:11 -0700 Subject: [PATCH 1/4] Use as_deref() instead of as_ref().map(Deref::deref) --- src/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.rs b/src/init.rs index 1934c21..123cb60 100644 --- a/src/init.rs +++ b/src/init.rs @@ -45,7 +45,7 @@ pub fn init() -> Result> { /// [`examples/simple`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/simple.rs #[allow(clippy::needless_pass_by_value)] pub fn init_with_options(options: InitOptions) -> Result> { - let rlbot_dll_directory = options.rlbot_dll_directory.as_ref().map(PathBuf::as_path); + let rlbot_dll_directory = options.rlbot_dll_directory.as_deref(); let dll = RLBotCoreInterface::load(rlbot_dll_directory)?; wait_for_initialized(&dll)?; From b00c9fa47f3bb77b8cdfe6335b271441d7b07a83 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 4 Mar 2020 22:04:59 -0700 Subject: [PATCH 2/4] Fix rendering 3D strings --- src/render.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render.rs b/src/render.rs index 9fb2872..90ce3fc 100644 --- a/src/render.rs +++ b/src/render.rs @@ -247,7 +247,7 @@ impl<'a> RenderGroup<'a> { let text = self.builder.create_string(text.as_ref()); let mut rm = flat::RenderMessageBuilder::new(&mut self.builder); - rm.add_renderType(flat::RenderType::DrawString2D); + rm.add_renderType(flat::RenderType::DrawString3D); rm.add_color(color); rm.add_start(&start); rm.add_scaleX(scale_x); From 02137ba152296d97a35116068418290aaea099be Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 4 Mar 2020 22:07:12 -0700 Subject: [PATCH 3/4] Fix rendering example --- examples/rendering.rs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/rendering.rs b/examples/rendering.rs index 299446d..ac0fe7e 100644 --- a/examples/rendering.rs +++ b/examples/rendering.rs @@ -6,6 +6,8 @@ use std::{error::Error, f32::consts::PI}; +const RADIUS: f32 = 250.0; + fn main() -> Result<(), Box> { let rlbot = rlbot::init()?; @@ -25,35 +27,45 @@ fn main() -> Result<(), Box> { total_ms -= sec * 1000; let min = total_ms / 1000 / 60; - let center_x = 100.0; - let center_y = 150.0; + let center_x = 0.0; + let center_y = -5120.0; + let center_z = 1540.0; let clock_hand = |fraction: f32, radius: f32| { let t = fraction * 2.0 * PI - PI / 2.0; - (center_x + t.cos() * radius, center_y + t.sin() * radius) + ( + center_x + t.cos() * radius, + center_y, + center_z - t.sin() * radius, + ) }; let mut group = rlbot.begin_render_group(0); let green = group.color_rgb(0, 255, 0); - group.draw_string_2d( - (40.0, 20.0), + let text = format!("{}:{:02}.{:03}", min, sec, ms); + group.draw_string_3d( + ( + center_x - 120.0 * text.len() as f32 / 2.0, + center_y, + center_z - RADIUS - 100.0, + ), (2, 2), - format!("{}:{:02}.{:03}", min, sec, ms), + text, green, ); - group.draw_line_2d( - (center_x, center_y), - clock_hand(min as f32 / 60.0, 60.0), + group.draw_line_3d( + (center_x, center_y, center_z), + clock_hand(min as f32 / 60.0, RADIUS * 0.75), green, ); - group.draw_line_2d( - (center_x, center_y), - clock_hand(sec as f32 / 60.0, 80.0), + group.draw_line_3d( + (center_x, center_y, center_z), + clock_hand(sec as f32 / 60.0, RADIUS), green, ); - group.draw_line_2d( - (center_x, center_y), - clock_hand(ms as f32 / 1000.0, 40.0), + group.draw_line_3d( + (center_x, center_y, center_z), + clock_hand(ms as f32 / 1000.0, RADIUS / 2.0), green, ); group.render()?; From 20865c43bdde6129718e95f8a334fd06c767610d Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 4 Mar 2020 22:09:19 -0700 Subject: [PATCH 4/4] Depreciate non-working rendering functions --- src/render.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/render.rs b/src/render.rs index 90ce3fc..f34a26a 100644 --- a/src/render.rs +++ b/src/render.rs @@ -123,6 +123,7 @@ impl<'a> RenderGroup<'a> { /// # let green = group.color_rgb(0, 255, 0); /// group.draw_line_2d((10.0, 10.0), (100.0, 100.0), green); /// ``` + #[deprecated(note = "Drawing 2D lines is not currently supported")] pub fn draw_line_2d( &mut self, (x1, y1): (f32, f32), @@ -178,6 +179,7 @@ impl<'a> RenderGroup<'a> { /// # let green = group.color_rgb(0, 255, 0); /// group.draw_line_2d_3d((10.0, 10.0), (100.0, 100.0, 100.0), green); /// ``` + #[deprecated(note = "Drawing 2D-3D lines is not currently supported")] pub fn draw_line_2d_3d( &mut self, (x1, y1): (f32, f32),