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

feat: sdk7 GltfContainerLoadingState component #5063

Merged
merged 14 commits into from
May 4, 2023

Conversation

pbosio
Copy link
Contributor

@pbosio pbosio commented Apr 26, 2023

What does this PR change?

add GltfContainerLoadingState component
fixes decentraland/sdk#736
adr https://adr.decentraland.org/adr/ADR-215

*most of the files modifications are related to a type changed on the protocol

Our Code Review Standards

https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md

Copilot summary

🤖 Generated by Copilot at 4e9a408

This pull request adds a new internal component InternalGltfContainerLoadingState to the ECS7 plugin, which tracks the loading and removal of GltfContainer components for each entity. It also updates the existing ECS7 components and systems to use this new component and changes the type of some collider fields from int to uint for consistency and performance. It modifies the assembly definitions and meta files accordingly.

@pbosio pbosio added No QA Needed Issues which do not require QA testing no_reviewers labels Apr 26, 2023
@pbosio pbosio self-assigned this Apr 26, 2023
@@ -11,6 +11,7 @@ public class GltfContainerLoadingStateSystem
{
private readonly IInternalECSComponent<InternalGltfContainerLoadingState> gltfContainerLoadingStateComponent;
private readonly IECSComponentWriter componentWriter;
private int timestamp = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This timestamp should be entity aware. I think you are setting it globally, is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was because I wasn't storing it at the crdt state, but I'm changing it right now, so timestamp will be at entity level, being prevComponentStateForEntity.timestamp +1

@pbosio pbosio marked this pull request as ready for review April 27, 2023 20:16
@pbosio pbosio requested a review from a team as a code owner April 27, 2023 20:16
@pbosio pbosio requested review from pravusjif and AjimenezDCL April 27, 2023 20:22
@AjimenezDCL AjimenezDCL requested review from mikhail-dcl and removed request for AjimenezDCL April 28, 2023 08:05

public void Update()
{
var components = gltfContainerLoadingStateComponent.GetForAll();
Copy link
Member

@pravusjif pravusjif May 2, 2023

Choose a reason for hiding this comment

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

Currently this implementation traverses all the entities with IInternalECSComponent<InternalGltfContainerLoadingState>, so basically EVERY entity with a GLTF (since we are adding that internal component to all).
Wouldn't it be better to just traverse the entities that have the new (not internal) GltfContainerLoadingState component instead? since those would be the only ones that we are interested in updating and reporting its loading state...

Maybe I'm missing the point here as I thought that to use the newGltfContainerLoadingState component from a scene with the SDK it should be added from the scene to an entity and then read it later... if we are adding that data to EVERY entity with GltfContainer why not add and update that loading state property in the GltfContainer component itself??? and avoid having a new unneeded component.

Copy link
Contributor Author

@pbosio pbosio May 2, 2023

Choose a reason for hiding this comment

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

Wouldn't it be better to just traverse the entities that have the new (not internal) GltfContainerLoadingState component instead?

No, since scene won't be sending the GltfContainerLoadingState to the renderer, the renderer will be sending the GltfContainerLoadingState to the scene. It's not sent by request, for every GltfContainer we expect to receive a GltfContainerLoadingState

Maybe I'm missing the point here as I thought that to use the newGltfContainerLoadingState component from a scene with the SDK it should be added from the scene to an entity and then read it later... if we are adding that data to EVERY entity with GltfContainer why not add and update that loading state property in the GltfContainer component itself??? and avoid having a new unneeded component.

GltfContainer is sent from the scene to the renderer, not the other way around
GltfContainerLoadingState is sent from the renderer to the scene, not the other way around
so we need two different components to avoid any write conflict.
plus, they are related but conceptually different components, one contains data of the gltf and the other the data of it loading state

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that explains why we couldn’t have that property in the GltfContainer itself, but why would we put the GltfContainerLoadingState on every entity that has the GltfContainer instead of leaving the usage of the GltfContainerLoadingState to the creators through the SDK in their scene code? that way Creators may only add that GltfContainerLoadingState component to entities that they really will be reading.

The current proposed implementation forces the client to traverse every entity that has a GltfContainer component (since we put the GltfContainerLoadingState on every entity that has a GltfContainer) when maybe none of them is actually read by the scene’s code in the end...


Also if the GltfContainerLoadingState is only sent by the renderer, it should probably be just a GrowOnlyValueSet component (using Append to update it from the renderer) instead of a LastWriteWin one, since the scene will never change it, just read it. But that can be changed in the future when decentraland/sdk#739 is tackled

Copy link
Contributor

@mikhail-dcl mikhail-dcl left a comment

Choose a reason for hiding this comment

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

I didn't spot anything catchy, everything matches the current approaches

@pbosio pbosio enabled auto-merge (squash) May 4, 2023 12:33
@pbosio pbosio merged commit b1d458c into dev May 4, 2023
@pbosio pbosio deleted the feat/sdk7-gltfcontainerloadingstate branch May 4, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No QA Needed Issues which do not require QA testing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

add GltfContainerLoadingState component
4 participants