# Checking if actor is visible to a user

**URL:** https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357
**Category:** Web
**Created:** [March 1, 2019, 4:01pm UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357 "2019-03-01T16:01:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![marf](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@marf](https://discourse.vtk.org/u/marf)
#### Post date: [March 1, 2019, 4:01pm UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357/1 "2019-03-01T16:01:39Z")

</div>

Hello,  
I try to check if an Actor can be seen by a user or if it is hidden behind another object. Currently I try doing this with a picker, since I thought it would only select the topmost Actor. But it selects all actors in its path, and I’ve run out of ideas.  
Also adding only the desired Actors to the pick list does not work, because they will be picked any time

What I do currently (pseudocode)

point = [actor.x, actor.y, 0]  
picker = vtkPointPicker.newInstance()  
picker.pick(point, renderer)

Now picker.getActors() will return all actors in the pickers ray cast, and they always have the same order to, so I can not decide if the actor can be seen by the user or is hidden behind one of the other actors.

Can anyone please help me?

---

<div class="post-metadata">

### Author: ![pettaa123](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pettaa123/32/218_2.png) [@pettaa123](https://discourse.vtk.org/u/pettaa123)
#### Post date: [March 3, 2019, 12:57pm UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357/3 "2019-03-03T12:57:45Z")

</div>

Have you trief Worldpointpicker instead of Pointpicker? According to documentation:  
[vtkWorldPointPicker](https://vtk.org/doc/nightly/html/classvtkWorldPointPicker.html) is the fastest picker, returning an x-y-z coordinate value using the hardware z-buffer.

Havent tried it myself, just an idea

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [March 4, 2019, 12:12am UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357/4 "2019-03-04T00:12:08Z")

</div>

The code in that test should give you a good starting point.

Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js

Unfortunately my previous posts fail due to the direct link I was putting trying to provide.

---

<div class="post-metadata">

### Author: ![marf](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@marf](https://discourse.vtk.org/u/marf)
#### Post date: [March 5, 2019, 12:55pm UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357/5 "2019-03-05T12:55:13Z")

</div>

Thank you so much, the HardwareSelector does exactly what I needed 🙃

---

<div class="post-metadata">

### Author: ![marf](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@marf](https://discourse.vtk.org/u/marf)
#### Post date: [March 6, 2019, 1:21pm UTC](https://discourse.vtk.org/t/checking-if-actor-is-visible-to-a-user/357/7 "2019-03-06T13:21:54Z")

</div>

Ok the efficiency issue was mostly on my part. For a group of actors I did one selection for each everytime the view was moved. Now I optimised it by doing on large selection where all actors could be included (if they are visible) and I only do this, once moving the view has ended.

The selection still takes 50 - 150ms, but its definitely smooth enough for my interaction.
