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

Subtraction trait not working for torus #9

Open
edap opened this issue Jan 6, 2023 · 2 comments
Open

Subtraction trait not working for torus #9

edap opened this issue Jan 6, 2023 · 2 comments

Comments

@edap
Copy link

edap commented Jan 6, 2023

If subtract a box from a sphere:

sdfu::Sphere::new(0.45).subtract(sdfu::Box::new(Vec3A::new(0.25, 0.25, 1.5)));

It works. But if I subtract a torus from a sphere:

sdfu::Sphere::new(0.45)..subtract(sdfu::Torus::new(0.45, 0.1))

I get this error message:

error[E0282]: type annotations needed
    |
539 |             .subtract(sdfu::Torus::new(0.45, 0.1))
    |              ^^^^^^^^
    |
help: try using a fully qualified path to specify the expected types
    |
538 |         <sdfu::Sphere<f32> as SDF<f32, V>>::subtract::<Torus<f32>>(sdfu::Sphere::new(0.45), sdfu::Torus::new(0.45, 0.1))
    |         +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                       ~

@fu5ha
Copy link
Owner

fu5ha commented Jan 6, 2023

This is because it can't infer the type of float, you should be able to just put 0.45f32 (or you may have to specify the vector type as well at some point, but it can hopefully figure that out itself). As long as you specify somewhere it should be able to infer the rest

@edap
Copy link
Author

edap commented Jan 6, 2023

I see, I have tried to specify the type

let sphere_radius :f32 = 0.35;
let torus_radius: f32 = sphere_radius - 0.1;
let torus_t: f32 = 0.1;
let sdf_sphere = TracedSDF::new( sdfu::Sphere::new(sphere_radius)
                              .subtract(sdfu::Torus::new(torus_radius, torus_t));

But the error persists.

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