Skip to content

Commit

Permalink
Just fixing warnings and other minor clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbasnett committed Aug 1, 2024
1 parent 36a1d18 commit f5a8ec8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ phf = { version = "0.11", features = ["macros"] }

[dependencies.pyo3]
version = "0.21.1"
features = ["extension-module", "macros"]
features = ["extension-module", "macros"]
19 changes: 7 additions & 12 deletions src/bsp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cgmath::{dot, InnerSpace};
use cgmath::InnerSpace;

use crate::box_::FBox;
use crate::math::{point_plane_distance, points_are_near, points_are_same, FPlane, FVector, THRESH_VECTORS_ARE_NEAR};
Expand All @@ -7,8 +7,6 @@ use crate::model::{EBspNodeFlags, FBspNode, FBspSurf, FVert, UModel, BSP_NODE_MA
use crate::brush::ABrush;
use crate::sphere::FSphere;
use arrayvec::ArrayVec;
use std::borrow::Borrow;
use std::collections::LinkedList;
use std::iter::{self, successors};


Expand Down Expand Up @@ -184,14 +182,14 @@ pub fn merge_near_points(model: &mut UModel, dist: f32) -> (usize, usize) {
// Remap VertPool.
for i in 0..model.vertices.len() {
// TODO: peril abound, vertex_index is INT in original code.
if model.vertices[i].point_index >= 0 && model.vertices[i].point_index < model.points.len() {
if model.vertices[i].point_index < model.points.len() {
model.vertices[i].point_index = point_remap[model.vertices[i].point_index];
}
}

// Remap Surfs.
for i in 0..model.surfaces.len() {
if model.surfaces[i].base_point_index >= 0 && model.surfaces[i].base_point_index < model.points.len() {
if model.surfaces[i].base_point_index < model.points.len() {
model.surfaces[i].base_point_index = point_remap[model.surfaces[i].base_point_index];
}
}
Expand Down Expand Up @@ -704,8 +702,9 @@ pub fn bsp_merge_coplanars(model: &mut UModel, should_remap_links: bool, should_
continue;
}

// BDK: Somehow, this doesn't fail when other_poly.vertices is empty in the original code even though
// there is no check for that here. I reckon what happens in the original code is that the
// BDK: This doesn't fail when other_poly.vertices is empty in the original code even though
// there is no check for that here. I reckon what happens in the original code is that it ends
// up just reading junk data. Folks on OldUnreal have reported that this can result in issues.
if other_poly.vertices.is_empty() {
continue;
}
Expand Down Expand Up @@ -766,7 +765,6 @@ pub fn bsp_validate_brush(brush: &mut UModel, force_validate: bool) {
poly.link = Some(i);
}

let mut n = 0;
for i in 0..brush.polys.len() {
if brush.polys[i].link == Some(i) {
// use get_many_mut
Expand All @@ -783,7 +781,6 @@ pub fn bsp_validate_brush(brush: &mut UModel, force_validate: bool) {
let distance = point_plane_distance(&other_poly.vertices[0], &ed_poly.vertices[0], &ed_poly.normal);
if distance > -0.001 && distance < 0.001 {
other_poly.link = Some(i);
n += 1;
}
}
}
Expand Down Expand Up @@ -968,7 +965,7 @@ pub fn bsp_brush_csg(
// Build the brush's coordinate system and find orientation of scale
// transform (if negative, edpolyTransform will reverse the clockness
// of the EdPoly points and invert the normal).
let (coords, uncoords, orientation) = ABrush::build_coords();
let (coords, _uncoords, orientation) = ABrush::build_coords();

// Transform original brush poly into same coordinate system as world
// so Bsp filtering operations make sense.
Expand Down Expand Up @@ -1330,8 +1327,6 @@ pub fn bsp_build_bounds(model: &mut UModel) {
/// Opt = Bsp optimization, BSP_Lame (fast), BSP_Good (medium), BSP_Optimal (slow)
/// Balance = 0-100, 0=only worry about minimizing splits, 100=only balance tree.
pub fn bsp_build(model: &mut UModel, optimization: EBspOptimization, balance: u8, portal_bias: u8, rebuild_mode: BspRebuildMode) {
let original_polys = model.polys.len();

// Empty the model's tables.
match rebuild_mode {
BspRebuildMode::AllButPolys => {
Expand Down
16 changes: 0 additions & 16 deletions src/coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ impl FCoords {
}
}

pub fn mirror_by_plane(&self, plane_base: &FVector, plane_normal: &FVector) -> FCoords {
!todo!("Implement mirror_by_plane")
}

/// Return this coordinate system's transpose.
/// If the coordinate system is orthogonal, this is equivalent to its inverse.
pub fn transpose(&self) -> FCoords {
Expand All @@ -62,18 +58,6 @@ impl FCoords {
}
}

pub fn inverse() -> FCoords {
!todo!("Implement inverse")
}

pub fn pivot_inverse() -> FCoords {
!todo!("Implement pivot_inverse")
}

pub fn apply_pivot(other: &FCoords) -> FCoords {
!todo!("Implement apply_pivot")
}

}

/// A model coordinate system, describing both the covariant and contravariant
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ fn csg_rebuild(brushes: Vec<PyRef<Brush>>, options: BspBuildOptions, progress_ca
Ok(Model::from(&level.model))
}

// TODO: move this elsewhere.
fn bsp_rebuild(model: &mut UModel, options: BspBuildOptions) {
bsp_build_fpolys(model, true, 0);
bsp_merge_coplanars(model, false, false);
Expand Down
2 changes: 0 additions & 2 deletions tests/bsp_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::io::Write;

use bdk_py::brush::ABrush;
use bdk_py::math::FVector;
use bdk_py::bsp::{bsp_add_node, bsp_brush_csg, bsp_validate_brush, find_best_split, merge_coplanars, try_to_merge, EBspOptimization, ENodePlace, bsp_merge_coplanars, bsp_build_fpolys};
Expand Down

0 comments on commit f5a8ec8

Please sign in to comment.