Commit e5a7533fad6f7f22b6ecef0e2ae5cc3032950fa7

Authored by Georg Hopp
1 parent e5318389

Start fixing vertex order

... ... @@ -275,7 +275,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
275 275 + Debug + Copy + From<i32> {
276 276
277 277 fn new(p :&'a Polygon<T>, direction :Direction) -> Self {
278   - let top = p.vert_min();
  278 + let top = p.vert_min(direction);
279 279 let next = p.next_y(top, direction);
280 280 let edge = match next {
281 281 None => None,
... ... @@ -330,7 +330,7 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
330 330 impl<T> Polygon<T>
331 331 where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
332 332 + Copy + Debug + From<i32> {
333   - fn vert_min<'a>(&'a self) -> usize {
  333 + fn vert_min<'a>(&'a self, d :Direction) -> usize {
334 334 let Polygon(Coordinates(cs)) = self;
335 335
336 336 type ICoord<'a,T> = (usize, &'a Coordinate<T>);
... ... @@ -341,7 +341,12 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
341 341 Some(a) => {
342 342 let Coordinate(_, ay, _) = a.1;
343 343 let Coordinate(_, xy, _) = x.1;
344   - if xy < ay {Some(x)} else {Some(a)}
  344 + match d {
  345 + Direction::Left =>
  346 + if xy < ay {Some(x)} else {Some(a)},
  347 + Direction::Right =>
  348 + if xy <= ay {Some(x)} else {Some(a)},
  349 + }
345 350 },
346 351 };
347 352
... ... @@ -401,6 +406,16 @@ where T: Add<Output = T> + Sub<Output = T> + Div<Output = T>
401 406 cmp::Ordering::Less => None,
402 407 // TODO On equal we need to find out which one of both to
403 408 // keep in the list… (the outermost)
  409 + // But how can we find the outermost...
  410 + // I think it depends on the previous and next one
  411 + // which means this might not be best suited for
  412 + // a recursive approach...we could keep both...
  413 + // Anyway, it looks like this is only a problem
  414 + // for the first vertex so maybe it is enough
  415 + // to choose the correct one when starting which
  416 + // would be in the vert_min method.
  417 + // Well, after adding some logic to vert_min it
  418 + // seems it is also relevant for the last one.
404 419 cmp::Ordering::Equal => inner(p, c, p.step(n, d), d),
405 420 cmp::Ordering::Greater => Some(n),
406 421 }
... ...
... ... @@ -342,8 +342,9 @@ fn _democanvas<T>( xcb :&XcbEasel
342 342 let rot1 = TMatrix::combine(vec!(rz, rx, t));
343 343 let rot2 = TMatrix::combine(vec!(rz, ry, t));
344 344
345   - let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00)
346   - , ( cube.transform(&rot2), 0x0000FF) );
  345 + let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00) );
  346 + //let objects = vec!( (tetrahedron.transform(&rot1), 0xFFFF00)
  347 + // , ( cube.transform(&rot2), 0x0000FF) );
347 348 //let objects = vec!( (triangle.transform(&rot1), 0xFFFF00) );
348 349
349 350 <XcbCanvas as Canvas<T>>::clear(&mut canvas);
... ...
Please register or login to post a comment