Line data Source code
1 : /* Copyright (C) 2026 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include "Model.h"
21 :
22 : #include "graphics/Decal.h"
23 : #include "graphics/MeshManager.h"
24 : #include "graphics/ModelDef.h"
25 : #include "graphics/RenderableObject.h"
26 : #include "graphics/SkeletonAnim.h"
27 : #include "graphics/SkeletonAnimDef.h"
28 : #include "lib/sysdep/rtl.h"
29 : #include "maths/BoundingBoxAligned.h"
30 : #include "maths/Matrix3D.h"
31 : #include "maths/Vector3D.h"
32 : #include "ps/CLogger.h"
33 : #include "ps/CStr.h"
34 : #include "ps/CStrIntern.h"
35 : #include "ps/CStrInternStatic.h"
36 : #include "ps/Profiler2.h"
37 : #include "renderer/RenderingOptions.h"
38 : #include "simulation2/components/ICmpTerrain.h"
39 : #include "simulation2/components/ICmpWaterManager.h"
40 : #include "simulation2/system/Component.h"
41 : #include "simulation2/system/Entity.h"
42 :
43 : #include <algorithm>
44 : #include <utility>
45 :
46 6 : CModel::CModel(const CSimulation2& simulation, const CMaterial& material, const CModelDefPtr& modeldef)
47 12 : : m_Simulation{simulation}, m_Material{material}, m_pModelDef{modeldef}
48 : {
49 6 : const size_t numberOfBones = modeldef->GetNumBones();
50 6 : if (numberOfBones != 0)
51 : {
52 0 : const size_t numberOfBlends = modeldef->GetNumBlends();
53 :
54 : // allocate matrices for bone transformations
55 : // (one extra matrix is used for the special case of bind-shape relative weighting)
56 0 : m_BoneMatrices = (CMatrix3D*)rtl_AllocateAligned(sizeof(CMatrix3D) * (numberOfBones + 1 + numberOfBlends), 16);
57 0 : for (size_t i = 0; i < numberOfBones + 1 + numberOfBlends; ++i)
58 : {
59 0 : m_BoneMatrices[i].SetIdentity();
60 : }
61 : }
62 :
63 6 : m_PositionValid = true;
64 6 : }
65 :
66 12 : CModel::~CModel()
67 : {
68 6 : rtl_FreeAligned(m_BoneMatrices);
69 18 : }
70 :
71 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
72 : // CalcBound: calculate the world space bounds of this model
73 0 : void CModel::CalcBounds()
74 : {
75 : // Need to calculate the object bounds first, if that hasn't already been done
76 0 : if (! (m_Anim && m_Anim->m_AnimDef))
77 : {
78 0 : if (m_ObjectBounds.IsEmpty())
79 0 : CalcStaticObjectBounds();
80 : }
81 : else
82 : {
83 0 : if (m_Anim->m_ObjectBounds.IsEmpty())
84 0 : CalcAnimatedObjectBounds(m_Anim->m_AnimDef, m_Anim->m_ObjectBounds);
85 0 : ENSURE(! m_Anim->m_ObjectBounds.IsEmpty()); // (if this happens, it'll be recalculating the bounds every time)
86 0 : m_ObjectBounds = m_Anim->m_ObjectBounds;
87 : }
88 :
89 : // Ensure the transform is set correctly before we use it
90 0 : ValidatePosition();
91 :
92 : // Now transform the object-space bounds to world-space bounds
93 0 : m_ObjectBounds.Transform(GetTransform(), m_WorldBounds);
94 0 : }
95 :
96 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
97 : // CalcObjectBounds: calculate object space bounds of this model, based solely on vertex positions
98 1 : void CModel::CalcStaticObjectBounds()
99 : {
100 1 : PROFILE2("CalcStaticObjectBounds");
101 1 : m_pModelDef->GetMaxBounds(nullptr, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION), m_ObjectBounds);
102 1 : }
103 :
104 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
105 : // CalcAnimatedObjectBound: calculate bounds encompassing all vertex positions for given animation
106 0 : void CModel::CalcAnimatedObjectBounds(CSkeletonAnimDef* anim, CBoundingBoxAligned& result)
107 : {
108 0 : PROFILE2("CalcAnimatedObjectBounds");
109 0 : m_pModelDef->GetMaxBounds(anim, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION), result);
110 0 : }
111 :
112 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
113 0 : const CBoundingBoxAligned CModel::GetWorldBoundsRec()
114 : {
115 0 : CBoundingBoxAligned bounds = GetWorldBounds();
116 0 : for (size_t i = 0; i < m_Props.size(); ++i)
117 0 : bounds += m_Props[i].m_Model->GetWorldBoundsRec();
118 0 : return bounds;
119 : }
120 :
121 0 : const CBoundingBoxAligned CModel::GetObjectSelectionBoundsRec()
122 : {
123 0 : CBoundingBoxAligned objBounds = GetObjectBounds(); // updates the (children-not-included) object-space bounds if necessary
124 :
125 : // now extend these bounds to include the props' selection bounds (if any)
126 0 : for (size_t i = 0; i < m_Props.size(); ++i)
127 : {
128 0 : const Prop& prop = m_Props[i];
129 0 : if (prop.m_Hidden || !prop.m_Selectable)
130 0 : continue; // prop is hidden from rendering, so it also shouldn't be used for selection
131 :
132 0 : CBoundingBoxAligned propSelectionBounds = prop.m_Model->GetObjectSelectionBoundsRec();
133 0 : if (propSelectionBounds.IsEmpty())
134 0 : continue; // submodel does not wish to participate in selection box, exclude it
135 :
136 : // We have the prop's bounds in its own object-space; now we need to transform them so they can be properly added
137 : // to the bounds in our object-space. For that, we need the transform of the prop attachment point.
138 : //
139 : // We have the prop point information; however, it's not trivial to compute its exact location in our object-space
140 : // since it may or may not be attached to a bone (see SPropPoint), which in turn may or may not be in the middle of
141 : // an animation. The bone matrices might be of interest, but they're really only meant to be used for the animation
142 : // system and are quite opaque to use from the outside (see @ref ValidatePosition).
143 : //
144 : // However, a nice side effect of ValidatePosition is that it also computes the absolute world-space transform of
145 : // our props and sets it on their respective models. In particular, @ref ValidatePosition will compute the prop's
146 : // world-space transform as either
147 : //
148 : // T' = T x B x O
149 : // or
150 : // T' = T x O
151 : //
152 : // where T' is the prop's world-space transform, T is our world-space transform, O is the prop's local
153 : // offset/rotation matrix, and B is an optional transformation matrix of the bone the prop is attached to
154 : // (taking into account animation and everything).
155 : //
156 : // From this, it is clear that either O or B x O is the object-space transformation matrix of the prop. So,
157 : // all we need to do is apply our own inverse world-transform T^(-1) to T' to get our desired result. Luckily,
158 : // this is precomputed upon setting the transform matrix (see @ref SetTransform), so it is free to fetch.
159 :
160 0 : CMatrix3D propObjectTransform = prop.m_Model->GetTransform(); // T'
161 0 : propObjectTransform.Concatenate(GetInvTransform()); // T^(-1) x T'
162 :
163 : // Transform the prop's bounds into our object coordinate space
164 0 : CBoundingBoxAligned transformedPropSelectionBounds;
165 0 : propSelectionBounds.Transform(propObjectTransform, transformedPropSelectionBounds);
166 :
167 0 : objBounds += transformedPropSelectionBounds;
168 : }
169 :
170 0 : return objBounds;
171 : }
172 :
173 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
174 : // Update: update this model to the given time, in msec
175 0 : void CModel::UpdateTo(float time)
176 : {
177 : // update animation time, but don't calculate bone matrices - do that (lazily) when
178 : // something requests them; that saves some calculation work for offscreen models,
179 : // and also assures the world space, inverted bone matrices (required for normal
180 : // skinning) are up to date with respect to m_Transform
181 0 : m_AnimTime = time;
182 :
183 : // mark vertices as dirty
184 0 : SetDirty(RENDERDATA_UPDATE_VERTICES);
185 :
186 : // mark matrices as dirty
187 0 : InvalidatePosition();
188 0 : }
189 :
190 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
191 : // InvalidatePosition
192 2 : void CModel::InvalidatePosition()
193 : {
194 2 : m_PositionValid = false;
195 :
196 2 : for (size_t i = 0; i < m_Props.size(); ++i)
197 0 : m_Props[i].m_Model->InvalidatePosition();
198 2 : }
199 :
200 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
201 : // ValidatePosition: ensure that current transform and bone matrices are both uptodate
202 0 : void CModel::ValidatePosition()
203 : {
204 0 : if (m_PositionValid)
205 : {
206 0 : ENSURE(!m_Parent || m_Parent->m_PositionValid);
207 0 : return;
208 : }
209 :
210 0 : if (m_Parent && !m_Parent->m_PositionValid)
211 : {
212 : // Make sure we don't base our calculations on
213 : // a parent animation state that is out of date.
214 0 : m_Parent->ValidatePosition();
215 :
216 : // Parent will recursively call our validation.
217 0 : ENSURE(m_PositionValid);
218 0 : return;
219 : }
220 :
221 0 : if (m_Anim && m_BoneMatrices)
222 : {
223 : // PROFILE( "generating bone matrices" );
224 :
225 0 : ENSURE(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys());
226 :
227 0 : m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime, m_BoneMatrices, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION));
228 : }
229 0 : else if (m_BoneMatrices)
230 : {
231 : // Bones but no animation - probably a buggy actor forgot to set up the animation,
232 : // so just render it in its bind pose
233 :
234 0 : for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++)
235 : {
236 0 : m_BoneMatrices[i].SetIdentity();
237 0 : m_BoneMatrices[i].Rotate(m_pModelDef->GetBones()[i].m_Rotation);
238 0 : m_BoneMatrices[i].Translate(m_pModelDef->GetBones()[i].m_Translation);
239 : }
240 : }
241 :
242 : // For CPU skinning, we precompute as much as possible so that the only
243 : // per-vertex work is a single matrix*vec multiplication.
244 : // For GPU skinning, we try to minimise CPU work by doing most computation
245 : // in the compute shader instead.
246 0 : const bool isGPUSkinningEnabled{g_RenderingOptions.GetGPUSkinning()};
247 0 : const bool worldSpaceBoneMatrices{!isGPUSkinningEnabled};
248 0 : const bool computeBlendMatrices{!isGPUSkinningEnabled};
249 :
250 0 : if (m_BoneMatrices && worldSpaceBoneMatrices)
251 : {
252 : // add world-space transformation to m_BoneMatrices
253 0 : const CMatrix3D transform = GetTransform();
254 0 : for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++)
255 0 : m_BoneMatrices[i].Concatenate(transform);
256 : }
257 :
258 : // our own position is now valid; now we can safely update our props' positions without fearing
259 : // that doing so will cause a revalidation of this model (see recursion above).
260 0 : m_PositionValid = true;
261 :
262 0 : CMatrix3D translate;
263 0 : CVector3D objTranslation = m_Transform.GetTranslation();
264 0 : float objectHeight = 0.0f;
265 :
266 0 : CmpPtr<ICmpTerrain> cmpTerrain(m_Simulation, SYSTEM_ENTITY);
267 0 : if (cmpTerrain)
268 0 : objectHeight = cmpTerrain->GetExactGroundLevel(objTranslation.X, objTranslation.Z);
269 :
270 : // Object height is incorrect for floating objects. We use water height instead.
271 0 : if (m_Flags & ModelFlag::FLOAT_ON_WATER)
272 : {
273 0 : CmpPtr<ICmpWaterManager> cmpWaterManager(m_Simulation, SYSTEM_ENTITY);
274 0 : if (cmpWaterManager)
275 : {
276 0 : const float waterHeight = cmpWaterManager->GetExactWaterLevel(objTranslation.X, objTranslation.Z);
277 0 : if (waterHeight >= objectHeight)
278 0 : objectHeight = waterHeight;
279 : }
280 : }
281 :
282 : // re-position and validate all props
283 0 : for (const Prop& prop : m_Props)
284 : {
285 0 : CMatrix3D proptransform = prop.m_Point->m_Transform;
286 0 : if (prop.m_Point->m_BoneIndex != 0xff)
287 : {
288 0 : CMatrix3D boneMatrix = m_BoneMatrices[prop.m_Point->m_BoneIndex];
289 0 : if (!worldSpaceBoneMatrices)
290 0 : boneMatrix.Concatenate(GetTransform());
291 0 : proptransform.Concatenate(boneMatrix);
292 : }
293 : else
294 : {
295 : // not relative to any bone; just apply world-space transformation (i.e. relative to object-space origin)
296 0 : proptransform.Concatenate(m_Transform);
297 : }
298 :
299 : // Adjust prop height to terrain level when needed
300 0 : if (cmpTerrain && (prop.m_MaxHeight != 0.f || prop.m_MinHeight != 0.f))
301 : {
302 0 : const CVector3D& propTranslation = proptransform.GetTranslation();
303 0 : const float propTerrain = cmpTerrain->GetExactGroundLevel(propTranslation.X, propTranslation.Z);
304 0 : const float translateHeight = std::min(prop.m_MaxHeight, std::max(prop.m_MinHeight, propTerrain - objectHeight));
305 0 : translate.SetTranslation(0.f, translateHeight, 0.f);
306 0 : proptransform.Concatenate(translate);
307 : }
308 :
309 0 : prop.m_Model->SetTransform(proptransform);
310 0 : prop.m_Model->ValidatePosition();
311 : }
312 :
313 0 : if (m_BoneMatrices)
314 : {
315 0 : for (size_t i = 0; i < m_pModelDef->GetNumBones(); i++)
316 : {
317 0 : m_BoneMatrices[i] = m_BoneMatrices[i] * m_pModelDef->GetInverseBindBoneMatrices()[i];
318 : }
319 :
320 : // Note: there is a special case of joint influence, in which the vertex
321 : // is influenced by the bind-shape transform instead of a particular bone,
322 : // which we indicate with the blending bone ID set to the total number
323 : // of bones. But since we're skinning in world space, we use the model's
324 : // world space transform and store that matrix in this special index.
325 : // (see https://gitea.wildfiregames.com/0ad/0ad/issues/1012)
326 0 : m_BoneMatrices[m_pModelDef->GetNumBones()] = m_Transform;
327 :
328 0 : if (computeBlendMatrices)
329 0 : m_pModelDef->BlendBoneMatrices(m_BoneMatrices);
330 : }
331 : }
332 :
333 :
334 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
335 : // SetAnimation: set the given animation as the current animation on this model;
336 : // return false on error, else true
337 5 : bool CModel::SetAnimation(CSkeletonAnim* anim, bool once)
338 : {
339 5 : m_Anim = nullptr; // in case something fails
340 :
341 5 : if (anim)
342 : {
343 2 : m_Flags &= ~ModelFlag::NO_LOOP_ANIMATION;
344 :
345 2 : if (once)
346 0 : m_Flags |= ModelFlag::NO_LOOP_ANIMATION;
347 :
348 : // Not rigged or animation is not valid.
349 2 : if (!m_BoneMatrices || !anim->m_AnimDef)
350 : return false;
351 :
352 0 : if (anim->m_AnimDef->GetNumKeys() != m_pModelDef->GetNumBones())
353 : {
354 0 : LOGERROR("Mismatch between model's skeleton and animation's skeleton ({}.dae has {} "
355 : "model bones while the animation {} has {} animation keys.)",
356 : m_pModelDef->GetName().string8(), m_pModelDef->GetNumBones(), anim->m_Name,
357 : anim->m_AnimDef->GetNumKeys());
358 0 : return false;
359 : }
360 :
361 : // Reset the cached bounds when the animation is changed.
362 0 : m_ObjectBounds.SetEmpty();
363 0 : InvalidateBounds();
364 :
365 : // Start anim from beginning.
366 0 : m_AnimTime = 0;
367 : }
368 :
369 3 : m_Anim = anim;
370 :
371 3 : return true;
372 : }
373 :
374 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
375 : // CopyAnimation
376 0 : void CModel::CopyAnimationFrom(CModel* source)
377 : {
378 0 : m_Anim = source->m_Anim;
379 0 : m_AnimTime = source->m_AnimTime;
380 :
381 0 : m_ObjectBounds.SetEmpty();
382 0 : InvalidateBounds();
383 0 : }
384 :
385 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
386 : // AddProp: add a prop to the model on the given point
387 4 : void CModel::AddProp(const SPropPoint* point, std::unique_ptr<CModelAbstract> model, CObjectEntry* objectentry, float minHeight, float maxHeight, bool selectable)
388 : {
389 : // position model according to prop point position
390 :
391 : // this next call will invalidate the bounds of "model", which will in turn also invalidate the selection box
392 4 : model->SetTransform(point->m_Transform);
393 4 : model->m_Parent = this;
394 :
395 4 : Prop prop;
396 4 : prop.m_Point = point;
397 4 : prop.m_Model = std::move(model);
398 4 : prop.m_ObjectEntry = objectentry;
399 4 : prop.m_MinHeight = minHeight;
400 4 : prop.m_MaxHeight = maxHeight;
401 4 : prop.m_Selectable = selectable;
402 4 : m_Props.push_back(std::move(prop));
403 4 : }
404 :
405 0 : void CModel::AddAmmoProp(const SPropPoint* point, std::unique_ptr<CModelAbstract> model, CObjectEntry* objectentry)
406 : {
407 0 : AddProp(point, std::move(model), objectentry);
408 0 : m_AmmoPropPoint = point;
409 0 : m_AmmoLoadedProp = m_Props.size() - 1;
410 0 : m_Props[m_AmmoLoadedProp].m_Hidden = true;
411 :
412 : // we only need to invalidate the selection box here if it is based on props and their visibilities
413 0 : if (!m_CustomSelectionShape)
414 0 : m_SelectionBoxValid = false;
415 0 : }
416 :
417 0 : void CModel::ShowAmmoProp()
418 : {
419 0 : if (m_AmmoPropPoint == NULL)
420 : return;
421 :
422 : // Show the ammo prop, hide all others on the same prop point
423 0 : for (size_t i = 0; i < m_Props.size(); ++i)
424 0 : if (m_Props[i].m_Point == m_AmmoPropPoint)
425 0 : m_Props[i].m_Hidden = (i != m_AmmoLoadedProp);
426 :
427 : // we only need to invalidate the selection box here if it is based on props and their visibilities
428 0 : if (!m_CustomSelectionShape)
429 0 : m_SelectionBoxValid = false;
430 : }
431 :
432 0 : void CModel::HideAmmoProp()
433 : {
434 0 : if (m_AmmoPropPoint == NULL)
435 : return;
436 :
437 : // Hide the ammo prop, show all others on the same prop point
438 0 : for (size_t i = 0; i < m_Props.size(); ++i)
439 0 : if (m_Props[i].m_Point == m_AmmoPropPoint)
440 0 : m_Props[i].m_Hidden = (i == m_AmmoLoadedProp);
441 :
442 : // we only need to invalidate here if the selection box is based on props and their visibilities
443 0 : if (!m_CustomSelectionShape)
444 0 : m_SelectionBoxValid = false;
445 : }
446 :
447 0 : CModelAbstract* CModel::FindFirstAmmoProp()
448 : {
449 0 : if (m_AmmoPropPoint)
450 0 : return m_Props[m_AmmoLoadedProp].m_Model.get();
451 :
452 0 : for (size_t i = 0; i < m_Props.size(); ++i)
453 : {
454 0 : CModel* propModel = m_Props[i].m_Model->ToCModel();
455 0 : if (propModel)
456 : {
457 0 : CModelAbstract* model = propModel->FindFirstAmmoProp();
458 0 : if (model)
459 0 : return model;
460 : }
461 : }
462 :
463 : return NULL;
464 : }
465 :
466 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
467 : // Clone: return a clone of this model
468 3 : std::unique_ptr<CModelAbstract> CModel::Clone() const
469 : {
470 3 : std::unique_ptr<CModel> clone = std::make_unique<CModel>(m_Simulation, m_Material, m_pModelDef);
471 3 : clone->m_ObjectBounds = m_ObjectBounds;
472 3 : clone->SetAnimation(m_Anim);
473 3 : clone->SetFlags(m_Flags);
474 :
475 5 : for (size_t i = 0; i < m_Props.size(); i++)
476 : {
477 : // eek! TODO, RC - need to investigate shallow clone here
478 2 : if (m_AmmoPropPoint && i == m_AmmoLoadedProp)
479 0 : clone->AddAmmoProp(m_Props[i].m_Point, m_Props[i].m_Model->Clone(), m_Props[i].m_ObjectEntry);
480 : else
481 4 : clone->AddProp(m_Props[i].m_Point, m_Props[i].m_Model->Clone(), m_Props[i].m_ObjectEntry, m_Props[i].m_MinHeight, m_Props[i].m_MaxHeight, m_Props[i].m_Selectable);
482 : }
483 :
484 3 : return clone;
485 3 : }
486 :
487 :
488 : /////////////////////////////////////////////////////////////////////////////////////////////////////////////
489 : // SetTransform: set the transform on this object, and reorientate props accordingly
490 2 : void CModel::SetTransform(const CMatrix3D& transform)
491 : {
492 : // call base class to set transform on this object
493 2 : CRenderableObject::SetTransform(transform);
494 2 : InvalidatePosition();
495 2 : }
496 :
497 : //////////////////////////////////////////////////////////////////////////
498 :
499 2 : void CModel::AddFlagsRec(int flags)
500 : {
501 2 : m_Flags |= flags;
502 :
503 2 : if (flags & ModelFlag::IGNORE_LOS)
504 : {
505 : // We need to add the define only to passes where LOS might appear.
506 8 : for (const auto pass : {CMaterial::Pass::MAIN, CMaterial::Pass::REFLECTIONS, CMaterial::Pass::REFRACTIONS})
507 6 : m_Material.AddShaderDefine(pass, str_IGNORE_LOS, str_1);
508 : }
509 :
510 4 : for (size_t i = 0; i < m_Props.size(); ++i)
511 2 : if (m_Props[i].m_Model->ToCModel())
512 1 : m_Props[i].m_Model->ToCModel()->AddFlagsRec(flags);
513 2 : }
514 :
515 2 : void CModel::RemoveShadowsCast()
516 : {
517 2 : m_Flags &= ~ModelFlag::CAST_SHADOWS;
518 4 : for (size_t i = 0; i < m_Props.size(); ++i)
519 : {
520 2 : if (m_Props[i].m_Model->ToCModel())
521 1 : m_Props[i].m_Model->ToCModel()->RemoveShadowsCast();
522 : }
523 2 : }
524 :
525 2 : void CModel::RemoveShadowsReceive()
526 : {
527 : // We need to add the define only to passes where shadows might appear.
528 8 : for (const auto pass : {CMaterial::Pass::MAIN, CMaterial::Pass::REFLECTIONS, CMaterial::Pass::REFRACTIONS})
529 6 : m_Material.AddShaderDefine(pass, str_DISABLE_RECEIVE_SHADOWS, str_1);
530 :
531 4 : for (size_t i = 0; i < m_Props.size(); ++i)
532 : {
533 2 : if (m_Props[i].m_Model->ToCModel())
534 1 : m_Props[i].m_Model->ToCModel()->RemoveShadowsReceive();
535 1 : else if (m_Props[i].m_Model->ToCModelDecal())
536 1 : m_Props[i].m_Model->ToCModelDecal()->RemoveShadowsReceive();
537 : }
538 2 : }
539 :
540 0 : void CModel::SetPlayerID(player_id_t id)
541 : {
542 0 : CModelAbstract::SetPlayerID(id);
543 :
544 0 : for (std::vector<Prop>::iterator it = m_Props.begin(); it != m_Props.end(); ++it)
545 0 : it->m_Model->SetPlayerID(id);
546 0 : }
547 :
548 0 : void CModel::SetShadingColor(const CColor& color)
549 : {
550 0 : CModelAbstract::SetShadingColor(color);
551 :
552 0 : for (std::vector<Prop>::iterator it = m_Props.begin(); it != m_Props.end(); ++it)
553 0 : it->m_Model->SetShadingColor(color);
554 0 : }
|