@@ -223,9 +223,11 @@ namespace plugin {
223223 data.geo_queue = std::queue<RE ::NiPointer<RE ::BSGeometry>>();
224224 recalcs_in_progress.insert_or_assign (p.first , data);
225225 }
226-
227226 auto &data = recalcs_in_progress[p.first ];
228227 if (auto actor = p.second .get ()) {
228+ if (!actor->Is3DLoaded ()) {
229+ actor->Load3D (false );
230+ }
229231 if (actor->Is3DLoaded ()) {
230232 if (auto obj = actor->Get3D1 (true )) {
231233 if (actor->Get3D1 (true ) != actor->Get3D1 (false )) {
@@ -425,18 +427,24 @@ namespace plugin {
425427 void GameEventHandler::onPostLoad () {
426428 logger::info (" onPostLoad()" );
427429 }
428-
429- class CellRecalculate : public RE ::BSTEventSink<RE ::TESCellAttachDetachEvent> {
430- RE ::BSEventNotifyControl ProcessEvent (const RE ::TESCellAttachDetachEvent *a_event,
431- RE ::BSTEventSource<RE ::TESCellAttachDetachEvent> *a_eventSource) {
432- if (a_event && a_event->reference && a_event->reference .get ()->Is3DLoaded ()) {
433- if (auto actor = a_event->reference .get ()->As <RE ::Actor>()) {
434- if (a_event->attached ==false ) {
430+ class CellRecalculate : public RE ::BSTEventSink<RE ::TESCellFullyLoadedEvent> {
431+ RE ::BSEventNotifyControl ProcessEvent (const RE ::TESCellFullyLoadedEvent *a_event,
432+ RE ::BSTEventSource<RE ::TESCellFullyLoadedEvent> *a_eventSource) {
433+ if (a_event && a_event->cell ) {
434+ a_event->cell ->ForEachReference ([](RE ::TESObjectREFR *ref) {
435+ if (auto actor = ref->As <RE ::Actor>()) {
436+ if (!actor->Is3DLoaded () == false ) {
437+ actor->Load3D (true );
438+ }
435439 if (RE::PlayerCharacter::GetSingleton ()) {
440+
436441 AddActorToRecalculate (actor);
437442 }
438- }
439- }
443+
444+ }
445+ return RE ::BSContainer::ForEachResult::kContinue ;
446+ });
447+
440448 }
441449
442450 return RE ::BSEventNotifyControl::kContinue ;
@@ -514,7 +522,7 @@ namespace plugin {
514522 recalchook = new Update3DModelRecalculate ();
515523 SKSE::GetNiNodeUpdateEventSource ()->AddEventSink <SKSE ::NiNodeUpdateEvent>(recalchook);
516524 recalchook2 = new CellRecalculate ();
517- RE::ScriptEventSourceHolder::GetSingleton ()->AddEventSink <RE ::TESCellAttachDetachEvent >(recalchook2);
525+ RE::ScriptEventSourceHolder::GetSingleton ()->AddEventSink <RE ::TESCellFullyLoadedEvent >(recalchook2);
518526 }
519527 }
520528 uint8_t signature1170[] = {0xff , 0x90 , 0xf0 , 0x03 , 0x00 , 0x00 };
@@ -590,7 +598,7 @@ namespace plugin {
590598 recalchook = new Update3DModelRecalculate ();
591599 SKSE::GetNiNodeUpdateEventSource ()->AddEventSink <SKSE ::NiNodeUpdateEvent>(recalchook);
592600 recalchook2 = new CellRecalculate ();
593- RE::ScriptEventSourceHolder::GetSingleton ()->AddEventSink <RE ::TESCellAttachDetachEvent >(recalchook2);
601+ RE::ScriptEventSourceHolder::GetSingleton ()->AddEventSink <RE ::TESCellFullyLoadedEvent >(recalchook2);
594602 }
595603 }
596604 }
0 commit comments