BVB Source Codes

CRYENGINE Show terrain_render.cpp Source code

Return Download CRYENGINE: download terrain_render.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   terrain_render.cpp
  5. //  Version:     v1.00
  6. //  Created:     28/5/2001 by Vladimir Kajalin
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: draw vis sectors
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #include "StdAfx.h"
  15. #include "terrain.h"
  16. #include "terrain_sector.h"
  17. #include "ObjMan.h"
  18. #include "VisAreas.h"
  19. #include "PolygonClipContext.h"
  20.  
  21. struct CTerrain__Cmp_Sectors
  22. {
  23.         CTerrain__Cmp_Sectors(const SRenderingPassInfo& state) : passInfo(state) {}
  24.  
  25.         bool __cdecl operator()(CTerrainNode* p1, CTerrainNode* p2)
  26.         {
  27.                 int nRecursiveLevel = passInfo.GetRecursiveLevel();
  28.  
  29.                 // if same - give closest sectors higher priority
  30.                 if (p1->m_arrfDistance[nRecursiveLevel] > p2->m_arrfDistance[nRecursiveLevel])
  31.                         return false;
  32.                 else if (p1->m_arrfDistance[nRecursiveLevel] < p2->m_arrfDistance[nRecursiveLevel])
  33.                         return true;
  34.  
  35.                 return false;
  36.         }
  37. private:
  38.         const SRenderingPassInfo passInfo;
  39. };
  40.  
  41. float GetPointToBoxDistance(Vec3 vPos, AABB bbox);
  42.  
  43. int   CTerrain::GetDetailTextureMaterials(IMaterial* materials[], int nSID)
  44. {
  45.         int materialNumber = 0;
  46.         //vector<IMaterial*> materials;
  47.  
  48.         uchar szProj[] = "XYZ";
  49.  
  50.         for (int s = 0; s < SRangeInfo::e_hole; s++)
  51.         {
  52.                 SSurfaceType* pSurf = &m_SSurfaceType[nSID][s];
  53.  
  54.                 if (pSurf->HasMaterial())
  55.                 {
  56.                         for (int p = 0; p < 3; p++)
  57.                         {
  58.                                 if (IMaterial* pMat = pSurf->GetMaterialOfProjection(szProj[p]))
  59.                                 {
  60.                                         if (materials)
  61.                                         {
  62.                                                 materials[materialNumber] = pMat;
  63.                                         }
  64.                                         materialNumber++;
  65.                                 }
  66.                         }
  67.                 }
  68.         }
  69.  
  70.         return materialNumber;
  71. }
  72.  
  73. void CTerrain::DrawVisibleSectors(const SRenderingPassInfo& passInfo)
  74. {
  75.         FUNCTION_PROFILER_3DENGINE;
  76.  
  77.         if (!passInfo.RenderTerrain() || !Get3DEngine()->m_bShowTerrainSurface)
  78.                 return;
  79.  
  80.         // sort to get good texture streaming priority
  81.         if (m_lstVisSectors.Count() > 0)
  82.                 std::sort(m_lstVisSectors.GetElements(), m_lstVisSectors.GetElements() + m_lstVisSectors.Count(), CTerrain__Cmp_Sectors(passInfo));
  83.  
  84.         for (CTerrainNode* pNode : m_lstVisSectors)
  85.         {
  86.                 if (!pNode->RenderNodeHeightmap(passInfo))
  87.                 {
  88.                         m_pTerrainUpdateDispatcher->QueueJob(pNode, passInfo);
  89.                 }
  90.         }
  91. }
  92.  
  93. void CTerrain::UpdateSectorMeshes(const SRenderingPassInfo& passInfo)
  94. {
  95.         FUNCTION_PROFILER_3DENGINE;
  96.  
  97.         m_pTerrainUpdateDispatcher->SyncAllJobs(false, passInfo);
  98. }
  99.  
downloadterrain_render.cpp 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