bevyengine / bevyengine/bevy

Indexes: look up entities by the value of their components

Open
#4,513 2 comments 24 reactions 0 assignees View on GitHub
A-ECS C-Feature S-Needs-Design-Doc
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

An "index" is a way to quickly find entries based on their value.
In the context of an ECS, indexes would let us e.g. "find all entities with components of this enum value", identify all entities inside a spatial region using a quadtree on `Transform`, quickly look up entities by their `Name`, or filter entities to find all components whose value lies within a range.

## What solution would you like?

Provide a native, efficient, fool-proof indexing solution.
Ideally, this should be user-extensible to account for other forms of acceleration data-structure.
This will be naturally coupled with change detection to ensure efficient updating.

The design of this is rather challenging, and requires a full RFC.

## What alternative(s) have you considered?

Linear time search will always work... slowly. Parallel query tools will help though.

Users can hand-roll this themselves right now, using a resource and `Query::get`. This is not particularly ergonomic, requires writing a lot of boilerplate, forces users to duplicate the API work for each project, and forces them to reckon with the perils of synchronization alone.

## Additional context

May be useful for #3742. Would be useful for #1470. #1205 discusses some of the challenges and possible designs for data synchronization.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.