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

Use collision detection ray to reposition an object already in the scene #96740

Merged

Conversation

ryevdokimov
Copy link
Contributor

@ryevdokimov ryevdokimov commented Sep 9, 2024

Closes: godotengine/godot-proposals#755

Related: #88511

Currently only works with one object at a time. Multiple objects would probably be a future PR if desired.

Currently does not have a key binding by default:

Works similar to "instant transformations" in that pressing the key initiates the function, and left click commits it.

image

2024-09-19.17-48-36.mp4

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of master f032af7), it works as expected.

I miss a way to offset the object so that it appears outside the ground/wall though. The dragged object's collision shape AABB should be taken into account (if the dragged object is a PhysicsBody3D or CollisionShape3D). Without having this feature in place, you either have to drag a parent node that is offset compared to its child (which can break center of mass with physics nodes) or have to reposition the object manually later on, which kind of defeats the point of the feature for most objects.

Additionally, using the mouse wheel could work to offset the position in local space (i.e. relative to the current view direction)? Something like this (from Cube 2: Sauerbraten's editor):

o.mp4

There could also be automatic rotation support according to the collision normal, but this can be left for a future PR.

Currently does not have a key binding by default:

I suggest binding Shift + G by default to match #78148.

@ryevdokimov
Copy link
Contributor Author

I miss a way to offset the object so that it appears outside the ground/wall though. The dragged object's collision shape AABB should be taken into account (if the dragged object is a PhysicsBody3D or CollisionShape3D).

Wouldn't this be resolved by: #88511?

@Calinou
Copy link
Member

Calinou commented Oct 4, 2024

Wouldn't this be resolved by: #88511?

Yes, this works perfectly 🙂

@ryevdokimov
Copy link
Contributor Author

I suggest binding Shift + G by default to match #78148.

Done.

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Oct 4, 2024
@ryevdokimov ryevdokimov force-pushed the collision_reposition branch from 0edad9e to 420dbf8 Compare October 4, 2024 20:52
@akien-mga akien-mga requested a review from Calinou October 4, 2024 20:55
@ryevdokimov ryevdokimov force-pushed the collision_reposition branch from 420dbf8 to fb768a7 Compare October 4, 2024 21:14
@ryevdokimov
Copy link
Contributor Author

Rebased and modified to work with: #88511

@Repiteo Repiteo merged commit a272d67 into godotengine:master Oct 14, 2024
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 14, 2024

Thanks!

@ryevdokimov ryevdokimov deleted the collision_reposition branch October 14, 2024 19:17
@thygrrr
Copy link
Contributor

thygrrr commented Nov 10, 2024

Question, in the Dev 4 snapshot blog, this video in the top post is shown, but this shows the collisionshape and mesh fully intersecting the surface (the snapping seems to be at the gizmo origin / anchor?

@ryevdokimov
Copy link
Contributor Author

Question, in the Dev 4 snapshot blog, this video in the top post is shown, but this shows the collisionshape and mesh fully intersecting the surface (the snapping seems to be at the gizmo origin / anchor?

I'm not sure I understand the question, but if you're suggesting that the video in the snapshot post is somewhat misleading to the functionality in the build I would agree. This PR was created separately yet complimentary with #88511, which was also merged prior to dev 4 build, and the behavior of both is reflected within the dev4 build of the engine. The final position is offset by bounds of the object being positioned.

@albinaask
Copy link
Contributor

Would it be impossible to make the box not clip the conveyor belt, like offset the placement by half the AABB of the box? I think it would be a much more plausible scenario that you don't want the objects to intersect than that they would intersect like shown in the video.

@ryevdokimov
Copy link
Contributor Author

Would it be impossible to make the box not clip the conveyor belt, like offset the placement by half the AABB of the box? I think it would be a much more plausible scenario that you don't want the objects to intersect than that they would intersect like shown in the video.

This is the behavior in the latest build. This PR was created along with #88511 but were both merged.

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.

Add object snapping to the floor/vertices for the 3D editor viewport
7 participants