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

Implement picking functionality #4657

Merged
merged 2 commits into from
Sep 29, 2021
Merged

Implement picking functionality #4657

merged 2 commits into from
Sep 29, 2021

Conversation

pixelflinger
Copy link
Collaborator

@pixelflinger pixelflinger commented Sep 21, 2021

This is a pixel accurate implementation of picking. Picking queries
can be created on view, and upon completion a user provided callback
is called with the Entity of the renderable at the queried coordinates
in the viewport.

Picking queries typically have 1 or 2 frame of latency and may impact
performance on some drivers.

It is mostly intended for use by editors, or when latency is not a major
concern. This api should not be used for dragging/moving objects, it is
intended for initial picking only.

Picking is implemented in the structure pass.

@google-cla google-cla bot added the cla: yes label Sep 21, 2021
@pixelflinger pixelflinger changed the title wip: picking Implement picking functionality Sep 25, 2021
@pixelflinger
Copy link
Collaborator Author

reviewers: it's almost ready, missing only the java API I think and maybe a sample.

filament/include/filament/View.h Outdated Show resolved Hide resolved
filament/include/filament/View.h Outdated Show resolved Hide resolved
filament/include/filament/View.h Outdated Show resolved Hide resolved
@bejado
Copy link
Member

bejado commented Sep 27, 2021

Should we add picking to matc's --variant-filter?

@pixelflinger pixelflinger marked this pull request as ready for review September 29, 2021 17:00
This is just a minimal change to get the R_INTEGER format to work.

- if src/dst types are identical, just copy (this avoids a mul and a div)
- add R,RG and INTEGER types
This is a pixel accurate implementation of picking. Picking queries
can be created on view, and upon completion a user provided callback
is called with the Entity of the renderable at the queried coordinates
in the viewport.

Picking queries typically have 1 or 2 frame of latency and may impact
performance on some drivers.

It is mostly intended for use by editors, or when latency is not a major
concern. This api should not be used for dragging/moving objects, it is
intended for initial picking only.

Picking is implemented in the structure pass.

The depth buffer value is retrieved and the fragment coordinate is
reconstructed and passed to PickingQueryResult. This can be used in
turn to calculate the view and/or world space position.
@zcufo123
Copy link

zcufo123 commented Oct 4, 2021

@pixelflinger

Thank you for providing this handy API for us and it can make our lives easier.

I have one question for you: If one picking query is requested and multiple entity is selected, how would the PickingQueryResult return these multiple entities?

@romainguy
Copy link
Collaborator

It won't, it will return the closest Entity.

@flykule
Copy link

flykule commented Oct 25, 2021

How to support pick moving/dragging objects?

@ozzbI
Copy link

ozzbI commented Dec 9, 2021

Is there any way to get picked material or primitive? Or idea what should be done to make it possible?

@flykule
Copy link

flykule commented Dec 11, 2021

Is there any way to get picked material or primitive? Or idea what should be done to make it possible?

The pick result callback has returned nearest entity. You can use renderableManager.getMaterialInstance to get selected material .

@ozzbI
Copy link

ozzbI commented Dec 11, 2021

Is there any way to get picked material or primitive? Or idea what should be done to make it possible?

The pick result callback has returned nearest entity. You can use renderableManager.getMaterialInstance to get selected material .

Thank you.
In my case instance can have multiple primitives with different materials attached to each primitive.
I can iterate over primitives and get all materials, but I am looking how to get particular material (or primitive index) which was picked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants