Coverage Report

Created: 2025-12-25 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ogre/PlugIns/OctreeSceneManager/include/OgreOctree.h
Line
Count
Source
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OGRE
4
(Object-oriented Graphics Rendering Engine)
5
For the latest info, see http://www.ogre3d.org/
6
7
Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
-----------------------------------------------------------------------------
27
*/
28
/***************************************************************************
29
octree.h  -  description
30
-------------------
31
begin                : Mon Sep 30 2002
32
copyright            : (C) 2002 by Jon Anderson
33
email                : janders@users.sf.net
34
35
***************************************************************************/
36
37
#ifndef OCTREE_H
38
#define OCTREE_H
39
40
#include "OgreAxisAlignedBox.h"
41
42
#include <list>
43
44
namespace Ogre
45
{
46
/** \addtogroup Plugins Plugins
47
*  @{
48
*/
49
/** \defgroup Octree OctreeSceneManager
50
* Octree datastructure for managing scene nodes.
51
*  @{
52
*/
53
class OctreeNode;
54
55
/** Octree datastructure for managing scene nodes.
56
57
This is a loose octree implementation, meaning that each
58
octant child of the octree actually overlaps it's siblings by a factor
59
of .5.  This guarantees that any thing that is half the size of the parent will
60
fit completely into a child, with no splitting necessary.
61
*/
62
63
class Octree : public NodeAlloc
64
{
65
public:
66
    Octree( Octree * p );
67
    ~Octree();
68
69
    /** Adds an Octree scene node to this octree level.
70
71
    This is called by the OctreeSceneManager after
72
    it has determined the correct Octree to insert the node into.
73
    */
74
    void _addNode( OctreeNode * );
75
76
    /** Removes an Octree scene node to this octree level.
77
    */
78
    void _removeNode( OctreeNode * );
79
80
    /** Returns the number of scene nodes attached to this octree
81
    */
82
    int numNodes()
83
0
    {
84
0
        return mNumNodes;
85
0
    };
86
87
    /** The bounding box of the octree
88
89
    This is used for octant index determination and rendering, but not culling
90
    */
91
    AxisAlignedBox mBox;
92
    WireBoundingBox* mWireBoundingBox;
93
    
94
    /** Creates the wire frame bounding box for this octant
95
    */
96
    WireBoundingBox* getWireBoundingBox();
97
98
    /** Vector containing the dimensions of this octree / 2
99
    */
100
    Vector3 mHalfSize;
101
102
    /** 3D array of children of this octree.
103
104
    Children are dynamically created as needed when nodes are inserted in the Octree.
105
    If, later, all the nodes are removed from the child, it is still kept around.
106
    */
107
    Octree * mChildren[ 2 ][ 2 ][ 2 ];
108
109
    /** Determines if this octree is twice as big as the given box.
110
111
    This method is used by the OctreeSceneManager to determine if the given
112
    box will fit into a child of this octree.
113
    */
114
    bool _isTwiceSize( const AxisAlignedBox &box ) const;
115
116
    /**  Returns the appropriate indexes for the child of this octree into which the box will fit.
117
118
    This is used by the OctreeSceneManager to determine which child to traverse next when
119
    finding the appropriate octree to insert the box.  Since it is a loose octree, only the
120
    center of the box is checked to determine the octant.
121
    */
122
    void _getChildIndexes( const AxisAlignedBox &, int *x, int *y, int *z ) const;
123
124
    /** Creates the AxisAlignedBox used for culling this octree.
125
126
    Since it's a loose octree, the culling bounds can be different than the actual bounds of the octree.
127
    */
128
    void _getCullBounds( AxisAlignedBox * ) const;
129
130
131
    typedef std::vector< OctreeNode * > NodeList;
132
    /** Public list of SceneNodes attached to this particular octree
133
    */
134
    NodeList mNodes;
135
136
protected:
137
138
    /** Increments the overall node count of this octree and all its parents
139
    */
140
    inline void _ref()
141
0
    {
142
0
        mNumNodes++;
143
144
0
        if ( mParent != 0 ) mParent -> _ref();
145
0
    };
146
147
    /** Decrements the overall node count of this octree and all its parents
148
    */
149
    inline void _unref()
150
0
    {
151
0
        mNumNodes--;
152
153
0
        if ( mParent != 0 ) mParent -> _unref();
154
0
    };
155
156
    ///number of SceneNodes in this octree and all its children.
157
    int mNumNodes;
158
159
    ///parent octree
160
    Octree * mParent;
161
162
};
163
/** @} */
164
/** @} */
165
}
166
#endif
167
168