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

Hashing algorithm is slow #2

Open
gamemachine opened this issue May 6, 2018 · 1 comment
Open

Hashing algorithm is slow #2

gamemachine opened this issue May 6, 2018 · 1 comment

Comments

@gamemachine
Copy link

Performance can be greatly increased here. I just pulled a few lines of C# code here from my own implementation, it is based on http://www.cs.ucf.edu/~jmesit/publications/scsc%202005.pdf

ConvFactor = 1.0f / CellSize;
Width = (int)(Max / CellSize);

int Hash(float x, float z)
{
     return (int)((x * ConvFactor)) + (int)((z * ConvFactor)) * Width;
}
@gamemachine
Copy link
Author

One thing I forgot with this algorithm. It doesn't work with negative numbers. So you need to pad the coordinates to keep them positive. I didn't even check to see if your current implementation has that same issue, might be worth checking if not already considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant