File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,8 @@ pub struct SamplerFlags {
4242#[ derive( Debug , Clone , PartialEq ) ]
4343pub struct TextureFlags {
4444 map : TextureMap ,
45- uv_index : UvIndex ,
4645 uv_translation : UvTranslationType ,
46+ uv_index : Option < UvIndex > ,
4747}
4848
4949#[ derive( Debug , Clone , PartialEq ) ]
@@ -70,7 +70,6 @@ pub enum TextureMap {
7070
7171#[ derive( Debug , Clone , PartialEq ) ]
7272pub enum UvIndex {
73- None = 15 ,
7473 Index0 = 0 ,
7574 Index1 ,
7675 Index2 ,
@@ -80,3 +79,7 @@ pub enum UvIndex {
8079 Index6 ,
8180 Index7 ,
8281}
82+
83+ impl UvIndex {
84+ const NONE : u32 = 15 ;
85+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ pub struct PyTexture {
2525#[ derive( Debug , Default , PartialEq , Clone ) ]
2626pub struct PyTextureFlags {
2727 #[ pyo3( get, set) ]
28- uv_index : u8 ,
28+ uv_index : Option < u8 > ,
2929 #[ pyo3( get, set) ]
3030 uv_translation : u8 ,
3131 /// 0: None,
@@ -73,7 +73,7 @@ impl From<TextureFlags> for PyTextureFlags {
7373 uv_translation,
7474 } = flags;
7575 let map = map as u8 ;
76- let uv_index = uv_index as u8 ;
76+ let uv_index = uv_index. map ( |x| x as u8 ) ;
7777 let uv_translation = uv_translation as u8 ;
7878 Self {
7979 map,
@@ -96,7 +96,7 @@ impl<'p> PyObjectProtocol<'p> for PyTextureFlags {
9696 fn __repr__ ( & ' p self ) -> PyResult < String > {
9797 let format = TextureMap :: from_byte ( self . map ) . unwrap_or ( TextureMap :: None ) ;
9898 Ok ( format ! (
99- "PyTextureFlags: {:?} UV {} {}" ,
99+ "PyTextureFlags: {:?} UV {:? } {}" ,
100100 format, self . uv_index, self . uv_translation
101101 ) )
102102 }
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ impl TextureFlags {
5757 fn parse ( i : & [ u8 ] ) -> IResult < & [ u8 ] , Self > {
5858 let b = i[ 0 ] ;
5959 let uv_index = b >> 4 ;
60- let uv_index = UvIndex :: from_byte ( uv_index) . unwrap_or ( UvIndex :: None ) ;
60+ let uv_index = UvIndex :: from_byte ( uv_index) ;
6161 let map = TextureMap :: from_byte ( b & 0x0F ) . unwrap ( ) ;
6262 let b = i[ 1 ] ;
6363 let uv_translation = b;
@@ -73,7 +73,6 @@ impl TextureFlags {
7373impl UvIndex {
7474 fn from_byte ( id : u8 ) -> Option < Self > {
7575 Some ( match id {
76- 15 => Self :: None ,
7776 0 => Self :: Index0 ,
7877 1 => Self :: Index1 ,
7978 2 => Self :: Index2 ,
You can’t perform that action at this time.
0 commit comments