@@ -1080,6 +1080,16 @@ namespace plugin {
10801080 if (is_main_or_task_thread ()) {
10811081 if (geo && param_5 && param_4) {
10821082 if (geo->_refCount > 0 && param_5->_refCount > 0 && param_4->_refCount > 0 ) {
1083+ if (auto refr_3d = refr->Get3D1 (false )) {
1084+ auto new_geo = refr_3d->GetObjectByName (geo->name );
1085+ if (geo != new_geo) {
1086+ logger::warn (" geometry doesn't match source pointer, skipping" );
1087+ return ;
1088+ }
1089+ } else {
1090+ logger::warn (" reference had no 3D when installing overlays" );
1091+ return ;
1092+ }
10831093 std::lock_guard l (shader_property_mutex);
10841094 InstallingOverlays = true ;
10851095 // logger::info("Installing Overlay on main thread");
@@ -1100,36 +1110,49 @@ namespace plugin {
11001110 } else {
11011111 std::string param2_str (param_2);
11021112 std::string param3_str (param_3);
1103- AddMainTask ([refrid, refr, param_4, param4id, inter, param2_str, param3_str, geo, param_5, param_6] {
1104- if (refr == RE::TESForm::LookupByID<RE::TESObjectREFR>(refrid) && refr && !(refr->IsDeleted ())) {
1105- if (param_4 == RE::TESForm::LookupByID<RE::TESObjectREFR>(param4id) && param_4 &&
1106- !(param_4->IsDeleted ())) {
1107- if (geo && param_5 && param_4) {
1108- if (geo->_refCount > 0 && param_5->_refCount > 0 && param_4->_refCount > 0 ) {
1109- std::lock_guard l (shader_property_mutex);
1110- InstallingOverlays = true ;
1111- // logger::info("Installing Overlay on task");
1112- InstallOverlayHook (inter, param2_str.c_str (), param3_str.c_str (), param_4, geo, param_5,
1113- param_6);
1114- // logger::info("Done installing Overlay on task thread");
1115- InstallingOverlays = false ;
1116- if (RE::NiAVObject* found_geometry = param_5->GetObjectByName (param2_str.c_str ())) {
1117- auto found_geo = found_geometry->AsGeometry ();
1118- QueueOverlayCullingFix (found_geo);
1113+ if (geo) {
1114+ RE::BSFixedString geometry_name = geo->name ;
1115+ AddMainTask ([geometry_name,refrid, refr, param_4, param4id, inter, param2_str, param3_str, geo, param_5, param_6] {
1116+ if (refr == RE::TESForm::LookupByID<RE::TESObjectREFR>(refrid) && refr && !(refr->IsDeleted ())) {
1117+ if (param_4 == RE::TESForm::LookupByID<RE::TESObjectREFR>(param4id) && param_4 &&
1118+ !(param_4->IsDeleted ())) {
1119+ if (auto refr_3d=refr->Get3D1 (false )) {
1120+ auto new_geo = refr_3d->GetObjectByName (geometry_name);
1121+ if (geo != new_geo) {
1122+ logger::warn (" geometry doesn't match source pointer, skipping" );
1123+ return ;
1124+ }
1125+ } else {
1126+ logger::warn (" reference had no 3D when installing overlays" );
1127+ return ;
1128+ }
1129+ if (geo && param_5 && param_4) {
1130+ if (geo->_refCount > 0 && param_5->_refCount > 0 && param_4->_refCount > 0 ) {
1131+ std::lock_guard l (shader_property_mutex);
1132+ InstallingOverlays = true ;
1133+ // logger::info("Installing Overlay on task");
1134+ InstallOverlayHook (inter, param2_str.c_str (), param3_str.c_str (), param_4, geo,
1135+ param_5, param_6);
1136+ // logger::info("Done installing Overlay on task thread");
1137+ InstallingOverlays = false ;
1138+ if (RE::NiAVObject* found_geometry = param_5->GetObjectByName (param2_str.c_str ())) {
1139+ auto found_geo = found_geometry->AsGeometry ();
1140+ QueueOverlayCullingFix (found_geo);
1141+ }
1142+ } else {
1143+ logger::error (" Invalid object or reference for Installing Overlay" );
1144+ }
1145+ } else {
1146+ logger::error (" Invalid object or reference" );
11191147 }
11201148 } else {
1121- logger::error ( " Invalid object or reference for Installing Overlay " );
1149+ logger::warn ( " Tried to Install Overlay with collected param_4 " );
11221150 }
11231151 } else {
1124- logger::error ( " Invalid object or reference " );
1152+ logger::warn ( " Tried Install Overlay with collected refr " );
11251153 }
1126- } else {
1127- logger::warn (" Tried to Install Overlay with collected param_4" );
1128- }
1129- } else {
1130- logger::warn (" Tried Install Overlay with collected refr" );
1131- }
1132- });
1154+ });
1155+ }
11331156 }
11341157 }
11351158 } else {
0 commit comments