Skip to content

Commit 6d1e710

Browse files
xarthurxclaude
andcommitted
chore: deep clean codebase, bump version to 0.5.6
Remove dead code (HEX_ROTATION_MAP, pick_structure_at_screen_pos, set_background_color, frame_tick/request_redraw stubs). Narrow #[allow(dead_code)] to specific fields. Consolidate boilerplate with impl_transform_accessors! and impl_structure_accessors! macros. Add From<u32> impls on camera enums to simplify ui_sync.rs. Net reduction of ~350 lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4d284c1 commit 6d1e710

21 files changed

Lines changed: 251 additions & 581 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.6] - 2026-02-03
9+
10+
### Changed
11+
- **Code cleanup:** Removed dead code (unused `HEX_ROTATION_MAP`, `pick_structure_at_screen_pos`, `set_background_color`, `frame_tick`, `request_redraw`)
12+
- **Code cleanup:** Narrowed `#[allow(dead_code)]` from struct-level to field-level on `ShadowMapPass`, `CurveNetwork`, `VolumeGridCellScalarQuantity`; removed unnecessary annotation from `VolumeGrid`
13+
- **Code consolidation:** Introduced `impl_transform_accessors!` macro to deduplicate transform getter/setter boilerplate
14+
- **Code consolidation:** Introduced `impl_structure_accessors!` macro to deduplicate `get_*`/`with_*`/`with_*_ref` across 6 structure modules
15+
- **Code consolidation:** Added `From<u32>` / `From<Enum> for u32` impls on `NavigationStyle`, `ProjectionMode`, `AxisDirection` to simplify `ui_sync.rs`
16+
- Net reduction of ~350 lines of boilerplate
17+
818
## [0.5.5] - 2025-02-03
919

1020
### Added

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code when working with this repository.
44

55
## Project Overview
66

