From 906f56a842c0e0e706087f80607ff6d816a23280 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 22 Jan 2024 18:55:41 +0100 Subject: w --- src/chunk-render.cpp | 2 +- src/object.cpp | 9 ++++++--- src/scenery.cpp | 5 ++++- src/world.hpp | 7 ++++++- 4 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') 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& e, global_coords pos, bool sorted); void do_kill_object(object_id id); std::shared_ptr 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(ret), pos, sorted); return ret; } + void do_make_object(const std::shared_ptr& e, global_coords pos, bool sorted); + + template std::shared_ptr make_unconnected_object(Xs&&... xs) + { + return std::shared_ptr(new T{0, operator[](chunk_coords_{}), {}, Utility::forward(xs)...}); + } template std::shared_ptr find_object(object_id id); -- cgit v1.2.3