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

fix(engine/rendering): Fix ChunkMeshRenderer listens to wrong deactivate event #4932

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onNewMesh(OnActivatedComponent event, EntityRef entity, ChunkMeshCom
disposalSet.add(new BuffersReference(mesh.mesh, disposalQueue));
}

@ReceiveEvent(components = {MeshComponent.class, LocationComponent.class})
@ReceiveEvent(components = {ChunkMeshComponent.class, LocationComponent.class})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@ReceiveEvent(components = {ChunkMeshComponent.class, LocationComponent.class})
@ReceiveEvent(components = {ChunkMeshComponent.class})

I think this is better @skaldarnar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

EntityBasedRenderableChunk depends on the existence of a LocationComponent, meaning psudoChunks will never contain an entity which doesn't have a LocationComponent, and that removing it from here would result in reacting to events which don't affect our state.

Copy link
Member

Choose a reason for hiding this comment

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

BeforeDeactivateComponent is called when a component is removed from an entity. you would get this hit if either LocationComponent or ChunkMeshComponent is removed. I guess in either case this would be valid behavior? would help to have some unit test verify the behavior. the fix is good as it is at the moment.

public void onDestroyMesh(BeforeDeactivateComponent event, EntityRef entity) {
pseudoChunks.remove(entity);
}
Expand Down