Skip to content

Commit

Permalink
fix NaN
Browse files Browse the repository at this point in the history
sqrt(-x)
  • Loading branch information
Uriopass committed Dec 17, 2023
1 parent 1de17d6 commit df8b813
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/shaders/terrain/unpack.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn unpack_height(h: u32) -> f32 {
fn unpack_normal(v: u32) -> vec3<f32> {
let x = f32(v >> 8u) / 128.0 - 1.0;
let y = f32(v & 0xFFu) / 128.0 - 1.0;
let z = sqrt(1.0 - x * x - y * y);
let z = sqrt(max(0.0, 1.0 - x * x - y * y));

return vec3<f32>(x, y, z);
}
2 changes: 1 addition & 1 deletion native_app/src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl Default for InspectedEntity {

#[derive(Copy, Clone, Default, Serialize, Deserialize, Eq, PartialEq)]
pub enum Tool {
#[default]
Hand,
RoadbuildStraight,
RoadbuildCurved,
Expand All @@ -115,7 +116,6 @@ pub enum Tool {
LotBrush,
SpecialBuilding,
Train,
#[default]
Terraforming,
}

Expand Down
2 changes: 1 addition & 1 deletion native_app/src/gui/terraforming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn terraforming(sim: &Simulation, uiworld: &mut UiWorld) {
impl Default for TerraformingResource {
fn default() -> Self {
Self {
kind: TerraformKind::Erode,
kind: TerraformKind::Elevation,
radius: 200.0,
amount: 200.0,
level: None,
Expand Down

0 comments on commit df8b813

Please sign in to comment.