Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Dec 15, 2024
1 parent b612e92 commit cb56e17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rts/Rendering/Common/ModelDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CModelDrawerBase : public CModelDrawerConcept {
static bool CanDrawDeferred() { return modelDrawerState->CanDrawDeferred(); }
static bool SetTeamColor(int team, const float alpha = 1.0f) { return modelDrawerState->SetTeamColor(team, alpha); }
static void SetNanoColor(const float4& color) { modelDrawerState->SetNanoColor(color); }
static const ScopedTransformMemAlloc& GetMatricesMemAlloc(const ObjType* o) { return const_cast<const TDrawerData*>(modelDrawerData)->GetObjectTransformMemAlloc(o); }
static const ScopedTransformMemAlloc& GetTransformMemAlloc(const ObjType* o) { return const_cast<const TDrawerData*>(modelDrawerData)->GetObjectTransformMemAlloc(o); }
public:
virtual void Update() const = 0;
// Draw*
Expand Down
5 changes: 2 additions & 3 deletions rts/Rendering/Common/ModelDrawerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class CModelDrawerDataBase : public CModelDrawerDataConcept

void ClearPreviousDrawFlags() { for (auto object : unsortedObjects) object->previousDrawFlag = 0; }

const ScopedTransformMemAlloc& GetObjectTransformMemAlloc(const T* o) const {
const auto& GetObjectTransformMemAlloc(const T* o) const {
const auto it = scTransMemAllocMap.find(const_cast<T*>(o));
return (it != scTransMemAllocMap.end()) ? it->second : ScopedTransformMemAlloc::Dummy();
}
ScopedTransformMemAlloc& GetObjectTransformMemAlloc(const T* o) { return scTransMemAllocMap[const_cast<T*>(o)]; }
auto& GetObjectTransformMemAlloc(const T* o) { return scTransMemAllocMap[const_cast<T*>(o)]; }
private:
static constexpr int MMA_SIZE0 = 2 << 16;
protected:
Expand Down Expand Up @@ -160,7 +160,6 @@ inline void CModelDrawerDataBase<T>::UpdateObjectSMMA(const T* o)
ScopedTransformMemAlloc& smma = GetObjectTransformMemAlloc(o);

const auto tmNew = o->GetTransformMatrix();
const auto& tmOld = const_cast<const ScopedTransformMemAlloc&>(smma)[0];

// from one point it doesn't worth the comparison, cause units usually move
// but having not updated smma[0] allows for longer solid no-update areas in ModelUniformsUploader::UpdateDerived()
Expand Down
4 changes: 2 additions & 2 deletions rts/Rendering/ModelsDataUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ std::size_t TransformsUploader::GetElemOffsetImpl(const CUnit* unit) const
return TransformsMemStorage::INVALID_INDEX;
}

if (std::size_t offset = CUnitDrawer::GetMatricesMemAlloc(unit).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) {
if (std::size_t offset = CUnitDrawer::GetTransformMemAlloc(unit).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) {
return offset;
}

Expand All @@ -235,7 +235,7 @@ std::size_t TransformsUploader::GetElemOffsetImpl(const CFeature* feature) const
return TransformsMemStorage::INVALID_INDEX;
}

if (std::size_t offset = CFeatureDrawer::GetMatricesMemAlloc(feature).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) {
if (std::size_t offset = CFeatureDrawer::GetTransformMemAlloc(feature).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) {
return offset;
}

Expand Down

0 comments on commit cb56e17

Please sign in to comment.