#Why can change 2D shapes into extrusions, and then only SOME into 3D shapes

1 messages · Page 1 of 1 (latest)

worn forum
#

I don't quite understand how extrusion works, I could extrude and turn into a mesh for some primitive 2D shapes but not others:
e.g. Here I can create an extrusion but I get error on the last line because it can't be converted to a mesh

let l: Line2d = Line2d { direction: Dir2::X };
let e = Extrusion::new(l, 4.0)
meshes.add(e)

Do I need to do something else to turn this into a mesh? whats the point in being able to turn it into an Extrusion if I can't turn it into a mesh after?

glacial latch
#

Although you could extrude a line, I feel like you'd need a direction instead of just a depth. Lines don't have a natural "normal" direction like say a plane or triangle does. Also when it was extruded, what would it generate? A plane, right? You'd have to extrude twice to get an actual 3d shape from a line.

worn forum
#

Thanks for your response!

It would not graphically generate anything is the problem

#

On meshes.add(e), I would get error:

the trait From<bevy::prelude::Extrusion<bevy::prelude::Line2d>> is not implemented for bevy::prelude::Mesh, which is required by bevy::prelude::Extrusion<bevy::prelude::Line2d>: Into<bevy::prelude::Mesh>

worn forum
glacial latch
#

I don’t think you can extrude twice. I’d suggest you create the Rectangle directly instead of extruding from a line. Then extrude that.

worn forum
glacial latch
#

Yeah, try using Polygon.

worn forum
worn forum
# glacial latch https://docs.rs/bevy/latest/bevy/math/prelude/struct.Polygon.html

This gives me a similar error to what I began with, the extrusion can not be turned into a mesh:

    let points2d = vec!
        [
            vec2(-6., 2.),
            vec2(-2., 4.),
            vec2(-3., 5.)
        ];
    let p = Polygon::new(points2d);
    let e = Extrusion::new(p, 2.0);
    let mesh_handle: Handle<Mesh> = meshes.add(e);

The error message:

the trait From<bevy::prelude::Extrusion<bevy::prelude::Polygon<_>>> is not implemented for bevy::prelude::Mesh, which is required by bevy::prelude::Extrusion<bevy::prelude::Polygon<_>>: Into<bevy::prelude::Mesh>

glacial latch
#

Maybe they don't want to deal with non-convex or intersecting boundaries, but it seems like those ought to look fine with extrusion.

worn forum
glacial latch
#

In a convex shape, a line between any two points within the shape never crosses to the outside. A circle is convex; a circle with a missing quadrant is not convex. It's a really nice property mathematically.

#

Personally I think added Polygon support would make for a good pull request.

worn forum
#

What would be wrong with creating extrusions on non-convex shapes?

glacial latch
#

Nothing visually, but maybe there's a complication for dealing with bounds or ray casting that I'm not aware of.

worn forum
#

Hmmm interesting, I follow what you are saying but idk enough about gamedev to think about this more or create a pull request haha

glacial latch
#

Yeah, I'd just use the crate you linked to and see if that'll work for you.

#

You can be assured that the very reasonable thing you want to do isn't supported in bevy yet.

worn forum
#

Ah okay, no worries thanks for your effor!

glacial latch
#

You could file an issue that might change your fortunes later: Add extrusion support for Polygon.

#

No problem. Happy to help.