Skip to content

Commit 11f71fc

Browse files
committed
switch from OnceCell to OnceLock so that parallel builds continue to work
1 parent 4d42d35 commit 11f71fc

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/csg.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::float_types::parry3d::{
1919
};
2020
use crate::float_types::rapier3d::prelude::*;
2121
use std::fmt::Debug;
22-
use std::cell::OnceCell;
22+
use std::sync::OnceLock;
2323

2424
#[cfg(feature = "parallel")]
2525
use rayon::prelude::*;
@@ -37,7 +37,7 @@ pub struct CSG<S: Clone> {
3737
pub geometry: GeometryCollection<Real>,
3838

3939
/// Lazily calculated AABB that spans `polygons` **and** any 2‑D geometry.
40-
pub bounding_box: OnceCell<Aabb>,
40+
pub bounding_box: OnceLock<Aabb>,
4141

4242
/// Metadata
4343
pub metadata: Option<S>,
@@ -49,7 +49,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
4949
CSG {
5050
polygons: Vec::new(),
5151
geometry: GeometryCollection::default(),
52-
bounding_box: OnceCell::new(),
52+
bounding_box: OnceLock::new(),
5353
metadata: None,
5454
}
5555
}
@@ -313,7 +313,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
313313
CSG {
314314
polygons: final_polys,
315315
geometry: final_gc,
316-
bounding_box: OnceCell::new(),
316+
bounding_box: OnceLock::new(),
317317
metadata: self.metadata.clone(),
318318
}
319319
}
@@ -378,7 +378,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
378378
CSG {
379379
polygons: a.all_polygons(),
380380
geometry: final_gc,
381-
bounding_box: OnceCell::new(),
381+
bounding_box: OnceLock::new(),
382382
metadata: self.metadata.clone(),
383383
}
384384
}
@@ -443,7 +443,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
443443
CSG {
444444
polygons: a.all_polygons(),
445445
geometry: final_gc,
446-
bounding_box: OnceCell::new(),
446+
bounding_box: OnceLock::new(),
447447
metadata: self.metadata.clone(),
448448
}
449449
}
@@ -575,7 +575,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
575575
csg.geometry = csg.geometry.affine_transform(&affine2);
576576

577577
// invalidate the old cached bounding box
578-
csg.bounding_box = OnceCell::new();
578+
csg.bounding_box = OnceLock::new();
579579

580580
csg
581581
}
@@ -730,7 +730,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
730730
CSG {
731731
polygons: all_csg.polygons,
732732
geometry: all_csg.geometry,
733-
bounding_box: OnceCell::new(),
733+
bounding_box: OnceLock::new(),
734734
metadata: self.metadata.clone(),
735735
}
736736
}
@@ -765,7 +765,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
765765
CSG {
766766
polygons: all_csg.polygons,
767767
geometry: all_csg.geometry,
768-
bounding_box: OnceCell::new(),
768+
bounding_box: OnceLock::new(),
769769
metadata: self.metadata.clone(),
770770
}
771771
}
@@ -796,7 +796,7 @@ impl<S: Clone + Debug + Send + Sync> CSG<S> {
796796
CSG {
797797
polygons: all_csg.polygons,
798798
geometry: all_csg.geometry,
799-
bounding_box: OnceCell::new(),
799+
bounding_box: OnceLock::new(),
800800
metadata: self.metadata.clone(),
801801
}
802802
}

src/extrudes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::vertex::Vertex;
55
use geo::{Area, CoordsIter, GeometryCollection, LineString, Polygon as GeoPolygon};
66
use nalgebra::{Point3, Vector3};
77
use std::fmt::Debug;
8-
use std::cell::OnceCell;
8+
use std::sync::OnceLock;
99

