@@ -146,6 +146,7 @@ pub struct JudgeLine {
146146 pub notes : Vec < Note > ,
147147 pub color : Anim < Color > ,
148148 pub parent : Option < usize > ,
149+ pub rot_with_parent : bool ,
149150 pub z_index : i32 ,
150151 /// Whether to show notes below the line, here below is defined in the time axis, which means the note should already be judged
151152 ///
@@ -157,15 +158,14 @@ pub struct JudgeLine {
157158}
158159
159160impl JudgeLine {
160- pub fn update ( & mut self , res : & mut Resource , tr : Matrix ) {
161+ pub fn update ( & mut self , res : & mut Resource , tr : Matrix , parent_rot : f32 ) {
161162 // self.object.set_time(res.time); // this is done by chart, chart has to calculate transform for us
162- let rot = self . object . rotation . now ( ) ;
163163 self . height . set_time ( res. time ) ;
164164 let line_height = self . height . now ( ) ;
165165 let mut ctrl_obj = self . ctrl_obj . borrow_mut ( ) ;
166166 self . cache . update_order . retain ( |id| {
167167 let note = & mut self . notes [ * id as usize ] ;
168- note. update ( res, rot , & tr, & mut ctrl_obj, line_height) ;
168+ note. update ( res, parent_rot , & tr, & mut ctrl_obj, line_height) ;
169169 !note. dead ( )
170170 } ) ;
171171 drop ( ctrl_obj) ;
@@ -208,18 +208,29 @@ impl JudgeLine {
208208 } ) ;
209209 }
210210
211+ pub fn fetch_rot ( & self , lines : & [ JudgeLine ] ) -> f32 {
212+ let mut rot = self . object . rotation . now ( ) ;
213+ if self . rot_with_parent {
214+ if let Some ( parent) = self . parent {
215+ rot += lines[ parent] . fetch_rot ( lines) ;
216+ }
217+ }
218+ rot
219+ }
220+
211221 pub fn fetch_pos ( & self , res : & Resource , lines : & [ JudgeLine ] ) -> Vector {
212222 if let Some ( parent) = self . parent {
213223 let parent = & lines[ parent] ;
214- let mut parent_translation = parent. fetch_pos ( res, lines) ;
215- parent_translation += Rotation2 :: new ( parent. object . rotation . now ( ) . to_radians ( ) ) * self . object . now_translation ( res) ;
216- return parent_translation;
224+ let parent_translation = parent. fetch_pos ( res, lines) ;
225+ return parent_translation + Rotation2 :: new ( parent. fetch_rot ( lines) . to_radians ( ) ) * self . object . now_translation ( res) ;
217226 }
218227 self . object . now_translation ( res)
219228 }
220229
221230 pub fn now_transform ( & self , res : & Resource , lines : & [ JudgeLine ] ) -> Matrix {
222- self . object . now_rotation ( ) . append_translation ( & self . fetch_pos ( res, lines) )
231+ Rotation2 :: new ( self . fetch_rot ( lines) . to_radians ( ) )
232+ . to_homogeneous ( )
233+ . append_translation ( & self . fetch_pos ( res, lines) )
223234 }
224235
225236 pub fn render ( & self , ui : & mut Ui , res : & mut Resource , lines : & [ JudgeLine ] , bpm_list : & mut BpmList , settings : & ChartSettings , id : usize ) {
0 commit comments