BVB Source Codes

CRYENGINE Show TerrainModifications.h Source code

Return Download CRYENGINE: download TerrainModifications.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __ENGINETERRAINMODIFICATIONS_H__
  4. #define __ENGINETERRAINMODIFICATIONS_H__
  5.  
  6. #pragma once
  7.  
  8. #include <CryNetwork/ISerialize.h>            // TSerialize
  9.  
  10. // helper class to serialize (load/save) terrain heighmap changes and limit the modification
  11. // also to remove some vegetation for the affected area
  12. class CTerrainModifications : public Cry3DEngineBase
  13. {
  14. public:
  15.         // constructor
  16.         CTerrainModifications();
  17.  
  18.         void SetTerrain(CTerrain& rTerrain);
  19.  
  20.         void FreeData();
  21.  
  22.         // Arguments:
  23.         //   fRadius - needs to be >0
  24.         // Returns:
  25.         //   true = modification was accepted, false=modifiction was rejected
  26.         bool PushModification(const Vec3& vPos, const float fRadius);
  27.  
  28.         // needed for savegames
  29.         void SerializeTerrainState(TSerialize ser);
  30.  
  31. private: // -------------------------------------------------------------------
  32.  
  33.         struct STerrainMod
  34.         {
  35.                 // default constructor (needed to serialize the vector)
  36.                 STerrainMod()
  37.                         : m_vPos(0, 0, 0), m_fHeight(0), m_fRadius(0)
  38.                 {
  39.                 }
  40.  
  41.                 // constructor
  42.                 STerrainMod(const Vec3& vPos, const float fRadius, const float fHeight)
  43.                         : m_vPos(vPos), m_fRadius(fRadius), m_fHeight(fHeight)
  44.                 {
  45.                 }
  46.  
  47.                 Vec3  m_vPos;             // midpoint
  48.                 float m_fHeight;          // old height at (m_vPos.x,m_vPos.y)  (explosion might not be at the ground)
  49.                 float m_fRadius;          //
  50.  
  51.                 void  Serialize(TSerialize ser)
  52.                 {
  53.                         ser.Value("pos", m_vPos);
  54.                         ser.Value("r", m_fRadius);
  55.                         ser.Value("height", m_fHeight);
  56.                 }
  57.         };
  58.  
  59.         // ---------------------------------------------------------------------------
  60.  
  61.         std::vector<STerrainMod> m_TerrainMods;               //
  62.         CTerrain*                m_pModifiedTerrain;          //
  63.  
  64.         // ---------------------------------------------------------------------------
  65.  
  66.         void MakeCrater(const STerrainMod& ref, const uint32 dwCheckExistingMods);
  67.  
  68.         // O(n), n=registered modifications and that should not be a huge number but that might need improvement
  69.         float ComputeMaxDepthAt(const float fX, const float fY, const uint32 dwCheckExistingMods) const;
  70. };
  71.  
  72. #endif // __ENGINETERRAINMODIFICATIONS_H__
  73.  
downloadTerrainModifications.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top