fix: empty frame in redis
It's caused an infinit loop. Now some point in (0, 0) with no light ar added instead of added empty frame.
This commit is contained in:
parent
baf149ef8a
commit
a006bd87a6
@ -153,6 +153,7 @@ fn get_next_frame(
|
||||
line = transformer.apply(&line, world_state);
|
||||
}
|
||||
|
||||
|
||||
info!("Draw Black -> {}", world_state.draw_black);
|
||||
info!("Draw Grid -> {}", world_state.draw_grid);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::point::Point;
|
||||
use crate::point::{Point, Color};
|
||||
use crate::transformer::Transformers;
|
||||
use crate::worldstate::WorldState;
|
||||
|
||||
@ -16,12 +16,17 @@ pub enum Replicate {
|
||||
impl Transformers for Replicate {
|
||||
fn apply(&self, point_list: &[Point], _ws: &WorldState) -> Vec<Point> {
|
||||
let mut point_list2 = vec![];
|
||||
|
||||
match self {
|
||||
Replicate::Until(n) => {
|
||||
while point_list2.len() < *n {
|
||||
if point_list.len() == 0 { // to prevent infinit loop in case of empty frame
|
||||
point_list2.append(&mut vec![Point{x:0., y:0., color: Color{r:0, g:0, b:0}}; *n].to_vec());
|
||||
} else {
|
||||
point_list2.append(&mut point_list.to_vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
Replicate::Times(n) => {
|
||||
for _ in 0..*n {
|
||||
point_list2.append(&mut point_list.to_vec());
|
||||
|
Loading…
Reference in New Issue
Block a user