Skip to content

Commit

Permalink
Merge pull request #413 from carboncopies/412-fix-divide-by-zero-erro…
Browse files Browse the repository at this point in the history
…r-in-texture-updater

412 fix divide by zero error in texture updater
  • Loading branch information
datacrystals authored Sep 25, 2022
2 parents c4bfb21 + ffc028b commit 7fd99d0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,10 @@ void ERS_CLASS_AsyncTextureUpdater::ProcessVRAMUpdate(int Index, ERS_STRUCT_Scen
int HighestTargetLevel = Scene->Models[Index]->TargetTextureLevelVRAM;

if (HighestTargetLevel > -1) {
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
float Priority = ((double)HighestTargetLevel + 0.0001f) / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = PushWorkItems_.size() * Priority;
InsertLocationIndex = std::min(InsertLocationIndex, (int)PushWorkItems_.size());
InsertLocationIndex = std::max(InsertLocationIndex, 0);
PushWorkItems_.insert(PushWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);
}
} else {
Expand Down Expand Up @@ -608,8 +610,10 @@ void ERS_CLASS_AsyncTextureUpdater::ProcessRAMUpdate(int Index, ERS_STRUCT_Scene
int HighestTargetLevel = Scene->Models[Index]->TargetTextureLevelVRAM;

if (HighestTargetLevel > -1) {
float Priority = HighestTargetLevel / Scene->Models[Index]->MaxTextureLevel_;
float Priority = ((double)HighestTargetLevel + 0.0001f) / Scene->Models[Index]->MaxTextureLevel_;
int InsertLocationIndex = LoadWorkItems_.size() * Priority;
InsertLocationIndex = std::min(InsertLocationIndex, (int)LoadWorkItems_.size());
InsertLocationIndex = std::max(InsertLocationIndex, 0);
LoadWorkItems_.insert(LoadWorkItems_.end() - InsertLocationIndex, Scene->Models[Index]);
}

Expand Down

0 comments on commit 7fd99d0

Please sign in to comment.