Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunks, Coordinates, & Collisions #21

Open
temportalflux opened this issue Jun 28, 2020 · 0 comments
Open

Chunks, Coordinates, & Collisions #21

temportalflux opened this issue Jun 28, 2020 · 0 comments
Assignees
Labels

Comments

@temportalflux
Copy link
Owner

temportalflux commented Jun 28, 2020

Chunks

Chunks are cubes which contain TDimension^3 references to blocks and handle collisions between entities and their contents. A chunk can be defined by 1 constexpr size which is used for the width, height, and length dimensions. The number of block ids it contains is equivalent to TDimension^3 and are stored as raw ids. Each id is keyed by a Vector3UInt indicating its position within the chunk. It is possible for a chunk to have many blocks which have null or empty ids. Each chunk has a Vector3UInt coordinate within the world.

Coordinates

Because each chunk has a Vector3UInt position and a set of Vector3UInt positions within it, an entities position can be defined as its Vector3UInt chunk coordinate, its Vector3UInt block coordinate (relative to the chunk coordinate) and its Vector3/Vector<f32, 3> offset coordinate (relative to the block coordinate).

Collisions

Each chunk is responsible for running collision checks against entities.

Chunk-Spectrum

An entity is definitely not colliding with a chunk if n + 1 > c where n is a dimension of the entity's current chunk coordinate and c is the same dimension of a given chunk's coordinate. (An entity could be colliding with a chunk if it is in an adjacent chunk but on its boundary).

Broad Block-Spectrum

Assuming each chunk has a sequential fixed-sized list (i.e. an array with no empty values) which represents the block coordinates which are non-empty, an entity is definitely not colliding with a given block if n + 1 > c where nn is the largest dimension of the entity's bounding box and c is any dimension of the block's coordinate within the chunk.

Narrow Block-Spectrum

For an blocks which could be colliding from the Broad Block-Spectrum, those that actually do collide will need to run their own specific collision checks. In most cases, an entity is definitely not colliding with a block if general cube collision fails against the entity's bounds. This can use the rectangular prism collision check against the block's general coordinates. This should be the default case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant