An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities

Overview

bevy_sparse_grid_2d

MIT/Apache 2.0

An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities.

Personally, I'm using it for simple stupid collision broad phase in a couple of my projects.

Usage

use bevy::{
    utils::HashSet,
    prelude::*,
    math::vec2,
};
use bevy_sparse_grid_2d::{Aabb, SparseGrid2d};
const TILE_SIZE: usize = 1; // how wide each cell is

let mut db = SparseGrid2d::<TILE_SIZE>::default();
let e1 = Entity::from_raw(1);
let e2 = Entity::from_raw(2);
db.insert_point(vec2(0.5, 0.5), e1);
db.insert_point(vec2(0.499, 0.501), e2);

// query a single point
let matches: HashSet<_> = db.point_iter(vec2(0.499, 0.501)).collect();
assert!(matches.contains(&e1));
assert!(matches.contains(&e2));
assert_eq!(matches.len(), 2);

// query an aabb
let matches = db.query_aabb(Aabb {
    min: vec2(0.0, 0.0),
    max: vec2(1.0, 1.0)
});
assert!(matches.contains(&e1));
assert!(matches.contains(&e2));
assert_eq!(matches.len(), 2);

See tests in lib.rs

Bevy Version Support

The main branch targets the latest bevy release.

bevy bevy_sparse_grid_2d
0.9 main

License

MIT or Apache-2.0

Contributions

PRs welcome!

You might also like...
3D wechat jump-jump game made with bevy engine.
3D wechat jump-jump game made with bevy engine.

English jump-jump 微信跳一跳游戏 角色跳跃动画 角色和平台蓄力效果 角色蓄力粒子特效 角色摔落效果 相机跟随 自动生成平台 飘分效果 分数统计 游戏UI 游戏音效 WASM支持 在线游玩:点这里(电脑版Chrome/Firefox/Edge打开) 运行 本地运行 cargo run

An opinionated 2D game engine for Rust

Coffee An opinionated 2D game engine for Rust focused on simplicity, explicitness, and type-safety. Coffee is in a very early stage of development. Ma

Blossom is an opinionated MUD engine written in Rust.

🌸 Blossom Blossom is an opinionated MUD engine written in Rust. This is still a VERY early work-in-progress and there will be sweeping, breaking chan

bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

A place to start when building webgl apps in Bevy. Use this to avoid writing the boilerplate.

Template Bevy project with WebGL enabled Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.to

Bevy plugin for an AssetServer that can load embedded resources, or use other AssetServers based on the path.

Bevy-Embasset Embed your asset folder inside your binary. bevy-embasset adds support for loading assets embedded into the binary. Furthermore, it can

A plugin to use the kajiya renderer with bevy

🕊️ 💡 bevy-kajiya A plugin that enables use of the kajiya renderer in bevy WARNING: This plugin is barebones and supports a limited set of features.

A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!
A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!

Bevy Wrapping Square example A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that

Releases(v0.1.0)
  • v0.1.0(Mar 7, 2023)

    What's Changed

    • Update for Bevy 0.10
    • Fix tilesize by @Vrixyz in https://github.com/johanhelsing/bevy_sparse_grid_2d/pull/2

    New Contributors

    • @Vrixyz made their first contribution in https://github.com/johanhelsing/bevy_sparse_grid_2d/pull/2

    Full Changelog: https://github.com/johanhelsing/bevy_sparse_grid_2d/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Johan Klokkhammer Helsing
Making names and taking games
Johan Klokkhammer Helsing
An opinionated, monolithic template for Bevy with cross-platform CI/CD, native + WASM launchers, and managed cross-platform deployment.

??️ Bevy Shell - Template An opinionated, monolithic template for Bevy with cross-platform CI/CD, native + WASM launchers, and managed cross-platform

Kurbos 218 Dec 30, 2022
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Work-in-Progress, opinionated game framework built on Bevy.

Bones A work-in-progress, opinionated game meta-engine built on Bevy. Under development for future use in the Jumpy game, and possibly other FishFolk

Fish Folk 9 Jan 3, 2023
Heavy - an opinionated, efficient, relatively lightweight, and tightly Lua-integrated game framework for Rust

Heavy - an opinionated, efficient, relatively lightweight, and tightly Lua-integrated game framework for Rust Slow down, upon the teeth of Orange Heav

Shea Leffler 12 Mar 18, 2022
A highly customizable snake clone made in Rust with the Bevy engine, named after the Japanese word for snake, 蛇.

Hebi ?? A highly customizable snake clone made in Rust with the Bevy engine, named after the Japanese word for snake, 蛇(へび). Configuration One of the

Elnu 79 Dec 7, 2022
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A game made for Bevy Jam #2

KPACUBO - A Bevy Template for Game Jams NOTE: This project is still WIP. It is usable but far from perfect. This project aims to provide a simple yet

Nikita Medvedev 11 Dec 8, 2022
A Serious (yet fun) Game made in Rust with Bevy

The Omega Ai Test for Brazilian Biome Image Classification PLAY A Serious (yet fun) Game made in Rust with Bevy How well do you know the Brazilian bio

Eliton Machado da Silva 2 Oct 24, 2022
Rubik's cube made with bevy engine.

English Rubik's Cube 魔方 3阶魔方 随机打乱魔方 重置魔方 鼠标拖拽魔方旋转 游戏UI 相机视角控制(缩放、移动) WASM支持 在线游玩:点这里(电脑版Chrome/Firefox/Edge打开) 运行 本地运行 cargo run WASM运行 rustup target

Night's Watch Games 4 Dec 31, 2022