LCOV - code coverage report
Current view: top level - source/simulation2/components - ICmpTerrain.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 2 2 100.0 %
Date: 2026-12-02 01:21:50 Functions: 0 0 -

          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             : #ifndef INCLUDED_ICMPTERRAIN
      19             : #define INCLUDED_ICMPTERRAIN
      20             : 
      21             : #include "maths/FixedVector3D.h"
      22             : #include "simulation2/helpers/Position.h"
      23             : #include "simulation2/system/Component.h"
      24             : #include "simulation2/system/Interface.h"
      25             : 
      26             : #include <js/Value.h>
      27             : 
      28             : class CTerrain;
      29             : class CVector3D;
      30             : 
      31          10 : class ICmpTerrain : public IComponent
      32             : {
      33             : public:
      34             :     virtual bool IsLoaded() const = 0;
      35             : 
      36             :     virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) const = 0;
      37             : 
      38             :     virtual CVector3D CalcExactNormal(float x, float z) const = 0;
      39             : 
      40             :     virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z) const = 0;
      41             : 
      42             :     virtual float GetExactGroundLevel(float x, float z) const = 0;
      43             : 
      44             :     /**
      45             :      * Returns number of tiles per side on the terrain.
      46             :      * Return value is always non-zero.
      47             :      */
      48             :     virtual std::uint16_t GetTilesPerSide() const = 0;
      49             : 
      50             :     /**
      51             :      * Returns number of vertices per side on the terrain.
      52             :      * Return value is always non-zero.
      53             :      */
      54             :     virtual std::uint16_t GetVerticesPerSide() const = 0;
      55             : 
      56             :     /**
      57             :      * Returns the map size in metres (world space units).
      58             :      */
      59             :     virtual std::uint32_t GetMapSize() const = 0;
      60             : 
      61             :     virtual CTerrain* GetCTerrain() = 0;
      62             : 
      63             :     /**
      64             :      * Call when the underlying CTerrain has been modified behind our backs.
      65             :      * (TODO: eventually we should manage the CTerrain in this class so nobody
      66             :      * can modify it behind our backs).
      67             :      */
      68             :     virtual void ReloadTerrain(bool ReloadWater = true) = 0;
      69             : 
      70             :     /**
      71             :      * Indicate that terrain tiles within the given region (inclusive lower bound,
      72             :      * exclusive upper bound) have been changed. CMessageTerrainChanged will be
      73             :      * sent to any components that care about terrain changes.
      74             :      */
      75             :     virtual void MakeDirty(std::int32_t i0, std::int32_t j0, std::int32_t i1, std::int32_t j1) = 0;
      76             : 
      77       14576 :     DECLARE_INTERFACE_TYPE(Terrain)
      78             : };
      79             : 
      80             : #endif // INCLUDED_ICMPTERRAIN

Generated by: LCOV version 1.16