-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Enhancement: Consider Node Ancestry in Proto Type Restrictions #6574
Enhancement: Consider Node Ancestry in Proto Type Restrictions #6574
Conversation
Signed-off-by: CoolSpy3 <[email protected]>
Signed-off-by: CoolSpy3 <[email protected]>
Signed-off-by: CoolSpy3 <[email protected]>
Note: The test suite is going to fail due to a bug in the |
Alright, I've updated the code to implement the new parsing behavior. I also updated a bunch of other instances where field values are validated (that I missed before) to point to the new implementation. I still have to test the |
That looks good to me. I do have a preference for the |
…enhancement-consider-node-ancestry-in-proto-type-restrictions
Alright, I think this is ready for review again! It looks like the type name and the following field SFNode{Solid{}+,Transform{}+} shape Solid{} Notes:
Edit: Hmmm... Looks like some of the tests are failing. I'll do some investigating. Edit 2: I think I might've fixed it. Testing... |
Tests are fixed! |
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.
Very good job! Thank you.
I would only request a couple of minor changes.
Co-authored-by: Olivier Michel <[email protected]>
Description
Currently if a
SFNode
orMFNode
field is value-restricted, any nodes added to the field, must exactly match the restricted type (or in the case of proto-nodes, directly derive from it). This PR updates the behavior so that the entire ancestry of the nodes are searched. (ex. A field restricted toPose
nodes can now also containSolid
nodes) See the linked issue for more information.A couple of notes about decisions made in this PR:
SolidDevice
, but rolled it back in favor of #CS41. This means that some of the code will have to be reworked if multiple-inheritance is desired in the future, however, the changes are fairly straight-forward, so I don't have any concerns.wrl
files. In my mind this makes the most sense because I would expect this information to be contained with theWbNodeModel
object, which is generated from these files. The only other ways I could think of doing this would be either writing out all of the relationships in a file (which would be more verbose and detached from the actual node definitions) or keeping track of constructor invocations at runtime (which would need to be done on every node instance creation rather than on every model instance creation and would add additional c++ code to convey information which is already expressed in the inheritance structure of the classes. The c++ heirarchy also includes the abstract nodes mentioned above. It would not make sense for these to be included, which is unclear from the c++ code, but is clearer when viewed in thewrl
context).Transform
nodes to be converted to aPose
during loading. This could disrupt this system in the case where someone restricts a field to aTransform
. There are a couple solutions (short of removing the linked code), which all have drawbacks. If I was to fix this, I would do it by interpreting aTransform
restriction as aPose
restriction. However, this would add a bit of extra clutter to the code, and given that 1) I doubt many people are restricting nodes toTransform
, and 2) this behavior would've already been present in previous versions, I've opted to just ignore it.If you feel that any of these decisions should be reconsidered, let me know, and I can update the appropriate code.
Related Issues
This pull-request fixes issue #6573.
Tasks
Documentation
PROTO Definition#field-value-restriction