OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreVolumeOctreeNodeSplitPolicy.h
Go to the documentation of this file.
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 #ifndef __Ogre_Volume_OctreeNodeSplitPolicy_H__
29 #define __Ogre_Volume_OctreeNodeSplitPolicy_H__
30 
31 #include "OgreVector3.h"
32 
34 
35 namespace Ogre {
36 namespace Volume {
37 
38  class OctreeNode;
39  class Source;
40 
46  {
47  protected:
48 
50  const Source *mSrc;
51 
54 
77  inline Real interpolate(const Real f000, const Real f001, const Real f010, const Real f011,
78  const Real f100, const Real f101, const Real f110, const Real f111, const Vector3 &position) const
79  {
80  Real oneMinX = (Real)1.0 - position.x;
81  Real oneMinY = (Real)1.0 - position.y;
82  Real oneMinZ = (Real)1.0 - position.z;
83  Real oneMinXoneMinY = oneMinX * oneMinY;
84  Real xOneMinY = position.x * oneMinY;
85  return oneMinZ * (f000 * oneMinXoneMinY
86  + f100 * xOneMinY
87  + f010 * oneMinX * position.y)
88  + position.z * (f001 * oneMinXoneMinY
89  + f101 * xOneMinY
90  + f011 * oneMinX * position.y)
91  + position.x * position.y * (f110 * oneMinZ
92  + f111 * position.z);
93  }
94 
95  public:
96 
103  OctreeNodeSplitPolicy(const Source *src, const Real maxCellSize);
104 
113  bool doSplit(OctreeNode *node, const Real geometricError) const;
114  };
115 
116 }
117 }
118 
119 #endif
float Real
Software floating point type.
Real mMaxCellSize
The maximum cell size where the policy stops the splitting.
Abstract class defining the density function.
const Source * mSrc
Holds the volume source to decide something.
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Real interpolate(const Real f000, const Real f001, const Real f010, const Real f011, const Real f100, const Real f101, const Real f110, const Real f111, const Vector3 &position) const
Trilinear interpolation of a relative point.
A node in the volume octree.
The class deciding on whether to split an octree node or not when building the octree.
#define _OgreVolumeExport