Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Sylmerria/Spatial-Hashing
Spatial hashing for Unity using ECS/DOTS
https://github.com/Sylmerria/Spatial-Hashing
dots ecs spatial-hash unity
Last synced: about 6 hours ago
JSON representation
Spatial hashing for Unity using ECS/DOTS
- Host: GitHub
- URL: https://github.com/Sylmerria/Spatial-Hashing
- Owner: Sylmerria
- License: mit
- Created: 2019-06-01T14:48:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T18:27:28.000Z (over 1 year ago)
- Last Synced: 2024-01-28T23:38:31.243Z (10 months ago)
- Topics: dots, ecs, spatial-hash, unity
- Language: C#
- Homepage:
- Size: 104 KB
- Stars: 31
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-unity3d - Spatial-Hashing - Spatial hashing for Unity using ECS/DOTS (Open Source Repositories / DOTS)
README
# 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![Spatial hashing image](https://zupimages.net/up/22/21/uw0s.png)
Source : https://www.researchgate.net/figure/Spatial-hashing-where-objects-are-mapped-into-uniformly-sized-cells_fig1_326306568
# 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
1. Implement ISpatialHashingItem on a struct
2. Allocate a SpatialHash of this struct
3. Use it##Automatically
1. Implement ISpatialHashingItem on a IComponentData struct
2. Implement a IComponentData struct to warn the system when an entity is dirty, typically a flag or an enablable component
3. Implement a child class inheritant SpatialHashingSystem (T is 1. component, TY will be HMH.ECS.SpatialHashing.SpatialHashingMirror (or similar), TZ will be 2. component
4. 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))]
5. good to go