pub struct Raycaster2D { /* private fields */ }Expand description
DDA Raycaster Engine for 2.5D Grid Maps.
Implementations§
Source§impl Raycaster2D
impl Raycaster2D
pub fn new(width: usize, height: usize) -> Self
Sourcepub fn render_walls(
&self,
pos_x: f32,
pos_y: f32,
angle: f32,
head_bob: i32,
map: &[u8],
map_size: usize,
wall_colors: &[Rgb565],
z_buffer: &mut [f32],
framebuf_u32: &mut [u32],
)
pub fn render_walls( &self, pos_x: f32, pos_y: f32, angle: f32, head_bob: i32, map: &[u8], map_size: usize, wall_colors: &[Rgb565], z_buffer: &mut [f32], framebuf_u32: &mut [u32], )
Render 3D textured walls over an existing Mode 7 / background framebuffer.
Sourcepub fn render_walls_textured<F>(
&self,
pos_x: f32,
pos_y: f32,
angle: f32,
head_bob: i32,
map: &[u8],
map_size: usize,
z_buffer: &mut [f32],
framebuf_u32: &mut [u32],
get_pixel: F,
)
pub fn render_walls_textured<F>( &self, pos_x: f32, pos_y: f32, angle: f32, head_bob: i32, map: &[u8], map_size: usize, z_buffer: &mut [f32], framebuf_u32: &mut [u32], get_pixel: F, )
Render 3D textured walls using a per-tile pixel callback instead of a flat colour palette.
The get_pixel closure receives (tile_id, tex_x, tex_y) and returns the raw
Rgb565 texel before distance shading is applied. This lets callers supply
hand-painted bitmaps, procedural patterns (brick mortar, tech panels, hazard
stripes …) or atlas lookups without the overhead of a full texture object.
All other parameters are identical to Self::render_walls.
Sourcepub fn render_sprites_fast<P, F, T>(
&self,
pos_x: f32,
pos_y: f32,
angle: f32,
head_bob: i32,
sprites: &[RaycastSprite],
z_buffer: &[f32],
framebuf: &mut [Rgb565],
prepare_sprite: P,
get_pixel: F,
)
pub fn render_sprites_fast<P, F, T>( &self, pos_x: f32, pos_y: f32, angle: f32, head_bob: i32, sprites: &[RaycastSprite], z_buffer: &[f32], framebuf: &mut [Rgb565], prepare_sprite: P, get_pixel: F, )
Fast-path sprite rendering using a per-sprite setup callback and per-pixel color getter.
prepare_sprite(sprite, transform_y) is called ONCE PER SPRITE with the perpendicular
distance transform_y. Return None to skip rendering the sprite, or Some(data) to pass
pre-calculated properties (such as pre-shaded colors) to get_pixel.
Sourcepub fn render_sprites<F>(
&self,
pos_x: f32,
pos_y: f32,
angle: f32,
head_bob: i32,
sprites: &[RaycastSprite],
z_buffer: &[f32],
framebuf: &mut [Rgb565],
get_color: F,
)
pub fn render_sprites<F>( &self, pos_x: f32, pos_y: f32, angle: f32, head_bob: i32, sprites: &[RaycastSprite], z_buffer: &[f32], framebuf: &mut [Rgb565], get_color: F, )
Render billboarded 2.5D sprites (enemies, items, projectiles) into a per-pixel
Rgb565 framebuffer with z-buffer occlusion against previously rendered walls.
Trait Implementations§
Source§impl Clone for Raycaster2D
impl Clone for Raycaster2D
Source§fn clone(&self) -> Raycaster2D
fn clone(&self) -> Raycaster2D
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Raycaster2D
impl RefUnwindSafe for Raycaster2D
impl Send for Raycaster2D
impl Sync for Raycaster2D
impl Unpin for Raycaster2D
impl UnsafeUnpin for Raycaster2D
impl UnwindSafe for Raycaster2D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.