1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSG_TILE_LOAD_BALANCER_H_
40 #define _OSG_TILE_LOAD_BALANCER_H_
48 #include "OSGTileGeometryLoad.h"
49 #include "OSGRenderNode.h"
55 /*! \ingroup GrpClusterWindowBalancer
56 \ingroup GrpLibOSGCluster
60 class OSG_CLUSTER_DLLMAPPING TileLoadBalancer
62 /*========================== PUBLIC =================================*/
78 typedef std::vector
<TileGeometryLoad
> TileGeometryLoadLstT
;
79 typedef std::map
<UInt32
,
80 TileGeometryLoadLstT::iterator
> TileGeometryLoadMapT
;
82 typedef std::vector
<Region
> ResultT
;
83 typedef std::vector
<RenderNode
> RenderNodeLstT
;
85 /*---------------------------------------------------------------------*/
90 /*---------------------------------------------------------------------*/
91 /*! \name General Fieldcontainer Declaration */
95 /*---------------------------------------------------------------------*/
96 /*! \name Constructors */
99 TileLoadBalancer(bool useFaceDistribution
=false,
100 bool cutBestDirection
=true);
101 TileLoadBalancer(const TileLoadBalancer
&source
);
104 /*---------------------------------------------------------------------*/
105 /*! \name Assignment */
108 TileLoadBalancer
& operator =(const TileLoadBalancer
&source
);
111 /*---------------------------------------------------------------------*/
112 /*! \name Destructor */
115 virtual ~TileLoadBalancer(void);
118 /*---------------------------------------------------------------------*/
119 /*! \name Load balancing functions */
122 void update (Node
*node
);
123 void balance (Viewport
*vp
,
126 void addRenderNode (const RenderNode
&rn
,UInt32 id
);
127 void drawVolumes (Window
*win
);
128 void setRegionStatistics(Viewport
*vp
,
132 /*---------------------------------------------------------------------*/
137 /*---------------------------------------------------------------------*/
142 /*---------------------------------------------------------------------*/
147 /*========================= PROTECTED ===============================*/
151 /*---------------------------------------------------------------------*/
161 RegionLoad ( TileGeometryLoad
*load
=NULL
);
162 Real32
getCost ( const RenderNode
&renderNode
);
163 Real32
getCost ( const RenderNode
&renderNode
,
165 const Int32 wmax
[2] ) const;
166 TileGeometryLoad
*getLoad ( void );
167 void updateCost( const Int32 wmin
[2],
168 const Int32 wmax
[2] );
170 Real32 _visibleFaces
;
171 Real32 _invisibleFaces
;
173 TileGeometryLoad
*_load
;
176 typedef std::vector
<RegionLoad
> RegionLoadVecT
;
179 /*---------------------------------------------------------------------*/
183 TileGeometryLoadLstT _tileGeometryLoad
;
184 RenderNodeLstT _renderNode
;
185 bool _useFaceDistribution
;
186 bool _cutBestDirection
;
189 /*---------------------------------------------------------------------*/
193 double runFaceBench(GLuint dlist
,UInt32 size
,Real32 visible
);
194 void updateSubtree (Node
* const node
,TileGeometryLoadMapT
&loadMap
);
195 void splitRegion (UInt32 rnFrom
,
197 RegionLoadVecT
&visible
,
202 Real32
findBestCut (const RenderNode
&renderNodeA
,
203 const RenderNode
&renderNodeB
,
204 RegionLoadVecT
&visible
,
209 double calcFaceRenderingCost(TileGeometryLoad
*load
,
210 Int32 amin
[2],Int32 amax
[2]);
214 /*========================== PRIVATE ================================*/
218 friend class RegionLoad
;
223 #include "OSGTileLoadBalancer.inl"
225 #endif /* _TILE_GEOMETRY_LOADMANAGER_H_ */