-
Notifications
You must be signed in to change notification settings - Fork 80
hashCode for Vector3 etc do not work well #198
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
Comments
Please provide a pull request with unit tests. |
Is this fixed by the fix for dart-lang/sdk#35116? |
@john |
@robertmuth There have been changes in the hashCode of numbers. Can you verify that this is still a problem? |
I just tracked this down for Vector3. We have class Vector3 implements Vector { @OverRide elsewhere we have import 'hash.dart' as quiver; where hash.dart is this file: The code for hashObjects is a functional programmers dream, incomprehensible, |
@robertmuth |
The sad part is that I do not remember where I encountered it anymore. But if hash of Vector3(0.1, 0.1, 0.1) != hash of Vector3(0.2, 0.2, 0.2) BTW: I see now the "i.hashCode" part in hashObjects so yeah there is no |
I did some spot checking and the problem is gone. |
Thanks! |
If two vectors are close to zero they will map to "0" in the current hashCode implementation.
A better approach would be something like this:
int hashVector3(VM.Vector3 v) {
int h = 0;
for (int i in v.storage.buffer.asInt32List()) {
h ^= i;
}
return h;
}
The text was updated successfully, but these errors were encountered: