11use super :: { CollisionGeometry , Geometry } ;
22use crate :: linear:: { Point3 , Vec3 } ;
3+ use crate :: Material ;
34use numpy:: { PyArrayLike1 , PyArrayLike2 } ;
45use pyo3:: exceptions:: PyIndexError ;
56use pyo3:: prelude:: * ;
67use raydeon:: WorldSpace ;
78use std:: sync:: Arc ;
89
910#[ pyclass( frozen, extends=Geometry , subclass) ]
10- pub ( crate ) struct AxisAlignedCuboid ( pub ( crate ) Arc < raydeon:: shapes:: AxisAlignedCuboid > ) ;
11+ pub ( crate ) struct AxisAlignedCuboid ( pub ( crate ) Arc < raydeon:: shapes:: AxisAlignedCuboid < Material > > ) ;
1112
1213impl :: std:: ops:: Deref for AxisAlignedCuboid {
13- type Target = Arc < raydeon:: shapes:: AxisAlignedCuboid > ;
14+ type Target = Arc < raydeon:: shapes:: AxisAlignedCuboid < Material > > ;
1415
1516 fn deref ( & self ) -> & Self :: Target {
1617 & self . 0
1718 }
1819}
1920
20- impl From < Arc < raydeon:: shapes:: AxisAlignedCuboid > > for AxisAlignedCuboid {
21- fn from ( value : Arc < raydeon:: shapes:: AxisAlignedCuboid > ) -> Self {
21+ impl From < Arc < raydeon:: shapes:: AxisAlignedCuboid < Material > > > for AxisAlignedCuboid {
22+ fn from ( value : Arc < raydeon:: shapes:: AxisAlignedCuboid < Material > > ) -> Self {
2223 Self ( value)
2324 }
2425}
2526
2627#[ pymethods]
2728impl AxisAlignedCuboid {
2829 #[ new]
29- #[ pyo3( signature = ( min, max, tag=0 ) ) ]
30- fn new (
31- min : & Bound < ' _ , PyAny > ,
32- max : & Bound < ' _ , PyAny > ,
33- tag : usize ,
34- ) -> PyResult < ( Self , Geometry ) > {
30+ #[ pyo3( signature = ( min, max) ) ]
31+ fn new ( min : & Bound < ' _ , PyAny > , max : & Bound < ' _ , PyAny > ) -> PyResult < ( Self , Geometry ) > {
3532 let min: Vec3 = min. try_into ( ) ?;
3633 let max: Vec3 = max. try_into ( ) ?;
3734
3835 let shape = Arc :: new ( raydeon:: shapes:: AxisAlignedCuboid :: tagged (
3936 min. cast_unit ( ) ,
4037 max. cast_unit ( ) ,
41- tag ,
38+ Material ,
4239 ) ) ;
43- let geom = Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace > > ) ;
40+ let geom =
41+ Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace , Material > > ) ;
4442
4543 Ok ( ( Self ( shape) , geom) )
4644 }
4745}
4846
4947#[ pyclass( frozen, extends=Geometry , subclass) ]
50- pub ( crate ) struct Tri ( pub ( crate ) Arc < raydeon:: shapes:: Triangle > ) ;
48+ pub ( crate ) struct Tri ( pub ( crate ) Arc < raydeon:: shapes:: Triangle < Material > > ) ;
5149
5250impl :: std:: ops:: Deref for Tri {
53- type Target = Arc < raydeon:: shapes:: Triangle > ;
51+ type Target = Arc < raydeon:: shapes:: Triangle < Material > > ;
5452
5553 fn deref ( & self ) -> & Self :: Target {
5654 & self . 0
5755 }
5856}
5957
60- impl From < Arc < raydeon:: shapes:: Triangle > > for Tri {
61- fn from ( value : Arc < raydeon:: shapes:: Triangle > ) -> Self {
58+ impl From < Arc < raydeon:: shapes:: Triangle < Material > > > for Tri {
59+ fn from ( value : Arc < raydeon:: shapes:: Triangle < Material > > ) -> Self {
6260 Self ( value)
6361 }
6462}
6563
6664#[ pymethods]
6765impl Tri {
6866 #[ new]
69- #[ pyo3( signature = ( p1, p2, p3, tag= 0 ) ) ]
67+ #[ pyo3( signature = ( p1, p2, p3) ) ]
7068 fn new (
7169 p1 : & Bound < ' _ , PyAny > ,
7270 p2 : & Bound < ' _ , PyAny > ,
7371 p3 : & Bound < ' _ , PyAny > ,
74- tag : usize ,
7572 ) -> PyResult < ( Self , Geometry ) > {
7673 let p1: Point3 = p1. try_into ( ) ?;
7774 let p2: Point3 = p2. try_into ( ) ?;
@@ -81,9 +78,10 @@ impl Tri {
8178 p1. cast_unit ( ) ,
8279 p2. cast_unit ( ) ,
8380 p3. cast_unit ( ) ,
84- tag ,
81+ Material ,
8582 ) ) ;
86- let geom = Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace > > ) ;
83+ let geom =
84+ Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace , Material > > ) ;
8785 Ok ( ( Self ( shape) , geom) )
8886 }
8987}
@@ -127,31 +125,30 @@ impl Plane {
127125}
128126
129127#[ pyclass( frozen, extends=Geometry , subclass) ]
130- pub ( crate ) struct Quad ( pub ( crate ) Arc < raydeon:: shapes:: Quad > ) ;
128+ pub ( crate ) struct Quad ( pub ( crate ) Arc < raydeon:: shapes:: Quad < Material > > ) ;
131129
132130impl :: std:: ops:: Deref for Quad {
133- type Target = Arc < raydeon:: shapes:: Quad > ;
131+ type Target = Arc < raydeon:: shapes:: Quad < Material > > ;
134132
135133 fn deref ( & self ) -> & Self :: Target {
136134 & self . 0
137135 }
138136}
139137
140- impl From < Arc < raydeon:: shapes:: Quad > > for Quad {
141- fn from ( value : Arc < raydeon:: shapes:: Quad > ) -> Self {
138+ impl From < Arc < raydeon:: shapes:: Quad < Material > > > for Quad {
139+ fn from ( value : Arc < raydeon:: shapes:: Quad < Material > > ) -> Self {
142140 Self ( value)
143141 }
144142}
145143
146144#[ pymethods]
147145impl Quad {
148146 #[ new]
149- #[ pyo3( signature = ( origin, basis, dims, tag= 0 ) ) ]
147+ #[ pyo3( signature = ( origin, basis, dims) ) ]
150148 fn new (
151149 origin : & Bound < ' _ , PyAny > ,
152150 basis : PyArrayLike2 < ' _ , f64 > ,
153151 dims : PyArrayLike1 < ' _ , f64 > ,
154- tag : usize ,
155152 ) -> PyResult < ( Self , Geometry ) > {
156153 let origin: Point3 = origin. try_into ( ) ?;
157154 let basis = basis
@@ -188,9 +185,10 @@ impl Quad {
188185 origin. 0 . cast_unit ( ) ,
189186 basis,
190187 dims,
191- tag ,
188+ Material ,
192189 ) ) ;
193- let geom = Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace > > ) ;
190+ let geom =
191+ Geometry :: native ( Arc :: clone ( & shape) as Arc < dyn raydeon:: Shape < WorldSpace , Material > > ) ;
194192 Ok ( ( Self ( shape) , geom) )
195193 }
196194}
0 commit comments