Add support for custom picking data#23245
Conversation
kfc35
left a comment
There was a problem hiding this comment.
This is cool. I approve. I checked out the branch and the example works.
The overarching comment I have is that the example can be improved to be more beginner friendly for comprehension, since examples serve as documentation of sorts and that code is accessible for people to read. I made a bunch of smaller comments to help with that.
|
Is #23285 considered a blocker? The new example uses no |
|
@m-edlund I don’t think it’s considered a blocker. As someone who reviewed that PR, I think the author may have been mistaken. Also, I saw your message on Discord regarding this PR. Sorry others haven’t been able to review! I think after the 0.19 milestone is cut, people will have more bandwidth to consider reviewing this. I’m not sure if this will get merged because we are only focusing on merging bug fixes currently, but I’ll try bumping your message one time to see if we can get anyone else to look at the PR. Since I don’t think it would add that much complication, maybe it can be considered. |
| && self.depth == other.depth | ||
| && self.position == other.position | ||
| && self.normal == other.normal | ||
| } |
There was a problem hiding this comment.
Why doesn't this check extra? This should be documented and justified in that documentation.
It looks like PartialEq is derived for all events, I'm not sure if they are deduplicated somewhere.
There was a problem hiding this comment.
Equality would require downcasting both sides every time there is a comparison (https://users.rust-lang.org/t/how-to-compare-two-trait-objects-for-equality/88063), which feels overkill. The explanation was added in e7c410d
| /// } | ||
| /// } | ||
| /// ``` | ||
| pub trait HitDataExtra: Any + Send + Sync + fmt::Debug { |
There was a problem hiding this comment.
Should this have a name method or similar to help aid debugging / figure out what to downcast to?
There was a problem hiding this comment.
Since HitDataExtra requires Debug, devs can just print the hit data to help with debugging at runtime. So unless I'm missing something, a name function feels like it just duplicates what Debug is already doing.
alice-i-cecile
left a comment
There was a problem hiding this comment.
On board with the motivation. The prior art was really compelling, thanks! Good docs, broadly solid implementation. Fixes needed:
- the upcasting strategy needs cleanup
- I would like a unit test
- the choice of Arc is good but needs clear documentation
Other feedback is non-blocking, but I am curious about your thoughts :)
d4c67be to
94183a8
Compare
Objective
Solution
extrafield to the HitData struct which can take any Data that implements HitDataExtra. This is stored in an Arc which can be downcast with a helper function in the system that consumes the hit.Testing
Showcase
Click to view showcase
Creating custom hits:
Reading custom hits:
An example of what you can do with this