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

Add InvisibleEntities vector [enhancement] [rendering] #518

Closed
rostyslav52 opened this issue Sep 19, 2020 · 6 comments
Closed

Add InvisibleEntities vector [enhancement] [rendering] #518

rostyslav52 opened this issue Sep 19, 2020 · 6 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@rostyslav52
Copy link

I have looked into https://docs.rs/bevy_render/0.1.3/src/bevy_render/camera/visible_entities.rs.html#26-60
If I understand correctly, this system looks into all entities in camera view and

  • if entity is_visible, renders it
  • if not, then entity will be ignored and will never be detected by camera

My suggestion is to add a vector InvisibleEntities to https://docs.rs/bevy/0.1.3/bevy/prelude/struct.Camera2dComponents.html
This vector will contain entities that are in camera view, but have is_visible set as false.

I believe that this would greatly simplify the detection of entities to render or not.

My usecase was that I wanted to render only entities that are in camera view.
Since there is no such vector as InvisibleEntities, I don't see any way to detect whether hidden entities (with is_visible set to false) are in camera view or not.

Obviously, the name of parameter can be different : HiddenEntities, InvisibleEntitiesInCameraView...

This seems related to #190 , but it is not.

@rostyslav52
Copy link
Author

Mainly, what bothers me is the condition :
https://docs.rs/bevy_render/0.1.3/src/bevy_render/camera/visible_entities.rs.html#38-40

It seems like there should be an additional check to render only what is in camera view. This way there won't even be any need to have InvisibleEntities vector.

@rostyslav52
Copy link
Author

rostyslav52 commented Sep 19, 2020

I describe a workaround that I think will work in my case :

I will create a Resource that will contain a vector of Tiles. Each Tile will contain an enum for tile type (grass, water etc) and a vector of entities to describe who is standing on that tile (for, example, if both flying and walking creatures are allowed on the same tile).

Then, I will have a system run constantly and query the camera to compute the corners of camera view. This way I will know the coordinates of tiles (and units on those tiles) to render.

As for rendering, I think I will simply add and remove Draw components.

I want to mention that I am aware of https://github.com/stararawn/bevy_tiled , but, unless I am wrong, it does not handle units (creatures).

And as final words : this is a workaround that works for me because of the design of my game. I think that the Issue should still be considered in case other users need this feature.

@rostyslav52
Copy link
Author

rostyslav52 commented Sep 19, 2020

It turned out that the solution I found has already been considered and implemented by others :
https://github.com/alexschrod/bevy_isometric_rendering_demo/blob/master/src/map_render.rs

It is quite similar to what I will develop in terms of tilemap data structure.
At least for now.

@GabCampbell
Copy link
Contributor

Hey thanks a lot for what you're doing here :)
There's not need to put tags in the title we gotchu

Depending on how we feel about this we might move this into Discussions to have a longer discussion on these improvements
Thanks a bunch for helping the community

@GabCampbell GabCampbell added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Sep 20, 2020
@alice-i-cecile
Copy link
Member

The new idiom for setting visibility is the Visibility component. We should investigate how the new changes impact this issue.

See
https://github.com/bevyengine/bevy/blob/ffecb05a0ab423b46ab991b49c54516bcaf2ea7b/crates/bevy_render/src/view/visibility/mod.rs

@mockersf
Copy link
Member

mockersf commented Nov 1, 2022

cameras now have a VisibleEntities component listing the visible entities

@mockersf mockersf closed this as completed Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

4 participants