text: /*
  * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  * its licensors.
  *
  * For complete copyright and license terms please see the LICENSE at the root of this
  * distribution (the "License"). All use of this software is governed by the License,
  * or, if provided, by the license below or the license accompanying this file. Do not
  * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *
  */
  // Original file Copyright Crytek GMBH or its affiliates, used under license.
  
  #ifndef CRYINCLUDE_CRYPHYSICS_HEIGHTFIELDGEOM_H
  #define CRYINCLUDE_CRYPHYSICS_HEIGHTFIELDGEOM_H
  #pragma once
  
  #if ENABLE_CRY_PHYSICS
  
  #include "trimesh.h"
  #include "heightfieldbv.h"
  
  class CHeightfield
      : public CTriMesh
  {
  public:
      CHeightfield() { m_pTree = &m_Tree; }
      virtual ~CHeightfield() { m_pTree = 0; }
  
      CHeightfield* CreateHeightfield(heightfield* phf);
      virtual int GetType() { return GEOM_HEIGHTFIELD; }
      virtual int Intersect(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts);
      virtual int PrepareForIntersectionTest(geometry_under_test* pGTest, CGeometry* pCollider, geometry_under_test* pGTestColl, bool bKeepPrevContacts = false);
      virtual int PointInsideStatus(const Vec3& pt);
      virtual int FindClosestPoint(geom_world_data* pgwd, int& iPrim, int& iFeature, const Vec3& ptdst0, const Vec3& ptdst1,
          Vec3* ptres, int nMaxIters = 10);
      virtual void CalcVolumetricPressure(geom_world_data* gwd, const Vec3& epicenter, float k, float rmin,
          const Vec3& centerOfMass, Vec3& P, Vec3& L);
      virtual int IsConvex(float tolerance) { return 0; }
      virtual int DrawToOcclusionCubemap(const geom_world_data* pgwd, int iStartPrim, int nPrims, int iPass, SOcclusionCubeMap* cubeMap);
      virtual void PrepareForRayTest(float raylen) {}
      virtual CBVTree* GetBVTree() { return &m_Tree; }
  
      virtual const primitive* GetData() { return &m_hf; }
      virtual Vec3 GetCenter() { return m_hf.origin + (Vec3(m_hf.size.x, m_hf.size.y, 0) * 0.5f) * m_hf.Basis; }
  
      virtual int GetPrimitive(int iPrim, primitive* pprim) { *(heightfield*)pprim = m_hf; return sizeof(heightfield); }
      virtual void GetMemoryStatistics(ICrySizer* pSizer);
  
      heightfield m_hf;
      CHeightfieldBV m_Tree;
      float m_minHeight, m_maxHeight;
      int m_nVerticesAlloc, m_nTrisAlloc;
      Vec3 m_lastOriginOffs;
  };
  
  #endif // ENABLE_CRY_PHYSICS
  
  #endif // CRYINCLUDE_CRYPHYSICS_HEIGHTFIELDGEOM_H