@@ -70,17 +70,17 @@ class CModelDrawerDataBase : public CModelDrawerDataConcept
7070 void ClearPreviousDrawFlags () { for (auto object : unsortedObjects) object->previousDrawFlag = 0 ; }
7171
7272 const ScopedTransformMemAlloc& GetObjectTransformMemAlloc (const T* o) const {
73- const auto it = matricesMemAllocs .find (const_cast <T*>(o));
74- return (it != matricesMemAllocs .end ()) ? it->second : ScopedTransformMemAlloc::Dummy ();
73+ const auto it = scTransMemAllocMap .find (const_cast <T*>(o));
74+ return (it != scTransMemAllocMap .end ()) ? it->second : ScopedTransformMemAlloc::Dummy ();
7575 }
76- ScopedTransformMemAlloc& GetObjectTransformMemAlloc (const T* o) { return matricesMemAllocs [const_cast <T*>(o)]; }
76+ ScopedTransformMemAlloc& GetObjectTransformMemAlloc (const T* o) { return scTransMemAllocMap [const_cast <T*>(o)]; }
7777private:
7878 static constexpr int MMA_SIZE0 = 2 << 16 ;
7979protected:
8080 std::array<ModelRenderContainer<T>, MODELTYPE_CNT> modelRenderers;
8181
8282 std::vector<T*> unsortedObjects;
83- std::unordered_map<T*, ScopedTransformMemAlloc> matricesMemAllocs ;
83+ std::unordered_map<T*, ScopedTransformMemAlloc> scTransMemAllocMap ;
8484
8585 bool & mtModelDrawer;
8686};
@@ -100,15 +100,15 @@ inline CModelDrawerDataBase<T>::CModelDrawerDataBase(const std::string& ecName,
100100 : CModelDrawerDataConcept(ecName, ecOrder)
101101 , mtModelDrawer(mtModelDrawer_)
102102{
103- matricesMemAllocs .reserve (MMA_SIZE0);
103+ scTransMemAllocMap .reserve (MMA_SIZE0);
104104 for (auto & mr : modelRenderers) { mr.Clear (); }
105105}
106106
107107template <typename T>
108108inline CModelDrawerDataBase<T>::~CModelDrawerDataBase ()
109109{
110110 unsortedObjects.clear ();
111- matricesMemAllocs .clear ();
111+ scTransMemAllocMap .clear ();
112112}
113113
114114template <typename T>
@@ -126,7 +126,7 @@ inline void CModelDrawerDataBase<T>::AddObject(const T* co, bool add)
126126 unsortedObjects.emplace_back (o);
127127
128128 const uint32_t numMatrices = (o->model ? o->model ->numPieces : 0 ) + 1u ;
129- matricesMemAllocs .emplace (o, ScopedTransformMemAlloc (numMatrices));
129+ scTransMemAllocMap .emplace (o, ScopedTransformMemAlloc (numMatrices));
130130
131131 modelUniformsStorage.GetObjOffset (co);
132132}
@@ -141,7 +141,7 @@ inline void CModelDrawerDataBase<T>::DelObject(const T* co, bool del)
141141 }
142142
143143 if (del && spring::VectorErase (unsortedObjects, o)) {
144- matricesMemAllocs .erase (o);
144+ scTransMemAllocMap .erase (o);
145145 modelUniformsStorage.GetObjOffset (co);
146146 }
147147}
@@ -164,8 +164,7 @@ inline void CModelDrawerDataBase<T>::UpdateObjectSMMA(const T* o)
164164
165165 // from one point it doesn't worth the comparison, cause units usually move
166166 // but having not updated smma[0] allows for longer solid no-update areas in ModelUniformsUploader::UpdateDerived()
167- if (tmNew != tmOld)
168- smma[0 ] = tmNew;
167+ smma.UpdateIfChanged (0 , tmNew);
169168
170169 for (int i = 0 ; i < o->localModel .pieces .size (); ++i) {
171170 const LocalModelPiece& lmp = o->localModel .pieces [i];
@@ -175,11 +174,13 @@ inline void CModelDrawerDataBase<T>::UpdateObjectSMMA(const T* o)
175174 continue ;
176175
177176 if unlikely (!lmp.GetScriptVisible ()) {
178- smma[i + 1 ] = CMatrix44f::Zero ();
177+ // smma[i + 1] = CMatrix44f::Zero();
178+ smma.UpdateForced (i + 1 , CMatrix44f::Zero ());
179179 continue ;
180180 }
181181
182- smma[i + 1 ] = lmp.GetModelSpaceMatrix ();
182+ // UpdateIfChanged is not needed, wasCustomDirty takes that role
183+ smma.UpdateForced (i + 1 , lmp.GetModelSpaceMatrix ());
183184 }
184185}
185186
0 commit comments