-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate light ray structs as binary rather than text.
I'm planning to switch to generating the entire “propagation table” at compile time, at which point we'll have a lot more data, which I want to not have to pass through all of rustc's processing for source code. So, this commit establishes the new data encoding technique before we actually change the data.
Showing
6 changed files
with
168 additions
and
66 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
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,26 @@ | ||
use crate::raycast::Ray; | ||
|
||
#[path = "chart_schema_shared.rs"] | ||
mod chart_schema_shared; | ||
pub(crate) use chart_schema_shared::OneRay; | ||
|
||
impl OneRay { | ||
pub fn ray(&self) -> Ray { | ||
Ray::new(self.origin, self.direction) | ||
} | ||
|
||
pub fn face_cosines(&self) -> crate::math::FaceMap<f32> { | ||
let [nx, ny, nz, px, py, pz] = self.face_cosines; | ||
crate::math::FaceMap { | ||
nx, | ||
ny, | ||
nz, | ||
px, | ||
py, | ||
pz, | ||
} | ||
} | ||
} | ||
|
||
/// Used by `chart_data` type declarations to have compatible behavior when cross-compiling. | ||
type TargetEndian<T> = T; |
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,26 @@ | ||
//! The single purpose of this file is to be used by both the regular crate code | ||
//! and the build script to share some binary structure layouts. | ||
//! | ||
//! This is the most efficient way I could think of to store and transfer the | ||
//! pre-computed light ray chart data. | ||
//! | ||
//! Currently, host and target endianness must be the same. | ||
//! In the future, this may be handled by using number types wrapped to be explicitly | ||
//! target endianness. | ||
// conditionally defined to be equal to f32 except in the build script | ||
use super::TargetEndian; | ||
|
||
#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] | ||
#[repr(C)] | ||
pub(crate) struct OneRay { | ||
// This can't be a `Ray` because `FaceMap` is not `repr(C)` | ||
pub origin: [TargetEndian<f64>; 3], | ||
pub direction: [TargetEndian<f64>; 3], | ||
// This can't be a `FaceMap` because `FaceMap` is not `repr(C)` | ||
pub face_cosines: [TargetEndian<f32>; 6], | ||
} | ||
|
||
// Note: All of the methods are either only used for reading or only used for writing, | ||
// so they're defined in the respective crates to reduce complications like what they depend on, | ||
// how `TargetEndian` is defined, and dead code warnings. |
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