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 meshes instead of colliders for positioning drag to instantiate in 3D #87969

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryevdokimov
Copy link
Contributor

@ryevdokimov ryevdokimov commented Feb 5, 2024

This is a proof of concept because it probably breaks compatibility, and the original solution may be more desirable in some circumstances.

If anyone is interested in it, feel free to build off it.

Some ideas:

Account for the bounds for both target and preview, so it doesn't sink into the target.
Create a mechanism to select positioning based off mesh or collisions.
Use a modifier key to ignore meshes/collisions.
Use this code to snap existing meshes to other existing meshes.

Currently the engine uses a physics-based ray to get an intersection of colliders to decide where to position the preview node. This comes with downsides such as depending on this physics tick rate, not snapping to meshes without colliders which is arguably the more intuitive behavior, and the code not being really straight forward as it needs to handle physics being ran on separate thread.

This PR uses the same cull ray that node selections use to detect a target mesh, and then calculates the intersection using the Visual Instance AABB.

2024-02-04.20-50-38.mp4

@ryevdokimov ryevdokimov requested a review from a team as a code owner February 5, 2024 03:51
@ryevdokimov ryevdokimov marked this pull request as draft February 5, 2024 03:51
@ryevdokimov ryevdokimov changed the title Use meshes instead of colliders for drag to instantiate in 3D Use meshes instead of colliders for positioning drag to instantiate in 3D Feb 5, 2024
@Calinou
Copy link
Member

Calinou commented Feb 5, 2024

Does this mean the geometry's shape is no longer followed? This is problematic for placing objects in large complex scenes where entire rooms are a single mesh.

@ryevdokimov
Copy link
Contributor Author

ryevdokimov commented Feb 5, 2024

Pretty much yeah, it will only snap to the AABB. It definitely isn't a replacement for the collider method in its current state, even though code is written that way. However, it does make it easier to test, and maybe a better strategy or use-case can be thought up of.

At the moment I just see this as a selectable option of "snapping modes", which could be applied both when instantiating new scenes or snapping together existing nodes (which could probably be its own proposal, if it isn't already).

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.

3 participants