- Timestamp:
- 01/05/06 00:47:59 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r498 r500 4 4 #include <QtOpenGL> 5 5 #include <QWaitCondition> 6 //#include <QGLPixelBuffer> 6 7 7 8 #include "Vector3.h" -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r492 r500 1922 1922 positions--; 1923 1923 } 1924 return true; // corr. matt 1924 1925 } 1925 1926 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r498 r500 1751 1751 nodeStack.push(mRoot); 1752 1752 1753 // planes needed to verify that we found neighbor leaf. 1753 // split planes from the root to this node 1754 // needed to verify that we found neighbor leaf 1754 1755 vector<Plane3> halfSpaces; 1755 1756 ExtractHalfSpaces(n, halfSpaces); … … 1783 1784 isAdjacent = false; 1784 1785 } 1785 1786 // neighbor was found 1786 1787 if (isAdjacent) 1787 1788 neighbors.push_back(dynamic_cast<BspLeaf *>(node)); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r495 r500 75 75 76 76 // Inline constructor 77 VspKdNode::VspKdNode(VspKd Interior*p):77 VspKdNode::VspKdNode(VspKdNode *p): 78 78 mParent(p), mAxis(-1), mDepth(p ? p->mDepth + 1 : 0) 79 79 {} … … 83 83 }; 84 84 85 inline VspKd Interior*VspKdNode::GetParent() const85 inline VspKdNode *VspKdNode::GetParent() const 86 86 { 87 87 return mParent; 88 88 } 89 89 90 inline void VspKdNode::SetParent(VspKd Interior*p)90 inline void VspKdNode::SetParent(VspKdNode *p) 91 91 { 92 92 mParent = p; … … 126 126 127 127 void VspKdInterior::ReplaceChildLink(VspKdNode *oldChild, 128 128 VspKdNode *newChild) 129 129 { 130 130 if (mBack == oldChild) … … 184 184 185 185 186 VspKdLeaf::VspKdLeaf(VspKd Interior*p,186 VspKdLeaf::VspKdLeaf(VspKdNode *p, 187 187 const int nRays, 188 188 const int maxCostMisses): … … 339 339 } 340 340 341 /*********************************************************/ 342 /* class VspKdTree implementation */ 343 /*********************************************************/ 341 342 /***************************************************************/ 343 /* class VspKdIntermediate implementation */ 344 /***************************************************************/ 345 346 347 VspKdIntermediate::VspKdIntermediate(VspKdInterior *p): 348 VspKdNode(p), mBack(NULL), mFront(NULL), mAccesses(0), mLastAccessTime(-1) 349 { 350 } 351 352 353 VspKdIntermediate::~VspKdIntermediate() 354 { 355 DEL_PTR(mFront); 356 DEL_PTR(mBack); 357 } 358 359 360 int VspKdIntermediate::Type() const 361 { 362 return EIntermediate; 363 } 364 365 366 VspKdLeaf *VspKdIntermediate::GetBack() const 367 { 368 return mBack; 369 } 370 371 372 VspKdLeaf *VspKdIntermediate::GetFront() const 373 { 374 return mFront; 375 } 376 377 378 void VspKdIntermediate::Print(ostream &s) const 379 { 380 s << endl << mSplitPlane << endl; 381 } 382 383 384 void VspKdIntermediate::SetupChildLinks(VspKdLeaf *b, VspKdLeaf *f) 385 { 386 mBack = b; 387 mFront = f; 388 389 b->SetParent(this); 390 f->SetParent(this); 391 } 392 393 394 int VspKdIntermediate::ComputeRayIntersection(const RayInfo &rayData, float &t) 395 { 396 return rayData.ComputeRayIntersection(mSplitPlane, t); 397 } 398 399 400 /*************************************************************/ 401 /* class VspKdTree implementation */ 402 /*************************************************************/ 344 403 345 404 … … 1131 1190 1132 1191 // add the new nodes to the tree 1133 VspKdInterior *node = new VspKdInterior(leaf->mParent); 1192 VspKdInterior *node = 1193 new VspKdInterior(dynamic_cast<VspKdInterior *>(leaf->mParent)); 1134 1194 1135 1195 node->mAxis = axis; … … 1147 1207 // replace a link from node's parent 1148 1208 if (leaf->mParent) 1149 leaf->mParent->ReplaceChildLink(leaf, node); 1209 { 1210 VspKdInterior *parent = dynamic_cast<VspKdInterior *>(leaf->mParent); 1211 parent->ReplaceChildLink(leaf, node); 1212 } 1150 1213 // and setup child links 1151 1214 node->SetupChildLinks(back, front); … … 1570 1633 VspKdLeaf *newLeaf = new VspKdLeaf(sroot->mParent, rayCount); 1571 1634 1572 if (newLeaf->mParent) 1573 { 1574 newLeaf->mParent->ReplaceChildLink(sroot, newLeaf); 1635 VspKdInterior *parent = 1636 dynamic_cast<VspKdInterior *>(newLeaf->mParent); 1637 1638 if (parent) 1639 { 1640 parent->ReplaceChildLink(sroot, newLeaf); 1575 1641 } 1576 1642 tstack.push(sroot); … … 1834 1900 1835 1901 if (!node->IsLeaf()) 1836 return (dynamic_cast<VspKdInterior *>(node))->mBox; 1837 1838 if (node->mParent->mAxis >= 3) 1839 return node->mParent->mBox; 1840 1841 AxisAlignedBox3 box(node->mParent->mBox); 1842 if (node->mParent->GetFront() == node) 1843 box.SetMin(node->mParent->mAxis, node->mParent->mPosition); 1902 { 1903 if (node->Type() == VspKdNode::EIntermediate) 1904 return (dynamic_cast<VspKdInterior *>(node))->mBox; 1905 else 1906 return (dynamic_cast<VspKdIntermediate *>(node))->mBox; 1907 } 1908 1909 VspKdInterior *parent = dynamic_cast<VspKdInterior *>(node->mParent); 1910 1911 if (parent->mAxis >= 3) 1912 return parent->mBox; 1913 1914 AxisAlignedBox3 box(parent->mBox); 1915 if (parent->GetFront() == node) 1916 box.SetMin(parent->mAxis, parent->mPosition); 1844 1917 else 1845 box.SetMax( node->mParent->mAxis, node->mParent->mPosition);1918 box.SetMax(parent->mAxis, parent->mPosition); 1846 1919 1847 1920 return box; … … 2348 2421 leaf->SetViewCell(vc); 2349 2422 2423 VspKdInterior *parent = 2424 dynamic_cast<VspKdInterior *>(leaf->mParent); 2350 2425 // replace a link from node's parent 2351 if ( leaf->mParent)2352 leaf->mParent->ReplaceChildLink(node, leaf);2426 if (parent) 2427 parent->ReplaceChildLink(node, leaf); 2353 2428 2354 2429 delete interior; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r495 r500 203 203 friend class VspKdTree; 204 204 205 enum {EInterior, E Leaf};205 enum {EInterior, EIntermediate, ELeaf}; 206 206 207 207 /** Constructs new interior node from the parent node. 208 208 */ 209 inline VspKdNode(VspKd Interior*p);209 inline VspKdNode(VspKdNode *p); 210 210 211 211 /** Destroys this node and the subtree. … … 226 226 227 227 /** Returns time needed to access this node. 228 */ 229 virtual int GetAccessTime(); // NOTE: don't really know how it is used! 228 @NOTE: don't really know how it is used! 229 */ 230 virtual int GetAccessTime(); 230 231 231 232 /** Returns parent node. 232 233 */ 233 VspKd Interior*GetParent() const;234 VspKdNode *GetParent() const; 234 235 235 236 /** Sets parent node. 236 237 */ 237 void SetParent(VspKd Interior*p);238 void SetParent(VspKdNode *p); 238 239 239 240 protected: … … 242 243 243 244 /// link to the parent 244 VspKd Interior*mParent;245 VspKdNode *mParent; 245 246 246 247 enum {SPLIT_X = 0, SPLIT_Y, SPLIT_Z}; … … 308 309 309 310 311 /** 312 Node type just before leaf holding abitrary split plane 313 */ 314 class VspKdIntermediate: public VspKdNode 315 { 316 public: 317 friend class VspKdTree; 318 319 /** Constructs new interior node from parent node. 320 */ 321 VspKdIntermediate(VspKdInterior *p); 322 323 //virtual int GetAccessTime(); 324 325 virtual int Type() const; 326 327 virtual ~VspKdIntermediate(); 328 329 virtual void Print(ostream &s) const; 330 331 /** Returns back child. 332 */ 333 inline VspKdLeaf *GetBack() const; 334 /** Returns front child. 335 */ 336 inline VspKdLeaf *GetFront() const; 337 338 protected: 339 340 /** Sets pointers to back child and front child. 341 */ 342 void SetupChildLinks(VspKdLeaf *b, VspKdLeaf *f); 343 /** Computes intersection of the ray with the node boundaries. 344 */ 345 int ComputeRayIntersection(const RayInfo &rayData, float &t); 346 347 // plane in local modelling coordinates 348 Plane3 mSplitPlane; 349 350 // pointers to children 351 VspKdLeaf *mBack; 352 VspKdLeaf *mFront; 353 354 // the bbox of the node 355 AxisAlignedBox3 mBox; 356 357 // data for caching 358 long mAccesses; 359 long mLastAccessTime; 360 }; 361 310 362 // -------------------------------------------------------------- 311 363 // KD-tree node - leaf node … … 322 374 @parma maxMisses how many times the max cost ratio was missed on the path to the leaf 323 375 */ 324 VspKdLeaf(VspKd Interior*p, const int nRays, const int maxCostMisses = 0);376 VspKdLeaf(VspKdNode *p, const int nRays, const int maxCostMisses = 0); 325 377 326 378 virtual ~VspKdLeaf(); … … 385 437 */ 386 438 int GetMaxCostMisses(); 387 388 439 389 440 //////////////////////////////////////////// … … 413 464 int mMaxCostMisses; 414 465 415 private:466 //private: 416 467 /// stores PVS size so we have to evaluate PVS size only once 417 468 int mPvsSize; 418 469 }; 419 420 470 421 471 … … 456 506 VspKdNode *mNode; 457 507 AxisAlignedBox3 mBox; 508 //TODO PolygonContainer *mPolys; 509 458 510 int mDepth; 459 511 //float mPriority; … … 480 532 { 481 533 // return a.node->queries.size() < b.node->queries.size(); 482 VspKdLeaf *leafa = (VspKdLeaf *) a.mNode;483 VspKdLeaf *leafb = (VspKdLeaf *) b.mNode;534 VspKdLeaf *leafa = dynamic_cast<VspKdLeaf *>(a.mNode); 535 VspKdLeaf *leafb = dynamic_cast<VspKdLeaf *>(b.mNode); 484 536 #if 0 485 537 return
Note: See TracChangeset
for help on using the changeset viewer.