-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Improve collision generation usability in the new 3D scene import workflow. #52266
Conversation
The constructor was expecting a mutable pointer, while the passed pointer was immutable (returns a const pointer), so the compilation was failing when iterating a constant.
// Decomposition | ||
Mesh::ConvexDecompositionSettings decomposition_default; | ||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "decomposition/advanced", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false)); | ||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "decomposition/precision", PROPERTY_HINT_RANGE, "1,10,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't need PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED modified for these. This flag is only for when changing the property results in other properties being added/removed/changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For advanced, I need it to make sure to show all the other properties, but for precision
you right, I don't need it, nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -980,6 +1017,65 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor | |||
case INTERNAL_IMPORT_CATEGORY_NODE: { | |||
} break; | |||
case INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE: { | |||
const bool generate_physics = | |||
p_options.has("generate/physics") && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, using .has()
is not needed, it is warranted that you will always get all the properties filled in (and if not there is likely a bug).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling .has()
is necessary, to avoid crash the engine while using the constant
version of operator[]
: https://github.com/godotengine/godot/blob/master/core/templates/map.h#L662
@@ -1016,6 +1112,33 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor | |||
return true; | |||
} | |||
|
|||
bool ResourceImporterScene::get_internal_option_update_view(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may use a different function like get_internal_option_update_view_required
to make it a bit clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, make sense, I'll change that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
…kflow. With this PR it's possible to add a collision during the Mesh import, directly in editor. To generate the shape is possible to chose between the following options: - Decompose Convex: The Mesh is decomposed in one or many Convex Shapes (Using the VHACD library). - Simple Convex: Is generated a convex shape that enclose the entire mesh. - Trimesh: Generate a trimesh shape using the Mesh faces. - Box: Add a primitive box shape, where you can tweak the `size`, `position`, `rotation`. - Sphere: Add a primitive sphere shape, where you can tweak the `radius`, `position`, `rotation`. - Cylinder: Add a primitive cylinder shape, where you can tweak the `height`, `radius`, `position`, `rotation`. - Capsule: Add a primitive capsule shape, where you can tweak the `height`, `radius`, `position`, `rotation`. It's also possible to chose the generated body, so you can create: - Rigid Body - Static Body - Area
I checked the functionality of this previously. The changes to the default precision from 0 to 5+ and defaulting to convex decompose have been made. We discussed how it was possible to make test cases for the matrix of cases. Looks good to me. |
params.m_resolution = p_settings.resolution; | ||
params.m_maxNumVerticesPerCH = p_settings.max_num_vertices_per_convex_hull; | ||
params.m_planeDownsampling = p_settings.plane_downsampling; | ||
params.m_convexhullDownsampling = p_settings.convexhull_downsampling; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanted: spelling changes on convexhull vs convex_hull. I prefer "convex_hull". The usage is inconsistent.
This change should not block merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
Thanks! |
Mirror of: #51985 that was merged for mistake.
Implements the proposal: godotengine/godot-proposals#3155
With this PR it's possible to add a collision during the Mesh import, directly in editor.
To generate the shape is possible to chose between the following options:
size
,position
,rotation
.radius
,position
,rotation
.height
,radius
,position
,rotation
.height
,radius
,position
,rotation
.It's also possible to chose the generated body, so you can create:
See it in action here: https://youtu.be/I-N1IXgeb00
2021-08-27.09-36-34.mp4