Skip to content

Commit

Permalink
Ensure sector polygons are always created when opening a map
Browse files Browse the repository at this point in the history
For some reason this was only happening on linux, but it would draw the map and init sector polygons before any sides were loaded (so no sectors had any connected side/line info).

Now we don't draw the map until it's fully loaded, and also reset sector polygon info when running the 'building sector polygons' step on map open
  • Loading branch information
sirjuddington committed Jan 28, 2025
1 parent 49fb5cd commit 4afaf7d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/MapEditor/Renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,13 @@ void Renderer::drawAnimations(gl::draw2d::Context& dc) const
// -----------------------------------------------------------------------------
void Renderer::drawMap2d(draw2d::Context& dc) const
{
if (!context_->map().isOpen())
{
// Map isn't open, just draw the grid
drawGrid(dc);
return;
}

auto mouse_state = context_->input().mouseState();

// Draw flats if needed
Expand Down
1 change: 1 addition & 0 deletions src/SLADEMap/MapObjectList/SectorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void SectorList::initPolygons() const
for (unsigned i = 0; i < count_; ++i)
{
ui::setSplashProgress(i, count_);
objects_[i]->resetPolygon();
objects_[i]->polygonVertices();
}
ui::setSplashProgress(1.0f);
Expand Down
3 changes: 3 additions & 0 deletions src/SLADEMap/SLADEMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ bool SLADEMap::readMap(const MapDesc& map)
recomputeSpecials();

opened_time_ = app::runTimer() + 10;
is_open_ = true;

return ok;
}
Expand All @@ -278,6 +279,8 @@ void SLADEMap::clearMap()
for (auto& entry : udmf_extra_entries_)
delete entry;
udmf_extra_entries_.clear();

is_open_ = false;
}

// -----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/SLADEMap/SLADEMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SLADEMap
long geometryUpdated() const { return geometry_updated_; }
long thingsUpdated() const { return things_updated_; }
const MapObjectCollection& mapData() const { return data_; }
bool isOpen() const { return is_open_; }

void setGeometryUpdated();
void setThingsUpdated();
Expand Down Expand Up @@ -155,6 +156,7 @@ class SLADEMap
MapFormat current_format_;
long opened_time_ = 0;
unique_ptr<MapSpecials> map_specials_;
bool is_open_ = false;

vector<ArchiveEntry*> udmf_extra_entries_; // UDMF Extras

Expand Down

0 comments on commit 4afaf7d

Please sign in to comment.