~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/COctreeTriangleSelector.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 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
 
 
10
namespace irr
 
11
{
 
12
namespace scene
 
13
{
 
14
 
 
15
class ISceneNode;
 
16
 
 
17
//! Stupid triangle selector without optimization
 
18
class COctreeTriangleSelector : public CTriangleSelector
 
19
{
 
20
public:
 
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
 
 
36
private:
 
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