Changeset 86 for trunk/VUT/Ogre/src
- Timestamp:
- 05/06/05 01:39:32 (20 years ago)
- Location:
- trunk/VUT/Ogre/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r85 r86 57 57 GtpVisibility::HierarchyNode *node2) const 58 58 { 59 // matt: change this (inefficient) 60 AxisAlignedBox box1, box2; 61 62 static_cast<Octree *>(node1)->_getCullBounds(&box1); 63 static_cast<Octree *>(node2)->_getCullBounds(&box2); 64 65 return GetSquaredViewDepth(mCamera, &box1) > GetSquaredViewDepth(mCamera, &box2); 59 return GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node1)->mBox) > 60 GetSquaredViewDepth(mCamera, &static_cast<Octree *>(node2)->mBox); 66 61 } 67 62 //----------------------------------------------------------------------- … … 70 65 { 71 66 Vector3 mid = ((box->getMinimum() - box->getMaximum()) * 0.5) + box->getMinimum(); 72 return (cam->getDerivedPosition() - mid).squaredLength(); 67 // use nearest point rather than midpoint 68 Vector3 camPos = cam->getDerivedPosition(); 69 70 Vector3 minPos(camPos.x < mid.x ? box->getMinimum().x : box->getMaximum().x, 71 camPos.y < mid.y ? box->getMinimum().y : box->getMaximum().y, 72 camPos.z < mid.z ? box->getMinimum().z : box->getMaximum().z); 73 74 return (camPos - minPos).squaredLength(); 73 75 } 74 76 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r85 r86 6 6 #include "OgrePlatformHierarchyInterface.h" 7 7 #include "OgrePlatformOcclusionQuery.h" 8 #include <windows.h> 8 9 9 10 namespace Ogre { … … 33 34 void PlatformHierarchyInterface::RenderBoundingBox(AxisAlignedBox *box) 34 35 { 36 static RenderOperation ro; 37 38 //TODO: this should be the full bounding box 39 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 40 41 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 42 mSceneManager->useRenderableViewProjMode(halfbox); 43 mSceneManager->setPass(halfbox->getTechnique()->getPass(0)); 44 35 45 // Render two halfes of the bounding box (using triangle fans) 36 46 for(int halfIdx = 0; halfIdx < 2; ++halfIdx) 37 47 { 38 //TODO: this should be the full bounding box 39 SolidHalfBoundingBox *halfbox = GetSolidHalfBoundingBox(); 40 halfbox->SetupBoundingBox(*box, halfIdx == 1); 48 halfbox->SetupBoundingBoxVertices(*box, halfIdx == 1); 41 49 42 mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);43 44 static RenderOperation ro;45 46 mSceneManager->useRenderableViewProjMode(halfbox);47 mSceneManager->setPass(GetSolidHalfBoundingBox()->getTechnique()->getPass(0));48 50 halfbox->getRenderOperation(ro); 49 51 ro.srcRenderable = halfbox; 50 mRenderSystem->_render(ro); 52 mRenderSystem->_render(ro); 51 53 } 52 54 } … … 70 72 { 71 73 GtpVisibility::HierarchyInterface::InitFrame(root); 74 mPreviousNode = NULL; 72 75 SetCamera(cam); 73 76 } … … 94 97 //----------------------------------------------------------------------- 95 98 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 96 GtpVisibility::HierarchyNode *node )99 GtpVisibility::HierarchyNode *node, const bool wasVisible) 97 100 { 98 101 // get next available test id … … 102 105 query->BeginQuery(); 103 106 104 RenderBoundingBox(GetBoundingBox(node)); 107 // if leaf and was visible => will be rendered anyway, thus we 108 // can also test with the real geometry 109 if(mUseOptimization && wasVisible && IsLeaf(node)) 110 { 111 // OutputDebugString("Using optimization!!\n"); 112 RenderNode(node); 113 } 114 else 115 { 116 // OutputDebugString("Not optimized!!\n"); 117 RenderBoundingBox(GetBoundingBox(node)); 118 } 105 119 106 120 query->EndQuery(); -
trunk/VUT/Ogre/src/OgrePlatformOcclusionQuery.cpp
r59 r86 1 1 #include "OgrePlatformOcclusionQuery.h" 2 2 #include <windows.h> 3 3 namespace Ogre { 4 4 … … 24 24 } 25 25 //----------------------------------------------------------------------- 26 unsigned int PlatformOcclusionQuery::GetQueryResult() const 26 bool PlatformOcclusionQuery::GetQueryResult(unsigned int &visiblePixels, 27 const bool waitForResult) const 27 28 { 28 unsigned int visiblePixels = 0; 29 // wait if result not available 30 mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels); 31 32 return visiblePixels; 33 } 34 //----------------------------------------------------------------------- 35 bool PlatformOcclusionQuery::ResultAvailable() const 36 { 37 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 38 return mHardwareOcclusionQuery->resultAvailable(); 39 #else 40 return true; 41 #endif 29 return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult); 42 30 } 43 31 -
trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp
r85 r86 26 26 Vector3 vmin = aab.getMinimum(); 27 27 28 Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength());29 mRadius = Math::Sqrt(sqLen);28 //Real sqLen = std::max(vmax.squaredLength(), vmin.squaredLength()); 29 //mRadius = Math::Sqrt(sqLen); 30 30 31 31 Real maxx = vmax.x; … … 90 90 91 91 // setup the bounding box of this SimpleRenderable 92 setBoundingBox(aabb);92 //setBoundingBox(aabb); 93 93 } 94 94 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r74 r86 18 18 19 19 //mDisplayNodes = true; 20 mShowBoundingBoxes = true;21 mShowBoxes = true;22 //mMaxDepth = 20;20 //mShowBoundingBoxes = true; 21 //mShowBoxes = true; 22 mMaxDepth = 20; 23 23 } 24 24 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreVisibilityOptionsManager.cpp
r75 r86 20 20 { 21 21 mVisibilityManager->SetVisibilityCullingThreshold(*static_cast<const int *>(val)); 22 22 return true; 23 } 24 if (key == "UseOptimization") 25 { 26 mHierarchyInterface->SetUseOptimization(*static_cast<const bool *>(val)); 23 27 return true; 24 28 } … … 53 57 return true; 54 58 } 59 55 60 return false; 56 61 } -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r85 r86 12 12 //namespace GtpVisibility { 13 13 //----------------------------------------------------------------------- 14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( GtpVisibility::VisibilityManager *visManager)15 :mVisibilityManager(visManager)14 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 15 GtpVisibility::VisibilityManager *visManager): mVisibilityManager(visManager) 16 16 { 17 17 mHierarchyInterface = 18 18 new OctreeHierarchyInterface(this, mDestRenderSystem); 19 19 20 setVisibilityManager(visManager);21 20 //mShowBoxes = true; 22 21 //mDisplayNodes = true;
Note: See TracChangeset
for help on using the changeset viewer.