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...
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

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

Rubik's cube made with bevy engine.
Rubik's cube made with bevy engine.

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

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

Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

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 simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

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
Attach Bevy's Handles/Entities statically to Types.

Easily attach bevy's Handles/Entities statically to types on startup and get them in any system, without using Resources. It's just a little less clut

Dekirisu 6 Sep 4, 2023
Bevy Entities are nice. Objects are better!

?? Moonshine Object An extension to Bevy which provides an ergonomic interface for managing complex Entity hierarchies. Entities are nice. Objects are

null 7 May 7, 2024
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
Random utility stuff for bevy for my personal use. You're welcome to use it, too, if you like.

bevy_cleancut Random utility stuff for bevy for my personal use. You're welcome to use it, too, if you like. Stuff It's all in the prelude: use bevy_c

Nathan Stocks 3 Aug 15, 2024
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