Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's tough to make this statement without providing users the full context. Someone may come and ask what is the
EntityComponentManager::CreateEntity
function for then; should it be made private and a friend of theSdfEntityCreator
so no system can use it, but theSdfEntityCreator
can?I think the message we'd like to convey is that there's functionality in the
Physics
plugin that relies on entities being created by theSdfEntityCreator
, specifically because of their order of creation, and that the plugin may misbehave for entities created directly through the ECM's API.We may even want to document that on the
Physics
system's header.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I look closer at the
SdfEntityCreator
API, I think that we would need to modify/expand its API a bit if we want to push users towards using it. There appear to beCreateEntities
methods for varioussdf
tags (sensor, model, etc.), but I also think that we should have a method that creates an "empty" entity: something like this:That way, for things like system plugins, users can create additional entities as needed (I had to do something similar to this in the logical audio sensor plugin - I'm not sure if what I did in this plugin is actually "best practices" or not). In terms of how this method is implemented, perhaps we can do something like have it call
EntityComponentManager::CreateEntity
if it's a friend of theSdfEntityCreator
. This method would also take care of setting the entity's parent, so users can use it like this:Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the name says, the
SdfEntityCreator
is concerned with creating entities from SDF structures 😉 Empty entities should be created directly with the ECM. It's important to keep the separation of concerns among the classes, I'm not sure what's would be the advantage of creating empty entities from theSdfEntityCreator
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good points, and you're right (again 🙂). It seems to me like for advanced use cases, users may need to create entities and components with the ECM (i.e., they can't just rely on the
SdfEntityCreator
).So, with that being said, I don't think that we can require the
SdfEntityCreator
to be used since some scenarios require making entities that don't come fromSDF
. I think that the best thing to do is to encourage the usage ofSdfEntityCreator
whenever possible, including how to use theSdfEntityCreator
(this is related to #628). As you mentioned in your original review comment, we can also provide more context to why using theSdfEntityCreator
is encouraged (for example, thephysics
system).Does simply re-wording the migration guide to discuss these items sound good enough to you? Or do we need to add more documentation elsewhere (and potentially modify/document source code) as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I have updated the PR title and description to indicate that
SdfEntityCreator
usage is recommended, but not required.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed during the meeting, we could also provide APIs to create entities from the
Model
,Link
andWorld
classes. We should be trying to add more functions to those classes so that beginners can use them, while advanced users can use the ECM for custom entities.I think that this, combined with the documentation that will come out of #628, should provide lots of pointers to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like updating the migration guide here and merging this PR may be difficult to do before addressing #628 and #805, since
SdfEntityCreator
usage depends a lot on documentation pointed out by these issues, which is missing/lacking at the time of this writing. I think we should mark this PR as a draft, address these other issues first, and then update the migration guide accordingly based on the documentation created by these other issues. Does that sound good to you?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, SGTM 👍