aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h b/src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h
new file mode 100644
index 0000000..2445467
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/COctreeTriangleSelector.h
@@ -0,0 +1,80 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_OCTREE_TRIANGLE_SELECTOR_H_INCLUDED__
6#define __C_OCTREE_TRIANGLE_SELECTOR_H_INCLUDED__
7
8#include "CTriangleSelector.h"
9
10namespace irr
11{
12namespace scene
13{
14
15class ISceneNode;
16
17//! Stupid triangle selector without optimization
18class COctreeTriangleSelector : public CTriangleSelector
19{
20public:
21
22 //! Constructs a selector based on a mesh
23 COctreeTriangleSelector(const IMesh* mesh, ISceneNode* node, s32 minimalPolysPerNode);
24
25 virtual ~COctreeTriangleSelector();
26
27 //! Gets all triangles which lie within a specific bounding box.
28 virtual void getTriangles(core::triangle3df* triangles, s32 arraySize, s32& outTriangleCount,
29 const core::aabbox3d<f32>& box, const core::matrix4* transform=0) const;
30
31 //! Gets all triangles which have or may have contact with a 3d line.
32 virtual void getTriangles(core::triangle3df* triangles, s32 arraySize,
33 s32& outTriangleCount, const core::line3d<f32>& line,
34 const core::matrix4* transform=0) const;
35
36private:
37
38 struct SOctreeNode
39 {
40 SOctreeNode()
41 {
42 for (u32 i=0; i!=8; ++i)
43 Child[i] = 0;
44 }
45
46 ~SOctreeNode()
47 {
48 for (u32 i=0; i!=8; ++i)
49 delete Child[i];
50 }
51
52 core::array<core::triangle3df> Triangles;
53 SOctreeNode* Child[8];
54 core::aabbox3d<f32> Box;
55 };
56
57
58 void constructOctree(SOctreeNode* node);
59 void deleteEmptyNodes(SOctreeNode* node);
60 void getTrianglesFromOctree(SOctreeNode* node, s32& trianglesWritten,
61 s32 maximumSize, const core::aabbox3d<f32>& box,
62 const core::matrix4* transform,
63 core::triangle3df* triangles) const;
64
65 void getTrianglesFromOctree(SOctreeNode* node, s32& trianglesWritten,
66 s32 maximumSize, const core::line3d<f32>& line,
67 const core::matrix4* transform,
68 core::triangle3df* triangles) const;
69
70 SOctreeNode* Root;
71 s32 NodeCount;
72 s32 MinimalPolysPerNode;
73};
74
75} // end namespace scene
76} // end namespace irr
77
78
79#endif
80