LCOV - code coverage report
Current view: top level - source/graphics - Decal.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 12 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2022 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_DECAL
      19             : #define INCLUDED_DECAL
      20             : 
      21             : #include "graphics/Material.h"
      22             : #include "graphics/ModelAbstract.h"
      23             : 
      24             : class CTerrain;
      25             : 
      26             : /**
      27             :  * Terrain decal definition.
      28             :  * Decals are rectangular textures that are projected vertically downwards
      29             :  * onto the terrain.
      30             :  */
      31           0 : struct SDecal
      32             : {
      33           0 :     SDecal(const CMaterial& material, float sizeX, float sizeZ, float angle,
      34             :             float offsetX, float offsetZ, bool floating)
      35           0 :         : m_Material(material), m_SizeX(sizeX), m_SizeZ(sizeZ), m_Angle(angle),
      36           0 :           m_OffsetX(offsetX), m_OffsetZ(offsetZ), m_Floating(floating)
      37             :     {
      38           0 :     }
      39             : 
      40             :     CMaterial m_Material;
      41             :     float m_SizeX;
      42             :     float m_SizeZ;
      43             :     float m_Angle;
      44             :     float m_OffsetX;
      45             :     float m_OffsetZ;
      46             :     bool m_Floating;
      47             : };
      48             : 
      49           0 : class CModelDecal : public CModelAbstract
      50             : {
      51             : public:
      52           0 :     CModelDecal(CTerrain* terrain, const SDecal& decal)
      53           0 :         : m_Terrain(terrain), m_Decal(decal)
      54             :     {
      55           0 :         ENSURE(terrain != NULL);
      56           0 :     }
      57             : 
      58             :     /// Dynamic cast
      59           0 :     virtual CModelDecal* ToCModelDecal()
      60             :     {
      61           0 :         return this;
      62             :     }
      63             : 
      64             :     virtual CModelAbstract* Clone() const;
      65             : 
      66             :     virtual void SetTerrainDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1);
      67             : 
      68             :     virtual void CalcBounds();
      69             :     virtual void ValidatePosition();
      70             :     virtual void InvalidatePosition();
      71             :     virtual void SetTransform(const CMatrix3D& transform);
      72             : 
      73             :     // remove shadow receiving
      74             :     void RemoveShadows();
      75             : 
      76             :     /**
      77             :      * Compute the terrain vertex indexes that bound the decal's
      78             :      * projection onto the terrain.
      79             :      * The returned indexes are clamped to the terrain size.
      80             :      */
      81             :     void CalcVertexExtents(ssize_t& i0, ssize_t& j0, ssize_t& i1, ssize_t& j1);
      82             : 
      83             :     CTerrain* m_Terrain;
      84             :     SDecal m_Decal;
      85             : };
      86             : 
      87             : #endif // INCLUDED_DECAL

Generated by: LCOV version 1.13