a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit 7b5566daf81467b540d8d7b4280ce33400338ca7
parent ae068a9ad665bbdb451b6f4665cd232de774908a
Author: amin <dev@aminmesbah.com>
Date:   Mon,  6 May 2019 01:47:53 +0000

Actually interleave bits

FossilOrigin-Name: 849bd91295169ff43a2d0abd34e129dc3a49aa0832b56734213a6d8a342783bd
Diffstat:
Msrc/world.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/world.c b/src/world.c @@ -50,7 +50,7 @@ internal u32 world_index_hash(v2i index) // TODO: profile this for (u32 i = 0; i < sizeof(u32); i++) { - morton_code |= (low_x & 1u << 0) << 0 | (low_y & 1u << 0) << (0 + 1); + morton_code |= (low_x & 1u << i) << i | (low_y & 1u << i) << (i + 1); } // NOTE(amin): We're not really after any of the specific cool things about // morton codes. I just picked a hash function that seemed sensible given @@ -119,6 +119,7 @@ internal struct WorldChunk* world_chunk_get_or_create(struct World *world, v2i c internal size_t world_room_get_index_within_chunk(v2i room_i) { + static_assert(-1 == ~0, "implementation doesn't use two's complement"); v2u room_i_lower_bits = { room_i.x & CHUNK_MASK_FOR_INTERNAL_ROOM_INDEX, room_i.y & CHUNK_MASK_FOR_INTERNAL_ROOM_INDEX,