-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Node3D gizmo improvements #50748
Node3D gizmo improvements #50748
Conversation
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.
Only had a cursory look through the code but it looks good to me.
* Clean-up of node_3d_editor_plugin.{h,cpp}: removed unused code, fixed some bugs. * Moved node_3d_editor_gizmos.{h,cpp} to editor/plugins. * Added support for multiple gizmos per node. This means custom gizmos will no longer override the built-in ones and that multiple gizmos can be used in more complex nodes. * Added support for handle IDs. When adding handles to a gizmo, an ID can be specified for each one, making it easier to work with gizmos that have a variable number of handles. * Added support for subgizmos, selectable elements that can be transformed without needing a node of their own. By overriding _subgizmo_intersect_frustum() and/or _subgizmo_intersect_ray() gizmos can define which subgizmos should be selected on a region or click selection. Subgizmo transformations are applied using get/set/commit virtual methods, similar to how handles work.
Thanks! |
@JFonS I'm working on applying it to SkeletonGizmo, but I'm a little confused about the id handling. Can you give me the MyNode sample code above? |
@JFonS And, there is a problem with the 2021-07-25.9.16.21.mov |
I will take a look at the sorting, you are right it probably makes more sense to select after checking the transform gizmo. The example code is already in the PR description. You have to open the "Example source code" section under the video :) |
I saw the sample code about GizmoPlugin, but I don't know what's about MyNode class. Does it simply have an array of xforms? |
I don't have the code for
|
Thanks, I understand about In this case, the transform can be retrieved in Transform3D Skeleton3DGizmoPlugin::get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const {
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
ERR_FAIL_COND_V(!skeleton, Transform3D());
Transform3D tr;
if (skeleton->get_selected_bone() == -1) {
tr = skeleton->get_global_transform();
} else {
tr = skeleton->get_bone_global_pose(skeleton->get_selected_bone());
}
return tr;
} |
@JFonS Does the above your example work when changing the When the parent Node's scale is not When Addition: |
This PR is very very great and will simplify my Character gizmos, where I was using many handles to move the head position and direction, etc.. This will simplify things a lot, thanks! As other thing you can consider to improve this this mechanism even more is to couple 2D and 3D gizmos. For example, I've some nodes that inherit directly from a |
Clean-up of
node_3d_editor_plugin.{h,cpp}
: removed unused code, fixed some bugs. I think I kept the selection behavior (with locked/grouped nodes, and shift pressed/unpressed) the same as before, but it wouldn't hurt if @foxydevloper and @EricEzaM could double check, since I had to rebase on their commits.Moved
node_3d_editor_gizmos.{h,cpp}
toeditor/plugins
.Added support for multiple gizmos per node. This means custom gizmos will no longer override the built-in ones and that multiple gizmos can be used in more complex nodes.
Added support for handle IDs. When adding handles to a gizmo, an ID can be specified for each one, making it easier to work with gizmos that have a variable number of handles.
Added support for subgizmos, selectable elements that can be transformed without needing a node of their own. By overriding
_subgizmo_intersect_frustum()
and/or_subgizmo_intersect_ray()
gizmos can define which subgizmos should be selected on a region or click selection. Subgizmo transformations are applied usingget/set/commit
virtual methods, similar to how handles work.With this changes we should be good to start implementing more advanced gizmos for
Skeleton3D
,Path3D
andMultimeshInstance3D
amongst others.Simple example implementation of subgizmos
In order to test the new subgizmo system I implemented a simple node that holds a list of transforms. The gizmo exposes a subgizmo for each transform and just displays them as boxes.
Peek.2021-07-22.19-27.mp4
Example source code