OGRE  1.9.0
OgreVolumeOctreeNodeSplitPolicy.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __Ogre_Volume_OctreeNodeSplitPolicy_H__
29#define __Ogre_Volume_OctreeNodeSplitPolicy_H__
30
31#include "OgreVector3.h"
32
33#include "OgreVolumeSource.h"
36
37namespace Ogre {
38namespace Volume {
39
40 class OctreeNode;
41
47 {
48 protected:
49
51 const Source *mSrc;
52
55
78 inline Real interpolate(const Real f000, const Real f001, const Real f010, const Real f011,
79 const Real f100, const Real f101, const Real f110, const Real f111, const Vector3 &position) const
80 {
81 Real oneMinX = (Real)1.0 - position.x;
82 Real oneMinY = (Real)1.0 - position.y;
83 Real oneMinZ = (Real)1.0 - position.z;
84 Real oneMinXoneMinY = oneMinX * oneMinY;
85 Real xOneMinY = position.x * oneMinY;
86 return oneMinZ * (f000 * oneMinXoneMinY
87 + f100 * xOneMinY
88 + f010 * oneMinX * position.y)
89 + position.z * (f001 * oneMinXoneMinY
90 + f101 * xOneMinY
91 + f011 * oneMinX * position.y)
92 + position.x * position.y * (f110 * oneMinZ
93 + f111 * position.z);
94 }
95
96 public:
97
104 OctreeNodeSplitPolicy(const Source *src, const Real maxCellSize);
105
114 bool doSplit(OctreeNode *node, const Real geometricError) const;
115 };
116
117}
118}
119
120#endif
#define _OgreVolumeExport
Standard 3-dimensional vector.
Definition OgreVector3.h:52
const Source * mSrc
Holds the volume source to decide something.
Real mMaxCellSize
The maximum cell size where the policy stops the splitting.
bool doSplit(OctreeNode *node, const Real geometricError) const
Decider for the splitting.
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.
OctreeNodeSplitPolicy(const Source *src, const Real maxCellSize)
Constructur.
A node in the volume octree.
Abstract class defining the density function.
float Real
Software floating point type.