From 0ae6ca062f5936ae6f595f45ca0a78ed049452bc Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Sun, 9 Apr 2023 19:11:39 +0200 Subject: =?UTF-8?q?=E2=9C=A8=20Add=20scene=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wanted to be able to for example move around freely in the scene but also have something that would for example follow key frames and render a gif. Abstracted it with a scene controller. You can hook up keybinds and other thigns for it as well. Right now there is only the interactive scene controller which keep the behaviours previous to this change. Now I could possibly switch it out with something that uses key frames to render several images to create for example a gif. List of other Misc changes: - Add configuration setting for scene controller (`scene_controller`) - Add configuration setting for renderer - Add configuration setting for preview renderer (`preview_renderer`) - Add clone to Config. - Add from implementation for Renderer to be created from the config object. - Add cancel event to image action. An action could be blocking when the application wants to exit. Actions can now listen to the cancel event to exit early and not block. - Fixed bug where WaitForSignal action would block after application tries to exit. - Add method to KeyInputs to be able to take a list of callbacks instead of manually registering every callback one at the time. --- racer-tracer/src/config.rs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'racer-tracer/src/config.rs') diff --git a/racer-tracer/src/config.rs b/racer-tracer/src/config.rs index 3992176..7d28ebe 100644 --- a/racer-tracer/src/config.rs +++ b/racer-tracer/src/config.rs @@ -6,13 +6,13 @@ use structopt::StructOpt; use crate::error::TracerError; -#[derive(Default, Debug, Deserialize)] +#[derive(Default, Clone, Debug, Deserialize)] pub struct Screen { pub height: usize, pub width: usize, } -#[derive(Default, Debug, Deserialize)] +#[derive(Default, Clone, Debug, Deserialize)] pub struct RenderConfigData { pub samples: usize, pub max_depth: usize, @@ -93,6 +93,23 @@ pub enum ImageAction { SavePng, } +#[derive(StructOpt, Debug, Clone, Deserialize, Default)] +pub enum ConfigSceneController { + #[default] + Interactive, +} + +#[derive(StructOpt, Debug, Clone, Deserialize, Default)] +pub enum Renderer { + #[default] + Cpu, + CpuPreview, +} + +fn default_preview_renderer() -> Renderer { + Renderer::CpuPreview +} + impl FromStr for ImageAction { type Err = TracerError; @@ -105,7 +122,7 @@ impl FromStr for ImageAction { } } -#[derive(Default, Debug, Deserialize)] +#[derive(Default, Clone, Debug, Deserialize)] pub struct Config { #[serde(default)] pub preview: RenderConfigData, @@ -124,6 +141,15 @@ pub struct Config { #[serde(default)] pub image_output_dir: Option, + + #[serde(default)] + pub scene_controller: ConfigSceneController, + + #[serde(default)] + pub renderer: Renderer, + + #[serde(default = "default_preview_renderer")] + pub preview_renderer: Renderer, } impl Config { -- cgit v1.2.3