diff --git a/src/emitter.cpp b/src/emitter.cpp index c355d31f..184924d9 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -74,9 +74,7 @@ void Emitter::TickDraw(float deltams) for (int i = 0; i < data->nparticles; i++) Scene::GetDefault()->AddTile(data->tileset, data->particles[i], - data->positions[i].x, - data->positions[i].y, - data->positions[i].z, 0); + data->positions[i], 0); } void Emitter::AddParticle(int id, vec3 pos, vec3 vel) diff --git a/src/font.cpp b/src/font.cpp index f55b23ad..782de129 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -78,8 +78,7 @@ void Font::Print(vec3i pos, char const *str) uint32_t ch = (uint8_t)*str++; if (ch != ' ') - scene->AddTile(data->tileset, ch & 255, - pos.x, pos.y, pos.z, 0); + scene->AddTile(data->tileset, ch & 255, pos, 0); pos.x += data->size.x; } diff --git a/src/layer.cpp b/src/layer.cpp index 3575e777..69447c19 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -54,8 +54,10 @@ void Layer::Render(int x, int y, int z) for (int i = 0; i < width; i++) if (data[j * width + i]) scene->AddTile(data[j * width + i], - x + i * 32, y + j * 32 - altitude, - altitude + z, orientation); + vec3i(x + i * 32, + y + j * 32 - altitude, + altitude + z), + orientation); #endif } diff --git a/src/map.cpp b/src/map.cpp index 5d6ee78b..43a53f21 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -95,7 +95,7 @@ Map::Map(char const *path) if (n == data->ntilers - 1 || id < gids[n + 1]) { - Log::Error("tilesets no longer work this way"); + Log::Error("tilesets no longer work this way\n"); //code = (data->tilesets[n] << 16) | (id - gids[n]); break; } diff --git a/src/scene.cpp b/src/scene.cpp index 8d936f6b..57e68664 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -30,7 +30,8 @@ struct Tile { TileSet *tileset; uint32_t prio; - int id, x, y, z, o; + vec3i pos; + int id, o; }; static Shader *stdshader = NULL; @@ -114,18 +115,16 @@ void Scene::Reset() SceneData::scene = NULL; } -void Scene::AddTile(TileSet *tileset, int id, int x, int y, int z, int o) +void Scene::AddTile(TileSet *tileset, int id, vec3i pos, int o) { if ((data->ntiles % 1024) == 0) data->tiles = (Tile *)realloc(data->tiles, (data->ntiles + 1024) * sizeof(Tile)); /* FIXME: this sorting only works for a 45-degree camera */ - data->tiles[data->ntiles].prio = -y - 2 * 32 * z + (o ? 0 : 32); + data->tiles[data->ntiles].prio = -pos.y - 2 * 32 * pos.z + (o ? 0 : 32); data->tiles[data->ntiles].tileset = tileset; data->tiles[data->ntiles].id = id; - data->tiles[data->ntiles].x = x; - data->tiles[data->ntiles].y = y; - data->tiles[data->ntiles].z = z; + data->tiles[data->ntiles].pos = pos; data->tiles[data->ntiles].o = o; data->ntiles++; } @@ -285,8 +284,7 @@ void Scene::Render() // XXX: rename to Blit() for (int j = i; j < n; j++) { data->tiles[i].tileset->BlitTile(data->tiles[j].id, - data->tiles[j].x, data->tiles[j].y, - data->tiles[j].z, data->tiles[j].o, + data->tiles[j].pos, data->tiles[j].o, vertex + 18 * (j - i), texture + 12 * (j - i)); } diff --git a/src/scene.h b/src/scene.h index e630eced..638b91f1 100644 --- a/src/scene.h +++ b/src/scene.h @@ -34,7 +34,7 @@ public: static Scene *GetDefault(); static void Reset(); - void AddTile(TileSet *tileset, int id, int x, int y, int z, int o); + void AddTile(TileSet *tileset, int id, vec3i pos, int o); void Render(); private: diff --git a/src/tileset.cpp b/src/tileset.cpp index 4c0081bf..c5e7a0d3 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -178,7 +178,7 @@ void TileSet::Bind() } } -void TileSet::BlitTile(uint32_t id, int x, int y, int z, int o, +void TileSet::BlitTile(uint32_t id, vec3i pos, int o, float *vertex, float *texture) { float tx = data->tx * ((id & 0xffff) % data->count.i); @@ -193,21 +193,21 @@ void TileSet::BlitTile(uint32_t id, int x, int y, int z, int o, { float tmp[10]; - *vertex++ = tmp[0] = x; - *vertex++ = tmp[1] = dilate * (y + dy); - *vertex++ = tmp[2] = dilate * (z + dz); + *vertex++ = tmp[0] = pos.x; + *vertex++ = tmp[1] = dilate * (pos.y + dy); + *vertex++ = tmp[2] = dilate * (pos.z + dz); *texture++ = tmp[3] = tx; *texture++ = tmp[4] = ty; - *vertex++ = x + dx; - *vertex++ = dilate * (y + dy); - *vertex++ = dilate * (z + dz); + *vertex++ = pos.x + dx; + *vertex++ = dilate * (pos.y + dy); + *vertex++ = dilate * (pos.z + dz); *texture++ = tx + data->tx; *texture++ = ty; - *vertex++ = tmp[5] = x + dx; - *vertex++ = tmp[6] = dilate * y; - *vertex++ = tmp[7] = dilate * z; + *vertex++ = tmp[5] = pos.x + dx; + *vertex++ = tmp[6] = dilate * pos.y; + *vertex++ = tmp[7] = dilate * pos.z; *texture++ = tmp[8] = tx + data->tx; *texture++ = tmp[9] = ty + data->ty; @@ -223,9 +223,9 @@ void TileSet::BlitTile(uint32_t id, int x, int y, int z, int o, *texture++ = tmp[8]; *texture++ = tmp[9]; - *vertex++ = x; - *vertex++ = dilate * y; - *vertex++ = dilate * z; + *vertex++ = pos.x; + *vertex++ = dilate * pos.y; + *vertex++ = dilate * pos.z; *texture++ = tx; *texture++ = ty + data->ty; } diff --git a/src/tileset.h b/src/tileset.h index 4ac39370..0c805e8b 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -44,7 +44,7 @@ public: vec2i GetCount() const; vec2i GetSize(int tileid) const; void Bind(); - void BlitTile(uint32_t id, int x, int y, int z, int o, + void BlitTile(uint32_t id, vec3i pos, int o, float *vertex, float *texture); private: