From 3e7961645a50bab1c3f08eaa2bf23993c33554b9 Mon Sep 17 00:00:00 2001 From: T1ti <40864460+T1ti@users.noreply.github.com> Date: Mon, 15 Sep 2025 23:27:08 +0200 Subject: [PATCH] fix previous unfinished merge conflicts --- src/math/ray.cpp | 15 +++---- src/math/ray.hpp | 10 ++++- src/noggit/AsyncLoader.cpp | 1 + src/noggit/MapTile.cpp | 18 ++++---- src/noggit/WMOInstance.cpp | 11 ++++- src/noggit/WMOInstance.h | 63 +++------------------------- src/noggit/rendering/WorldRender.cpp | 6 +-- 7 files changed, 44 insertions(+), 80 deletions(-) diff --git a/src/math/ray.cpp b/src/math/ray.cpp index 0dd6d938..e65c88d3 100755 --- a/src/math/ray.cpp +++ b/src/math/ray.cpp @@ -32,25 +32,26 @@ namespace math { assert(false); } + // pre compute inverted direction + _inverted_direction.x = (_direction.x != 0.0f) ? 1.0f / _direction.x : std::numeric_limits::max(); + _inverted_direction.y = (_direction.y != 0.0f) ? 1.0f / _direction.y : std::numeric_limits::max(); + _inverted_direction.z = (_direction.z != 0.0f) ? 1.0f / _direction.z : std::numeric_limits::max(); + } std::optional ray::intersect_bounds (glm::vec3 const& min, glm::vec3 const& max) const noexcept { -<<<<<<< HEAD + float tmin (std::numeric_limits::lowest()); float tmax (std::numeric_limits::max()); if (_direction.x != 0.0f) { - float tx1 = (min.x - _origin.x) * _inverted_direction.x; - float tx2 = (max.x - _origin.x) * _inverted_direction.x; + const float tx1 = (min.x - _origin.x) * _inverted_direction.x; + const float tx2 = (max.x - _origin.x) * _inverted_direction.x; // float const tx1((min.x - _origin.x) / _direction.x); // float const tx2((max.x - _origin.x) / _direction.x); -======= - float tmin(std::numeric_limits::lowest()); - float tmax(std::numeric_limits::max()); ->>>>>>> origin/ground_effects_editor tmin = std::max(tmin, std::min(tx1, tx2)); tmax = std::min(tmax, std::max(tx1, tx2)); diff --git a/src/math/ray.hpp b/src/math/ray.hpp index 7ac631e5..7d085c7c 100755 --- a/src/math/ray.hpp +++ b/src/math/ray.hpp @@ -40,8 +40,14 @@ namespace math return _origin + _direction * distance; } + glm::vec3 const origin() const + { + return _origin; + } + private: - glm::vec3 _origin; - glm::vec3 _direction; + glm::vec3 const _origin; + glm::vec3 const _direction; + glm::vec3 _inverted_direction; }; } diff --git a/src/noggit/AsyncLoader.cpp b/src/noggit/AsyncLoader.cpp index 62b9636f..186290c2 100755 --- a/src/noggit/AsyncLoader.cpp +++ b/src/noggit/AsyncLoader.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 6ca0e127..67cc9afb 100644 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1614,27 +1614,27 @@ void MapTile::setVertexColorImage(QImage const& baseimage, int mode, bool tiledE case 1: // Add { auto color = image.pixelColor((k * 16) + x, (l * 16) + y); - colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x + color.redF() * 2.f)); - colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y + color.greenF() * 2.f)); - colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z + color.blueF() * 2.f)); + colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x + static_cast(color.redF() * 2.f))); + colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y + static_cast(color.greenF() * 2.f))); + colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z + static_cast(color.blueF() * 2.f))); break; } case 2: // Subtract { auto color = image.pixelColor((k * 16) + x, (l * 16) + y); - colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x - color.redF() * 2.f)); - colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y - color.greenF() * 2.f)); - colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z - color.blueF() * 2.f)); + colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x - static_cast(color.redF() * 2.f))); + colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y - static_cast(color.greenF() * 2.f))); + colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z - static_cast(color.blueF() * 2.f))); break; } case 3: // Multiply { auto color = image.pixelColor((k * 16) + x, (l * 16) + y); - colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x * color.redF() * 2.f)); - colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y * color.greenF() * 2.f)); - colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z * color.blueF() * 2.f)); + colors[idx].x = std::min(2.0f, std::max(0.0f, colors[idx].x * static_cast(color.redF() * 2.f))); + colors[idx].y = std::min(2.0f, std::max(0.0f, colors[idx].y * static_cast(color.greenF() * 2.f))); + colors[idx].z = std::min(2.0f, std::max(0.0f, colors[idx].z * static_cast(color.blueF() * 2.f))); break; } } diff --git a/src/noggit/WMOInstance.cpp b/src/noggit/WMOInstance.cpp index 93bf3b43..bc1fd535 100755 --- a/src/noggit/WMOInstance.cpp +++ b/src/noggit/WMOInstance.cpp @@ -76,7 +76,11 @@ WMOInstance::WMOInstance(WMOInstance&& other) noexcept , _doodadset(other._doodadset) , _doodads_per_group(other._doodads_per_group) , _need_doodadset_update(other._need_doodadset_update) - , _need_recalc_extents(other._need_recalc_extents) + , _update_group_extents(other._update_group_extents) + // , hasLowResModel(other.hasLowResModel) + , render_low_res(other.render_low_res) + , lowResInstance(other.lowResInstance) + , lowResWmo(other.lowResWmo) { std::swap(extents, other.extents); pos = other.pos; @@ -107,6 +111,11 @@ WMOInstance& WMOInstance::operator= (WMOInstance&& other) noexcept std::swap(_transform_mat_inverted, other._transform_mat_inverted); std::swap(_context, other._context); std::swap(_need_recalc_extents, other._need_recalc_extents); + std::swap(_update_group_extents, other._update_group_extents); + // std::swap(hasLowResModel, other.hasLowResModel); + std::swap(render_low_res, other.render_low_res); + std::swap(lowResInstance, other.lowResInstance); + std::swap(lowResWmo, other.lowResWmo); return *this; } diff --git a/src/noggit/WMOInstance.h b/src/noggit/WMOInstance.h index 3cf03278..3a7ae346 100755 --- a/src/noggit/WMOInstance.h +++ b/src/noggit/WMOInstance.h @@ -28,12 +28,11 @@ public: bool render_low_res = false; - uint16_t doodadset() const { return _doodadset; }; + uint16_t doodadset() const; void change_doodadset(uint16_t doodad_set); [[nodiscard]] std::map> const& getGroupExtents(); - std::map> const& getGroupExtents() { _update_group_extents = true; ensureExtents(); return group_extents; } private: void update_doodads(); @@ -53,63 +52,12 @@ public: WMOInstance(WMOInstance const& other) = default; WMOInstance& operator=(WMOInstance const& other) = default; - WMOInstance (WMOInstance&& other) - : SceneObject(other._type, other._context) - , wmo (std::move (other.wmo)) - , group_extents(other.group_extents) - , mFlags (other.mFlags) - , mNameset (other.mNameset) - , _doodadset (other._doodadset) - , _doodads_per_group(other._doodads_per_group) - , _need_doodadset_update(other._need_doodadset_update) - WMOInstance (WMOInstance&& other) noexcept; - , _update_group_extents(other._update_group_extents) - // , hasLowResModel(other.hasLowResModel) - , render_low_res(other.render_low_res) - , lowResInstance(other.lowResInstance) - , lowResWmo(other.lowResWmo) - { - std::swap (extents, other.extents); - pos = other.pos; - scale = other.scale; - dir = other.dir; - _context = other._context; - uid = other.uid; - - _transform_mat = other._transform_mat; - _transform_mat_inverted = other._transform_mat_inverted; - } + WMOInstance(WMOInstance&& other) noexcept; WMOInstance& operator= (WMOInstance&& other) noexcept; - WMOInstance& operator= (WMOInstance&& other) - { - std::swap(wmo, other.wmo); - std::swap(pos, other.pos); - std::swap(extents, other.extents); - std::swap(group_extents, other.group_extents); - std::swap(dir, other.dir); - std::swap(uid, other.uid); - std::swap(scale, other.scale); - std::swap(mFlags, other.mFlags); - std::swap(mNameset, other.mNameset); - std::swap(_doodadset, other._doodadset); - std::swap(_doodads_per_group, other._doodads_per_group); - std::swap(_need_doodadset_update, other._need_doodadset_update); - std::swap(_transform_mat, other._transform_mat); - std::swap(_transform_mat_inverted, other._transform_mat_inverted); - std::swap(_context, other._context); - std::swap(_need_recalc_extents, other._need_recalc_extents); - std::swap(_update_group_extents, other._update_group_extents); - // std::swap(hasLowResModel, other.hasLowResModel); - std::swap(render_low_res, other.render_low_res); - std::swap(lowResInstance, other.lowResInstance); - std::swap(lowResWmo, other.lowResWmo); - return *this; - } + void draw ( OpenGL::Scoped::use_program& wmo_shader - , glm::mat4x4 const& model_view - , glm::mat4x4 const& projection , const glm::mat4x4 const& model_view , const glm::mat4x4 const& projection , math::frustum const& frustum @@ -134,16 +82,15 @@ public: std::array const& getExtents() override; // axis aligned std::array const& getLocalExtents() const; std::array getBoundingBox() override; // not axis aligned - inline bool extentsDirty() const { return _need_recalc_extents || !wmo->finishedLoading(); }; + bool extentsDirty() const;; void recalcExtents() override; void change_nameset(uint16_t name_set); void ensureExtents() override; - bool finishedLoading() override { return wmo->finishedLoading(); }; + bool finishedLoading() override;; virtual void updateDetails(Noggit::Ui::detail_infos* detail_widget) override; [[nodiscard]] AsyncObject* instance_model() const override;; - AsyncObject* instance_model() const override { return wmo.get(); }; std::vector get_visible_doodads( math::frustum const& frustum , float const& cull_distance diff --git a/src/noggit/rendering/WorldRender.cpp b/src/noggit/rendering/WorldRender.cpp index 028dd038..16f17349 100755 --- a/src/noggit/rendering/WorldRender.cpp +++ b/src/noggit/rendering/WorldRender.cpp @@ -1336,7 +1336,7 @@ void WorldRender::draw (glm::mat4x4 const& model_view } // Draw Sky/Light spheres - gl.cullFace(GL_FRONT); + glCullFace(GL_FRONT); if (!render_settings.draw_only_inside_light_sphere) { for (Sky const& sky : skies()->skies) @@ -1375,7 +1375,7 @@ void WorldRender::draw (glm::mat4x4 const& model_view } // now draw the current light (light that we're inside of) - gl.cullFace(GL_BACK); + glCullFace(GL_BACK); for (Sky const& sky : skies()->skies) { if (sky.global) @@ -2114,7 +2114,7 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings* , 0.f, 0.f, 0.f, 1.f )); - gl.finish(); + glFinish(); drawMinimap(mTile , look_at