summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-26 00:16:10 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-26 00:16:10 +0100
commit50273c040e605b6dbee3389c0c2adce2b8d85701 (patch)
tree2fc25c2acbad8f03e7cf25f02dc2a3ac70e981ec
parentd4f254dc95a7e103e593f7f7af508de3f9137a10 (diff)
a
-rw-r--r--scenery/scenery.json8
-rw-r--r--src/anim-atlas.cpp6
-rw-r--r--src/character.cpp2
-rw-r--r--src/chunk-render.cpp13
-rw-r--r--src/entity.cpp6
5 files changed, 16 insertions, 19 deletions
diff --git a/scenery/scenery.json b/scenery/scenery.json
index 807e143e..270674a3 100644
--- a/scenery/scenery.json
+++ b/scenery/scenery.json
@@ -54,8 +54,8 @@
"name": "shelf4",
"type": "generic",
"atlas-name": "furniture/shelf4",
- "bbox-offset": "0 x -4",
- "bbox-size": "107 x 53"
+ "bbox-offset": "4 x 0",
+ "bbox-size": "107 x 64"
},
{
"name": "shelf6",
@@ -76,8 +76,8 @@
"name": "table1",
"type": "generic",
"atlas-name": "furniture/table1",
- "bbox-offset": "-4 x 0",
- "bbox-size": "70 x 96"
+ "bbox-offset": "0 x 0",
+ "bbox-size": "77 x 98"
},
{
"name": "table4",
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp
index f5370cb5..54c12077 100644
--- a/src/anim-atlas.cpp
+++ b/src/anim-atlas.cpp
@@ -112,9 +112,9 @@ auto anim_atlas::frame_quad(const Vector3& center, rotation r, size_t i) const n
{
enum : size_t { x, y, z };
const auto f = frame(r, i);
- const auto gx = (float)f.ground[x]*.5f, gy = (float)f.ground[y]*.5f;
- const auto size = Vector2d(f.size);
- const auto sx = (float)size[x]*.5f, sy = (float)size[y]*.5f;
+ const auto gx = f.ground[x]*.5f, gy = f.ground[y]*.5f;
+ const auto size = Vector2(f.size);
+ const auto sx = size[x]*.5f, sy = size[y]*.5f;
const auto bottom_right = tile_shader::unproject({ sx - gx, sy - gy }),
top_right = tile_shader::unproject({ sx - gx, - gy }),
bottom_left = tile_shader::unproject({ - gx, sy - gy }),
diff --git a/src/character.cpp b/src/character.cpp
index 5a021681..4812c1f6 100644
--- a/src/character.cpp
+++ b/src/character.cpp
@@ -133,7 +133,7 @@ Vector2 character::depth_offset() const { return {}; }
Vector2 character::ordinal_offset(Vector2b offset) const
{
(void)offset;
- return {};
+ return Vector2(offset);
}
bool character::update(size_t i, float dt)
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index 9d7787e3..be3d64c4 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -136,13 +136,10 @@ auto chunk::ensure_scenery_mesh(Array<draw_entity>& array) noexcept -> scenery_m
const auto size = _entities.size();
- {
- ensure_scenery_draw_array(array);
- for (auto i = 0uz; const auto& e : _entities)
- array[i++] = { e.get(), e->ordinal() };
- std::sort(array.begin(), array.begin() + size, entity_ord_lessp);
- //do { Debug{} << "scenery-mesh: sorting" << size; fflush(stdout); } while (false);
- }
+ ensure_scenery_draw_array(array);
+ for (auto i = 0uz; const auto& e : _entities)
+ array[i++] = { e.get(), e->ordinal() };
+ std::sort(array.begin(), array.begin() + size, entity_ord_lessp);
const auto es = ArrayView<draw_entity>{array, size};
@@ -164,7 +161,7 @@ auto chunk::ensure_scenery_mesh(Array<draw_entity>& array) noexcept -> scenery_m
for (const auto& [e, ord] : es)
{
- if (e->atlas->info().fps > 0)
+ if (e->is_dynamic())
continue;
const auto i = scenery_indexes.size();
diff --git a/src/entity.cpp b/src/entity.cpp
index e0c060ff..b0d12d12 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -4,6 +4,7 @@
#include "anim-atlas.hpp"
#include "src/RTree-search.hpp"
#include "compat/exception.hpp"
+#include "shaders/tile.hpp"
#include <cmath>
#include <algorithm>
@@ -54,10 +55,9 @@ float entity::ordinal() const
float entity::ordinal(local_coords xy, Vector2b offset, Vector2s z_offset) const
{
constexpr auto inv_tile_size = 1.f/TILE_SIZE2;
- constexpr float width = TILE_MAX_DIM+1;
auto offset_ = ordinal_offset(offset);
- auto vec = Vector2(xy) + offset_*inv_tile_size + Vector2(z_offset)*inv_tile_size;
- return vec[1]*width + vec[0];
+ auto vec = Vector2(xy) + offset_*inv_tile_size;
+ return vec[0] + vec[1] + Vector2(z_offset).sum();
}
struct chunk& entity::chunk() const