···2525}
26262727impl DistributionType {
2828- #[deprecated(
2929- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
3030- )]
2828+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
3129 #[allow(deprecated)]
3230 fn compute_offset(
3331 &self,
···107105 }
108106109107 #[test]
108108+ fn step() {
109109+ for i in 0..12 {
110110+ assert_eq!(
111111+ DistributionType::Step.compute_offset(i, 12, &Filter::default(), 1.0, None, None),
112112+ i as f32
113113+ );
114114+ }
115115+ }
116116+117117+ #[test]
110118 fn wave_negative() {
111119 for i in 0..12 {
112120 assert_eq!(
···117125 }
118126119127 #[test]
120120- fn step() {
128128+ fn step_negative() {
121129 for i in 0..12 {
122130 assert_eq!(
123123- DistributionType::Step.compute_offset(i, 12, &Filter::default(), 1.0, None, None),
124124- i as f32
131131+ DistributionType::Step.compute_offset(i, 12, &Filter::default(), -1.0, None, None),
132132+ -i as f32
125133 );
126134 }
127135 }
···270278 None
271279 ),
272280 12.0 - i as f32
281281+ );
282282+ }
283283+ }
284284+285285+ #[test]
286286+ fn wave_with_chunks_of_size_two() {
287287+ for i in 0..6 {
288288+ let filter = Filter {
289289+ chunks: Some(6),
290290+ ..Default::default()
291291+ };
292292+ assert_eq!(
293293+ DistributionType::Wave.compute_offset(i * 2, 12, &filter, 6.0, None, None),
294294+ i as f32
295295+ );
296296+ assert_eq!(
297297+ DistributionType::Wave.compute_offset(i * 2 + 1, 12, &filter, 6.0, None, None),
298298+ i as f32
299299+ );
300300+ }
301301+ }
302302+303303+ #[test]
304304+ fn step_with_chunks_of_size_two() {
305305+ for i in 0..6 {
306306+ let filter = Filter {
307307+ chunks: Some(6),
308308+ ..Default::default()
309309+ };
310310+ assert_eq!(
311311+ DistributionType::Step.compute_offset(i * 2, 12, &filter, 1.0, None, None),
312312+ i as f32
313313+ );
314314+ assert_eq!(
315315+ DistributionType::Step.compute_offset(i * 2 + 1, 12, &filter, 1.0, None, None),
316316+ i as f32
317317+ );
318318+ }
319319+ }
320320+321321+ #[test]
322322+ fn wave_with_chunks_of_size_six() {
323323+ for i in 0..6 {
324324+ let filter = Filter {
325325+ chunks: Some(2),
326326+ ..Default::default()
327327+ };
328328+ assert_eq!(
329329+ DistributionType::Wave.compute_offset(i, 12, &filter, 2.0, None, None),
330330+ 0.0
331331+ );
332332+ assert_eq!(
333333+ DistributionType::Wave.compute_offset(i + 6, 12, &filter, 2.0, None, None),
334334+ 1.0
335335+ );
336336+ }
337337+ }
338338+339339+ #[test]
340340+ fn step_with_chunks_of_size_six() {
341341+ for i in 0..6 {
342342+ let filter = Filter {
343343+ chunks: Some(2),
344344+ ..Default::default()
345345+ };
346346+ assert_eq!(
347347+ DistributionType::Step.compute_offset(i, 12, &filter, 1.0, None, None),
348348+ 0.0
349349+ );
350350+ assert_eq!(
351351+ DistributionType::Step.compute_offset(i + 6, 12, &filter, 1.0, None, None),
352352+ 1.0
353353+ );
354354+ }
355355+ }
356356+357357+ #[test]
358358+ fn wave_with_chunks_out_of_bounds() {
359359+ for i in 0..12 {
360360+ let filter = Filter {
361361+ chunks: Some(24),
362362+ ..Default::default()
363363+ };
364364+ assert_eq!(
365365+ DistributionType::Wave.compute_offset(i, 12, &filter, 12.0, None, None),
366366+ i as f32
367367+ );
368368+ }
369369+ }
370370+371371+ #[test]
372372+ fn step_with_chunks_out_of_bounds() {
373373+ for i in 0..12 {
374374+ let filter = Filter {
375375+ chunks: Some(24),
376376+ ..Default::default()
377377+ };
378378+ assert_eq!(
379379+ DistributionType::Step.compute_offset(i, 12, &filter, 1.0, None, None),
380380+ i as f32
273381 );
274382 }
275383 }
+87-15
src/difficulty/lightshow/filter.rs
···6161 parameter1: 1,
6262 parameter2: 0,
6363 reverse: LooseBool::False,
6464- chunks: Some(1),
6464+ chunks: Some(0),
6565 random_behaviour: Some(RandomBehaviour::None),
6666 random_seed: Some(0),
6767 limit_behaviour: Some(LimitBehaviour::None),
···7878 /// Will panic if the light ID is greater than or equal to the group size.
7979 #[must_use]
8080 #[inline]
8181- #[deprecated(
8282- note = "Experimental. Does not consider chunks, random, or limit in calculations."
8383- )]
8484- pub fn is_in_filter(&self, mut light_id: i32, group_size: i32) -> bool {
8181+ #[deprecated(note = "Experimental. Does not consider random or limit in calculations.")]
8282+ pub fn is_in_filter(&self, mut light_id: i32, mut group_size: i32) -> bool {
8583 assert!(light_id < group_size);
86848785 if self.reverse.is_true() {
8886 light_id = group_size - light_id - 1;
8987 }
90888989+ if let Some(chunks) = self.chunks
9090+ && chunks > 0
9191+ && chunks < group_size
9292+ {
9393+ light_id = (light_id as f32 / (group_size as f32 / chunks as f32)) as i32;
9494+ group_size = chunks;
9595+ }
9696+9197 match self.filter_type {
9298 FilterType::Division => {
9399 let start = self.parameter2 * group_size / self.parameter1.max(1);
···102108 }
103109 }
104110105105- /// Returns the number of lights effected by the filter.
111111+ /// Returns the number of light chunks effected by the filter.
106112 /// # Unknown
107113 /// If the [`FilterType`] is `Unknown` then the result will be the same as `group_size`.
108114 #[must_use]
109115 #[inline]
110110- #[deprecated(
111111- note = "Experimental. Does not consider chunks, random, or limit in calculations."
112112- )]
113113- pub fn count_filtered(&self, group_size: i32) -> i32 {
116116+ #[deprecated(note = "Experimental. Does not consider random or limit in calculations.")]
117117+ pub fn count_filtered(&self, mut group_size: i32) -> i32 {
118118+ if let Some(chunks) = self.chunks
119119+ && chunks > 0
120120+ && chunks < group_size
121121+ {
122122+ group_size = chunks;
123123+ }
124124+114125 match self.filter_type {
115126 FilterType::Division => {
116127 let start = self.parameter2 * group_size / self.parameter1.max(1);
···124135 }
125136 }
126137127127- /// Returns the light ID relative to the filtered count.
138138+ #[allow(deprecated)]
139139+ /// Returns the light chunk ID relative to the [filtered count](Self::count_filtered).
128140 /// # Unknown
129141 /// If the [`FilterType`] is `Unknown` then the result will be the same as `light_id`.
130142 /// # Panics
131143 /// Will panic if the light ID is greater than or equal to the group size.
132144 #[must_use]
133145 #[inline]
134134- #[deprecated(
135135- note = "Experimental. Does not consider chunks, random, or limit in calculations."
136136- )]
137137- pub fn get_relative_index(&self, mut light_id: i32, group_size: i32) -> i32 {
146146+ #[deprecated(note = "Experimental. Does not consider random or limit in calculations.")]
147147+ pub fn get_relative_index(&self, mut light_id: i32, mut group_size: i32) -> i32 {
138148 assert!(light_id < group_size);
139149140150 if self.reverse.is_true() {
141151 light_id = group_size - light_id;
152152+ }
153153+154154+ if let Some(chunks) = self.chunks
155155+ && chunks > 0
156156+ && chunks < group_size
157157+ {
158158+ light_id = (light_id as f32 / (group_size as f32 / chunks as f32)) as i32;
159159+ group_size = chunks;
142160 }
143161144162 match self.filter_type {
···378396 }
379397 }
380398 assert_eq!(filter.count_filtered(12), 6);
399399+ }
400400+401401+ #[test]
402402+ fn chunks_of_two() {
403403+ let filter = Filter {
404404+ chunks: Some(6),
405405+ ..Default::default()
406406+ };
407407+408408+ assert!((0..12).all(|i| filter.is_in_filter(i, 12)));
409409+ assert_eq!(filter.count_filtered(12), 6);
410410+ assert!((0..6).all(|i| {
411411+ filter.get_relative_index(i * 2, 12) == i
412412+ && filter.get_relative_index(i * 2 + 1, 12) == i
413413+ }));
414414+ }
415415+416416+ #[test]
417417+ fn chunks_of_six() {
418418+ let filter = Filter {
419419+ chunks: Some(2),
420420+ ..Default::default()
421421+ };
422422+423423+ assert!((0..12).all(|i| filter.is_in_filter(i, 12)));
424424+ assert_eq!(filter.count_filtered(12), 2);
425425+ assert!((0..6).all(|i| filter.get_relative_index(i, 12) == 0));
426426+ assert!((0..6).all(|i| filter.get_relative_index(i + 6, 12) == 1));
427427+ }
428428+429429+ #[test]
430430+ fn chunks_out_of_bounds() {
431431+ let filter = Filter {
432432+ chunks: Some(24),
433433+ ..Default::default()
434434+ };
435435+436436+ assert!((0..12).all(|i| filter.is_in_filter(i, 12)));
437437+ assert_eq!(filter.count_filtered(12), 12);
438438+ assert!((0..12).all(|i| filter.get_relative_index(i, 12) == i));
439439+ }
440440+441441+ #[test]
442442+ fn chunks_non_factor() {
443443+ let filter = Filter {
444444+ chunks: Some(3),
445445+ ..Default::default()
446446+ };
447447+448448+ assert!((0..8).all(|i| filter.is_in_filter(i, 8)));
449449+ assert_eq!(filter.count_filtered(8), 3);
450450+ assert!((0..3).all(|i| filter.get_relative_index(i, 8) == 0));
451451+ assert!((3..6).all(|i| filter.get_relative_index(i, 8) == 1));
452452+ assert!((6..8).all(|i| filter.get_relative_index(i, 8) == 2));
381453 }
382454}
+2-6
src/difficulty/lightshow/group.rs
···4444 /// Returns the number of beats that the event will be offset for a given light ID.
4545 /// # Panics
4646 /// Will panic if the light ID is greater than or equal to the group size.
4747- #[deprecated(
4848- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
4949- )]
4747+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
5048 fn get_beat_offset(&self, light_id: i32, group_size: i32) -> f32;
51495250 /// Returns the value (i.e. brightness) that the event will be offset for a given light ID.
5351 /// # Panics
5452 /// Will panic if the light ID is greater than or equal to the group size.
5555- #[deprecated(
5656- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
5757- )]
5353+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
5854 fn get_value_offset(&self, light_id: i32, group_size: i32) -> f32;
5955}
6056
+1-3
src/difficulty/lightshow/group/color.rs
···9393 /// Returns the brightness that the event will be offset for a given light ID.
9494 /// # Panics
9595 /// Will panic if the light ID is greater than or equal to the group size.
9696- #[deprecated(
9797- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
9898- )]
9696+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
9997 #[allow(deprecated)]
10098 pub fn get_brightness_offset(&self, light_id: i32, group_size: i32) -> f32 {
10199 self.bright_dist_type.compute_offset(
+1-3
src/difficulty/lightshow/group/rotation.rs
···101101 /// Returns the number of degrees that the event will be offset for a given light ID.
102102 /// # Panics
103103 /// Will panic if the light ID is greater than or equal to the group size.
104104- #[deprecated(
105105- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
106106- )]
104104+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
107105 #[allow(deprecated)]
108106 pub fn get_rotation_offset(&self, light_id: i32, group_size: i32) -> f32 {
109107 self.rotation_dist_type.compute_offset(
+1-3
src/difficulty/lightshow/group/translation.rs
···107107 /// Returns the number of units that the event will be offset for a given light ID.
108108 /// # Panics
109109 /// Will panic if the light ID is greater than or equal to the group size.
110110- #[deprecated(
111111- note = "Experimental. Does not consider chunks, random, or limit in filter calculations."
112112- )]
110110+ #[deprecated(note = "Experimental. Does not consider random or limit in filter calculations.")]
113111 #[allow(deprecated)]
114112 pub fn get_translation_offset(&self, light_id: i32, group_size: i32) -> f32 {
115113 self.translation_dist_type.compute_offset(