diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp index b1619af..177637b 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp @@ -330,7 +330,7 @@ void WorldEditorImGui::handleMouseSelection(float const fbPaneScale) noexcept { if (io.MouseDown[0]) { auto const fbPos = world::fbPos(ox::Vec2{io.MousePos}); auto const startSel = io.MouseClicked[0] && ImGui::IsItemHovered(); - auto const scaledViewSz = static_cast(m_view.drawSize()) * fbPaneScale; + auto const scaledViewSz = ox::Vec2{m_view.drawSize()} * fbPaneScale; m_selTracker.updateCursorPoint(fbPtToTileAddr(fbPos, scaledViewSz), startSel); if (m_selTracker.selectionOngoing()) { m_view.setSelection(m_selTracker.selection()); @@ -351,7 +351,7 @@ ox::Error WorldEditorImGui::handleDrop(float const fbPaneScale) noexcept { auto const viewSz = m_view.drawSize(); auto const tileAddr = fbPtToTileAddr( fbPos, - ox::Vec2{ + { static_cast(viewSz.width) * fbPaneScale, static_cast(viewSz.height) * fbPaneScale}); if (tileAddr.x < m_doc.columns && tileAddr.y < m_doc.rows) { diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp index cdeb30e..008f50a 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.hpp @@ -48,7 +48,7 @@ class WorldEditorImGui: public studio::Editor { } m_sizeEditor; public: - WorldEditorImGui(studio::StudioContext &ctx, ox::StringParam path); + WorldEditorImGui(studio::StudioContext &sctx, ox::StringParam path); void draw(studio::StudioContext&) noexcept final; diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.cpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.cpp index 0209e67..04735d9 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.cpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.cpp @@ -10,9 +10,9 @@ namespace jasper::world { WorldEditorView::WorldEditorView(studio::StudioContext &sctx, WorldStatic const&worldStatic): m_sctx{sctx}, - m_cctx{ncore::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()}, + m_nctx{ncore::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()}, m_worldStatic{worldStatic}, - m_world{*m_cctx, m_worldStatic} {} + m_world{*m_nctx, m_worldStatic} {} ox::Error WorldEditorView::setupTile( uint32_t const lyr, @@ -51,7 +51,7 @@ void WorldEditorView::draw(ox::Size const&targetSz) noexcept { turbine::setRefreshWithin(m_sctx.tctx, wakeUp.value); } } - ncore::gl::draw(*m_cctx, m_scale); + ncore::gl::draw(*m_nctx, m_scale); m_highlighter.draw(); } @@ -79,32 +79,4 @@ ox::Size WorldEditorView::drawSize() const noexcept { return ncore::gl::drawSize(m_scale); } -void WorldEditorView::setPixelBufferObject( - unsigned vertexRow, - float x, float y, - bool const selected, - float *vbo, - GLuint *ebo) const noexcept { - auto constexpr xmod = static_cast(ncore::TileWidth) / 240.f * 4; - auto constexpr ymod = static_cast(ncore::TileHeight) / 160.f * 4; - x *= xmod; - y *= -ymod; - x -= 1.0f; - y += 1.0f - ymod; - auto const selection = 1.f * static_cast(selected); - // don't worry, these memcpys gets optimized to something much more ideal - std::array const vertices{ - x, y, selection, // bottom left - x + xmod, y, selection, // bottom right - x + xmod, y + ymod, selection, // top right - x, y + ymod, selection, // top left - }; - memcpy(vbo, vertices.data(), sizeof(vertices)); - ox::Array const elms{ - vertexRow + 0, vertexRow + 1, vertexRow + 2, - vertexRow + 2, vertexRow + 3, vertexRow + 0, - }; - memcpy(ebo, elms.data(), sizeof(elms)); -} - } diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.hpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.hpp index 4fe8ce9..15d31f7 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.hpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditorview.hpp @@ -23,7 +23,7 @@ class WorldEditorView: public ox::SignalHandler { private: studio::StudioContext &m_sctx; - ncore::ContextUPtr m_cctx; + ncore::ContextUPtr m_nctx; WorldStatic const&m_worldStatic; int m_columns{}, m_rows{}; World m_world; @@ -63,14 +63,6 @@ class WorldEditorView: public ox::SignalHandler { [[nodiscard]] ox::Size drawSize() const noexcept; - private: - void setPixelBufferObject( - unsigned vertexRow, - float x, float y, - bool selected, - float *vbo, - GLuint *ebo) const noexcept; - }; } diff --git a/src/jasper/modules/world/src/worlddoc.cpp b/src/jasper/modules/world/src/worlddoc.cpp index c48271e..5e2dde0 100644 --- a/src/jasper/modules/world/src/worlddoc.cpp +++ b/src/jasper/modules/world/src/worlddoc.cpp @@ -6,15 +6,6 @@ namespace jasper::world { -ObjectSetEntry const*objSetEntry(WorldDoc const&doc, size_t id) noexcept { - for (auto const&e : doc.objSets) { - if (e.id == id) { - return &e; - } - } - return nullptr; -} - void resize(WorldDoc &doc, ox::Size const&sz) noexcept { doc.columns = sz.width; doc.rows = sz.height;