1010
impl<S: Clone + Debug> CSG<S>
1111
where S: Clone + Send + Sync {
@@ -183,7 +183,7 @@ where S: Clone + Send + Sync {
183183
CSG {
184184
polygons: final_polygons,
185185
geometry: self.geometry.clone(),
186-
bounding_box: OnceCell::new(),
186+
bounding_box: OnceLock::new(),
187187
metadata: self.metadata.clone(),
188188
}
189189
}
@@ -692,7 +692,7 @@ where S: Clone + Send + Sync {
692692
CSG {
693693
polygons: new_polygons,
694694
geometry: GeometryCollection::default(),
695-
bounding_box: OnceCell::new(),
695+
bounding_box: OnceLock::new(),
696696
metadata: self.metadata.clone(),
697697
}
698698
}

src/flatten_slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use geo::{
1010
use hashbrown::HashMap;
1111
use nalgebra::Point3;
1212
use std::fmt::Debug;
13-
use std::cell::OnceCell;
13+
use std::sync::OnceLock;
1414
use small_str::{ format_smallstr, SmallStr };
1515

1616
impl<S: Clone + Debug> CSG<S>
@@ -76,7 +76,7 @@ where S: Clone + Send + Sync {
7676
CSG {
7777
polygons: Vec::new(),
7878
geometry: new_gc,
79-
bounding_box: OnceCell::new(),
79+
bounding_box: OnceLock::new(),
8080
metadata: self.metadata.clone(),
8181
}
8282
}
@@ -158,7 +158,7 @@ where S: Clone + Send + Sync {
158158
CSG {
159159
polygons: Vec::new(),
160160
geometry: new_gc,
161-
bounding_box: OnceCell::new(),
161+
bounding_box: OnceLock::new(),
162162
metadata: self.metadata.clone(),
163163
}
164164
}

src/offset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::float_types::Real;
33
use geo::{Geometry, GeometryCollection};
44
use geo_buf::{buffer_multi_polygon, buffer_polygon};
55
use std::fmt::Debug;
6-
use std::cell::OnceCell;
6+
use std::sync::OnceLock;
77

88
impl<S: Clone + Debug> CSG<S>
99
where S: Clone + Send + Sync {
@@ -35,7 +35,7 @@ where S: Clone + Send + Sync {
3535
CSG {
3636
polygons: self.polygons.clone(),
3737
geometry: new_collection,
38-
bounding_box: OnceCell::new(),
38+
bounding_box: OnceLock::new(),
3939
metadata: self.metadata.clone(),
4040
}
4141
}

src/polygon.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::vertex::Vertex;
44
use geo::{LineString, Polygon as GeoPolygon, coord};
55
use nalgebra::{Point2, Point3, Vector3};
66
use crate::float_types::parry3d::bounding_volume::Aabb;
7-
use std::cell::OnceCell;
7+
use std::sync::OnceLock;
88

99
/// A polygon, defined by a list of vertices.
1010
/// - `S` is the generic metadata type, stored as `Option<S>`.
@@ -17,7 +17,7 @@ pub struct Polygon<S: Clone> {
1717
pub plane: Plane,
1818

1919
/// Lazily‑computed axis‑aligned bounding box of the Polygon
20-
pub bounding_box: OnceCell<Aabb>,
20+
pub bounding_box: OnceLock<Aabb>,
2121

2222
/// Generic metadata associated with the Polygon
2323
pub metadata: Option<S>,
@@ -34,7 +34,7 @@ where S: Clone + Send + Sync {
3434
Polygon {
3535
vertices,
3636
plane,
37-
bounding_box: OnceCell::new(),
37+
bounding_box: OnceLock::new(),
3838
metadata,
3939
}
4040
}

src/shapes2d.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::csg::CSG;
22
use crate::float_types::{Real, PI, EPSILON, FRAC_PI_2, TAU};
33
use geo::{line_string, GeometryCollection, Geometry, LineString, MultiPolygon, Polygon as GeoPolygon, BooleanOps, Orient, orient::Direction};
44
use std::fmt::Debug;
5-
use std::cell::OnceCell;
5+
use std::sync::OnceLock;
66

77
impl<S: Clone + Debug> CSG<S>
88
where S: Clone + Send + Sync {
@@ -449,7 +449,7 @@ where S: Clone + Send + Sync {
449449
CSG {
450450
geometry: shape.geometry,
451451
polygons: shape.polygons,
452-
bounding_box: OnceCell::new(),
452+
bounding_box: OnceLock::new(),
453453
metadata,
454454
}
455455
}

0 commit comments

Comments
 (0)