Skip to content

Commit

Permalink
FEAT: Make face inversion face-specific instead of brush-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
magicaldave committed Oct 23, 2024
1 parent e93ef5a commit e44b1ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
6 changes: 3 additions & 3 deletions resources/GameConfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
{
"name": "Smooth Shading",
"description": "Use phong shading. Value key above will set the shading group *not yet implemented*"
}
],
"contentflags": [
},
{
"name": "Invert Faces",
"description": "Draw the rendered mesh inside-out; intended for use with fake skyboxes."
}
],
"contentflags": [
],
"defaults": {
"scale": [0.25, 0.25]
}
Expand Down
31 changes: 9 additions & 22 deletions src/brush_ni_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl BrushNiNode {
continue;
};

let (content_flags, mut surface_flags, _value) = match &map_data
let (_content_flags, mut surface_flags, _value) = match &map_data
.geomap
.face_extensions
.get(face_id)
Expand All @@ -332,27 +332,17 @@ impl BrushNiNode {

let vertices = &map_data.face_vertices.get(&face_id).unwrap();

let mut use_inverted_tris = false;

if content_flags & surfaces::NiBroomContent::InvertFaces as u32 == 1 {
use_inverted_tris = true;
}

let mut indices = if use_inverted_tris {
let indices = if surface_flags & surfaces::NiBroomSurface::InvertFaces as u32 != 0 {
map_data.inverted_face_tri_indices.get(&face_id).unwrap_or_else(|| {
panic!("Critical error: Missing inverted face triangle indices for face_id: {:?}", face_id)
}).clone()
})
} else {
map_data
.face_tri_indices
.get(&face_id)
.unwrap_or_else(|| {
panic!(
"Critical error: Missing face triangle indices for face_id: {:?}",
face_id
)
})
.clone()
map_data.face_tri_indices.get(&face_id).unwrap_or_else(|| {
panic!(
"Critical error: Missing face triangle indices for face_id: {:?}",
face_id
)
})
};

// We can't do fuzzier matches on this, so,
Expand All @@ -367,9 +357,6 @@ panic!("Critical error: Missing inverted face triangle indices for face_id: {:?}
|| texture_name.to_ascii_lowercase().contains("lava")
|| texture_name.to_ascii_lowercase().contains("mwat")
{
let inverted_indices = map_data.inverted_face_tri_indices.get(&face_id).unwrap();
indices.extend_from_slice(inverted_indices);

surface_flags |= surfaces::NiBroomSurface::NoClip as u32;
println!("{face_id} interpreted as liquid")
}
Expand Down
5 changes: 2 additions & 3 deletions src/surfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ pub mod colors {}
pub enum NiBroomSurface {
NoClip = 1,
SmoothShading = 2,
InvertFaces = 4,
}

pub enum NiBroomContent {
InvertFaces = 1,
}
pub enum NiBroomContent {}

0 comments on commit e44b1ba

Please sign in to comment.