Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business


OverviewFelgo 3 Support (Qt 5) › Visibility of an entity

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #18585


    Have a question about entity and when is it visible.
    In my scenario I have many entities outside of what user can see, basically “outside” of scene(lest say y position is -1000), for example.
    The problem is Qt still recognizes this entity as visible.
    Is there an easy to way to tell if entity is really visible, like on the screen?
    Or I need to do things like bodyAt to find the x and y if there are visible to the user.


    I have some logic which should work only when entity is visible, but it works when user doesn’t see the entity just yet, so that causes some issues.
    I am also concerned about performance.
    From what I know Qt doesn’t execute some operations for entity if it’s not visible, in this case(entity not visible for user) those optimizations are not active but they should?


    Felgo Team

    Hi Marcin,

    since you are already using physics, I’d recommend using a sensor collider. You could either add 4 colliders at the edges (or rather a bit outside) of your screen, or a single one filling (or even a bit bigger) your screen.

    For the latter option, as soon as your entity collides with the sensor you know it enters the screen, and as soon as collision ends it left the screen. With 4 distinct colliders you will need some more logic to know if it either entered or left the screen.

    Physics uses all C++ behind the scenes, thus this will have better performance than running checks from QML on every frame.

    Is this sufficient for your use case?




    Hi Alex,
    Thank you for hint.
    Will look closer into it.



    I like the idea of a sensor the size of the screen (or a bit bigger).  However, since the screen can be so many different sizes (and even change if someone changes resolution), how do you define such a sensor?


    Could you provide a code snippet to show this?



Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded