BVB Source Codes

CRYENGINE Show ClipVolume.cpp Source code

Return Download CRYENGINE: download ClipVolume.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4.  
  5. #include "ClipVolume.h"
  6. #include <CryEntitySystem/IEntitySystem.h>
  7.  
  8. CClipVolume::CClipVolume()
  9.         : m_nStencilRef(0)
  10.         , m_WorldTM(IDENTITY)
  11.         , m_InverseWorldTM(IDENTITY)
  12.         , m_BBoxWS(AABB::RESET)
  13.         , m_BBoxLS(AABB::RESET)
  14.         , m_pBspTree(NULL)
  15. {
  16.         memset(m_sName, 0x0, sizeof(m_sName));
  17. }
  18.  
  19. CClipVolume::~CClipVolume()
  20. {
  21.         m_pRenderMesh = NULL;
  22.  
  23.         AUTO_LOCK(m_lstRenderNodesCritSection);
  24.         for (size_t i = 0; i < m_lstRenderNodes.size(); ++i)
  25.         {
  26.                 IRenderNode* pNode = m_lstRenderNodes[i];
  27.                 if (pNode->m_pTempData)
  28.                         pNode->m_pTempData->userData.m_pClipVolume = NULL;
  29.         }
  30. }
  31.  
  32. void CClipVolume::SetName(const char* szName)
  33. {
  34.         cry_strcpy(m_sName, szName);
  35. }
  36.  
  37. void CClipVolume::GetClipVolumeMesh(_smart_ptr<IRenderMesh>& renderMesh, Matrix34& worldTM) const
  38. {
  39.         renderMesh = m_pRenderMesh;
  40.         worldTM = m_WorldTM;
  41. }
  42.  
  43. AABB CClipVolume::GetClipVolumeBBox() const
  44. {
  45.         return m_BBoxWS;
  46. }
  47.  
  48. void CClipVolume::Update(_smart_ptr<IRenderMesh> pRenderMesh, IBSPTree3D* pBspTree, const Matrix34& worldTM, uint32 flags)
  49. {
  50.         const bool bMeshUpdated = m_pRenderMesh != pRenderMesh;
  51.  
  52.         m_pRenderMesh = pRenderMesh;
  53.         m_pBspTree = pBspTree;
  54.         m_WorldTM = worldTM;
  55.         m_InverseWorldTM = worldTM.GetInverted();
  56.         m_BBoxWS.Reset();
  57.         m_BBoxLS.Reset();
  58.         m_nFlags = flags;
  59.  
  60.         if (m_pRenderMesh)
  61.         {
  62.                 pRenderMesh->GetBBox(m_BBoxLS.min, m_BBoxLS.max);
  63.                 m_BBoxWS.SetTransformedAABB(worldTM, m_BBoxLS);
  64.         }
  65. }
  66.  
  67. bool CClipVolume::IsPointInsideClipVolume(const Vec3& point) const
  68. {
  69.         FUNCTION_PROFILER_3DENGINE;
  70.  
  71.         if (!m_pRenderMesh || !m_pBspTree || !m_BBoxWS.IsContainPoint(point))
  72.                 return false;
  73.  
  74.         Vec3 pt = m_InverseWorldTM.TransformPoint(point);
  75.         return m_BBoxLS.IsContainPoint(pt) && m_pBspTree->IsInside(pt);
  76. }
  77.  
  78. void CClipVolume::RegisterRenderNode(IRenderNode* pRenderNode)
  79. {
  80.         AUTO_LOCK(m_lstRenderNodesCritSection);
  81.         if (m_lstRenderNodes.Find(pRenderNode) < 0)
  82.         {
  83.                 m_lstRenderNodes.Add(pRenderNode);
  84.  
  85.                 if (pRenderNode->m_pTempData)
  86.                         pRenderNode->m_pTempData->userData.m_pClipVolume = this;
  87.         }
  88. }
  89. void CClipVolume::UnregisterRenderNode(IRenderNode* pRenderNode)
  90. {
  91.         AUTO_LOCK(m_lstRenderNodesCritSection);
  92.         if (m_lstRenderNodes.Delete(pRenderNode) && pRenderNode->m_pTempData)
  93.                 pRenderNode->m_pTempData->userData.m_pClipVolume = NULL;
  94. }
  95.  
  96. void CClipVolume::GetMemoryUsage(class ICrySizer* pSizer) const
  97. {
  98.         pSizer->AddObject(this, sizeof(*this));
  99. }
  100.  
downloadClipVolume.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