7-
polyscope-rs is a Rust-native 3D visualization library for geometric data, ported from C++ [Polyscope](https://polyscope.run). **Core paradigm**: Structures (geometric objects) + Quantities (data on structures). Version 0.5.5, ~100% feature parity with C++ Polyscope 2.x.
7+
polyscope-rs is a Rust-native 3D visualization library for geometric data, ported from C++ [Polyscope](https://polyscope.run). **Core paradigm**: Structures (geometric objects) + Quantities (data on structures). Version 0.5.6, ~100% feature parity with C++ Polyscope 2.x.
88

99
## Build Commands
1010

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
]
1010

1111
[workspace.package]
12-
version = "0.5.5"
12+
version = "0.5.6"
1313
edition = "2024"
1414
rust-version = "1.85"
1515
license = "MIT"

crates/polyscope-render/src/camera.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@ pub enum NavigationStyle {
2121
None,
2222
}
2323

24+
impl From<u32> for NavigationStyle {
25+
fn from(v: u32) -> Self {
26+
match v {
27+
0 => Self::Turntable,
28+
1 => Self::Free,
29+
2 => Self::Planar,
30+
3 => Self::Arcball,
31+
4 => Self::FirstPerson,
32+
_ => Self::None,
33+
}
34+
}
35+
}
36+
37+
impl From<NavigationStyle> for u32 {
38+
fn from(v: NavigationStyle) -> Self {
39+
match v {
40+
NavigationStyle::Turntable => 0,
41+
NavigationStyle::Free => 1,
42+
NavigationStyle::Planar => 2,
43+
NavigationStyle::Arcball => 3,
44+
NavigationStyle::FirstPerson => 4,
45+
NavigationStyle::None => 5,
46+
}
47+
}
48+
}
49+
2450
/// Camera projection mode.
2551
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2652
pub enum ProjectionMode {
@@ -31,6 +57,24 @@ pub enum ProjectionMode {
3157
Orthographic,
3258
}
3359

60+
impl From<u32> for ProjectionMode {
61+
fn from(v: u32) -> Self {
62+
match v {
63+
0 => Self::Perspective,
64+
_ => Self::Orthographic,
65+
}
66+
}
67+
}
68+
69+
impl From<ProjectionMode> for u32 {
70+
fn from(v: ProjectionMode) -> Self {
71+
match v {
72+
ProjectionMode::Perspective => 0,
73+
ProjectionMode::Orthographic => 1,
74+
}
75+
}
76+
}
77+
3478
/// Axis direction for up/front vectors.
3579
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
3680
pub enum AxisDirection {
@@ -49,6 +93,32 @@ pub enum AxisDirection {
4993
NegZ,
5094
}
5195

96+
impl From<u32> for AxisDirection {
97+
fn from(v: u32) -> Self {
98+
match v {
99+
0 => Self::PosX,
100+
1 => Self::NegX,
101+
2 => Self::PosY,
102+
3 => Self::NegY,
103+
4 => Self::PosZ,
104+
_ => Self::NegZ,
105+
}
106+
}
107+
}
108+
109+
impl From<AxisDirection> for u32 {
110+
fn from(v: AxisDirection) -> Self {
111+
match v {
112+
AxisDirection::PosX => 0,
113+
AxisDirection::NegX => 1,
114+
AxisDirection::PosY => 2,
115+
AxisDirection::NegY => 3,
116+
AxisDirection::PosZ => 4,
117+
AxisDirection::NegZ => 5,
118+
}
119+
}
120+
}
121+
52122
impl AxisDirection {
53123
/// Returns the unit vector for this direction.
54124
#[must_use]

crates/polyscope-render/src/shadow_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ impl Default for BlurUniforms {
4343
}
4444

4545
/// Shadow map render resources.
46-
#[allow(dead_code)]
4746
pub struct ShadowMapPass {
48-
/// Shadow map depth texture.
47+
/// Shadow map depth texture (kept alive for GPU resource lifetime).
48+
#[allow(dead_code)]
4949
depth_texture: wgpu::Texture,
5050
/// Shadow map depth view.
5151
depth_view: wgpu::TextureView,

crates/polyscope-structures/src/curve_network/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use wgpu::util::DeviceExt;
1515
pub use quantities::*;
1616

1717
/// A curve network structure (nodes connected by edges).
18-
#[allow(dead_code)]
1918
pub struct CurveNetwork {
2019
name: String,
2120

@@ -41,10 +40,14 @@ pub struct CurveNetwork {
4140
/// Render mode: 0 = line, 1 = tube (cylinder)
4241
render_mode: u32,
4342

44-
// Variable radius
43+
// Variable radius (reserved for future use)
44+
#[allow(dead_code)]
4545
node_radius_quantity_name: Option<String>,
46+
#[allow(dead_code)]
4647
edge_radius_quantity_name: Option<String>,
48+
#[allow(dead_code)]
4749
node_radius_autoscale: bool,
50+
#[allow(dead_code)]
4851
edge_radius_autoscale: bool,
4952

5053
// GPU resources

crates/polyscope-structures/src/volume_grid/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use polyscope_render::CurveNetworkRenderData;
1717
/// - Bounding box (min and max corners in world space)
1818
///
1919
/// Node values are at grid vertices, cell values are at grid cell centers.
20-
#[allow(dead_code)]
2120
pub struct VolumeGrid {
2221
name: String,
2322

crates/polyscope-structures/src/volume_grid/scalar_quantity.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ impl Quantity for VolumeGridNodeScalarQuantity {
606606
}
607607

608608
/// A scalar quantity defined at grid cells.
609-
#[allow(dead_code)]
610609
pub struct VolumeGridCellScalarQuantity {
611610
name: String,
612611
structure_name: String,
@@ -623,8 +622,10 @@ pub struct VolumeGridCellScalarQuantity {
623622
gridcube_render_data: Option<GridcubeRenderData>,
624623
gridcube_dirty: bool,
625624

626-
// Grid geometry
625+
// Grid geometry (reserved for future gridcube world-space mapping)
626+
#[allow(dead_code)]
627627
bound_min: Vec3,
628+
#[allow(dead_code)]
628629
bound_max: Vec3,
629630

630631
// Pick state

crates/polyscope-structures/src/volume_mesh/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,19 +1439,6 @@ pub struct VolumeMeshRenderGeometry {
14391439
pub vertex_colors: Option<Vec<Vec3>>,
14401440
}
14411441

1442-
/// Rotation map for hex vertices to place vertex 0 in canonical position.
1443-
#[allow(dead_code)]
1444-
const HEX_ROTATION_MAP: [[usize; 8]; 8] = [
1445-
[0, 1, 2, 3, 4, 5, 6, 7],
1446-
[1, 0, 4, 5, 2, 3, 7, 6],
1447-
[2, 1, 5, 6, 3, 0, 4, 7],
1448-
[3, 0, 1, 2, 7, 4, 5, 6],
1449-
[4, 0, 3, 7, 5, 1, 2, 6],
1450-
[5, 1, 0, 4, 6, 2, 3, 7],
1451-
[6, 2, 1, 5, 7, 3, 0, 4],
1452-
[7, 3, 2, 6, 4, 0, 1, 5],
1453-
];
1454-
14551442
/// Diagonal decomposition patterns (5 tets).
14561443
const HEX_TO_TET_PATTERN: [[usize; 4]; 5] = [
14571444
[0, 1, 2, 5],

crates/polyscope/src/app/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ impl App {
139139
self.screenshot_counter += 1;
140140
self.screenshot_pending = Some(filename);
141141
}
142-
143-
/// Sets the background color.
144-
#[allow(dead_code)]
145-
pub fn set_background_color(&mut self, color: Vec3) {
146-
self.background_color = color;
147-
}
148142
}
149143

150144
impl Default for App {

0 commit comments

Comments
 (0)