Awesome
Spatial hashing for Unity using ECS
A spatial hash is one way of indexing objects in space. This package allows you to indexing struct manually or automatically (via IComponentData) with high speed
Requirement
- Unity 2022.2.20
- Package Entities 1.0.8
How to add to your project
- Open manifest.json at %RepertoryPath%/Packages
- Add
"com.lennethproduction.spatialhashing": "https://github.com/Sylmerria/Spatial-Hashing.git"
in dependencies section
How to start
##Manually
- Implement ISpatialHashingItem on a struct
- Allocate a SpatialHash of this struct
- Use it
##Automatically
- Implement ISpatialHashingItem on a IComponentData struct
- Implement a IComponentData struct to warn the system when an entity is dirty, typically a flag or an enablable component
- Implement a child class inheritant SpatialHashingSystem (T is 1. component, TY will be HMH.ECS.SpatialHashing.SpatialHashingMirror (or similar), TZ will be 2. component
- Add that before the child class (See unit test to concrete example)
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.IncreaseSpatialHashSizeJob))]
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.AddSpatialHashingJob))]
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.AddSpatialHashingEndJob))]
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.UpdateSpatialHashingRemoveFastJob))]
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.UpdateSpatialHashingAddFastJob))]
[assembly: RegisterGenericJobType(typeof({CHILDCLASSTYPE}.RemoveSpatialHashingJob))]
- good to go