BVB Source Codes

CRYENGINE Show Voxelizer.h Source code

Return Download CRYENGINE: download Voxelizer.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __MNM_VOXELIZER_H
  4. #define __MNM_VOXELIZER_H
  5.  
  6. #pragma once
  7.  
  8. #include "DynamicSpanGrid.h"
  9.  
  10. namespace MNM
  11. {
  12. class Voxelizer
  13. {
  14. public:
  15.         Voxelizer();
  16.  
  17.         void                          Reset();
  18.         void                          Start(const AABB& volume, const Vec3& voxelSize);
  19.         void                          RasterizeTriangle(const Vec3 v0, const Vec3 v1, const Vec3 v2);
  20.  
  21.         inline const DynamicSpanGrid& GetSpanGrid() const
  22.         {
  23.                 return m_spanGrid;
  24.         }
  25.  
  26. #if DEBUG_MNM_ENABLED
  27.         void SetDebugRawGeometryContainer(std::vector<Triangle>* pDebugRawGeometry)
  28.         {
  29.                 m_pDebugRawGeometry = pDebugRawGeometry;
  30.         }
  31. #endif // DEBUG_MNM_ENABLED
  32.  
  33. protected:
  34.         template<typename Ty>
  35.         inline Vec3_tpl<Ty> Maximize(const Vec3_tpl<Ty> a, const Vec3_tpl<Ty> b)
  36.         {
  37.                 return Vec3_tpl<Ty>(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
  38.         }
  39.  
  40.         template<typename Ty>
  41.         inline Vec3_tpl<Ty> Maximize(const Vec3_tpl<Ty> a, const Vec3_tpl<Ty> b, const Vec3_tpl<Ty> c)
  42.         {
  43.                 return Vec3_tpl<Ty>(max(max(a.x, b.x), c.x), max(max(a.y, b.y), c.y), max(max(a.z, b.z), c.z));
  44.         }
  45.  
  46.         template<typename Ty>
  47.         inline Vec3_tpl<Ty> Minimize(const Vec3_tpl<Ty> a, const Vec3_tpl<Ty> b)
  48.         {
  49.                 return Vec3_tpl<Ty>(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
  50.         }
  51.  
  52.         template<typename Ty>
  53.         inline Vec3_tpl<Ty> Minimize(const Vec3_tpl<Ty> a, const Vec3_tpl<Ty> b, const Vec3_tpl<Ty> c)
  54.         {
  55.                 return Vec3_tpl<Ty>(min(min(a.x, b.x), c.x), min(min(a.y, b.y), c.y), min(min(a.z, b.z), c.z));
  56.         }
  57.  
  58.         inline void Evaluate2DEdge(Vec2& edgeNormal, float& distanceEdge, bool cw, const Vec2 edge,
  59.                                    const Vec2 vertex, const Vec2 ext)
  60.         {
  61.                 edgeNormal = cw ? Vec2(edge.y, -edge.x) : Vec2(-edge.y, edge.x);
  62.                 distanceEdge = edgeNormal.Dot(Vec2(edgeNormal.x >= 0.0f ? ext.x : 0.0f, edgeNormal.y >= 0.0f ? ext.y : 0.0f) - vertex);
  63.         }
  64.  
  65.         AABB            m_volumeAABB;
  66.         Vec3            m_voxelSize;
  67.         Vec3            m_voxelConv;
  68.         Vec3i           m_voxelSpaceSize;
  69.  
  70.         DynamicSpanGrid m_spanGrid;
  71.  
  72. #if DEBUG_MNM_ENABLED
  73.         std::vector<Triangle>* m_pDebugRawGeometry;
  74. #endif   // DEBUG_MNM_ENABLED
  75. };
  76.  
  77. class WorldVoxelizer
  78.         : public Voxelizer
  79. {
  80. public:
  81.         size_t ProcessGeometry(uint32 hashValueSeed = 0, uint32 hashTest = 0, uint32* hashValue = 0,
  82.                                NavigationMeshEntityCallback pEntityCallback = NULL);
  83.         void   CalculateWaterDepth();
  84.  
  85. private:
  86.         void   VoxelizeGeometry(const Vec3* vertices, size_t triCount, const Matrix34& worldTM);
  87.         void   VoxelizeGeometry(const strided_pointer<Vec3>& vertices, const index_t* indices, size_t triCount,
  88.                                 const Matrix34& worldTM);
  89.         void   VoxelizeGeometry(const Vec3* vertices, const uint32* indices, size_t triCount, const Matrix34& worldTM);
  90.         AABB   ComputeTerrainAABB(IGeometry* geometry);
  91.         size_t VoxelizeTerrain(IGeometry* geometry, const Matrix34& worldTM);
  92.         size_t VoxelizeGeometry(IGeometry* geometry, const Matrix34& worldTM);
  93. };
  94. }
  95.  
  96. #endif  // #ifndef __MNM_VOXELIZER_H
  97.  
downloadVoxelizer.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