Ray Casting Through a Spatial Hash Grid (C++ Space Arcade Game Update 2)
Автор: enigma tutorials
Загружено: 2020-01-25
Просмотров: 1720
Описание:
The tech I'm developing to cast a ray/line through my spatial hash system. The ray calculates all the spatial hash grid/voxels that it intersects. This returns a list of grid nodes. It is optimized to only return grid nodes for which there actually exists
This will be used to determine which grid nodes a projectile is potentially colliding with.
full playlist: • Spatial Hashing (C++ Space Arcade Game Upd...
Recorded 06-18-19
0:00 projectile model
0:55 test firing projectile in game
1:49 framerate hitch space skipping issue
2:48 spatial hash line trace test bed
My spatial hash grid has the ability to look up collision shapes within a given spatial hash cell.
But I did not really have the ability to easily query a line of individual cells.
If I wanted to trace a line through the spatial hash, I would need a shape encompassed the entire line.
This was extremely wasteful, as it would include a lot of insignificant cells (imagine a big box around the line trace).
So I wrote code that determines which cells the line passes through.
I can then run a special query only for those cells, which is much faster than a large box overlap.
The goal of this this ray casting system is assist projectiles.
Since projectiles are moving very fast, there is the potential that they may skip space if there is a large delta time.
But I can determine the line representing the projectile's movement since the last frame.
I can use this line to figure out which cells it intersects, and query those cells to see if any ships are within that portion of the grid.
If this line then also intersects any shapes contained within a cell, then it should process that as a collision.
This game is open source and not commercial.
Current libraries:
glm math library
glfw for window abstraction
glad for opengl function mapping
assimp for parsing model files
stbimage for image loading
imgui for debug GUI
nlohmann/json for json parsing and serializing in c++
rendering API is OpenGL 3.3
Update:
game released, play here: https://enigma-tutorials.itch.io/spac...
Disclaimer:
Opinions are my own and not associated with my employer.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: