From fdbcb79c3d7a78ab6c10613f6a9f2ed9ae8b2108 Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Sun, 10 Sep 2023 18:00:30 +0000 Subject: [PATCH] Queries water manager only if a model should account it. Tested By: phosit Differential Revision: https://code.wildfiregames.com/D5122 This was SVN commit r27833. --- source/graphics/Model.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp index d2bd9f6ca3..59caad8450 100644 --- a/source/graphics/Model.cpp +++ b/source/graphics/Model.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -297,12 +297,15 @@ void CModel::ValidatePosition() objectHeight = cmpTerrain->GetExactGroundLevel(objTranslation.X, objTranslation.Z); // Object height is incorrect for floating objects. We use water height instead. - CmpPtr cmpWaterManager(m_Simulation, SYSTEM_ENTITY); - if (cmpWaterManager) + if (m_Flags & MODELFLAG_FLOATONWATER) { - float waterHeight = cmpWaterManager->GetExactWaterLevel(objTranslation.X, objTranslation.Z); - if (waterHeight >= objectHeight && m_Flags & MODELFLAG_FLOATONWATER) - objectHeight = waterHeight; + CmpPtr cmpWaterManager(m_Simulation, SYSTEM_ENTITY); + if (cmpWaterManager) + { + const float waterHeight = cmpWaterManager->GetExactWaterLevel(objTranslation.X, objTranslation.Z); + if (waterHeight >= objectHeight) + objectHeight = waterHeight; + } } // re-position and validate all props