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

PlaneMeshBuilder: Different amounts of subdivisions in X and Z directions #16437

Open
ulmer-a opened this issue Nov 19, 2024 · 0 comments
Open
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@ulmer-a
Copy link

ulmer-a commented Nov 19, 2024

What problem does this solve or what need does it fill?

I have a use case where I need a plane mesh that has different amounts of subdivisions in the x and z directions, respectively. When I use PlaneMeshBuilderto build the mesh, I only have the option to do this:

Plane3d::default()
    .mesh()
    .size(100, 100)
    .subdivisions(5), // can only do this where i would like to do `.subdivisions_xz(5, 10)`

What solution would you like?

This could be trivially implemented by just changing this

pub struct PlaneMeshBuilder {
    pub plane: Plane3d,
    pub subdivisions: u32,
}
impl MeshBuilder for PlaneMeshBuilder {
    fn build(&self) -> Mesh {
        let z_vertex_count = self.subdivisions + 2;
        let x_vertex_count = self.subdivisions + 2;
        let num_vertices = (z_vertex_count * x_vertex_count) as usize;
        // ...

into this:

pub struct PlaneMeshBuilder {
    pub plane: Plane3d,
    pub subdivisions_x: u32,
    pub subdivisions_z: u32,
}
impl MeshBuilder for PlaneMeshBuilder {
    fn build(&self) -> Mesh {
        let z_vertex_count = self.subdivisions_z + 2;
        let x_vertex_count = self.subdivisions_x + 2;
        let num_vertices = (z_vertex_count * x_vertex_count) as usize;
        // ...

and of course adding the corresponding builder methods etc. Also, the current API would not change!

Additional context

The issue where subdivisions were introduced: #13258. Someone mentioned that subdivisions should be part of Meshable trait. Is this relevant?

I would be happy to implement this if you guys approve this.

@ulmer-a ulmer-a added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant