[1237] | 1 | #ifndef _BvHierarchy_H__
|
---|
| 2 | #define _BvHierarchy_H__
|
---|
| 3 |
|
---|
| 4 | #include <stack>
|
---|
| 5 |
|
---|
| 6 | #include "Mesh.h"
|
---|
| 7 | #include "Containers.h"
|
---|
| 8 | #include "Statistics.h"
|
---|
| 9 | #include "VssRay.h"
|
---|
| 10 | #include "RayInfo.h"
|
---|
| 11 | #include "gzstream.h"
|
---|
[1239] | 12 | #include "SubdivisionCandidate.h"
|
---|
[1237] | 13 | #include "AxisAlignedBox3.h"
|
---|
[1315] | 14 | #include "IntersectableWrapper.h"
|
---|
[1667] | 15 | #include "HierarchyManager.h"
|
---|
[1237] | 16 |
|
---|
| 17 |
|
---|
| 18 | namespace GtpVisibilityPreprocessor {
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | class ViewCellLeaf;
|
---|
| 22 | class Plane3;
|
---|
| 23 | class AxisAlignedBox3;
|
---|
| 24 | class Ray;
|
---|
| 25 | class ViewCellsStatistics;
|
---|
| 26 | class ViewCellsManager;
|
---|
| 27 | class MergeCandidate;
|
---|
| 28 | class Beam;
|
---|
| 29 | class ViewCellsTree;
|
---|
| 30 | class Environment;
|
---|
| 31 | class BvhInterior;
|
---|
| 32 | class BvhLeaf;
|
---|
| 33 | class BvhNode;
|
---|
| 34 | class BvhTree;
|
---|
| 35 | class VspTree;
|
---|
| 36 | class ViewCellsContainer;
|
---|
[1370] | 37 | class HierarchyManager;
|
---|
[1237] | 38 |
|
---|
[1297] | 39 |
|
---|
[1237] | 40 | /** View space partition statistics.
|
---|
| 41 | */
|
---|
| 42 | class BvhStatistics: public StatisticsBase
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
[1370] | 45 |
|
---|
| 46 | /// Constructor
|
---|
[1237] | 47 | BvhStatistics()
|
---|
| 48 | {
|
---|
| 49 | Reset();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | int Nodes() const {return nodes;}
|
---|
| 53 | int Interior() const { return nodes / 2; }
|
---|
| 54 | int Leaves() const { return (nodes / 2) + 1; }
|
---|
| 55 |
|
---|
| 56 | double AvgDepth() const
|
---|
| 57 | { return accumDepth / (double)Leaves(); }
|
---|
| 58 |
|
---|
[1370] | 59 | double AvgObjectRefs() const
|
---|
| 60 | { return objectRefs / (double)Leaves(); }
|
---|
| 61 |
|
---|
| 62 | double AvgRayRefs() const
|
---|
| 63 | { return rayRefs / (double)Leaves(); }
|
---|
| 64 |
|
---|
[1763] | 65 |
|
---|
[1237] | 66 | void Reset()
|
---|
| 67 | {
|
---|
| 68 | nodes = 0;
|
---|
| 69 | splits = 0;
|
---|
| 70 | maxDepth = 0;
|
---|
[1705] | 71 |
|
---|
[1237] | 72 | minDepth = 99999;
|
---|
| 73 | accumDepth = 0;
|
---|
| 74 | maxDepthNodes = 0;
|
---|
| 75 | minProbabilityNodes = 0;
|
---|
| 76 | maxCostNodes = 0;
|
---|
[1370] | 77 | ///////////////////
|
---|
| 78 | minObjectsNodes = 0;
|
---|
[1237] | 79 | maxObjectRefs = 0;
|
---|
[1370] | 80 | minObjectRefs = 999999999;
|
---|
[1237] | 81 | objectRefs = 0;
|
---|
[1408] | 82 | emptyNodes = 0;
|
---|
[1370] | 83 |
|
---|
| 84 | ///////////////////
|
---|
| 85 | minRaysNodes = 0;
|
---|
| 86 | maxRayRefs = 0;
|
---|
| 87 | minRayRefs = 999999999;
|
---|
| 88 | rayRefs = 0;
|
---|
| 89 | maxRayContriNodes = 0;
|
---|
[1449] | 90 | mGlobalCostMisses = 0;
|
---|
[1237] | 91 | }
|
---|
| 92 |
|
---|
[1370] | 93 |
|
---|
| 94 | public:
|
---|
| 95 |
|
---|
| 96 | // total number of nodes
|
---|
| 97 | int nodes;
|
---|
| 98 | // number of splits
|
---|
| 99 | int splits;
|
---|
| 100 | // maximal reached depth
|
---|
| 101 | int maxDepth;
|
---|
| 102 | // minimal depth
|
---|
| 103 | int minDepth;
|
---|
| 104 | // max depth nodes
|
---|
| 105 | int maxDepthNodes;
|
---|
| 106 | // accumulated depth (used to compute average)
|
---|
| 107 | int accumDepth;
|
---|
| 108 | // minimum area nodes
|
---|
| 109 | int minProbabilityNodes;
|
---|
| 110 | /// nodes termination because of max cost ratio;
|
---|
| 111 | int maxCostNodes;
|
---|
[1449] | 112 | // global cost ratio violations
|
---|
| 113 | int mGlobalCostMisses;
|
---|
[1370] | 114 |
|
---|
[1449] | 115 | //////////////////
|
---|
[1370] | 116 | // nodes with minimum objects
|
---|
| 117 | int minObjectsNodes;
|
---|
| 118 | // max number of rays per node
|
---|
| 119 | int maxObjectRefs;
|
---|
| 120 | // min number of rays per node
|
---|
| 121 | int minObjectRefs;
|
---|
| 122 | /// object references
|
---|
| 123 | int objectRefs;
|
---|
[1408] | 124 | // leaves with no objects
|
---|
| 125 | int emptyNodes;
|
---|
[1370] | 126 |
|
---|
| 127 | //////////////////////////
|
---|
| 128 | // nodes with minimum rays
|
---|
| 129 | int minRaysNodes;
|
---|
| 130 | // max number of rays per node
|
---|
| 131 | int maxRayRefs;
|
---|
| 132 | // min number of rays per node
|
---|
| 133 | int minRayRefs;
|
---|
| 134 | /// object references
|
---|
| 135 | int rayRefs;
|
---|
| 136 | /// nodes with max ray contribution
|
---|
| 137 | int maxRayContriNodes;
|
---|
| 138 |
|
---|
[1237] | 139 | void Print(ostream &app) const;
|
---|
| 140 |
|
---|
| 141 | friend ostream &operator<<(ostream &s, const BvhStatistics &stat)
|
---|
| 142 | {
|
---|
| 143 | stat.Print(s);
|
---|
| 144 | return s;
|
---|
| 145 | }
|
---|
| 146 | };
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | /**
|
---|
| 150 | VspNode abstract class serving for interior and leaf node implementation
|
---|
| 151 | */
|
---|
[1758] | 152 | class BvhNode: public Intersectable
|
---|
[1237] | 153 | {
|
---|
| 154 | public:
|
---|
| 155 |
|
---|
| 156 | // types of vsp nodes
|
---|
| 157 | enum {Interior, Leaf};
|
---|
| 158 |
|
---|
[1297] | 159 | BvhNode();
|
---|
[1237] | 160 | BvhNode(const AxisAlignedBox3 &bbox);
|
---|
| 161 | BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent);
|
---|
| 162 |
|
---|
| 163 | virtual ~BvhNode(){};
|
---|
| 164 |
|
---|
| 165 | /** Determines whether this node is a leaf or not
|
---|
| 166 | @return true if leaf
|
---|
| 167 | */
|
---|
| 168 | virtual bool IsLeaf() const = 0;
|
---|
| 169 |
|
---|
| 170 | /** Determines whether this node is a root
|
---|
| 171 | @return true if root
|
---|
| 172 | */
|
---|
| 173 | virtual bool IsRoot() const;
|
---|
| 174 |
|
---|
| 175 | /** Returns parent node.
|
---|
| 176 | */
|
---|
| 177 | BvhInterior *GetParent();
|
---|
| 178 |
|
---|
| 179 | /** Sets parent node.
|
---|
| 180 | */
|
---|
| 181 | void SetParent(BvhInterior *parent);
|
---|
| 182 |
|
---|
[1666] | 183 | /** collects all objects under this node.
|
---|
| 184 | */
|
---|
[1614] | 185 | virtual void CollectObjects(ObjectContainer &objects) = 0;
|
---|
[1666] | 186 |
|
---|
[1237] | 187 | /** The bounding box specifies the node extent.
|
---|
| 188 | */
|
---|
[1357] | 189 | inline
|
---|
[1237] | 190 | AxisAlignedBox3 GetBoundingBox() const
|
---|
| 191 | { return mBoundingBox; }
|
---|
| 192 |
|
---|
[1666] | 193 | /** Sets bouding box of this node.
|
---|
| 194 | */
|
---|
[1357] | 195 | inline
|
---|
[1237] | 196 | void SetBoundingBox(const AxisAlignedBox3 &boundingBox)
|
---|
| 197 | { mBoundingBox = boundingBox; }
|
---|
| 198 |
|
---|
[1679] | 199 | /** Cost of mergin this node.
|
---|
| 200 | */
|
---|
| 201 | float GetMergeCost() {return (float)-mTimeStamp; }
|
---|
[1237] | 202 |
|
---|
[1763] | 203 | virtual int GetRandomEdgePoint(Vector3 &point,
|
---|
| 204 | Vector3 &normal);
|
---|
[1666] | 205 |
|
---|
[1763] | 206 | inline int GetTimeStamp() const { return mTimeStamp; }
|
---|
| 207 | inline void SetTimeStamp(const int timeStamp) { mTimeStamp = timeStamp; };
|
---|
| 208 |
|
---|
[1237] | 209 |
|
---|
[1786] | 210 | ////////////////////////
|
---|
[1758] | 211 | //-- inherited functions from Intersectable
|
---|
| 212 |
|
---|
| 213 | AxisAlignedBox3 GetBox() const { return mBoundingBox; }
|
---|
| 214 |
|
---|
| 215 | int CastRay(Ray &ray) { return 0; }
|
---|
| 216 |
|
---|
| 217 | bool IsConvex() const { return true; }
|
---|
| 218 | bool IsWatertight() const { return true; }
|
---|
| 219 | float IntersectionComplexity() { return 1; }
|
---|
| 220 |
|
---|
| 221 | int NumberOfFaces() const { return 6; };
|
---|
| 222 |
|
---|
[1877] | 223 | int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
[1758] | 224 | GtpVisibilityPreprocessor::Vector3 &normal)
|
---|
| 225 | {
|
---|
| 226 | // TODO
|
---|
| 227 | return 0;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
|
---|
| 231 | GtpVisibilityPreprocessor::Vector3 &normal,
|
---|
| 232 | const GtpVisibilityPreprocessor::Vector3 &viewpoint,
|
---|
| 233 | const int maxTries)
|
---|
| 234 | {
|
---|
| 235 | // TODO
|
---|
| 236 | return 0;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | int Type() const
|
---|
| 240 | {
|
---|
| 241 | return Intersectable::BVH_INTERSECTABLE;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | ostream &Describe(ostream &s) { return s; }
|
---|
| 245 |
|
---|
[1237] | 246 | ///////////////////////////////////
|
---|
| 247 |
|
---|
[1786] | 248 | float mRenderCost;
|
---|
| 249 |
|
---|
[1237] | 250 | protected:
|
---|
| 251 |
|
---|
| 252 | /// the bounding box of the node
|
---|
| 253 | AxisAlignedBox3 mBoundingBox;
|
---|
| 254 | /// parent of this node
|
---|
| 255 | BvhInterior *mParent;
|
---|
[1763] | 256 | int mTimeStamp;
|
---|
[1237] | 257 | };
|
---|
| 258 |
|
---|
| 259 |
|
---|
| 260 | /** BSP interior node implementation
|
---|
| 261 | */
|
---|
| 262 | class BvhInterior: public BvhNode
|
---|
| 263 | {
|
---|
| 264 | public:
|
---|
| 265 | /** Standard contructor taking a bounding box as argument.
|
---|
| 266 | */
|
---|
| 267 | BvhInterior(const AxisAlignedBox3 &bbox);
|
---|
| 268 | BvhInterior(const AxisAlignedBox3 &bbox, BvhInterior *parent);
|
---|
| 269 |
|
---|
| 270 | ~BvhInterior();
|
---|
| 271 | /** @return false since it is an interior node
|
---|
| 272 | */
|
---|
| 273 | bool IsLeaf() const;
|
---|
[1294] | 274 |
|
---|
[1237] | 275 | BvhNode *GetBack() { return mBack; }
|
---|
| 276 | BvhNode *GetFront() { return mFront; }
|
---|
| 277 |
|
---|
| 278 | /** Replace front or back child with new child.
|
---|
| 279 | */
|
---|
| 280 | void ReplaceChildLink(BvhNode *oldChild, BvhNode *newChild);
|
---|
| 281 |
|
---|
| 282 | /** Replace front and back child.
|
---|
| 283 | */
|
---|
| 284 | void SetupChildLinks(BvhNode *front, BvhNode *back);
|
---|
| 285 |
|
---|
| 286 | friend ostream &operator<<(ostream &s, const BvhInterior &A)
|
---|
| 287 | {
|
---|
| 288 | return s << A.mBoundingBox;
|
---|
| 289 | }
|
---|
[1679] | 290 |
|
---|
| 291 | virtual void CollectObjects(ObjectContainer &objects);
|
---|
[1684] | 292 |
|
---|
[1237] | 293 | protected:
|
---|
| 294 |
|
---|
| 295 | /// back node
|
---|
| 296 | BvhNode *mBack;
|
---|
| 297 | /// front node
|
---|
| 298 | BvhNode *mFront;
|
---|
| 299 | };
|
---|
| 300 |
|
---|
| 301 |
|
---|
| 302 | /** BSP leaf node implementation.
|
---|
| 303 | */
|
---|
| 304 | class BvhLeaf: public BvhNode
|
---|
| 305 | {
|
---|
| 306 | public:
|
---|
| 307 | /** Standard contructor taking a bounding box as argument.
|
---|
| 308 | */
|
---|
| 309 | BvhLeaf(const AxisAlignedBox3 &bbox);
|
---|
[1920] | 310 | BvhLeaf(const AxisAlignedBox3 &bbox, BvhInterior *parent);
|
---|
[1237] | 311 | BvhLeaf(const AxisAlignedBox3 &bbox, BvhInterior *parent, const int numObjects);
|
---|
| 312 |
|
---|
| 313 | ~BvhLeaf();
|
---|
| 314 |
|
---|
| 315 | /** @return true since it is an interior node
|
---|
| 316 | */
|
---|
| 317 | bool IsLeaf() const;
|
---|
| 318 |
|
---|
[1297] | 319 | SubdivisionCandidate *GetSubdivisionCandidate()// const
|
---|
[1237] | 320 | {
|
---|
| 321 | return mSubdivisionCandidate;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[1297] | 324 | void SetSubdivisionCandidate(SubdivisionCandidate *candidate)
|
---|
| 325 | {
|
---|
| 326 | mSubdivisionCandidate = candidate;
|
---|
| 327 | }
|
---|
[1684] | 328 |
|
---|
| 329 | virtual void CollectObjects(ObjectContainer &objects);
|
---|
| 330 |
|
---|
[1707] | 331 | /** Returns level of the hierarchy that is "active" right now.
|
---|
[1706] | 332 | */
|
---|
| 333 | BvhNode *GetActiveNode()
|
---|
| 334 | {
|
---|
| 335 | return mActiveNode;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
[1707] | 338 | /** Returns level of the hierarchy that is "active" right now.
|
---|
| 339 | */
|
---|
| 340 | void SetActiveNode(BvhNode *node)
|
---|
| 341 | {
|
---|
| 342 | mActiveNode = node;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
[1237] | 345 | public:
|
---|
[1785] | 346 | // gl list use to store the geometry on the gl server
|
---|
| 347 | int mGlList;
|
---|
| 348 |
|
---|
| 349 | /// objects
|
---|
| 350 | ObjectContainer mObjects;
|
---|
| 351 |
|
---|
[1920] | 352 |
|
---|
[1237] | 353 | protected:
|
---|
[1785] | 354 |
|
---|
| 355 | /// pointer to a split plane candidate splitting this leaf
|
---|
| 356 | SubdivisionCandidate *mSubdivisionCandidate;
|
---|
| 357 |
|
---|
| 358 | /// the active node which will be accounted for in the pvs
|
---|
| 359 | BvhNode *mActiveNode;
|
---|
[1237] | 360 | };
|
---|
| 361 |
|
---|
| 362 |
|
---|
| 363 | /** View Space Partitioning tree.
|
---|
| 364 | */
|
---|
| 365 | class BvHierarchy
|
---|
| 366 | {
|
---|
| 367 | friend class ViewCellsParseHandlers;
|
---|
| 368 | friend class HierarchyManager;
|
---|
| 369 |
|
---|
[1379] | 370 | protected:
|
---|
[1345] | 371 | struct SortableEntry;
|
---|
| 372 | typedef vector<SortableEntry> SortableEntryContainer;
|
---|
| 373 |
|
---|
[1379] | 374 | public:
|
---|
| 375 |
|
---|
[1237] | 376 | /** Additional data which is passed down the BSP tree during traversal.
|
---|
| 377 | */
|
---|
| 378 | class BvhTraversalData
|
---|
| 379 | {
|
---|
| 380 | public:
|
---|
[1294] | 381 |
|
---|
[1237] | 382 | BvhTraversalData():
|
---|
| 383 | mNode(NULL),
|
---|
| 384 | mDepth(0),
|
---|
| 385 | mMaxCostMisses(0),
|
---|
[1370] | 386 | mAxis(0),
|
---|
[1912] | 387 | mNumRays(0),
|
---|
| 388 | mCorrectedPvs(0),
|
---|
| 389 | mPvs(0),
|
---|
[1913] | 390 | mCorrectedVolume(0),
|
---|
| 391 | mVolume(0)
|
---|
[1357] | 392 | {
|
---|
[1778] | 393 | for (int i = 0; i < 4; ++ i)
|
---|
| 394 | mSortedObjects[i] = NULL;
|
---|
[1357] | 395 | }
|
---|
[1237] | 396 |
|
---|
| 397 | BvhTraversalData(BvhLeaf *node,
|
---|
| 398 | const int depth,
|
---|
[1370] | 399 | const float v,
|
---|
| 400 | const int numRays):
|
---|
[1237] | 401 | mNode(node),
|
---|
| 402 | mDepth(depth),
|
---|
| 403 | mMaxCostMisses(0),
|
---|
[1370] | 404 | mAxis(0),
|
---|
[1912] | 405 | mNumRays(numRays),
|
---|
| 406 | mCorrectedPvs(0),
|
---|
| 407 | mPvs(0),
|
---|
[1913] | 408 | mCorrectedVolume(0),
|
---|
| 409 | mVolume(v)
|
---|
[1357] | 410 | {
|
---|
[1778] | 411 | for (int i = 0; i < 4; ++ i)
|
---|
| 412 | mSortedObjects[i] = NULL;
|
---|
[1357] | 413 | }
|
---|
[1237] | 414 |
|
---|
[1357] | 415 | /** Deletes contents and sets them to NULL.
|
---|
| 416 | */
|
---|
[1237] | 417 | void Clear()
|
---|
| 418 | {
|
---|
[1294] | 419 | DEL_PTR(mNode);
|
---|
[1778] | 420 | for (int i = 0; i < 4; ++ i)
|
---|
| 421 | DEL_PTR(mSortedObjects[i]);
|
---|
[1237] | 422 | }
|
---|
| 423 |
|
---|
[1294] | 424 | /// the current node
|
---|
| 425 | BvhLeaf *mNode;
|
---|
| 426 | /// current depth
|
---|
| 427 | int mDepth;
|
---|
[1913] | 428 | /// the volume of the node
|
---|
| 429 | float mVolume;
|
---|
| 430 | /// the corrected volume
|
---|
| 431 | float mCorrectedVolume;
|
---|
[1294] | 432 | /// how often this branch has missed the max-cost ratio
|
---|
| 433 | int mMaxCostMisses;
|
---|
| 434 | /// current axis
|
---|
| 435 | int mAxis;
|
---|
[1370] | 436 | /// number of rays
|
---|
| 437 | int mNumRays;
|
---|
[1912] | 438 | /// parent Pvs;
|
---|
| 439 | float mPvs;
|
---|
| 440 | /// parent pvs correction factor
|
---|
| 441 | float mCorrectedPvs;
|
---|
| 442 |
|
---|
[1357] | 443 | /// the sorted objects for the three dimensions
|
---|
[1778] | 444 | ObjectContainer *mSortedObjects[4];
|
---|
[1237] | 445 | };
|
---|
| 446 |
|
---|
[1357] | 447 |
|
---|
| 448 | /** Candidate for a object space split.
|
---|
[1237] | 449 | */
|
---|
| 450 | class BvhSubdivisionCandidate: public SubdivisionCandidate
|
---|
| 451 | {
|
---|
| 452 | public:
|
---|
| 453 |
|
---|
[1294] | 454 | BvhSubdivisionCandidate(const BvhTraversalData &tData): mParentData(tData)
|
---|
[1237] | 455 | {};
|
---|
| 456 |
|
---|
[1305] | 457 | ~BvhSubdivisionCandidate()
|
---|
| 458 | {
|
---|
| 459 | mParentData.Clear();
|
---|
| 460 | }
|
---|
[1294] | 461 |
|
---|
[1237] | 462 | int Type() const { return OBJECT_SPACE; }
|
---|
| 463 |
|
---|
[1667] | 464 | void EvalCandidate(bool computeSplitplane = true)
|
---|
[1237] | 465 | {
|
---|
[1705] | 466 | mDirty = false;
|
---|
[1667] | 467 | sBvHierarchy->EvalSubdivisionCandidate(*this, computeSplitplane);
|
---|
[1237] | 468 | }
|
---|
| 469 |
|
---|
[1633] | 470 | bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet)
|
---|
[1632] | 471 | {
|
---|
[1667] | 472 | BvhNode *n = sBvHierarchy->Subdivide(splitQueue, this, terminationCriteriaMet);
|
---|
| 473 |
|
---|
[1632] | 474 | // local or global termination criteria failed
|
---|
| 475 | return !n->IsLeaf();
|
---|
[1633] | 476 | }
|
---|
[1632] | 477 |
|
---|
[1633] | 478 | void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
|
---|
| 479 | const bool onlyUnmailed)
|
---|
| 480 | {
|
---|
| 481 | sBvHierarchy->CollectDirtyCandidates(this, dirtyList, onlyUnmailed);
|
---|
| 482 | }
|
---|
| 483 |
|
---|
[1237] | 484 | bool GlobalTerminationCriteriaMet() const
|
---|
| 485 | {
|
---|
| 486 | return sBvHierarchy->GlobalTerminationCriteriaMet(mParentData);
|
---|
| 487 | }
|
---|
| 488 |
|
---|
[1667] | 489 | BvhSubdivisionCandidate(const ObjectContainer &frontObjects,
|
---|
| 490 | const ObjectContainer &backObjects,
|
---|
| 491 | const BvhTraversalData &tData):
|
---|
[1237] | 492 | mFrontObjects(frontObjects), mBackObjects(backObjects), mParentData(tData)
|
---|
| 493 | {}
|
---|
[1294] | 494 |
|
---|
[1667] | 495 | float GetPriority() const
|
---|
| 496 | {
|
---|
[1705] | 497 | return mPriority;
|
---|
[1667] | 498 | }
|
---|
| 499 |
|
---|
[1912] | 500 | /////////////////////////////7
|
---|
| 501 |
|
---|
[1305] | 502 | /// pointer to parent tree.
|
---|
[1294] | 503 | static BvHierarchy *sBvHierarchy;
|
---|
[1680] | 504 |
|
---|
[1294] | 505 | /// parent data
|
---|
| 506 | BvhTraversalData mParentData;
|
---|
[1305] | 507 | /// the objects on the front of the potential split
|
---|
[1294] | 508 | ObjectContainer mFrontObjects;
|
---|
[1305] | 509 | /// the objects on the back of the potential split
|
---|
[1294] | 510 | ObjectContainer mBackObjects;
|
---|
[1912] | 511 |
|
---|
| 512 | float mCorrectedFrontPvs;
|
---|
| 513 | float mCorrectedBackPvs;
|
---|
| 514 |
|
---|
[1913] | 515 | float mCorrectedFrontVolume;
|
---|
| 516 | float mCorrectedBackVolume;
|
---|
[1237] | 517 | };
|
---|
| 518 |
|
---|
| 519 | /** Struct for traversing line segment.
|
---|
| 520 | */
|
---|
| 521 | struct LineTraversalData
|
---|
| 522 | {
|
---|
| 523 | BvhNode *mNode;
|
---|
| 524 | Vector3 mExitPoint;
|
---|
| 525 |
|
---|
| 526 | float mMaxT;
|
---|
| 527 |
|
---|
| 528 | LineTraversalData () {}
|
---|
| 529 | LineTraversalData (BvhNode *n, const Vector3 &p, const float maxt):
|
---|
| 530 | mNode(n), mExitPoint(p), mMaxT(maxt) {}
|
---|
| 531 | };
|
---|
| 532 |
|
---|
| 533 |
|
---|
| 534 | /** Default constructor creating an empty tree.
|
---|
| 535 | */
|
---|
| 536 | BvHierarchy();
|
---|
| 537 |
|
---|
| 538 | /** Default destructor.
|
---|
| 539 | */
|
---|
| 540 | ~BvHierarchy();
|
---|
| 541 |
|
---|
| 542 | /** Returns tree statistics.
|
---|
| 543 | */
|
---|
| 544 | const BvhStatistics &GetStatistics() const;
|
---|
| 545 |
|
---|
| 546 | /** Returns bounding box of the specified node.
|
---|
| 547 | */
|
---|
| 548 | AxisAlignedBox3 GetBoundingBox(BvhNode *node) const;
|
---|
| 549 |
|
---|
| 550 | /** Reads parameters from environment singleton.
|
---|
| 551 | */
|
---|
| 552 | void ReadEnvironment();
|
---|
| 553 |
|
---|
| 554 | /** Evaluates candidate for splitting.
|
---|
| 555 | */
|
---|
[1680] | 556 | void EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitData,
|
---|
| 557 | bool computeSplitPlane = true);
|
---|
[1237] | 558 |
|
---|
[1707] | 559 | /** Returns vector of leaves.
|
---|
[1237] | 560 | */
|
---|
[1707] | 561 | void CollectLeaves(BvhNode *root, vector<BvhLeaf *> &leaves) const;
|
---|
[1237] | 562 |
|
---|
| 563 | /** Returns bounding box of the whole tree (= bbox of root node)
|
---|
| 564 | */
|
---|
| 565 | AxisAlignedBox3 GetBoundingBox()const;
|
---|
| 566 |
|
---|
| 567 | /** Returns root of the view space partitioning tree.
|
---|
| 568 | */
|
---|
| 569 | BvhNode *GetRoot() const;
|
---|
| 570 |
|
---|
| 571 | /** finds neighbouring leaves of this tree node.
|
---|
| 572 | */
|
---|
| 573 | int FindNeighbors(BvhLeaf *n,
|
---|
| 574 | vector<BvhLeaf *> &neighbors,
|
---|
| 575 | const bool onlyUnmailed) const;
|
---|
| 576 |
|
---|
| 577 | /** Returns random leaf of BSP tree.
|
---|
| 578 | @param halfspace defines the halfspace from which the leaf is taken.
|
---|
| 579 | */
|
---|
| 580 | BvhLeaf *GetRandomLeaf(const Plane3 &halfspace);
|
---|
| 581 |
|
---|
| 582 | /** Returns random leaf of BSP tree.
|
---|
| 583 | @param onlyUnmailed if only unmailed leaves should be returned.
|
---|
| 584 | */
|
---|
| 585 | BvhLeaf *GetRandomLeaf(const bool onlyUnmailed = false);
|
---|
| 586 |
|
---|
| 587 | /** Casts line segment into the tree.
|
---|
| 588 | @param origin the origin of the line segment
|
---|
| 589 | @param termination the end point of the line segment
|
---|
| 590 | @returns view cells intersecting the line segment.
|
---|
| 591 | */
|
---|
| 592 | int CastLineSegment(const Vector3 &origin,
|
---|
| 593 | const Vector3 &termination,
|
---|
| 594 | ViewCellContainer &viewcells);
|
---|
| 595 |
|
---|
| 596 | /** Sets pointer to view cells manager.
|
---|
| 597 | */
|
---|
| 598 | void SetViewCellsManager(ViewCellsManager *vcm);
|
---|
| 599 |
|
---|
[1913] | 600 | float GetViewSpaceVolume() const;
|
---|
[1237] | 601 | /** Writes tree to output stream
|
---|
| 602 | */
|
---|
| 603 | bool Export(OUT_STREAM &stream);
|
---|
| 604 |
|
---|
[1640] | 605 | /** Collects rays associated with the objects.
|
---|
[1237] | 606 | */
|
---|
| 607 | void CollectRays(const ObjectContainer &objects, VssRayContainer &rays) const;
|
---|
| 608 |
|
---|
| 609 | /** Intersects box with the tree and returns the number of intersected boxes.
|
---|
| 610 | @returns number of view cells found
|
---|
| 611 | */
|
---|
[1640] | 612 | int ComputeBoxIntersections(const AxisAlignedBox3 &box,
|
---|
| 613 | ViewCellContainer &viewCells) const;
|
---|
[1237] | 614 |
|
---|
| 615 | /** Returns leaf the point pt lies in, starting from root.
|
---|
| 616 | */
|
---|
| 617 | BvhLeaf *GetLeaf(Intersectable *obj, BvhNode *root = NULL) const;
|
---|
| 618 |
|
---|
[1370] | 619 | /** Sets a pointer to the view cells tree.
|
---|
| 620 | */
|
---|
[1237] | 621 | ViewCellsTree *GetViewCellsTree() const { return mViewCellsTree; }
|
---|
[1707] | 622 |
|
---|
[1370] | 623 | /** See Get
|
---|
| 624 | */
|
---|
[1237] | 625 | void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; }
|
---|
| 626 |
|
---|
[1640] | 627 | /** Returns estimated memory usage of tree.
|
---|
| 628 | */
|
---|
| 629 | float GetMemUsage() const;
|
---|
[1237] | 630 |
|
---|
[1707] | 631 | /** Sets this node to be an active node.
|
---|
| 632 | */
|
---|
| 633 | void SetActive(BvhNode *node) const;
|
---|
[1680] | 634 |
|
---|
[1707] | 635 |
|
---|
[1684] | 636 | ///////////////////////////
|
---|
| 637 | // hacks in order to provide interleaved heurisitcs
|
---|
| 638 |
|
---|
[1686] | 639 | BvhNode *SubdivideAndCopy(SplitQueue &tQueue, SubdivisionCandidate *splitCandidate);
|
---|
[1684] | 640 |
|
---|
| 641 | /////////////////////////////////
|
---|
| 642 |
|
---|
[1703] | 643 | static float EvalAbsCost(const ObjectContainer &objects);
|
---|
[1698] | 644 |
|
---|
[1913] | 645 | float EvalProb(const ObjectContainer &objects) const;
|
---|
| 646 |
|
---|
[1718] | 647 | void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects);
|
---|
[1707] | 648 |
|
---|
[1786] | 649 | float GetRenderCostIncrementially(BvhNode *node) const;
|
---|
| 650 |
|
---|
[1844] | 651 | void Compress();
|
---|
[1843] | 652 | void CreateUniqueObjectIds();
|
---|
[1786] | 653 |
|
---|
[1237] | 654 | protected:
|
---|
| 655 |
|
---|
| 656 | /** Returns true if tree can be terminated.
|
---|
| 657 | */
|
---|
[1251] | 658 | bool LocalTerminationCriteriaMet(const BvhTraversalData &data) const;
|
---|
[1237] | 659 |
|
---|
| 660 | /** Returns true if global tree can be terminated.
|
---|
| 661 | */
|
---|
[1251] | 662 | bool GlobalTerminationCriteriaMet(const BvhTraversalData &data) const;
|
---|
[1237] | 663 |
|
---|
[1287] | 664 | /** For sorting the objects during the heuristics
|
---|
| 665 | */
|
---|
[1237] | 666 | struct SortableEntry
|
---|
| 667 | {
|
---|
[1287] | 668 | Intersectable *mObject;
|
---|
[1237] | 669 | float mPos;
|
---|
| 670 |
|
---|
| 671 | SortableEntry() {}
|
---|
| 672 |
|
---|
[1287] | 673 | SortableEntry(Intersectable *obj, const float pos):
|
---|
| 674 | mObject(obj), mPos(pos)
|
---|
[1237] | 675 | {}
|
---|
| 676 |
|
---|
| 677 | bool operator<(const SortableEntry &b) const
|
---|
| 678 | {
|
---|
| 679 | return mPos < b.mPos;
|
---|
| 680 | }
|
---|
| 681 | };
|
---|
[1345] | 682 |
|
---|
[1287] | 683 | /** Evaluate balanced object partition.
|
---|
[1237] | 684 | */
|
---|
[1640] | 685 | float EvalLocalObjectPartition(const BvhTraversalData &tData,
|
---|
| 686 | const int axis,
|
---|
| 687 | ObjectContainer &objectsFront,
|
---|
| 688 | ObjectContainer &objectsBack);
|
---|
[1237] | 689 |
|
---|
[1640] | 690 | /** Evaluate surface area heuristic for the node.
|
---|
| 691 | */
|
---|
| 692 | float EvalSah(const BvhTraversalData &tData,
|
---|
| 693 | const int axis,
|
---|
| 694 | ObjectContainer &objectsFront,
|
---|
| 695 | ObjectContainer &objectsBack);
|
---|
[1323] | 696 |
|
---|
[1237] | 697 |
|
---|
[1379] | 698 | /** Evaluates render cost of the bv induced by these objects
|
---|
[1237] | 699 | */
|
---|
[1379] | 700 | float EvalRenderCost(const ObjectContainer &objects) const;
|
---|
[1237] | 701 |
|
---|
| 702 | /** Evaluates tree stats in the BSP tree leafs.
|
---|
| 703 | */
|
---|
| 704 | void EvaluateLeafStats(const BvhTraversalData &data);
|
---|
| 705 |
|
---|
| 706 | /** Subdivides node using a best split priority queue.
|
---|
| 707 | @param tQueue the best split priority queue
|
---|
| 708 | @param splitCandidate the candidate for the next split
|
---|
| 709 | @param globalCriteriaMet if the global termination criteria were already met
|
---|
| 710 | @returns new root of the subtree
|
---|
| 711 | */
|
---|
[1640] | 712 | BvhNode *Subdivide(SplitQueue &tQueue,
|
---|
| 713 | SubdivisionCandidate *splitCandidate,
|
---|
| 714 | const bool globalCriteriaMet);
|
---|
[1237] | 715 |
|
---|
| 716 | /** Subdivides leaf.
|
---|
[1345] | 717 | @param sc the subdivisionCandidate holding all necessary data for subdivision
|
---|
[1237] | 718 |
|
---|
[1345] | 719 | @param frontData returns the traversal data for the front node
|
---|
| 720 | @param backData returns the traversal data for the back node
|
---|
[1237] | 721 |
|
---|
[1345] | 722 | @returns the new interior node = the of the subdivision
|
---|
[1237] | 723 | */
|
---|
[1640] | 724 | BvhInterior *SubdivideNode(const BvhSubdivisionCandidate &sc,
|
---|
| 725 | BvhTraversalData &frontData,
|
---|
| 726 | BvhTraversalData &backData);
|
---|
[1237] | 727 |
|
---|
| 728 | /** Splits the objects for the next subdivision.
|
---|
| 729 | @returns cost for this split
|
---|
| 730 | */
|
---|
[1640] | 731 | float SelectObjectPartition(const BvhTraversalData &tData,
|
---|
| 732 | ObjectContainer &frontObjects,
|
---|
[1676] | 733 | ObjectContainer &backObjects,
|
---|
| 734 | bool useVisibilityBasedHeuristics);
|
---|
[1237] | 735 |
|
---|
| 736 | /** Writes the node to disk
|
---|
| 737 | @note: should be implemented as visitor.
|
---|
| 738 | */
|
---|
| 739 | void ExportNode(BvhNode *node, OUT_STREAM &stream);
|
---|
| 740 |
|
---|
[1640] | 741 | /** Exports objects associated with this leaf.
|
---|
| 742 | */
|
---|
[1286] | 743 | void ExportObjects(BvhLeaf *leaf, OUT_STREAM &stream);
|
---|
| 744 |
|
---|
[1548] | 745 | /** Associates the objects with their bvh leaves.
|
---|
[1294] | 746 | */
|
---|
[1486] | 747 | static void AssociateObjectsWithLeaf(BvhLeaf *leaf);
|
---|
| 748 |
|
---|
| 749 |
|
---|
[1237] | 750 | /////////////////////////////
|
---|
| 751 | // Helper functions for local cost heuristics
|
---|
| 752 |
|
---|
[1357] | 753 | /** Prepare split candidates for cost heuristics using axis aligned splits.
|
---|
[1237] | 754 | @param node the current node
|
---|
| 755 | @param axis the current split axis
|
---|
| 756 | */
|
---|
[1640] | 757 | void PrepareLocalSubdivisionCandidates(const BvhTraversalData &tData,
|
---|
| 758 | const int axis);
|
---|
[1237] | 759 |
|
---|
[1640] | 760 | static void CreateLocalSubdivisionCandidates(const ObjectContainer &objects,
|
---|
| 761 | SortableEntryContainer **subdivisionCandidates,
|
---|
| 762 | const bool sort,
|
---|
| 763 | const int axis);
|
---|
[1357] | 764 |
|
---|
[1779] | 765 | float EvalPriority(const BvhSubdivisionCandidate &splitCandidate,
|
---|
| 766 | const float renderCostDecr,
|
---|
| 767 | const float oldRenderCost) const;
|
---|
| 768 |
|
---|
[1357] | 769 | /** Computes object partition with the best cost according to the heurisics.
|
---|
| 770 | @param tData the traversal data
|
---|
| 771 | @param axis the split axis
|
---|
| 772 | @param objectsFront the objects in the front child bv
|
---|
| 773 | @param objectsBack the objects in the back child bv
|
---|
| 774 | @param backObjectsStart the iterator marking the position where the back objects begin
|
---|
| 775 |
|
---|
| 776 | @returns relative cost (relative to parent cost)
|
---|
[1237] | 777 | */
|
---|
[1640] | 778 | float EvalLocalCostHeuristics(const BvhTraversalData &tData,
|
---|
| 779 | const int axis,
|
---|
| 780 | ObjectContainer &objectsFront,
|
---|
| 781 | ObjectContainer &objectsBack);
|
---|
[1237] | 782 |
|
---|
[1287] | 783 | /** Evaluates the contribution to the front and back volume
|
---|
| 784 | when this object is changing sides in the bvs.
|
---|
[1237] | 785 |
|
---|
[1287] | 786 | @param object the object
|
---|
| 787 | @param volLeft updates the left pvs
|
---|
| 788 | @param volPvs updates the right pvs
|
---|
[1237] | 789 | */
|
---|
[1640] | 790 | void EvalHeuristicsContribution(Intersectable *obj,
|
---|
| 791 | float &volLeft,
|
---|
| 792 | float &volRight);
|
---|
[1237] | 793 |
|
---|
| 794 | /** Prepares objects for the cost heuristics.
|
---|
| 795 | @returns sum of volume of associated view cells
|
---|
| 796 | */
|
---|
[1287] | 797 | float PrepareHeuristics(const BvhTraversalData &tData, const int axis);
|
---|
[1237] | 798 |
|
---|
[1705] | 799 | /** Evaluates cost for a leaf given the surface area heuristics.
|
---|
| 800 | */
|
---|
[1779] | 801 | float EvalSahCost(BvhLeaf *leaf) const;
|
---|
[1633] | 802 |
|
---|
[1237] | 803 | ////////////////////////////////////////////////
|
---|
| 804 |
|
---|
| 805 |
|
---|
| 806 | /** Prepares construction for vsp and osp trees.
|
---|
| 807 | */
|
---|
[1640] | 808 | AxisAlignedBox3 EvalBoundingBox(const ObjectContainer &objects,
|
---|
| 809 | const AxisAlignedBox3 *parentBox = NULL) const;
|
---|
[1237] | 810 |
|
---|
[1370] | 811 | /** Collects list of invalid candidates. Candidates
|
---|
| 812 | are invalidated by a view space subdivision step
|
---|
| 813 | that affects this candidate.
|
---|
| 814 | */
|
---|
[1640] | 815 | void CollectDirtyCandidates(BvhSubdivisionCandidate *sc,
|
---|
| 816 | vector<SubdivisionCandidate *> &dirtyList,
|
---|
| 817 | const bool onlyUnmailed);
|
---|
[1237] | 818 |
|
---|
[1287] | 819 | /** Collect view cells which see this bvh leaf.
|
---|
[1237] | 820 | */
|
---|
[1744] | 821 | int CollectViewCells(const ObjectContainer &objects,
|
---|
| 822 | ViewCellContainer &viewCells,
|
---|
| 823 | const bool setCounter,
|
---|
[1941] | 824 | const bool onlyUnmailedRays) const;
|
---|
[1237] | 825 |
|
---|
[1933] | 826 | /** Collects view cells which see an object.
|
---|
| 827 | @param useMailBoxing if mailing should be used and
|
---|
| 828 | only unmailed object should pass
|
---|
| 829 | @param setCounter counter for the sweep algorithm
|
---|
[1941] | 830 | @param onlyUnmailedRays if only unmailed rays should be considered
|
---|
[1933] | 831 | */
|
---|
| 832 | int CollectViewCells(Intersectable *object,
|
---|
| 833 | ViewCellContainer &viewCells,
|
---|
| 834 | const bool useMailBoxing,
|
---|
| 835 | const bool setCounter,
|
---|
[1941] | 836 | const bool onlyUnmailedRays) const;
|
---|
[1933] | 837 |
|
---|
[1576] | 838 | /** Counts the view cells of this object. note: only
|
---|
| 839 | counts unmailed objects.
|
---|
| 840 | */
|
---|
| 841 | int CountViewCells(Intersectable *obj) const;
|
---|
| 842 |
|
---|
| 843 | /** Counts the view cells seen by this bvh leaf
|
---|
| 844 | */
|
---|
| 845 | int CountViewCells(const ObjectContainer &objects) const;
|
---|
| 846 |
|
---|
| 847 | /** Evaluates increase in pvs size.
|
---|
| 848 | */
|
---|
[1912] | 849 | int EvalPvsEntriesIncr(BvhSubdivisionCandidate &splitCandidate, const float avgRayContri) const;
|
---|
[1576] | 850 |
|
---|
[1237] | 851 | /** Rays will be clipped to the bounding box.
|
---|
| 852 | */
|
---|
[1640] | 853 | void PreprocessRays(BvhLeaf *root,
|
---|
| 854 | const VssRayContainer &sampleRays,
|
---|
| 855 | RayInfoContainer &rays);
|
---|
[1237] | 856 |
|
---|
[1287] | 857 | /** Print the subdivision stats in the subdivison log.
|
---|
| 858 | */
|
---|
| 859 | void PrintSubdivisionStats(const SubdivisionCandidate &tData);
|
---|
[1237] | 860 |
|
---|
[1370] | 861 | /** Prints out the stats for this subdivision.
|
---|
| 862 | */
|
---|
[1640] | 863 | void AddSubdivisionStats(const int viewCells,
|
---|
| 864 | const float renderCostDecr,
|
---|
| 865 | const float totalRenderCost);
|
---|
[1237] | 866 |
|
---|
[1370] | 867 | /** Stores rays with objects that see the rays.
|
---|
| 868 | */
|
---|
| 869 | int AssociateObjectsWithRays(const VssRayContainer &rays) const;
|
---|
[1237] | 870 |
|
---|
[1370] | 871 | /** Tests if object is in this leaf.
|
---|
| 872 | @note: assumes that objects are sorted by their id.
|
---|
| 873 | */
|
---|
[1237] | 874 | bool IsObjectInLeaf(BvhLeaf *, Intersectable *object) const;
|
---|
| 875 |
|
---|
[1370] | 876 | /** Prepares the construction of the bv hierarchy and returns
|
---|
| 877 | the first subdivision candidate.
|
---|
| 878 | */
|
---|
[1779] | 879 | void PrepareConstruction(SplitQueue &tQueue,
|
---|
| 880 | const VssRayContainer &sampleRays,
|
---|
| 881 | const ObjectContainer &objects);
|
---|
[1237] | 882 |
|
---|
[1548] | 883 | /** Resets bv hierarchy. E.g. deletes root and resets stats.
|
---|
| 884 | */
|
---|
[1779] | 885 | void Reset(SplitQueue &tQueue,
|
---|
| 886 | const VssRayContainer &rays,
|
---|
| 887 | const ObjectContainer &objects);
|
---|
[1548] | 888 |
|
---|
[1370] | 889 | /** Evaluates volume of view cells that see the objects.
|
---|
| 890 | */
|
---|
[1287] | 891 | float EvalViewCellsVolume(const ObjectContainer &objects) const;
|
---|
[1237] | 892 |
|
---|
[1580] | 893 | /** Assigns or newly creates initial list of sorted objects.
|
---|
[1370] | 894 | */
|
---|
[1779] | 895 | void AssignInitialSortedObjectList(BvhTraversalData &tData,
|
---|
| 896 | const ObjectContainer &objects);
|
---|
[1259] | 897 |
|
---|
[1370] | 898 | /** Assigns sorted objects to front and back data.
|
---|
| 899 | */
|
---|
[1640] | 900 | void AssignSortedObjects(const BvhSubdivisionCandidate &sc,
|
---|
| 901 | BvhTraversalData &frontData,
|
---|
| 902 | BvhTraversalData &backData);
|
---|
[1548] | 903 |
|
---|
[1640] | 904 | /** Creates new root of hierarchy and computes bounding box.
|
---|
| 905 | Has to be called before the preparation of the subdivision.
|
---|
[1548] | 906 | */
|
---|
[1640] | 907 | void Initialise(const ObjectContainer &objects);
|
---|
| 908 |
|
---|
| 909 |
|
---|
[1779] | 910 | ////////////////////
|
---|
[1774] | 911 | // initial subdivision
|
---|
| 912 |
|
---|
| 913 | /** Makes an initial parititon of the object space based on
|
---|
| 914 | some criteria (size, shader)
|
---|
| 915 | */
|
---|
[1779] | 916 | void ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate,
|
---|
[1789] | 917 | vector<SubdivisionCandidate *> &candidateContainer);
|
---|
[1774] | 918 |
|
---|
[1784] | 919 | void ApplyInitialSplit(const BvhTraversalData &tData,
|
---|
| 920 | ObjectContainer &frontObjects,
|
---|
| 921 | ObjectContainer &backObjects);
|
---|
[1774] | 922 |
|
---|
[1779] | 923 | bool InitialTerminationCriteriaMet(const BvhTraversalData &tData) const;
|
---|
| 924 |
|
---|
| 925 |
|
---|
[1237] | 926 | protected:
|
---|
| 927 |
|
---|
[1345] | 928 | /// pre-sorted subdivision candidtes for all three directions.
|
---|
| 929 | vector<SortableEntry> *mGlobalSubdivisionCandidates[3];
|
---|
[1237] | 930 | /// pointer to the hierarchy of view cells
|
---|
| 931 | ViewCellsTree *mViewCellsTree;
|
---|
| 932 | /// The view cells manager
|
---|
| 933 | ViewCellsManager *mViewCellsManager;
|
---|
| 934 | /// candidates for placing split planes during cost heuristics
|
---|
| 935 | vector<SortableEntry> *mSubdivisionCandidates;
|
---|
| 936 | /// Pointer to the root of the tree
|
---|
| 937 | BvhNode *mRoot;
|
---|
| 938 | /// Statistics for the object space partition
|
---|
[1370] | 939 | BvhStatistics mBvhStats;
|
---|
[1237] | 940 | /// box around the whole view domain
|
---|
| 941 | AxisAlignedBox3 mBoundingBox;
|
---|
[1370] | 942 | /// the hierarchy manager
|
---|
| 943 | HierarchyManager *mHierarchyManager;
|
---|
[1237] | 944 |
|
---|
| 945 |
|
---|
[1449] | 946 | ////////////////////
|
---|
[1357] | 947 | //-- local termination criteria
|
---|
[1237] | 948 |
|
---|
| 949 | /// maximal possible depth
|
---|
| 950 | int mTermMaxDepth;
|
---|
| 951 | /// mininum probability
|
---|
[1287] | 952 | float mTermMinProbability;
|
---|
[1237] | 953 | /// minimal number of objects
|
---|
| 954 | int mTermMinObjects;
|
---|
| 955 | /// maximal acceptable cost ratio
|
---|
| 956 | float mTermMaxCostRatio;
|
---|
| 957 | /// tolerance value indicating how often the max cost ratio can be failed
|
---|
| 958 | int mTermMissTolerance;
|
---|
[1370] | 959 | /// minimum number of rays
|
---|
| 960 | int mTermMinRays;
|
---|
[1237] | 961 |
|
---|
| 962 |
|
---|
[1449] | 963 | ////////////////////
|
---|
[1357] | 964 | //-- global termination criteria
|
---|
[1237] | 965 |
|
---|
[1580] | 966 | /// the minimal accepted global cost ratio
|
---|
[1237] | 967 | float mTermMinGlobalCostRatio;
|
---|
[1580] | 968 | //// number of accepted misses of the global cost ratio
|
---|
[1237] | 969 | int mTermGlobalCostMissTolerance;
|
---|
| 970 | /// maximal number of view cells
|
---|
| 971 | int mTermMaxLeaves;
|
---|
| 972 | /// maximal tree memory
|
---|
| 973 | float mMaxMemory;
|
---|
| 974 | /// the tree is out of memory
|
---|
| 975 | bool mOutOfMemory;
|
---|
| 976 |
|
---|
| 977 |
|
---|
[1357] | 978 | ////////////////////////////////////////
|
---|
[1237] | 979 | //-- split heuristics based parameters
|
---|
| 980 |
|
---|
[1643] | 981 | /// if a heuristics should be used for finding a split plane
|
---|
| 982 | bool mUseCostHeuristics;
|
---|
| 983 | /// if sah heuristcs should be used for finding a split plane
|
---|
| 984 | bool mUseSah;
|
---|
| 985 | /// balancing factor for PVS criterium
|
---|
[1237] | 986 | float mCtDivCi;
|
---|
| 987 | /// if only driving axis should be used for split
|
---|
| 988 | bool mOnlyDrivingAxis;
|
---|
| 989 | /// current time stamp (used for keeping split history)
|
---|
| 990 | int mTimeStamp;
|
---|
| 991 | // if rays should be stored in leaves
|
---|
| 992 | bool mStoreRays;
|
---|
[1357] | 993 | // subdivision stats output file
|
---|
[1237] | 994 | ofstream mSubdivisionStats;
|
---|
| 995 | /// keeps track of cost during subdivision
|
---|
| 996 | float mTotalCost;
|
---|
[1662] | 997 | int mPvsEntries;
|
---|
[1237] | 998 | /// keeps track of overall pvs size during subdivision
|
---|
| 999 | int mTotalPvsSize;
|
---|
| 1000 | /// number of currenly generated view cells
|
---|
| 1001 | int mCreatedLeaves;
|
---|
| 1002 | /// represents min and max band for sweep
|
---|
| 1003 | float mSplitBorder;
|
---|
| 1004 | /// weight between render cost decrease and node render cost
|
---|
| 1005 | float mRenderCostDecreaseWeight;
|
---|
[1758] | 1006 |
|
---|
[1580] | 1007 | /// if the objects should be sorted in one global step
|
---|
| 1008 | bool mUseGlobalSorting;
|
---|
[1237] | 1009 |
|
---|
[1662] | 1010 | bool mUseBboxAreaForSah;
|
---|
| 1011 |
|
---|
[1779] | 1012 | //SortableEntryContainer *mSortedObjects[4];
|
---|
[1676] | 1013 |
|
---|
| 1014 | int mMinRaysForVisibility;
|
---|
[1727] | 1015 |
|
---|
[1732] | 1016 | /// constant value for driving the heuristics
|
---|
| 1017 | float mMemoryConst;
|
---|
| 1018 |
|
---|
[1786] | 1019 | int mMaxTests;
|
---|
| 1020 |
|
---|
[1779] | 1021 | bool mIsInitialSubdivision;
|
---|
| 1022 |
|
---|
| 1023 | bool mApplyInitialPartition;
|
---|
[1786] | 1024 |
|
---|
| 1025 | int mInitialMinObjects;
|
---|
| 1026 | float mInitialMaxAreaRatio;
|
---|
| 1027 | float mInitialMinArea;
|
---|
[1237] | 1028 | };
|
---|
| 1029 |
|
---|
| 1030 | }
|
---|
| 1031 |
|
---|
| 1032 | #endif
|
---|