Merge pull request #3218 from akortunov/groundcover_deleted

Support deleted CellRefs in groundcover
pull/3206/head
Bret Curtis 3 years ago committed by GitHub
commit ca64d7bc18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -235,6 +235,8 @@
Bug #6043: Actor can have torch missing when torch animation is played
Bug #6047: Mouse bindings can be triggered during save loading
Bug #6136: Game freezes when NPCs try to open doors that are about to be closed
Bug #6142: Groundcover plugins change cells flags
Bug #6276: Deleted groundcover instances are not deleted in game
Bug #6294: Game crashes with empty pathgrid
Feature #390: 3rd person look "over the shoulder"
Feature #832: OpenMW-CS: Handle deleted references

@ -181,6 +181,8 @@ namespace MWRender
void Groundcover::collectInstances(InstanceMap& instances, float size, const osg::Vec2f& center)
{
if (mDensity <=0.f) return;
const MWWorld::ESMStore& worldStore = MWBase::Environment::get().getWorld()->getStore();
osg::Vec2f minBound = (center - osg::Vec2f(size/2.f, size/2.f));
osg::Vec2f maxBound = (center + osg::Vec2f(size/2.f, size/2.f));
@ -195,6 +197,7 @@ namespace MWRender
if (!cell) continue;
calculator.reset();
std::map<ESM::RefNum, ESM::CellRef> refs;
for (size_t i=0; i<cell->mContextList.size(); ++i)
{
unsigned int index = cell->mContextList[i].index;
@ -206,18 +209,21 @@ namespace MWRender
bool deleted = false;
while(cell->getNextRef(esm[index], ref, deleted))
{
if (deleted) continue;
if (!calculator.isInstanceEnabled()) continue;
if (!isInChunkBorders(ref, minBound, maxBound)) continue;
std::string model = getGroundcoverModel(ref.mRefID, mGroundcoverStore, worldStore);
if (model.empty()) continue;
model = "meshes/" + model;
if (!deleted && refs.find(ref.mRefNum) == refs.end() && !calculator.isInstanceEnabled()) deleted = true;
if (!deleted && !isInChunkBorders(ref, minBound, maxBound)) deleted = true;
instances[model].emplace_back(std::move(ref));
if (deleted) { refs.erase(ref.mRefNum); continue; }
refs[ref.mRefNum] = std::move(ref);
}
}
for (auto& pair : refs)
{
ESM::CellRef& ref = pair.second;
const std::string& model = getGroundcoverModel(ref.mRefID, mGroundcoverStore, worldStore);
if (!model.empty())
instances["meshes\\" + model].emplace_back(std::move(ref));
}
}
}
}

Loading…
Cancel
Save