-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
58e6d4f
commit 4c15426
Showing
12 changed files
with
1,353 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//use crate::prelude::*; | ||
use rstar::{PointDistance, RTree, RTreeObject, AABB}; | ||
use theframework::prelude::*; | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)] | ||
pub struct PreRenderedData { | ||
pub location: (f32, f32), | ||
pub pixel_location: (i32, i32), | ||
} | ||
|
||
impl PointDistance for PreRenderedData { | ||
// Calculate the squared distance to a point | ||
fn distance_2(&self, point: &[f32; 2]) -> f32 { | ||
let dx = self.location.0 - point[0]; | ||
let dy = self.location.1 - point[1]; | ||
dx * dx + dy * dy | ||
} | ||
|
||
// This optional method improves performance by eliminating objects quickly from consideration | ||
fn contains_point(&self, point: &[f32; 2]) -> bool { | ||
self.location.0 == point[0] && self.location.1 == point[1] | ||
} | ||
} | ||
|
||
impl RTreeObject for PreRenderedData { | ||
type Envelope = AABB<[f32; 2]>; | ||
|
||
fn envelope(&self) -> Self::Envelope { | ||
AABB::from_point([self.location.0, self.location.1]) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug)] | ||
pub struct PreRendered { | ||
pub albedo: TheRGBABuffer, | ||
pub color: FxHashMap<(i32, i32), RGBA>, | ||
pub tree: RTree<PreRenderedData>, | ||
} | ||
|
||
impl Default for PreRendered { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl PreRendered { | ||
pub fn new() -> Self { | ||
Self { | ||
albedo: TheRGBABuffer::default(), | ||
color: FxHashMap::default(), | ||
tree: RTree::new(), | ||
} | ||
} | ||
} |
Oops, something went wrong.