diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-22 18:55:41 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-22 18:55:41 +0100 |
commit | 906f56a842c0e0e706087f80607ff6d816a23280 (patch) | |
tree | 730ed20091649482691baeaeae753dd40c468402 /src | |
parent | 49f455887a29a2a879e330dca9e050296e617720 (diff) |
w
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk-render.cpp | 2 | ||||
-rw-r--r-- | src/object.cpp | 9 | ||||
-rw-r--r-- | src/scenery.cpp | 5 | ||||
-rw-r--r-- | src/world.hpp | 7 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp index 459f51b7..3072f472 100644 --- a/src/chunk-render.cpp +++ b/src/chunk-render.cpp @@ -57,7 +57,7 @@ auto chunk::ensure_ground_mesh() noexcept -> ground_mesh_tuple const auto& atlas = _ground->atlases[i]; const local_coords pos{i}; const auto quad = floor_quad(Vector3(pos) * TILE_SIZE, TILE_SIZE2); - const auto texcoords = atlas->texcoords_for_id(_ground->variants[i]); + const auto texcoords = atlas->texcoords_for_id(_ground->variants[i] % _ground->atlases[i]->num_tiles()); const float depth = tile_shader::depth_value(pos, tile_shader::ground_depth_offset + hack_offset); auto& v = vertexes[k]; for (auto j = 0uz; j < 4; j++) diff --git a/src/object.cpp b/src/object.cpp index 0139362c..ce3bb51f 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -55,9 +55,12 @@ object::object(object_id id, struct chunk& c, const object_proto& proto) : bbox_size{proto.bbox_size}, delta{proto.delta}, frame{proto.frame}, r{proto.r}, pass{proto.pass} { - fm_soft_assert(atlas); - fm_soft_assert(atlas->check_rotation(r)); - fm_soft_assert(frame < atlas->info().nframes); + if (id != 0) + { + fm_soft_assert(atlas); + fm_soft_assert(atlas->check_rotation(r)); + fm_soft_assert(frame < atlas->info().nframes); + } } object::~object() noexcept diff --git a/src/scenery.cpp b/src/scenery.cpp index f3a11f6d..24431a6b 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -152,7 +152,10 @@ scenery::scenery(object_id id, struct chunk& c, const scenery_proto& proto) : object{id, c, proto}, sc_type{proto.sc_type}, active{proto.active}, closing{proto.closing}, interactive{proto.interactive} { - fm_debug_assert(atlas); // todo add placeholder graphic +#ifndef FM_NO_DEBUG + if (id != 0) + fm_debug_assert(atlas); // todo add placeholder graphic +#endif } } // namespace floormat diff --git a/src/world.hpp b/src/world.hpp index 88927166..6bb85a18 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -43,7 +43,6 @@ private: explicit world(size_t capacity); - void do_make_object(const std::shared_ptr<object>& e, global_coords pos, bool sorted); void do_kill_object(object_id id); std::shared_ptr<object> find_object_(object_id id); [[noreturn]] static void throw_on_wrong_object_type(object_id id, object_type actual, object_type expected); @@ -86,6 +85,12 @@ public: do_make_object(static_pointer_cast<object>(ret), pos, sorted); return ret; } + void do_make_object(const std::shared_ptr<object>& e, global_coords pos, bool sorted); + + template<typename T, typename... Xs> std::shared_ptr<object> make_unconnected_object(Xs&&... xs) + { + return std::shared_ptr<T>(new T{0, operator[](chunk_coords_{}), {}, Utility::forward<Xs>(xs)...}); + } template<typename T = object> std::shared_ptr<T> find_object(object_id id); |