[1237] | 1 | #ifndef _HierarchyManager_H__
|
---|
| 2 | #define _HierarchyManager_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 |
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | namespace GtpVisibilityPreprocessor {
|
---|
| 17 |
|
---|
| 18 | class ViewCellLeaf;
|
---|
| 19 | class OspTree;
|
---|
| 20 | class VspTree;
|
---|
| 21 | class Plane3;
|
---|
| 22 | class AxisAlignedBox3;
|
---|
| 23 | class Ray;
|
---|
| 24 | class ViewCellsStatistics;
|
---|
| 25 | class ViewCellsManager;
|
---|
| 26 | class MergeCandidate;
|
---|
| 27 | class Beam;
|
---|
| 28 | class ViewCellsTree;
|
---|
| 29 | class Environment;
|
---|
| 30 | class VspInterior;
|
---|
| 31 | class VspLeaf;
|
---|
| 32 | class VspNode;
|
---|
| 33 | class KdNode;
|
---|
| 34 | class KdInterior;
|
---|
| 35 | class KdLeaf;
|
---|
| 36 | class OspTree;
|
---|
| 37 | class KdIntersectable;
|
---|
| 38 | class KdTree;
|
---|
| 39 | class VspTree;
|
---|
| 40 | class KdTreeStatistics;
|
---|
[1259] | 41 | class BvHierarchy;
|
---|
[1287] | 42 | class Exporter;
|
---|
[1667] | 43 | class ViewCellsParseHandlers;
|
---|
[1237] | 44 |
|
---|
[1667] | 45 |
|
---|
[1649] | 46 | #define COUNT_ORIGIN_OBJECTS 1
|
---|
[1237] | 47 |
|
---|
[1551] | 48 | /** View space / object space hierarchy statistics.
|
---|
[1288] | 49 | */
|
---|
| 50 | class HierarchyStatistics: public StatisticsBase
|
---|
| 51 | {
|
---|
| 52 | public:
|
---|
[1576] | 53 | /// total number of entries in the pvs
|
---|
[1624] | 54 | int mPvsEntries;
|
---|
[1640] | 55 | /// storage cost in MB
|
---|
| 56 | float mMemory;
|
---|
[1288] | 57 | /// total number of nodes
|
---|
[1624] | 58 | int mNodes;
|
---|
[1288] | 59 | /// maximal reached depth
|
---|
[1624] | 60 | int mMaxDepth;
|
---|
[1288] | 61 | /// accumulated depth
|
---|
[1624] | 62 | int mAccumDepth;
|
---|
[1449] | 63 | /// time spent for queue repair
|
---|
[1624] | 64 | float mRepairTime;
|
---|
| 65 |
|
---|
[1449] | 66 | // global cost ratio violations
|
---|
| 67 | int mGlobalCostMisses;
|
---|
[1624] | 68 | /// total cost of subdivision
|
---|
| 69 | float mTotalCost;
|
---|
| 70 | /// render cost decrease of subdivision
|
---|
| 71 | float mRenderCostDecrease;
|
---|
[1313] | 72 |
|
---|
[1288] | 73 | // Constructor
|
---|
| 74 | HierarchyStatistics()
|
---|
| 75 | {
|
---|
| 76 | Reset();
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[1624] | 79 | int Nodes() const {return mNodes;}
|
---|
[1640] | 80 | int Interior() const { return mNodes / 2 - 1; }
|
---|
[1624] | 81 | int Leaves() const { return (mNodes / 2) + 1; }
|
---|
[1288] | 82 |
|
---|
| 83 | // TODO: computation wrong
|
---|
[1624] | 84 | double AvgDepth() const { return mAccumDepth / (double)Leaves();}
|
---|
[1288] | 85 |
|
---|
[1449] | 86 | void Reset()
|
---|
[1288] | 87 | {
|
---|
[1449] | 88 | mGlobalCostMisses = 0;
|
---|
[1624] | 89 | mTotalCost = 0;
|
---|
| 90 | mRenderCostDecrease = 0;
|
---|
| 91 |
|
---|
| 92 | mNodes = 0;
|
---|
| 93 | mMaxDepth = 0;
|
---|
| 94 | mAccumDepth = 0;
|
---|
| 95 | mRepairTime = 0;
|
---|
| 96 | mMemory = 0;
|
---|
| 97 | mPvsEntries = 0;
|
---|
[1288] | 98 | }
|
---|
| 99 |
|
---|
| 100 | void Print(ostream &app) const;
|
---|
| 101 |
|
---|
| 102 | friend ostream &operator<<(ostream &s, const HierarchyStatistics &stat)
|
---|
| 103 | {
|
---|
| 104 | stat.Print(s);
|
---|
| 105 | return s;
|
---|
| 106 | }
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 |
|
---|
[1237] | 110 | /** This class implements a structure holding two different hierarchies,
|
---|
| 111 | one for object space partitioning and one for view space partitioning.
|
---|
| 112 |
|
---|
| 113 | The object space and the view space are subdivided using a cost heuristics.
|
---|
| 114 | If an object space split or a view space split is chosen is also evaluated
|
---|
| 115 | based on the heuristics.
|
---|
| 116 |
|
---|
| 117 | The view space heuristics is evaluated by weighting and adding the pvss of the back and
|
---|
| 118 | front node of each specific split. unlike for the standalone method vspbsp tree,
|
---|
| 119 | the pvs of an object would not be the pvs of single object but that of all objects
|
---|
| 120 | which are contained in the same leaf of the object subdivision. This could be done
|
---|
| 121 | by storing the pointer to the object space partition parent, which would allow access to all children.
|
---|
| 122 | Another possibility is to include traced kd-cells in the ray casing process.
|
---|
| 123 |
|
---|
| 124 | Accordingly, the object space heuristics is evaluated by storing a pvs of view cells with each object.
|
---|
| 125 | the contribution to an object to the pvs is the number of view cells it can be seen from.
|
---|
| 126 |
|
---|
| 127 | @note
|
---|
| 128 | There is a potential efficiency problem involved in a sense that once a certain type
|
---|
| 129 | of split is chosen for view space / object space, the candidates for the next split of
|
---|
| 130 | object space / view space must be reevaluated.
|
---|
| 131 | */
|
---|
| 132 | class HierarchyManager
|
---|
| 133 | {
|
---|
| 134 | public:
|
---|
[1421] | 135 | /** Constructor with the view space partition tree and
|
---|
| 136 | the object space hierarchy type as argument.
|
---|
[1237] | 137 | */
|
---|
[1421] | 138 | HierarchyManager(const int objectSpaceHierarchyType);
|
---|
[1279] | 139 | /** Hack: OspTree will copy the content from this kd tree.
|
---|
| 140 | Only view space hierarchy will be constructed.
|
---|
| 141 | */
|
---|
[1421] | 142 | HierarchyManager(KdTree *kdTree);
|
---|
[1237] | 143 |
|
---|
[1421] | 144 | /** Deletes space partition and view space partition.
|
---|
| 145 | */
|
---|
[1286] | 146 | ~HierarchyManager();
|
---|
| 147 |
|
---|
[1237] | 148 | /** Constructs the view space and object space subdivision from a given set of rays
|
---|
| 149 | and a set of objects.
|
---|
| 150 | @param sampleRays the set of sample rays the construction is based on
|
---|
| 151 | @param objects the set of objects
|
---|
| 152 | */
|
---|
[1308] | 153 | void Construct(
|
---|
[1293] | 154 | const VssRayContainer &sampleRays,
|
---|
| 155 | const ObjectContainer &objects,
|
---|
| 156 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1237] | 157 |
|
---|
[1259] | 158 | enum
|
---|
| 159 | {
|
---|
| 160 | NO_OBJ_SUBDIV,
|
---|
| 161 | KD_BASED_OBJ_SUBDIV,
|
---|
| 162 | BV_BASED_OBJ_SUBDIV
|
---|
| 163 | };
|
---|
[1237] | 164 |
|
---|
[1370] | 165 | enum
|
---|
| 166 | {
|
---|
| 167 | NO_VIEWSPACE_SUBDIV,
|
---|
| 168 | KD_BASED_VIEWSPACE_SUBDIV
|
---|
| 169 | };
|
---|
| 170 |
|
---|
[1259] | 171 | /** The type of object space subdivison
|
---|
| 172 | */
|
---|
[1370] | 173 | int GetObjectSpaceSubdivisionType() const;
|
---|
| 174 | /** The type of view space space subdivison
|
---|
| 175 | */
|
---|
| 176 | int GetViewSpaceSubdivisionType() const;
|
---|
| 177 | /** Sets a pointer to the view cells manager.
|
---|
| 178 | */
|
---|
[1279] | 179 | void SetViewCellsManager(ViewCellsManager *vcm);
|
---|
[1370] | 180 | /** Sets a pointer to the view cells tree.
|
---|
| 181 | */
|
---|
[1279] | 182 | void SetViewCellsTree(ViewCellsTree *vcTree);
|
---|
[1370] | 183 | /** Exports the object hierarchy to disc.
|
---|
| 184 | */
|
---|
[1279] | 185 | void ExportObjectSpaceHierarchy(OUT_STREAM &stream);
|
---|
[1370] | 186 | /** Adds a sample to the pvs of the specified view cell.
|
---|
| 187 | */
|
---|
[1279] | 188 | bool AddSampleToPvs(
|
---|
| 189 | Intersectable *obj,
|
---|
| 190 | const Vector3 &hitPoint,
|
---|
| 191 | ViewCell *vc,
|
---|
| 192 | const float pdf,
|
---|
| 193 | float &contribution) const;
|
---|
| 194 |
|
---|
[1421] | 195 | /** Print out statistics.
|
---|
| 196 | */
|
---|
| 197 | void PrintHierarchyStatistics(ostream &stream) const;
|
---|
[1279] | 198 |
|
---|
[1421] | 199 | /** Returns the view space partition tree.
|
---|
| 200 | */
|
---|
[1379] | 201 | VspTree *GetVspTree();
|
---|
[1279] | 202 |
|
---|
[1421] | 203 | /** Returns view space bounding box.
|
---|
| 204 | */
|
---|
[1563] | 205 | //AxisAlignedBox3 GetViewSpaceBox() const;
|
---|
[1624] | 206 |
|
---|
[1421] | 207 | /** Returns object space bounding box.
|
---|
| 208 | */
|
---|
[1416] | 209 | AxisAlignedBox3 GetObjectSpaceBox() const;
|
---|
[1379] | 210 |
|
---|
[1421] | 211 | /** Exports object space hierarchy for visualization.
|
---|
| 212 | */
|
---|
[1626] | 213 | void ExportObjectSpaceHierarchy(Exporter *exporter,
|
---|
| 214 | const ObjectContainer &objects,
|
---|
| 215 | const AxisAlignedBox3 *bbox,
|
---|
| 216 | const bool exportBounds = true) const;
|
---|
[1279] | 217 |
|
---|
[1421] | 218 | /** Returns intersectable pierced by this ray.
|
---|
| 219 | */
|
---|
[1626] | 220 | Intersectable *GetIntersectable(const VssRay &ray, const bool isTermination) const;
|
---|
[1418] | 221 |
|
---|
[1626] | 222 | /** Export object space partition bounding boxes.
|
---|
| 223 | */
|
---|
| 224 | void ExportBoundingBoxes(OUT_STREAM &stream, const ObjectContainer &objects);
|
---|
| 225 |
|
---|
[1419] | 226 | friend ostream &operator<<(ostream &s, const HierarchyManager &hm)
|
---|
| 227 | {
|
---|
[1421] | 228 | hm.PrintHierarchyStatistics(s);
|
---|
[1419] | 229 | return s;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[1667] | 232 | HierarchyStatistics &GetHierarchyStats() { return mHierarchyStats; };
|
---|
| 233 |
|
---|
| 234 | inline bool ConsiderMemory() const { return mConsiderMemory; }
|
---|
[1676] | 235 | inline float GetMemoryConst() const { return mMemoryConst; }
|
---|
[1667] | 236 |
|
---|
[1686] | 237 |
|
---|
| 238 | void EvaluateSubdivision(const VssRayContainer &sampleRays,
|
---|
| 239 | const ObjectContainer &objects,
|
---|
| 240 | const string &filename);
|
---|
[1676] | 241 |
|
---|
[1710] | 242 | void EvaluateSubdivision2(ofstream &splitsStats,
|
---|
[1713] | 243 | const int splitsStepSize);
|
---|
[1709] | 244 |
|
---|
| 245 |
|
---|
[1686] | 246 | float mInitialRenderCost;
|
---|
| 247 |
|
---|
| 248 |
|
---|
[1237] | 249 | protected:
|
---|
| 250 |
|
---|
[1625] | 251 | /** Returns true if the global termination criteria were met.
|
---|
| 252 | */
|
---|
[1237] | 253 | bool GlobalTerminationCriteriaMet(SubdivisionCandidate *candidate) const;
|
---|
| 254 |
|
---|
| 255 | /** Prepare construction of the hierarchies, set parameters, compute
|
---|
| 256 | first split candidates.
|
---|
| 257 | */
|
---|
[1625] | 258 | SubdivisionCandidate *PrepareObjectSpaceSubdivision(const VssRayContainer &sampleRays,
|
---|
| 259 | const ObjectContainer &objects);
|
---|
[1237] | 260 |
|
---|
[1625] | 261 |
|
---|
[1640] | 262 | /** Create bounding box and root.
|
---|
| 263 | */
|
---|
| 264 | void InitialiseObjectSpaceSubdivision(const ObjectContainer &objects);
|
---|
| 265 |
|
---|
| 266 | /** Returns memory usage of object space hierarchy.
|
---|
| 267 | */
|
---|
| 268 | float GetObjectSpaceMemUsage() const;
|
---|
| 269 |
|
---|
[1667] | 270 |
|
---|
[1625] | 271 | //////////////////////////////
|
---|
| 272 | // the main loop
|
---|
| 273 |
|
---|
| 274 | /** This is for interleaved construction / sequential construction.
|
---|
| 275 | */
|
---|
| 276 | void RunConstruction(const bool repairQueue,
|
---|
| 277 | const VssRayContainer &sampleRays,
|
---|
| 278 | const ObjectContainer &objects,
|
---|
[1640] | 279 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1449] | 280 |
|
---|
[1625] | 281 | /** This is for interleaved construction using some objects
|
---|
| 282 | and some view space splits.
|
---|
| 283 | */
|
---|
| 284 | int RunConstruction(SplitQueue &splitQueue,
|
---|
| 285 | SubdivisionCandidateContainer &chosenCandidates,
|
---|
[1667] | 286 | //const float minRenderCostDecr,
|
---|
| 287 | SubdivisionCandidate *oldCandidate,
|
---|
[1676] | 288 | const int minSteps,
|
---|
| 289 | const int maxSteps);
|
---|
[1625] | 290 |
|
---|
| 291 | /** Default subdivision method.
|
---|
| 292 | */
|
---|
[1449] | 293 | void RunConstruction(const bool repairQueue);
|
---|
| 294 |
|
---|
[1625] | 295 | ////////////////////////////////////////////////
|
---|
| 296 |
|
---|
[1580] | 297 | /** Evaluates the subdivision candidate and executes the split.
|
---|
| 298 | */
|
---|
[1625] | 299 | bool ApplySubdivisionCandidate(SubdivisionCandidate *sc,
|
---|
| 300 | SplitQueue &splitQueue,
|
---|
| 301 | const bool repairQueue);
|
---|
[1237] | 302 |
|
---|
[1625] | 303 | /** Tests if hierarchy construction is finished.
|
---|
| 304 | */
|
---|
[1237] | 305 | bool FinishedConstruction() const;
|
---|
| 306 |
|
---|
[1625] | 307 | /** Returns next subdivision candidate from the split queue.
|
---|
| 308 | */
|
---|
| 309 | SubdivisionCandidate *NextSubdivisionCandidate(SplitQueue &splitQueue);
|
---|
[1237] | 310 |
|
---|
[1625] | 311 | /** Repairs the dirty entries of the subdivision candidate queue. The
|
---|
| 312 | list of entries is given in the dirty list.
|
---|
[1580] | 313 | */
|
---|
[1633] | 314 | void RepairQueue(const SubdivisionCandidateContainer &dirtyList,
|
---|
| 315 | SplitQueue &splitQueue,
|
---|
| 316 | const bool recomputeSplitPlaneOnRepair);
|
---|
[1237] | 317 |
|
---|
[1625] | 318 | /** Collect subdivision candidates which were affected by the splits from the
|
---|
| 319 | chosenCandidates list.
|
---|
| 320 | */
|
---|
| 321 | void CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates,
|
---|
| 322 | SubdivisionCandidateContainer &dirtyList);
|
---|
| 323 |
|
---|
[1580] | 324 | /** Evaluate subdivision stats for log.
|
---|
| 325 | */
|
---|
[1624] | 326 | void EvalSubdivisionStats();
|
---|
[1237] | 327 |
|
---|
[1625] | 328 | void AddSubdivisionStats(const int splits,
|
---|
| 329 | const float renderCostDecr,
|
---|
| 330 | const float totalRenderCost,
|
---|
| 331 | const int totalPvsEntries,
|
---|
[1640] | 332 | const float memory,
|
---|
[1654] | 333 | const float renderCostPerStorage,
|
---|
| 334 | const float vspOspRatio);
|
---|
[1237] | 335 |
|
---|
[1625] | 336 | bool AddSampleToPvs(Intersectable *obj,
|
---|
| 337 | const float pdf,
|
---|
| 338 | float &contribution) const;
|
---|
[1237] | 339 |
|
---|
[1625] | 340 | /** Collect affected view space candidates.
|
---|
| 341 | */
|
---|
| 342 | void CollectViewSpaceDirtyList(SubdivisionCandidate *sc,
|
---|
| 343 | SubdivisionCandidateContainer &dirtyList);
|
---|
[1259] | 344 |
|
---|
[1625] | 345 | /** Collect affected object space candidates.
|
---|
| 346 | */
|
---|
| 347 | void CollectObjectSpaceDirtyList(SubdivisionCandidate *sc,
|
---|
| 348 | SubdivisionCandidateContainer &dirtyList);
|
---|
[1259] | 349 |
|
---|
[1625] | 350 | /** Export object space partition tree.
|
---|
| 351 | */
|
---|
| 352 | void ExportOspTree(Exporter *exporter,
|
---|
| 353 | const ObjectContainer &objects) const;
|
---|
[1259] | 354 |
|
---|
[1625] | 355 | /** Parse the environment variables.
|
---|
| 356 | */
|
---|
[1418] | 357 | void ParseEnvironment();
|
---|
[1415] | 358 |
|
---|
[1418] | 359 | bool StartObjectSpaceSubdivision() const;
|
---|
| 360 | bool StartViewSpaceSubdivision() const;
|
---|
| 361 |
|
---|
[1667] | 362 |
|
---|
[1625] | 363 | ////////////////////////////
|
---|
| 364 | // Helper function for preparation of subdivision
|
---|
[1286] | 365 |
|
---|
[1625] | 366 | /** Prepare bv hierarchy for subdivision
|
---|
| 367 | */
|
---|
| 368 | SubdivisionCandidate *PrepareBvHierarchy(const VssRayContainer &sampleRays,
|
---|
| 369 | const ObjectContainer &objects);
|
---|
[1286] | 370 |
|
---|
[1625] | 371 | /** Prepare object space kd tree for subdivision.
|
---|
| 372 | */
|
---|
| 373 | SubdivisionCandidate *PrepareOspTree(const VssRayContainer &sampleRays,
|
---|
| 374 | const ObjectContainer &objects);
|
---|
[1308] | 375 |
|
---|
[1625] | 376 | /** Prepare view space subdivision and add candidate to queue.
|
---|
| 377 | */
|
---|
| 378 | SubdivisionCandidate *PrepareViewSpaceSubdivision(const VssRayContainer &sampleRays,
|
---|
| 379 | const ObjectContainer &objects);
|
---|
| 380 |
|
---|
| 381 | /** Was object space subdivision already constructed?
|
---|
| 382 | */
|
---|
[1313] | 383 | bool ObjectSpaceSubdivisionConstructed() const;
|
---|
[1625] | 384 |
|
---|
| 385 | /** Was view space subdivision already constructed?
|
---|
| 386 | */
|
---|
[1329] | 387 | bool ViewSpaceSubdivisionConstructed() const;
|
---|
[1311] | 388 |
|
---|
[1625] | 389 | /** Reset the split queue, i.e., reevaluate the split candidates.
|
---|
| 390 | */
|
---|
[1640] | 391 | void ResetQueue(SplitQueue &splitQueue, const bool recomputeSplitPlane);
|
---|
[1313] | 392 |
|
---|
[1625] | 393 | /** After the suddivision has ended, do some final tasks.
|
---|
| 394 | */
|
---|
[1654] | 395 | void FinishObjectSpaceSubdivision(const ObjectContainer &objects,
|
---|
| 396 | const bool removeRayRefs = true) const;
|
---|
[1313] | 397 |
|
---|
[1625] | 398 | /** Returns depth of object space subdivision.
|
---|
| 399 | */
|
---|
[1370] | 400 | int GetObjectSpaceSubdivisionDepth() const;
|
---|
| 401 |
|
---|
[1640] | 402 | /** Returns number of leaves in object space subdivision.
|
---|
| 403 | */
|
---|
| 404 | int GetObjectSpaceSubdivisionLeaves() const;
|
---|
[1663] | 405 | int GetObjectSpaceSubdivisionNodes() const;
|
---|
[1640] | 406 |
|
---|
[1625] | 407 | /** Construct object space partition interleaved with view space partition.
|
---|
| 408 | Each time the best object or view space candidate is selected
|
---|
| 409 | for the next split.
|
---|
| 410 | */
|
---|
[1626] | 411 | void ConstructInterleaved(const VssRayContainer &sampleRays,
|
---|
| 412 | const ObjectContainer &objects,
|
---|
| 413 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1449] | 414 |
|
---|
[1625] | 415 | /** Construct object space partition interleaved with view space partition.
|
---|
| 416 | The method chooses a number candidates of each type for subdivision.
|
---|
| 417 | The number is determined by the "gradient", i.e., the render cost decrease.
|
---|
| 418 | Once this render cost decrease is lower than the render cost decrease
|
---|
| 419 | for the splits of previous type, the method will stop current subdivision and
|
---|
| 420 | evaluate if view space or object space would be the beneficial for the
|
---|
| 421 | next number of split.
|
---|
| 422 | */
|
---|
[1626] | 423 | void ConstructInterleavedWithGradient(const VssRayContainer &sampleRays,
|
---|
| 424 | const ObjectContainer &objects,
|
---|
| 425 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1624] | 426 |
|
---|
[1548] | 427 | /** Use iteration to construct the object space hierarchy.
|
---|
| 428 | */
|
---|
[1626] | 429 | void ConstructMultiLevel(const VssRayContainer &sampleRays,
|
---|
| 430 | const ObjectContainer &objects,
|
---|
| 431 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1449] | 432 |
|
---|
[1640] | 433 | /** Based on a given subdivision, we try to optimize using an
|
---|
| 434 | multiple iteration over view and object space.
|
---|
| 435 | */
|
---|
| 436 | void OptimizeMultiLevel(const VssRayContainer &sampleRays,
|
---|
| 437 | const ObjectContainer &objects,
|
---|
| 438 | AxisAlignedBox3 *forcedViewSpace);
|
---|
| 439 |
|
---|
[1548] | 440 | /** Reset the object space subdivision.
|
---|
| 441 | E.g., deletes hierarchy and resets stats.
|
---|
| 442 | so construction can be restarted.
|
---|
| 443 | */
|
---|
[1625] | 444 | SubdivisionCandidate *ResetObjectSpaceSubdivision(const VssRayContainer &rays,
|
---|
| 445 | const ObjectContainer &objects);
|
---|
[1449] | 446 |
|
---|
[1625] | 447 | SubdivisionCandidate *ResetViewSpaceSubdivision(const VssRayContainer &rays,
|
---|
[1642] | 448 | const ObjectContainer &objects,
|
---|
| 449 | AxisAlignedBox3 *forcedViewSpace);
|
---|
[1557] | 450 |
|
---|
[1614] | 451 |
|
---|
[1686] | 452 | ///////////////////////////
|
---|
[1680] | 453 |
|
---|
[1686] | 454 | void ExportStats(ofstream &stats, SplitQueue &tQueue, const ObjectContainer &objects);
|
---|
| 455 |
|
---|
[1706] | 456 | void CollectBestSet(const int maxSplits,
|
---|
| 457 | const float maxMemoryCost,
|
---|
[1707] | 458 | ViewCellContainer &viewCells,
|
---|
[1706] | 459 | vector<BvhNode *> &bvhNodes);
|
---|
| 460 |
|
---|
[1713] | 461 | int ExtractStatistics(const int maxSplits,
|
---|
| 462 | const float maxMemoryCost,
|
---|
| 463 | float &renderCost,
|
---|
| 464 | float &memory,
|
---|
| 465 | int &pvsEntries);
|
---|
[1709] | 466 |
|
---|
| 467 |
|
---|
[1237] | 468 | protected:
|
---|
| 469 |
|
---|
[1627] | 470 | /** construction types
|
---|
| 471 | sequential: construct first view space, then object space
|
---|
| 472 | interleaved: construct view space and object space fully interleaved
|
---|
| 473 | gradient: construct view space / object space until a threshold is reached
|
---|
| 474 | multilevel: iterate until subdivisions converge to the optimum.
|
---|
| 475 | */
|
---|
| 476 | enum {SEQUENTIAL, INTERLEAVED, GRADIENT, MULTILEVEL};
|
---|
| 477 |
|
---|
[1580] | 478 | /// type of hierarchy construction
|
---|
| 479 | int mConstructionType;
|
---|
| 480 |
|
---|
| 481 | /// Type of object space partition
|
---|
[1308] | 482 | int mObjectSpaceSubdivisionType;
|
---|
[1580] | 483 | /// Type of view space partition
|
---|
[1329] | 484 | int mViewSpaceSubdivisionType;
|
---|
| 485 |
|
---|
[1589] | 486 | /// the traversal queue
|
---|
| 487 | SplitQueue mTQueue;
|
---|
| 488 |
|
---|
[1580] | 489 | ////////////
|
---|
| 490 | //-- helper variables
|
---|
| 491 |
|
---|
| 492 | // the original osp type
|
---|
[1323] | 493 | int mSavedObjectSpaceSubdivisionType;
|
---|
[1580] | 494 | // the original vsp type
|
---|
[1329] | 495 | int mSavedViewSpaceSubdivisionType;
|
---|
[1580] | 496 | /// the current subdivision candidate
|
---|
[1624] | 497 | //SubdivisionCandidate *mCurrentCandidate;
|
---|
[1323] | 498 |
|
---|
[1259] | 499 |
|
---|
[1580] | 500 | ///////////////////
|
---|
| 501 | // Hierarchies
|
---|
| 502 |
|
---|
| 503 | /// view space hierarchy
|
---|
[1259] | 504 | VspTree *mVspTree;
|
---|
[1580] | 505 | /// object space partition kd tree
|
---|
[1259] | 506 | OspTree *mOspTree;
|
---|
[1625] | 507 |
|
---|
[1589] | 508 | public:
|
---|
[1580] | 509 | /// bounding volume hierarchy
|
---|
[1259] | 510 | BvHierarchy *mBvHierarchy;
|
---|
[1580] | 511 |
|
---|
[1589] | 512 | protected:
|
---|
[1237] | 513 |
|
---|
| 514 |
|
---|
[1580] | 515 | //////////
|
---|
[1576] | 516 | //-- global termination criteria
|
---|
| 517 |
|
---|
[1580] | 518 | /// the mininal acceptable cost ratio for a split
|
---|
[1237] | 519 | float mTermMinGlobalCostRatio;
|
---|
[1580] | 520 | /// the threshold for global cost miss tolerance
|
---|
[1237] | 521 | int mTermGlobalCostMissTolerance;
|
---|
[1580] | 522 | /// maximum number of leaves
|
---|
| 523 | int mTermMaxLeaves;
|
---|
[1649] | 524 | /// Maximal allowed memory consumption.
|
---|
| 525 | float mTermMaxMemory;
|
---|
[1580] | 526 |
|
---|
[1667] | 527 |
|
---|
[1576] | 528 | ////////////////////
|
---|
| 529 |
|
---|
[1667] | 530 | /// number of minimal steps of the same type
|
---|
[1640] | 531 | int mMinStepsOfSameType;
|
---|
[1684] | 532 | int mMaxStepsOfSameType;
|
---|
[1640] | 533 |
|
---|
[1580] | 534 | /// statistics about the hierarchy
|
---|
[1288] | 535 | HierarchyStatistics mHierarchyStats;
|
---|
| 536 |
|
---|
[1308] | 537 | int mMinDepthForObjectSpaceSubdivion;
|
---|
[1370] | 538 | int mMinDepthForViewSpaceSubdivion;
|
---|
[1580] | 539 |
|
---|
[1625] | 540 | //int mMinRenderCostDecrease;
|
---|
[1624] | 541 |
|
---|
[1237] | 542 | ofstream mSubdivisionStats;
|
---|
[1314] | 543 |
|
---|
[1580] | 544 | /// if the queue should be repaired after a subdivision steps
|
---|
[1314] | 545 | bool mRepairQueue;
|
---|
[1370] | 546 |
|
---|
| 547 | bool mStartWithObjectSpace;
|
---|
[1580] | 548 | /** if multi level construction method should be used
|
---|
| 549 | where we iterate over both hierarchies until we
|
---|
| 550 | converge to the optimum.
|
---|
| 551 | */
|
---|
[1449] | 552 | bool mUseMultiLevelConstruction;
|
---|
[1640] | 553 |
|
---|
[1580] | 554 | /// number of iteration steps for multilevel approach
|
---|
| 555 | int mNumMultiLevels;
|
---|
[1640] | 556 |
|
---|
[1633] | 557 | /** if split plane should be recomputed for the repair.
|
---|
| 558 | Otherwise only the priority is recomputed, the
|
---|
| 559 | split plane itself stays the same
|
---|
| 560 | */
|
---|
| 561 | bool mRecomputeSplitPlaneOnRepair;
|
---|
[1662] | 562 |
|
---|
| 563 | /** If memory should be considered during choosing
|
---|
| 564 | of the next split type during gradient method.
|
---|
| 565 | */
|
---|
| 566 | bool mConsiderMemory;
|
---|
[1666] | 567 |
|
---|
[1673] | 568 | /// constant value for driving the heuristics
|
---|
[1666] | 569 | float mMemoryConst;
|
---|
[1673] | 570 |
|
---|
| 571 | bool mConsiderMemory2;
|
---|
[1667] | 572 |
|
---|
[1679] | 573 | int mTimeStamp;
|
---|
[1667] | 574 | friend VspTree;
|
---|
| 575 | friend OspTree;
|
---|
| 576 | friend BvHierarchy;
|
---|
| 577 | friend ViewCellsParseHandlers;
|
---|
| 578 |
|
---|
[1237] | 579 | };
|
---|
| 580 |
|
---|
| 581 | }
|
---|
| 582 |
|
---|
| 583 | #endif
|
---|