分批更新

This commit is contained in:
codeboss 2025-10-14 01:24:01 +08:00
parent 4f511a2a5d
commit 25f73007f8
1 changed files with 6 additions and 2 deletions

View File

@ -123,7 +123,8 @@ void MapPresent::paintEvent(QPaintEvent* ev)
if (_updated_index_list.size()) {
QPainter pic_painter(&_paint_buffer);
for (auto unit_idx : _updated_index_list) {
const int update_batch_count = 1200;
for (auto unit_idx : _updated_index_list.mid(0, update_batch_count)) {
pic_painter.save();
auto opt = _visible_units[unit_idx];
@ -147,7 +148,10 @@ void MapPresent::paintEvent(QPaintEvent* ev)
pic_painter.restore();
}
_updated_index_list.clear();
_updated_index_list = _updated_index_list.mid(update_batch_count);
if (_updated_index_list.size()) {
this->update();
}
}
QPainter widget_painter(this);