Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw_lines example error on Mac OS #318

Open
dsillman2000 opened this issue Feb 2, 2023 · 1 comment
Open

draw_lines example error on Mac OS #318

dsillman2000 opened this issue Feb 2, 2023 · 1 comment

Comments

@dsillman2000
Copy link

dsillman2000 commented Feb 2, 2023

As per Issue #307,

          I'm experiencing the same error.
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1281`,
 right: `0`', /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/renderer/line_renderer.rs:89:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:203:5
   4: <kiss3d::renderer::line_renderer::LineRenderer as kiss3d::renderer::renderer::Renderer>::render
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/renderer/line_renderer.rs:89:9
   5: kiss3d::window::window::Window::render_scene
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/window/window.rs:1183:9
   6: kiss3d::window::window::Window::render_single_frame
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/window/window.rs:1114:13
   7: kiss3d::window::window::Window::do_render_with
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/window/window.rs:1074:29
   8: kiss3d::window::window::Window::render_with
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/window/window.rs:1044:9
   9: kiss3d::window::window::Window::render
             at /Users/dsillman/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.35.0/src/window/window.rs:977:9
  10: shape_log_viewer::main
             at ./src/main.rs:13:11
  11: core::ops::function::FnOnce::call_once
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/ops/function.rs:251:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I'm using version 0.35.0 of kiss3d. I'm using rustc 1.66.1. I'm on Mac OS Monterey 12.6.1 (apple M1 chip, Macbook Pro 2022). Any idea what might be causing this @donkeyteethUX ?

Originally posted by @dsillman2000 in #307 (comment)

The example is

extern crate kiss3d;

use kiss3d::nalgebra as na;
use kiss3d::light::Light;
use kiss3d::window::Window;
use na::{Point2, Point3};

fn main() {
    let mut window = Window::new("Kiss3d: lines");

    window.set_light(Light::StickToCamera);

    while window.render() {
        let a = Point3::new(-0.1, -0.1, 0.0);
        let b = Point3::new(0.0, 0.1, 0.0);
        let c = Point3::new(0.1, -0.1, 0.0);

        window.set_line_width(2.0);
        window.draw_line(&a, &b, &Point3::new(1.0, 0.0, 0.0));
        window.draw_line(&b, &c, &Point3::new(0.0, 1.0, 0.0));
        window.draw_line(&c, &a, &Point3::new(0.0, 0.0, 1.0));

        window.draw_planar_line(
            &Point2::new(-100.0, -200.0),
            &Point2::new(100.0, -200.0),
            &Point3::new(1.0, 1.0, 1.0),
        );
    }
}
@jamwaffles
Copy link

Using the latest release (0.35) on macOS I can reproduce this error. It is caused by something in kiss3d when calling window.set_line_width. If you don't call this method, everything works (for me at least). Because I'm not relying on the lines being super visible, I just turn off calls to set_lines_width when under macOS:

#[cfg(not(target_os = "macos"))]
window.set_line_width(1.0);

This is also relevant to specific objects, e.g.

let ball = ncollide3d::procedural::sphere(2.0, 20, 20, false);
let mut ball = window.add_trimesh(ball, Vector3::from_element(1.0));
ball.set_color(0.7, 0.7, 0.7);

#[cfg(not(target_os = "macos"))]
ball.set_lines_width(1.0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants