Movement.
This commit is contained in:
@ -27,8 +27,10 @@ void entitiesUpdate() {
|
||||
entitiesdataent_t *dst = &ENTITIES_DATA.entities[i];
|
||||
|
||||
// Copy position data.
|
||||
assertTrue(
|
||||
(&src->subY - &src->x) + sizeof(uint8_t) == sizeof(uint_t),
|
||||
assertMemoryRangeMatches(
|
||||
&src->x,
|
||||
&src->direction,
|
||||
sizeof(uint_t),
|
||||
"Entity data is not packed correctly any more."
|
||||
);
|
||||
memcpy(&dst->position, &src->x, sizeof(uint_t));
|
||||
|
@ -26,8 +26,8 @@ vec2 entityGetVertice(uint instanceIndex, uint indiceIndex) {
|
||||
|
||||
uint x = packedGetU8(0u, entities[instanceIndex].position);
|
||||
uint y = packedGetU8(1u, entities[instanceIndex].position);
|
||||
uint subX = packedGetU8(2u, entities[instanceIndex].position);
|
||||
uint subY = packedGetU8(3u, entities[instanceIndex].position);
|
||||
int subX = packedGetI8(2u, entities[instanceIndex].position);
|
||||
int subY = packedGetI8(3u, entities[instanceIndex].position);
|
||||
|
||||
vert.x += float(x);
|
||||
vert.y += float(y);
|
||||
|
@ -5,4 +5,9 @@
|
||||
|
||||
uint packedGetU8(uint position, uint data) {
|
||||
return (data >> (position * 8u)) & 0xFFu;
|
||||
}
|
||||
|
||||
int packedGetI8(uint position, uint data) {
|
||||
int shift = int(position * 8u);
|
||||
return int(data << (24 - shift)) >> 24;
|
||||
}
|
Reference in New Issue
Block a user