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

Compile error trying to use Aabb2 #138

Open
supagu opened this issue Apr 6, 2024 · 0 comments
Open

Compile error trying to use Aabb2 #138

supagu opened this issue Apr 6, 2024 · 0 comments

Comments

@supagu
Copy link

supagu commented Apr 6, 2024

I've copied the Aabb2 code from here: https://github.com/rustgd/collision-rs/blob/master/benches/dbvt.rs

fn aabb2(minx: f32, miny: f32, maxx: f32, maxy: f32) -> Aabb2<f32> {
    Aabb2::new(Point2::new(minx, miny), Point2::new(maxx, maxy))
}

but in my project it gives me a compile error:

error[E0308]: arguments to this function are incorrect
  --> src/v2/body.rs:20:5
   |
20 |     Aabb2::new(Point2::new(minx, miny), Point2::new(maxx, maxy))
   |     ^^^^^^^^^^
   |
note: expected `cgmath::point::Point2<f32>`, found `Point2<f32>`
  --> src/v2/body.rs:20:16
   |
20 |     Aabb2::new(Point2::new(minx, miny), Point2::new(maxx, maxy))
   |                ^^^^^^^^^^^^^^^^^^^^^^^
   = note: `Point2<f32>` and `cgmath::point::Point2<f32>` have similar names, but are actually distinct types
note: `Point2<f32>` is defined in crate `cgmath`
  --> /Users/fabian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cgmath-0.18.0/src/point.rs:50:1
   |
50 | pub struct Point2<S> {
   | ^^^^^^^^^^^^^^^^^^^^
note: `cgmath::point::Point2<f32>` is defined in crate `cgmath`
  --> /Users/fabian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cgmath-0.17.0/src/point.rs:50:1
   |
50 | pub struct Point2<S> {
   | ^^^^^^^^^^^^^^^^^^^^
   = note: perhaps two different versions of crate `cgmath` are being used?
note: expected `cgmath::point::Point2<f32>`, found `Point2<f32>`
  --> src/v2/body.rs:20:41
   |
20 |     Aabb2::new(Point2::new(minx, miny), Point2::new(maxx, maxy))
   |                                         ^^^^^^^^^^^^^^^^^^^^^^^
   = note: `Point2<f32>` and `cgmath::point::Point2<f32>` have similar names, but are actually distinct types
note: `Point2<f32>` is defined in crate `cgmath`
  --> /Users/fabian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cgmath-0.18.0/src/point.rs:50:1
   |
50 | pub struct Point2<S> {
   | ^^^^^^^^^^^^^^^^^^^^
note: `cgmath::point::Point2<f32>` is defined in crate `cgmath`
  --> /Users/fabian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cgmath-0.17.0/src/point.rs:50:1
   |
50 | pub struct Point2<S> {
   | ^^^^^^^^^^^^^^^^^^^^
   = note: perhaps two different versions of crate `cgmath` are being used?
note: associated function defined here
  --> /Users/fabian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/collision-0.20.1/src/volume/aabb/aabb2.rs:26:12
   |
26 |     pub fn new(p1: Point2<S>, p2: Point2<S>) -> Aabb2<S> {
   |            ^^^

Here are the deps from my cargo.toml:

[dependencies]
rand = "0.8.5"
cgmath = "0.18.0"
collision = "0.20.1"
sdl2 = { version = "0.36.0", features = ["unsafe_textures", "gfx", "image"] }

I notice when i do a cargo build it installs cgmath 0.18.0 and 0.17.0:

% cargo build
    Blocking waiting for file lock on build directory
   Compiling num-traits v0.2.18
   Compiling approx v0.3.2
   Compiling approx v0.4.0
   Compiling cgmath v0.17.0
   Compiling cgmath v0.18.0
   Compiling collision v0.20.1

so not sure if the problem is that or not. And I am not sure why 2 versions of cgmath is being installed.

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

1 participant