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

Tag entity exclusion #59

Conversation

alek-kam-robotec-ai
Copy link
Collaborator

This pr adds a new way to exclude entities from raycasting using the Tag component.

  • excluded tag names were added as a field to the scene configuration component.
  • added a way to dynamically handle entity exclusion from raycasting based on their tags.

To exclude an entity from raycasting tag it using the tag component and include the tag name in the scene configuration componet.

Signed-off-by: Aleksander Kamiński <[email protected]>
Base automatically changed from feature/bc3-support/alkam to feature/configurable-pc-message/alkam November 12, 2024 15:27
Copy link
Contributor

@msz-rai msz-rai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍

When testing I got the following bug:

  1. I added cube with tag that is excluded in scene configuration.
  2. I ran the simulation and the cube was ignored by RGL 👍
  3. I stopped the simulation and removed tag from the cube (Tag component is still present)
  4. I ran the simulation again and the cube was ignored by RGL even though the tag was removed.

Please investigate my test case. Also, I left some comments to address.

Code/Source/RGLSystemComponent.cpp Outdated Show resolved Hide resolved
Comment on lines +235 to +243
void RGLSystemComponent::OnTick(float deltaTime, AZ::ScriptTimePoint time)
{
for (auto entityId : m_managersToBeRemoved)
{
m_entityManagers.erase(entityId);
m_unprocessedEntities.insert(entityId);
}
m_managersToBeRemoved.clear();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why couldn't we erase entity manager in ReviseEntityPresence(AZ::EntityId entityId)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so that the caller can signal revision inside a bus notification and can then safely disconnect from said bus after the call has ended (on destruction).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, the only caller is EntityTagListener which is not destroyed in ReviseEntityPresence() so your case doesn't occur. Is it solution for the future usages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I believe that this could lead to bugs that would be hard to track down as in previous iterations of the solution the entity manager handlet the tag notification bus and the ReviseEntityPresence method was called from within the callbacks which lead to segfaults caused by destruction of the entity manager before the callback was finished. In my opinion a small amount of additional complexity in this case is worth it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating the new class and having separate container for it in RGLSystemComponent I'd extend EntityManager with LmbrCentral::TagComponentNotificationsBus::Handler. I see no advantages in having this separation.

Copy link
Collaborator Author

@alek-kam-robotec-ai alek-kam-robotec-ai Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow for a scenario where an entity is excluded from the raycasting due it being tagged with an excluded tag after which the tag is removed and the entity must be processed. With the bus handled by the entity manager we would not be able to achieve this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if dynamic handling of tag creation/destruction is necessary (if there are any real use cases). If not, this solution could be significantly simplified to checking ShouldEntityBeExcluded in OnEntityContextCreateEntity and discarding entities that should be excluded (skipping processing them and putting them to m_unprocessedEntities). Did you get the detailed requirements for this feature?

Copy link
Collaborator Author

@alek-kam-robotec-ai alek-kam-robotec-ai Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Tag Component allows for tag addition and removal at runtime. I believe we should cover these cases as some proved useful before (as seen in this pr).

@alek-kam-robotec-ai
Copy link
Collaborator Author

Good job 👍

When testing I got the following bug:

  1. I added cube with tag that is excluded in scene configuration.
  2. I ran the simulation and the cube was ignored by RGL 👍
  3. I stopped the simulation and removed tag from the cube (Tag component is still present)
  4. I ran the simulation again and the cube was ignored by RGL even though the tag was removed.

Please investigate my test case. Also, I left some comments to address.

@msz-rai
This must be a bug in the engine. I read the entity's tag list on demand. I've checked this and the tag component lists the excluded tag after edition in the editor.

Signed-off-by: Aleksander Kamiński <[email protected]>
Signed-off-by: Aleksander Kamiński <[email protected]>
Copy link
Contributor

@msz-rai msz-rai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@alek-kam-robotec-ai alek-kam-robotec-ai merged commit 251b50b into feature/configurable-pc-message/alkam Nov 14, 2024
@alek-kam-robotec-ai alek-kam-robotec-ai deleted the feature/better-entity-exclusion/alkam branch November 14, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants