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

Make sure MeshLibrary shape array has correct number of elements #56891

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

rafallus
Copy link
Contributor

The shape array shown in the inspector increases and decreases by 2, ensuring that the last elements (when increasing) is a shape-transform pair.
Fixes: #53897

Comment on lines +269 to +272
Ref<BoxShape3D> box_shape;
box_shape.instantiate();
arr_shapes[size - 1] = box_shape;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, that seems pretty arbitrary, and could lead to a lot of instantiations that will then need to be freed and replaced by what the user wants to use.

Wouldn't it be sufficient to just make the step 2 for the SpinBox?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be sufficient to just make the step 2 for the SpinBox?

Well not sure that's actually possible currently in the array editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The array is expecting to have a shape. If there is anything else, even an empty Variant() the array won't update and the size won't change. A few lines below that piece of code you can find

if (sd.shape.is_valid()) {
	shapes.push_back(sd);
}

So, if it isn't a valid shape, nothing happens. Could you think of other way of doing it? It is absolutely arbitrary but is the way I found to do it.

@akien-mga akien-mga added bug cherrypick:3.4 cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:3d topic:editor labels Jan 18, 2022
@akien-mga akien-mga added this to the 4.0 milestone Jan 18, 2022
@akien-mga akien-mga requested review from a team January 18, 2022 09:18
@akien-mga akien-mga merged commit fba4c66 into godotengine:master Jan 25, 2022
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 25, 2022
@akien-mga
Copy link
Member

Cherry-picked for 3.4.3.

@rafallus rafallus deleted the meshlib_shapes_array branch January 25, 2022 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't add element to the MeshLibrary Item Shapes array
2 participants