-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb2297e
commit dfb56bc
Showing
9 changed files
with
115 additions
and
65 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
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,36 @@ | ||
/// Index representing which camera we're referring to. | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
pub enum CameraIndex { | ||
Viewport, | ||
Shadow(u32), | ||
} | ||
|
||
impl CameraIndex { | ||
/// Returns `true` if the camera index is [`Viewport`]. | ||
/// | ||
/// [`Viewport`]: CameraIndex::Viewport | ||
#[must_use] | ||
pub fn is_viewport(&self) -> bool { | ||
matches!(self, Self::Viewport) | ||
} | ||
|
||
/// Returns `true` if the camera index is [`Shadow`]. | ||
/// | ||
/// [`Shadow`]: CameraIndex::Shadow | ||
#[must_use] | ||
pub fn is_shadow(&self) -> bool { | ||
matches!(self, Self::Shadow(..)) | ||
} | ||
|
||
/// Returns a shader compatible index for the camera, using u32::MAX for the viewport camera. | ||
#[must_use] | ||
pub fn to_shader_index(&self) -> u32 { | ||
match *self { | ||
Self::Viewport => u32::MAX, | ||
Self::Shadow(index) => { | ||
assert_ne!(index, u32::MAX, "Shadow camera index cannot be 0xFFFF_FFFF"); | ||
index | ||
} | ||
} | ||
} | ||
} |
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,7 +1,9 @@ | ||
//! Common utilities used throughout the crate. | ||
mod camera; | ||
mod interfaces; | ||
mod samplers; | ||
|
||
pub use camera::*; | ||
pub use interfaces::*; | ||
pub use samplers::*; |
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
Oops, something went wrong.