-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch engine to use physical lighting
- Loading branch information
Showing
11 changed files
with
179 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod building; | ||
mod camera; | ||
mod canon_upgrade; | ||
mod debugger_3_d; | ||
mod water_jet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use godot::{builtin::Dictionary, classes::Camera3D, engine::Node3D, obj::Gd}; | ||
use godot_rust_script::{godot_script_impl, CastToScript, GodotScript, RsRef}; | ||
use itertools::Itertools; | ||
|
||
use crate::{ | ||
debug, info, | ||
scripts::world::solar_setup::{ISolarSetup, SolarSetup}, | ||
warn, | ||
}; | ||
|
||
#[derive(GodotScript, Debug)] | ||
#[script(base = Camera3D)] | ||
struct Camera { | ||
#[export] | ||
pub exposure_times: Dictionary, | ||
|
||
#[export] | ||
pub solar_setup_node: Option<Gd<Node3D>>, | ||
|
||
solar_setup: Option<RsRef<SolarSetup>>, | ||
|
||
base: Gd<Camera3D>, | ||
} | ||
|
||
#[godot_script_impl] | ||
impl Camera { | ||
pub fn _ready(&mut self) { | ||
self.solar_setup = self.solar_setup_node.clone().map(|node| node.into_script()); | ||
} | ||
|
||
pub fn _process(&mut self, _delta: f64) { | ||
let Some(solar_setup) = self.solar_setup.as_mut() else { | ||
warn!("Solar setup is not available!"); | ||
return; | ||
}; | ||
|
||
let Some(mut attributes) = self.base.get_attributes() else { | ||
warn!("Camera has no attributes!"); | ||
return; | ||
}; | ||
|
||
let game_time = solar_setup.get_ingame_time_h(); | ||
|
||
let exposure = self | ||
.exposure_times | ||
.iter_shared() | ||
.sorted_by(|(key_a, _), (key_b, _)| key_a.to::<f64>().total_cmp(&key_b.to::<f64>())) | ||
.rev() | ||
.find(|(key, _)| key.to::<f64>() <= game_time) | ||
.map(|(_, value)| value.to::<f32>()) | ||
.unwrap_or(0.0); | ||
|
||
if attributes.get_exposure_sensitivity() == exposure { | ||
return; | ||
} | ||
|
||
info!("Updating camera exposure to {} at {}", exposure, game_time); | ||
|
||
attributes.set_exposure_sensitivity(exposure); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
mod buildings; | ||
mod solar_setup; | ||
pub mod solar_setup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters