From f9e5ef76bd240ad0245738c4db6eae65eb478034 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sun, 15 May 2022 11:51:42 +0000 Subject: [PATCH] IVideoDriver::getOcclusionQueryResult works now with const node pointer. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6401 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/IVideoDriver.h | 2 +- source/Irrlicht/CD3D9Driver.cpp | 9 +++------ source/Irrlicht/CD3D9Driver.h | 2 +- source/Irrlicht/CNullDriver.cpp | 2 +- source/Irrlicht/CNullDriver.h | 7 ++++++- source/Irrlicht/COpenGLDriver.cpp | 9 +++------ source/Irrlicht/COpenGLDriver.h | 2 +- source/Irrlicht/CSceneManager.cpp | 2 +- source/Irrlicht/CSoftwareDriver2.cpp | 4 ++-- source/Irrlicht/CSoftwareDriver2.h | 2 +- 10 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index 55f5bc2..361800b 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -460,7 +460,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const =0; //! Create render target. virtual IRenderTarget* addRenderTarget() = 0; diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 73f9e61..cf8769b 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -1253,13 +1253,10 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block) /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 CD3D9Driver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 CD3D9Driver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); - if (index != -1) - return OcclusionQueries[index].Result; - else - return ~0; + const s32 index = OcclusionQueries.linear_search(node); + return index < 0 ? ~0 : OcclusionQueries[index].Result; } diff --git a/source/Irrlicht/CD3D9Driver.h b/source/Irrlicht/CD3D9Driver.h index 596cd1c..a879015 100644 --- a/source/Irrlicht/CD3D9Driver.h +++ b/source/Irrlicht/CD3D9Driver.h @@ -115,7 +115,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! Create render target. virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE; diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 56925d4..dc439de 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1994,7 +1994,7 @@ void CNullDriver::updateAllOcclusionQueries(bool block) /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ -u32 CNullDriver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 CNullDriver::getOcclusionQueryResult(const scene::ISceneNode* node) const { return ~0; } diff --git a/source/Irrlicht/CNullDriver.h b/source/Irrlicht/CNullDriver.h index e4cc569..a799aa6 100644 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@ -477,7 +477,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! Create render target. virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE; @@ -832,6 +832,11 @@ namespace video return other.Node==Node; } + bool operator==(const scene::ISceneNode* other) const + { + return other==Node; + } + scene::ISceneNode* Node; const scene::IMesh* Mesh; union diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index f508a06..2c7469e 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -786,13 +786,10 @@ void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block) /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 COpenGLDriver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 COpenGLDriver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); - if (index != -1) - return OcclusionQueries[index].Result; - else - return ~0; + const s32 index = OcclusionQueries.linear_search(node); + return index < 0 ? ~0 : OcclusionQueries[index].Result; } diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index b65efb3..333c626 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -110,7 +110,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! Create render target. virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE; diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index d921cca..4302cfa 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -1247,7 +1247,7 @@ bool CSceneManager::isCulled(const ISceneNode* node) const // has occlusion query information if (node->getAutomaticCulling() & scene::EAC_OCC_QUERY) { - result = (Driver->getOcclusionQueryResult(const_cast(node))==0); + result = (Driver->getOcclusionQueryResult(node)==0); } // can be seen by a bounding box ? diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 90b0517..e2331b0 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -4810,9 +4810,9 @@ void CBurningVideoDriver::updateOcclusionQuery(scene::ISceneNode* node, bool blo /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 CBurningVideoDriver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 CBurningVideoDriver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + const s32 index = OcclusionQueries.linear_search(node); return index < 0 ? ~0 : OcclusionQueries[index].Result; } diff --git a/source/Irrlicht/CSoftwareDriver2.h b/source/Irrlicht/CSoftwareDriver2.h index 441ccd6..18ed97e 100644 --- a/source/Irrlicht/CSoftwareDriver2.h +++ b/source/Irrlicht/CSoftwareDriver2.h @@ -48,7 +48,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! sets transformation virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) IRR_OVERRIDE;