Change default level back to 'lava_lake'; Revert 'f16' usage for shaders; Remove Cargo lock from gitignore; Remove 'wgpu' as submodule; Fix invalid veretx layout; Update docs; Rename 'BERNIE' block tag to 'COMBUSTIBLE';
This commit is contained in:
parent
8911a03089
commit
30d23c0858
21 changed files with 2569 additions and 60 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
/Cargo.lock
|
||||
/target
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "wgpu"]
|
||||
path = wgpu
|
||||
url = https://github.com/gfx-rs/wgpu
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -3,6 +3,16 @@
|
|||
This is the changelog of Bedrock.
|
||||
See `README.md` for more information.
|
||||
|
||||
## 0.5.0-3
|
||||
|
||||
* Change default level back to `lava_lake`
|
||||
* Revert `f16` usage for shaders
|
||||
* Remove Cargo lock from gitignore
|
||||
* Remove `wgpu` as submodule
|
||||
* Fix invalid veretx layout
|
||||
* Update docs
|
||||
* Rename `BERNIE` block tag to `COMBUSTIBLE`
|
||||
|
||||
## 0.5.0-2
|
||||
|
||||
* Add `is_spawnable` flag to chunks
|
||||
|
|
2483
Cargo.lock
generated
Normal file
2483
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "bedrock"
|
||||
version = "0.5.0-2"
|
||||
version = "0.5.0-3"
|
||||
authors = ["Achernar", "Gabriel Bjørnager Jensen"]
|
||||
edition = "2024"
|
||||
repository = "https://mandelbrot.dk/achernar/bedrock/"
|
||||
|
@ -10,14 +10,13 @@ ctrlc = "3.4"
|
|||
pollster = "0.4"
|
||||
rand = "0.9"
|
||||
toml = "0.8"
|
||||
wgpu = "24.0"
|
||||
winit = "0.30"
|
||||
|
||||
polywave = { version = "0.8", features = ["zerocopy"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
zerocopy = { version = "0.8", features = ["derive", "float-nightly"] }
|
||||
|
||||
wgpu = { version = "24.0", path = "wgpu/wgpu" }
|
||||
|
||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
||||
tikv-jemallocator = "0.6"
|
||||
|
||||
|
|
|
@ -97,6 +97,6 @@ impl ApplicationHandler<UserEvent> for App {
|
|||
|
||||
fn memory_warning(&mut self, _event_loop: &ActiveEventLoop) {
|
||||
log!("got low memory warning");
|
||||
log!(note, "we don't know what to do");
|
||||
log!(note, "we don't know what to do about it");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,4 @@ pub(super) enum UserEvent {
|
|||
RedrawMap,
|
||||
|
||||
Terminate,
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,14 @@ impl InitGraphicsContext {
|
|||
log!(debug, "creating device and queue");
|
||||
|
||||
let (device, queue) = {
|
||||
match block_on(adapter.request_device(&Default::default())) {
|
||||
let descriptor = wgpu::DeviceDescriptor {
|
||||
label: Some("device"),
|
||||
memory_hints: wgpu::MemoryHints::MemoryUsage,
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
match block_on(adapter.request_device(&descriptor, None)) {
|
||||
Ok((device, queue)) => (device, queue),
|
||||
|
||||
Err(e) => panic!("unable to find device: {e}"),
|
||||
|
|
|
@ -27,8 +27,8 @@ impl InitGraphicsContext {
|
|||
(x_factor, y_factor)
|
||||
};
|
||||
|
||||
let x_radius = (x_factor / 2.0 * 3.0) as f16;
|
||||
let y_radius = (y_factor / 2.0 * 3.0) as f16;
|
||||
let x_radius = (x_factor / 2.0 * 3.0) as f32;
|
||||
let y_radius = (y_factor / 2.0 * 3.0) as f32;
|
||||
|
||||
let clip_top = Vec2::new( 0.0, 3.0);
|
||||
let clip_bottom_left = Vec2::new(-3.0, -3.0);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// Copyright 2025 Gabriel Bjørnager Jensen.
|
||||
|
||||
enable f16;
|
||||
|
||||
struct VertexInput {
|
||||
@location(0x0) global: vec2<f32>,
|
||||
@location(0x1) texture: vec2<f32>,
|
||||
|
|
|
@ -5,19 +5,19 @@ use zerocopy::{FromZeros, Immutable, IntoBytes, KnownLayout};
|
|||
|
||||
#[repr(align(0x4), C)]
|
||||
#[derive(Clone, Copy, Default, FromZeros, Immutable, IntoBytes, KnownLayout, PartialEq, PartialOrd)]
|
||||
pub struct Vec2([f16; 0x2]);
|
||||
pub struct Vec2([f32; 0x2]);
|
||||
|
||||
impl Vec2 {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn new(x: f16, y: f16) -> Self {
|
||||
pub const fn new(x: f32, y: f32) -> Self {
|
||||
let buf = [x, y];
|
||||
Self(buf)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn get(self) -> (f16, f16) {
|
||||
pub const fn get(self) -> (f32, f32) {
|
||||
let [x, y] = self.0;
|
||||
(x, y)
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ impl Debug for Vec2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<(f16, f16)> for Vec2 {
|
||||
impl From<(f32, f32)> for Vec2 {
|
||||
#[inline(always)]
|
||||
fn from((x, y): (f16, f16)) -> Self {
|
||||
fn from((x, y): (f32, f32)) -> Self {
|
||||
Self::new(x, y)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ impl Vertex {
|
|||
wgpu::VertexAttribute {
|
||||
offset: offset_of!(Self, clip) as wgpu::BufferAddress,
|
||||
shader_location: 0x0,
|
||||
format: wgpu::VertexFormat::Float16x4,
|
||||
format: wgpu::VertexFormat::Float32x2,
|
||||
},
|
||||
|
||||
wgpu::VertexAttribute {
|
||||
offset: offset_of!(Self, texture) as wgpu::BufferAddress,
|
||||
shader_location: 0x1,
|
||||
format: wgpu::VertexFormat::Float16x2,
|
||||
format: wgpu::VertexFormat::Float32x2,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const _: () = assert!(Vertex::LAYOUT.attributes[0x0].offset == 0x0);
|
||||
const _: () = assert!(Vertex::LAYOUT.attributes[0x1].offset == 0x4);
|
||||
const _: () = assert!(Vertex::LAYOUT.attributes[0x1].offset == 0x8);
|
||||
|
|
|
@ -98,15 +98,15 @@ macro_rules! def_is {
|
|||
}
|
||||
|
||||
def_is! {
|
||||
is_none: NONE,
|
||||
is_static: STATIC,
|
||||
is_liquid: LIQUID,
|
||||
is_hot: HOT,
|
||||
is_cold: COLD,
|
||||
is_emtpy: EMPTY,
|
||||
is_divine: DIVINE,
|
||||
is_sticky: STICKY,
|
||||
is_bernie: BERNIE,
|
||||
is_volatile: VOLATILE,
|
||||
is_any: ALL,
|
||||
is_none: NONE,
|
||||
is_static: STATIC,
|
||||
is_liquid: LIQUID,
|
||||
is_hot: HOT,
|
||||
is_cold: COLD,
|
||||
is_emtpy: EMPTY,
|
||||
is_divine: DIVINE,
|
||||
is_sticky: STICKY,
|
||||
is_combustible: COMBUSTIBLE,
|
||||
is_volatile: VOLATILE,
|
||||
is_any: ALL,
|
||||
}
|
||||
|
|
|
@ -21,71 +21,71 @@ pub struct BlockTags(u32);
|
|||
|
||||
impl BlockTags {
|
||||
/// The block has no tags.
|
||||
pub const NONE: Self = Self(0b00000000_00000000_00000000_00000000);
|
||||
pub const NONE: Self = Self(0b00000000_00000000_00000000_00000000);
|
||||
|
||||
/// The block is not affected by gravity.
|
||||
pub const STATIC: Self = Self(0b00000000_00000000_00000000_00000001);
|
||||
pub const STATIC: Self = Self(0b00000000_00000000_00000000_00000001);
|
||||
|
||||
/// The block is a liquid.
|
||||
pub const LIQUID: Self = Self(0b00000000_00000000_00000000_00000010);
|
||||
pub const LIQUID: Self = Self(0b00000000_00000000_00000000_00000010);
|
||||
|
||||
/// The block is hot.
|
||||
///
|
||||
/// Some blocks may be affected by being in the vicinity of "hot" blocks.
|
||||
pub const HOT: Self = Self(0b00000000_00000000_00000000_00000100);
|
||||
pub const HOT: Self = Self(0b00000000_00000000_00000000_00000100);
|
||||
|
||||
/// The block is cold.
|
||||
///
|
||||
/// Some blocks may be affected by being in the vicinity of "cold" blocks.
|
||||
pub const COLD: Self = Self(0b00000000_00000000_00000000_00001000);
|
||||
pub const COLD: Self = Self(0b00000000_00000000_00000000_00001000);
|
||||
|
||||
/// The block does not affect collisions.
|
||||
pub const EMPTY: Self = Self(0b00000000_00000000_00000000_00010000);
|
||||
pub const EMPTY: Self = Self(0b00000000_00000000_00000000_00010000);
|
||||
|
||||
/// The block cannot be destroyed.
|
||||
pub const DIVINE: Self = Self(0b00000000_00000000_00000000_00100000);
|
||||
pub const DIVINE: Self = Self(0b00000000_00000000_00000000_00100000);
|
||||
|
||||
/// The block is partially affected by gravity.
|
||||
///
|
||||
/// The behaviour of sticky blocks overlap with that of statics and ordinary blocks; if a sticky block is physically connected to another block of the same material, then the two are not affected by gravity.
|
||||
pub const STICKY: Self = Self(0b00000000_00000000_00000000_01000000);
|
||||
/// The behaviour of sticky blocks overlap with that of statics and ordinary blocks; if a sticky block is physically connected to another sticky block of the same material, then the two are not affected by gravity.
|
||||
pub const STICKY: Self = Self(0b00000000_00000000_00000000_01000000);
|
||||
|
||||
/// The block is burnt by hot blocks.
|
||||
pub const BERNIE: Self = Self(0b00000000_00000000_00000000_10000000);
|
||||
pub const COMBUSTIBLE: Self = Self(0b00000000_00000000_00000000_10000000);
|
||||
|
||||
/// The block is evaporated by hot blocks.
|
||||
pub const VOLATILE: Self = Self(0b00000000_00000000_00000001_00000000);
|
||||
pub const VOLATILE: Self = Self(0b00000000_00000000_00000001_00000000);
|
||||
|
||||
/// The block contains all tags.
|
||||
pub const ALL: Self = Self(0b11111111_11111111_11111111_11111111);
|
||||
pub const ALL: Self = Self(0b11111111_11111111_11111111_11111111);
|
||||
}
|
||||
|
||||
impl BlockTags {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn union(self, other: Self) -> Self {
|
||||
let value = self.0 | other.0;
|
||||
let value = self.0 | other.0;
|
||||
Self(value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn intersection(self, other: Self) -> Self {
|
||||
let value = self.0 & other.0;
|
||||
let value = self.0 & other.0;
|
||||
Self(value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn difference(self, other: Self) -> Self {
|
||||
let value = self.0.wrapping_sub(other.0);
|
||||
let value = self.0.wrapping_sub(other.0);
|
||||
Self(value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn symmetric_difference(self, other: Self) -> Self {
|
||||
let value = self.0 ^ other.0;
|
||||
let value = self.0 ^ other.0;
|
||||
Self(value)
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ impl BlockTags {
|
|||
}
|
||||
|
||||
impl BitAnd for BlockTags {
|
||||
type Output = Self;
|
||||
type Output = Self;
|
||||
|
||||
#[inline(always)]
|
||||
fn bitand(self, rhs: Self) -> Self::Output {
|
||||
|
@ -120,7 +120,7 @@ impl BitAndAssign for BlockTags {
|
|||
}
|
||||
|
||||
impl BitOr for BlockTags {
|
||||
type Output = Self;
|
||||
type Output = Self;
|
||||
|
||||
#[inline(always)]
|
||||
fn bitor(self, rhs: Self) -> Self::Output {
|
||||
|
@ -136,7 +136,7 @@ impl BitOrAssign for BlockTags {
|
|||
}
|
||||
|
||||
impl BitXor for BlockTags {
|
||||
type Output = Self;
|
||||
type Output = Self;
|
||||
|
||||
#[inline(always)]
|
||||
fn bitxor(self, rhs: Self) -> Self::Output {
|
||||
|
@ -159,7 +159,7 @@ impl Debug for BlockTags {
|
|||
}
|
||||
|
||||
impl Not for BlockTags {
|
||||
type Output = Self;
|
||||
type Output = Self;
|
||||
|
||||
#[inline(always)]
|
||||
fn not(self) -> Self::Output {
|
||||
|
@ -168,7 +168,7 @@ impl Not for BlockTags {
|
|||
}
|
||||
|
||||
impl Sub for BlockTags {
|
||||
type Output = Self;
|
||||
type Output = Self;
|
||||
|
||||
#[inline(always)]
|
||||
fn sub(self, rhs: Self) -> Self::Output {
|
||||
|
|
|
@ -21,6 +21,6 @@ pub struct Level {
|
|||
impl Default for Level {
|
||||
#[inline(always)]
|
||||
fn default() -> Self {
|
||||
Self::LAKE
|
||||
Self::LAVA_LAKE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::level::MaterialFromStrError;
|
|||
use std::mem::transmute;
|
||||
use std::str::FromStr;
|
||||
|
||||
/// A material.
|
||||
/// A block material.
|
||||
///
|
||||
/// Each [block](crate::level::Block) has an associated material that defines some of the block's properties.
|
||||
/// This type denotes the set of possible materials.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
/// A [block material](crate::level::Material) could not be parsed from a string.
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct MaterialFromStrError {
|
||||
pub name: Box<str>,
|
||||
|
|
|
@ -4,11 +4,20 @@ use std::fmt::{self, Debug, Display, Formatter};
|
|||
use rand::Rng;
|
||||
use rand::distr::{Distribution, StandardUniform};
|
||||
|
||||
/// A block seed.
|
||||
///
|
||||
/// Each [block](crate::level::Block) has contains a seed that defines the block's variant.
|
||||
/// Along with the block's [material](crate::level::Material), this seed defines the properties of the block.
|
||||
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
#[rustc_layout_scalar_valid_range_end(0x3)]
|
||||
pub struct Seed(u8);
|
||||
|
||||
impl Seed {
|
||||
/// Creates a new block seed.
|
||||
///
|
||||
/// See [`new_unchecked`](Self::new_unchecked) for the unsafe version of this function.
|
||||
///
|
||||
/// The provided value must be in the range `0..=3`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn new(value: u8) -> Option<Self> {
|
||||
|
@ -20,6 +29,13 @@ impl Seed {
|
|||
Some(this)
|
||||
}
|
||||
|
||||
/// Unsafely creates a new block seed.
|
||||
///
|
||||
/// See [`new`](Self::new) for the safe version of this function.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The provided value must be in the range `0..=3`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const unsafe fn new_unchecked(value: u8) -> Self {
|
||||
|
@ -28,6 +44,9 @@ impl Seed {
|
|||
unsafe { Self(value) }
|
||||
}
|
||||
|
||||
/// Converts the seed into `u8`.
|
||||
///
|
||||
/// The returned value is always in the range `0..=3`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn to_u8(self) -> u8 {
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#![feature(cold_path)]
|
||||
#![feature(default_field_values)]
|
||||
#![feature(f16)]
|
||||
#![feature(generic_arg_infer)]
|
||||
#![feature(portable_simd)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
extern crate self as bedrock;
|
||||
|
|
|
@ -15,7 +15,7 @@ impl Version {
|
|||
major: 0x0,
|
||||
minor: 0x5,
|
||||
patch: 0x0,
|
||||
pre: Some(0x2),
|
||||
pre: Some(0x3),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
1
wgpu
1
wgpu
|
@ -1 +0,0 @@
|
|||
Subproject commit 52f1227374cff72ce456db8efa2c1798f0728468
|
Loading…
Add table
Reference in a new issue