Skip to content

Commit bcae300

Browse files
committed
Addendum to dfd0189
1 parent bef3238 commit bcae300

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Client/game_sa/CRenderWareSA.TextureReplacing.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,6 +3281,7 @@ CModelTexturesInfo* CRenderWareSA::GetModelTexturesInfo(unsigned short usModelId
32813281

32823282
std::unordered_map<unsigned short, CModelInfoSA*> modelInfoCache;
32833283
std::vector<std::pair<SReplacementTextures*, std::vector<unsigned short>>> replacementsToReapply;
3284+
std::vector<std::pair<SReplacementTextures*, std::vector<unsigned short>>> pendingGeometryLess;
32843285
std::vector<SReplacementTextures*> originalUsed;
32853286

32863287
// Computed before the collection loop; that loop erases from usedInModelIds,
@@ -3293,6 +3294,7 @@ CModelTexturesInfo* CRenderWareSA::GetModelTexturesInfo(unsigned short usModelId
32933294

32943295
originalUsed.push_back(pReplacement);
32953296
std::vector<unsigned short> modelIds;
3297+
std::vector<unsigned short> geometryLessIds;
32963298
for (unsigned short modelId : pReplacement->usedInModelIds)
32973299
{
32983300
auto& pCachedModInfo = modelInfoCache[modelId];
@@ -3308,10 +3310,14 @@ CModelTexturesInfo* CRenderWareSA::GetModelTexturesInfo(unsigned short usModelId
33083310

33093311
if (pCachedModInfo->GetRwObject())
33103312
modelIds.push_back(modelId);
3313+
else
3314+
geometryLessIds.push_back(modelId);
33113315
}
33123316
}
33133317
if (!pReplacement->textures.empty() && !modelIds.empty())
33143318
replacementsToReapply.emplace_back(pReplacement, std::move(modelIds));
3319+
if (!pReplacement->textures.empty() && !geometryLessIds.empty())
3320+
pendingGeometryLess.emplace_back(pReplacement, std::move(geometryLessIds));
33153321
}
33163322

33173323
for (auto& entry : replacementsToReapply)
@@ -3686,6 +3692,18 @@ CModelTexturesInfo* CRenderWareSA::GetModelTexturesInfo(unsigned short usModelId
36863692
}
36873693
info.bReapplyingTextures = false;
36883694
}
3695+
3696+
// Queue deferred texture application for models that had no geometry
3697+
// during stale reapply. Their perTxdList entries were cleaned above;
3698+
// TryApplyPendingReplacements will apply when streaming loads geometry.
3699+
if (!pendingGeometryLess.empty())
3700+
{
3701+
for (auto& pendingEntry : pendingGeometryLess)
3702+
{
3703+
for (unsigned short usModelId : pendingEntry.second)
3704+
QueuePendingReplacement(usModelId, pendingEntry.first, 0, 0);
3705+
}
3706+
}
36893707
}
36903708

36913709
// Handle leaked entries with empty originalTextures (cleared at StaticReset).

0 commit comments

Comments
 (0)