1 /*---------------------------------------------------------------------------*\
5 * Copyright 2000-2002 by OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
42 TileLoadBalancer::RegionLoad::RegionLoad(TileGeometryLoad *load):
44 _invisibleFaces(0.f ),
50 /** Update region dependent values
53 void TileLoadBalancer::RegionLoad::updateCost(const Int32 wmin[2],
56 Real32 faces =Real32(_load->getFaces());
61 visible=_load->getVisibleFraction(wmin,wmax,vismin,vismax);
64 _visibleFaces=faces*visible;
65 _invisibleFaces=faces-_visibleFaces;
67 (vismax[0] - vismin[0] + 1)*
68 (vismax[1] - vismin[1] + 1));
78 /** Calculate the rendering cost
80 * \param renderNode Node to render the geometry
84 Real32 TileLoadBalancer::RegionLoad::getCost(const RenderNode &renderNode)
86 return renderNode.estimatePerformance(_invisibleFaces,
91 /** Calculate the rendering cost for the given region
93 * \param renderNode Node to render the geometry
94 * \param wmin bottom, left corner of the area
95 * \param wmax top, right corner of the area
99 Real32 TileLoadBalancer::RegionLoad::getCost(const RenderNode &renderNode,
101 const Int32 wmax[2]) const
106 Real32 invisibleFaces;
109 Real32 faces =Real32(_load->getFaces());
110 visible=_load->getVisibleFraction(wmin,wmax,vismin,vismax);
113 visibleFaces=faces*visible;
114 invisibleFaces=faces-visibleFaces;
116 (vismax[0] - vismin[0] + 1)*
117 (vismax[1] - vismin[1] + 1));
118 return renderNode.estimatePerformance(invisibleFaces,
123 /** Return gemetry load info object
126 TileGeometryLoad * TileLoadBalancer::RegionLoad::getLoad(void)