mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
review fix
This commit is contained in:
parent
0c44ae5c8a
commit
783cdc351b
@ -208,7 +208,4 @@ Graphic3d_Layer.cxx
|
||||
Graphic3d_Layer.hxx
|
||||
Graphic3d_ZLayerId.hxx
|
||||
Graphic3d_ZLayerSettings.hxx
|
||||
Graphic3d_OcclusionQuery.hxx
|
||||
Graphic3d_OcclusionQuery.cxx
|
||||
Graphic3d_ViewOcclusionMask.hxx
|
||||
Graphic3d_ViewOcclusionMask.cxx
|
||||
|
@ -167,13 +167,15 @@ public:
|
||||
|
||||
//! Returns True if the structure occulded in specified view, otherwise
|
||||
//! returns False.
|
||||
Standard_Boolean IsOccluded(const Standard_Integer theViewId) const {
|
||||
Standard_Boolean IsOccluded(const Standard_Integer theViewId) const
|
||||
{
|
||||
return (!OcclusionMask->IsVisible(theViewId));
|
||||
}
|
||||
|
||||
//! Marks structure as Occluded by other strcuture in specified view,!
|
||||
void SetOccluded(const Standard_Integer theViewId) const {
|
||||
OcclusionMask->SetVisible(Standard_False, theViewId);
|
||||
void SetOccluionSate(const Standard_Integer theViewId, const bool theIsVisible) const
|
||||
{
|
||||
OcclusionMask->SetVisible(theViewId, !theIsVisible);
|
||||
}
|
||||
|
||||
//! Returns whether check of object's bounding box clipping is enabled before drawing of object; TRUE by default.
|
||||
@ -229,8 +231,8 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
|
||||
Handle(Graphic3d_ViewOcclusionMask) OcclusionMask; //!< view occlusion mask
|
||||
Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
|
||||
Handle(Graphic3d_ViewOcclusionMask) OcclusionMask; //!< view occlusion mask
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -132,6 +132,9 @@ public:
|
||||
|
||||
//! Returns number of occluded strcutures in the view
|
||||
Standard_EXPORT void OccludedStructures(Graphic3d_MapOfStructure& theStructures) const;
|
||||
|
||||
//! update occlusion test for dispalyed strcutures in the view
|
||||
Standard_EXPORT virtual void UpdateOcclusion() = 0 ;
|
||||
|
||||
//! Returns number of displayed structures in the view.
|
||||
virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Created on: 2024-02-20
|
||||
// Created by: Hossam Ali
|
||||
// Copyright (c) 2024 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in
|
||||
// OCCT distribution for complete text of the license and disclaimer of any
|
||||
// warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_OcclusionQuery.hxx>
|
||||
|
||||
#include <Standard_Dump.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_OcclusionQuery, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : GetNumSamplesPassed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned int Graphic3d_OcclusionQuery::GetNumSamplesPassed() const {
|
||||
return samplesPassed;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AnySamplesPassed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_OcclusionQuery::AnySamplesPassed() const {
|
||||
return samplesPassed > 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_OcclusionQuery::DumpJson(Standard_OStream &theOStream,
|
||||
Standard_Integer) const {
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, queryID)
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, samplesPassed)
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
// Created on: 2024-02-20
|
||||
// Created by: Hossam Ali
|
||||
// Copyright (c) 2024 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in
|
||||
// OCCT distribution for complete text of the license and disclaimer of any
|
||||
// warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_OcclusionQuery_HeaderFile
|
||||
#define _Graphic3d_OcclusionQuery_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
//! Base class provides access to occlusion query functionality.
|
||||
class Graphic3d_OcclusionQuery : public Standard_Transient {
|
||||
public:
|
||||
//! Empty constructor.
|
||||
Graphic3d_OcclusionQuery() : queryID(0), samplesPassed(0) {}
|
||||
|
||||
//! Begins occlusion query. Until the query is ended, samples that pass the
|
||||
//! rendering pipeline are counted.
|
||||
Standard_EXPORT virtual void BeginQuery() const = 0;
|
||||
|
||||
//! Ends occlusion query and caches the result - number of samples that passed
|
||||
//! the rendering pipeline.
|
||||
Standard_EXPORT virtual void EndQuery() = 0;
|
||||
|
||||
//! Gets number of samples that have passed the rendering pipeline.
|
||||
unsigned int GetNumSamplesPassed() const;
|
||||
|
||||
//! Helper method that returns if any samples have passed the rendering
|
||||
//! pipeline.
|
||||
bool AnySamplesPassed() const;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT void DumpJson(Standard_OStream &theOStream,
|
||||
Standard_Integer theDepth = -1) const;
|
||||
|
||||
protected:
|
||||
unsigned int queryID; // Query object ID
|
||||
int samplesPassed; // Number of samples passed in last query
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_OcclusionQuery, Standard_Transient)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_OcclusionQuery, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_OcclusionQuery_HeaderFile
|
@ -1,32 +0,0 @@
|
||||
// Created on: 2024-02-20
|
||||
// Created by: Hossam Ali
|
||||
// Copyright (c) 2024 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in
|
||||
// OCCT distribution for complete text of the license and disclaimer of any
|
||||
// warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_ViewOcclusionMask.hxx>
|
||||
|
||||
#include <Standard_Dump.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ViewOcclusionMask, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : DumpJson
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ViewOcclusionMask::DumpJson(Standard_OStream &theOStream,
|
||||
Standard_Integer) const {
|
||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
|
||||
|
||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myMask)
|
||||
}
|
@ -17,62 +17,9 @@
|
||||
#ifndef _Graphic3d_ViewOcclusionMask_HeaderFile
|
||||
#define _Graphic3d_ViewOcclusionMask_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Graphic3d_ViewAffinity.hxx>
|
||||
|
||||
//! Structure display state.
|
||||
class Graphic3d_ViewOcclusionMask : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
//! define occlusion mask as alias for view affinity mask .
|
||||
typedef Graphic3d_ViewAffinity Graphic3d_ViewOcclusionMask;
|
||||
|
||||
//! Empty constructor.
|
||||
Graphic3d_ViewOcclusionMask()
|
||||
{
|
||||
SetVisible (Standard_True);
|
||||
}
|
||||
|
||||
//! Return visibility flag.
|
||||
bool IsVisible (const Standard_Integer theViewId) const
|
||||
{
|
||||
const unsigned int aBit = 1 << theViewId;
|
||||
return (myMask & aBit) != 0;
|
||||
}
|
||||
|
||||
//! Setup visibility flag for all views.
|
||||
void SetVisible (const Standard_Boolean theIsVisible)
|
||||
{
|
||||
::memset (&myMask, theIsVisible ? 0xFF : 0x00, sizeof(myMask));
|
||||
}
|
||||
|
||||
//! Setup visibility flag.
|
||||
void SetVisible (const Standard_Integer theViewId,
|
||||
const bool theIsVisible)
|
||||
{
|
||||
const unsigned int aBit = 1 << theViewId;
|
||||
if (theIsVisible)
|
||||
{
|
||||
myMask |= aBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
myMask &= ~aBit;
|
||||
}
|
||||
}
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
|
||||
|
||||
private:
|
||||
|
||||
unsigned int myMask; //!< affinity mask
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_ViewOcclusionMask,Standard_Transient)
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_ViewOcclusionMask, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_ViewOcclusionMask_HeaderFile
|
||||
#endif //_Graphic3d_ViewOcclusionMask_HeaderFile
|
@ -25,6 +25,7 @@
|
||||
#include <OpenGl_VertexBuffer.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_OcclusionQuery.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -875,11 +876,8 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
//function : updateOcclusion
|
||||
//purpose : update Occlsuion state for each struct in each layer
|
||||
//=======================================================================
|
||||
void OpenGl_LayerList::UpdateOcclusion( const Handle(OpenGl_Workspace) & theWorkspace,
|
||||
const Standard_Boolean theToDrawImmediate,
|
||||
const OpenGl_FrameBuffer *theReadDrawFbo,
|
||||
const OpenGl_FrameBuffer *theOitAccumFbo)
|
||||
{
|
||||
void OpenGl_LayerList::UpdateOcclusion( const Handle(OpenGl_Workspace) & theWorkspace)
|
||||
{
|
||||
const Handle(OpenGl_Context) &aCtx = theWorkspace->GetGlContext();
|
||||
aCtx->core11fwd->glEnable(GL_DEPTH_TEST);
|
||||
aCtx->core11fwd->glDepthFunc (GL_LESS);
|
||||
@ -893,7 +891,6 @@ void OpenGl_LayerList::UpdateOcclusion( const Handle(OpenGl_Workspace) & theWork
|
||||
|
||||
// Turn off writing to depth and color buffers
|
||||
aCtx->core11fwd->glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
aCtx->core11fwd->glDepthMask(GL_FALSE);
|
||||
|
||||
// Start record occlusion test computational cost
|
||||
const Handle(OpenGl_FrameStats) &aStats = theWorkspace->GetGlContext()->FrameStats();
|
||||
@ -910,11 +907,7 @@ void OpenGl_LayerList::UpdateOcclusion( const Handle(OpenGl_Workspace) & theWork
|
||||
if (aLayer->IsCulled())
|
||||
continue;
|
||||
|
||||
/// TODO Change below to Graphic3d_Query
|
||||
GLuint query_ID;
|
||||
GLint samplesPassed;
|
||||
|
||||
aCtx->core20->glGenQueries(1, &query_ID);
|
||||
aCtx->core11fwd->glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Render priority list
|
||||
const Standard_Integer aViewId = theWorkspace->View()->Identification();
|
||||
@ -930,29 +923,9 @@ void OpenGl_LayerList::UpdateOcclusion( const Handle(OpenGl_Workspace) & theWork
|
||||
if (aStruct->IsCulled() || !aStruct->IsVisible(aViewId))
|
||||
continue;
|
||||
|
||||
// Begin occlusion query
|
||||
aCtx->core20->glBeginQuery(GL_SAMPLES_PASSED, query_ID);
|
||||
|
||||
// Dry rendering for conservative approximation of the complex object
|
||||
aStruct->RenderOccluder(theWorkspace);
|
||||
|
||||
// End query and count no of samples
|
||||
aCtx->core20->glEndQuery(GL_SAMPLES_PASSED);
|
||||
aCtx->core20->glGetQueryObjectiv(query_ID, GL_QUERY_RESULT, &samplesPassed);
|
||||
|
||||
if (samplesPassed <= 0)
|
||||
aStruct->SetOccluded(aViewId);
|
||||
|
||||
std::cout << "layerID: " << aLayer->LayerId()
|
||||
<< " structureID: " << aStruct->Identification()
|
||||
<< " clocation: " << aStruct->BoundingBox().Center().z()
|
||||
<< " queryID: " << query_ID
|
||||
<< " sample passsed : " << samplesPassed << std::endl;
|
||||
samplesPassed=0;
|
||||
aStruct->UpdateOcclusion(theWorkspace);
|
||||
}
|
||||
}
|
||||
// Release query resources
|
||||
aCtx->core20->glDeleteQueries(1, &query_ID);
|
||||
}
|
||||
|
||||
// Back to prev settings
|
||||
|
@ -107,10 +107,7 @@ public:
|
||||
OpenGl_FrameBuffer* theOitAccumFbo) const;
|
||||
|
||||
//! Update occlusion test
|
||||
Standard_EXPORT void UpdateOcclusion(const Handle(OpenGl_Workspace) & theWorkspace,
|
||||
const Standard_Boolean theToDrawImmediate,
|
||||
const OpenGl_FrameBuffer *theReadDrawFbo,
|
||||
const OpenGl_FrameBuffer *theOitAccumFbo);
|
||||
Standard_EXPORT void UpdateOcclusion(const Handle(OpenGl_Workspace) & theWorkspace);
|
||||
|
||||
//! Returns the set of OpenGL Z-layers.
|
||||
const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const { return myLayers; }
|
||||
|
@ -14,46 +14,97 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include "OpenGl_OcclusionQuery.hxx"
|
||||
#include <OpenGl_OcclusionQuery.hxx>
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_GlCore15.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_OcclusionQuery, Graphic3d_OcclusionQuery)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_OcclusionQuery, OpenGl_Resource)
|
||||
|
||||
// =======================================================================
|
||||
// function :
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_EXPORT
|
||||
OpenGl_OcclusionQuery::OpenGl_OcclusionQuery(const Handle(OpenGl_Context) &
|
||||
theCtx)
|
||||
: aCtx(theCtx) {
|
||||
aCtx->core15->glGenQueries(1, &queryID);
|
||||
OpenGl_OcclusionQuery::OpenGl_OcclusionQuery(): myID(0), inUse(false), started(false)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function :
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_EXPORT OpenGl_OcclusionQuery::~OpenGl_OcclusionQuery() {
|
||||
aCtx->core15->glDeleteQueries(1, &queryID);
|
||||
queryID = 0;
|
||||
OpenGl_OcclusionQuery::~OpenGl_OcclusionQuery()
|
||||
{
|
||||
Release(NULL);
|
||||
}
|
||||
// =======================================================================
|
||||
// function : Create()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_OcclusionQuery::Create(const Handle(OpenGl_Context) & theCtx,
|
||||
GLenum theQueryType) {
|
||||
theCtx->core15->glGenQueries(1, &myID);
|
||||
myType = theQueryType;
|
||||
inUse = false;
|
||||
started = false;
|
||||
}
|
||||
// =======================================================================
|
||||
// function : Begin()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_OcclusionQuery::Begin(const Handle(OpenGl_Context) & theCtx)
|
||||
{
|
||||
inUse = true;
|
||||
started = true;
|
||||
theCtx->core15->glBeginQuery(myType, myID);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : End()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_OcclusionQuery::End(const Handle(OpenGl_Context) & theCtx) const
|
||||
{
|
||||
theCtx->core15->glEndQuery(myType);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BeginQuery()
|
||||
// function : isResultsReady()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_EXPORT void OpenGl_OcclusionQuery::BeginQuery() const {
|
||||
aCtx->core15->glBeginQuery(GL_SAMPLES_PASSED, queryID);
|
||||
int OpenGl_OcclusionQuery::IsResultsReady(const Handle(OpenGl_Context) & theCtx) const
|
||||
{
|
||||
// check if the query started before check for results
|
||||
if(!started)
|
||||
return false;
|
||||
|
||||
GLint aReady = 0;
|
||||
theCtx->core15->glGetQueryObjectiv(myID, GL_QUERY_RESULT_AVAILABLE, &aReady);
|
||||
return aReady;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetResults()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int OpenGl_OcclusionQuery::GetResults(const Handle(OpenGl_Context) & theCtx)
|
||||
{
|
||||
inUse = false;
|
||||
GLint aResult;
|
||||
theCtx->core15->glGetQueryObjectiv(myID, GL_QUERY_RESULT, &aResult);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : EndQuery()
|
||||
// purpose :
|
||||
// function : Release()
|
||||
// purpose : Destroy the query opengl resources
|
||||
// =======================================================================
|
||||
Standard_EXPORT void OpenGl_OcclusionQuery::EndQuery() {
|
||||
aCtx->core15->glEndQuery(GL_SAMPLES_PASSED);
|
||||
aCtx->core15->glGetQueryObjectiv(queryID, GL_QUERY_RESULT, &samplesPassed);
|
||||
}
|
||||
void OpenGl_OcclusionQuery::Release(OpenGl_Context *theCtx) {
|
||||
if (myID == 0)
|
||||
return;
|
||||
if (theCtx != NULL) {
|
||||
theCtx->core15->glDeleteQueries(1, &myID);
|
||||
myID = 0;
|
||||
started = false;
|
||||
}
|
||||
}
|
@ -14,38 +14,59 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef OpenGl_View_HeaderFile
|
||||
#define OpenGl_View_HeaderFile
|
||||
#ifndef OpenGl_OcclusionQuery_HeaderFile
|
||||
#define OpenGl_OcclusionQuery_HeaderFile
|
||||
|
||||
#include <Graphic3d_OcclusionQuery.hxx>
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <OpenGl_GlCore15.hxx>
|
||||
|
||||
class OpenGl_Context;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_OcclusionQuery, Graphic3d_OcclusionQuery)
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_OcclusionQuery, OpenGl_Resource)
|
||||
|
||||
//! Implementation of OpenGl view.
|
||||
class OpenGl_OcclusionQuery : public Graphic3d_OcclusionQuery {
|
||||
|
||||
class OpenGl_OcclusionQuery : public OpenGl_Resource {
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_OcclusionQuery, OpenGl_Resource)
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT OpenGl_OcclusionQuery(const Handle(OpenGl_Context) & theCtx);
|
||||
Standard_EXPORT OpenGl_OcclusionQuery();
|
||||
|
||||
//! Default destructor.
|
||||
Standard_EXPORT virtual ~OpenGl_OcclusionQuery();
|
||||
|
||||
//! Create the occlusion test Gl resources.
|
||||
Standard_EXPORT virtual void Create(const Handle(OpenGl_Context)& theCtx, GLenum theType);
|
||||
|
||||
//! Begins occlusion query.
|
||||
Standard_EXPORT virtual void BeginQuery() const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Begin(const Handle(OpenGl_Context) & theCtx);
|
||||
|
||||
//! Ends occlusion query and caches the result
|
||||
Standard_EXPORT virtual void EndQuery() Standard_OVERRIDE;
|
||||
//! Ends occlusion query
|
||||
Standard_EXPORT virtual void End(const Handle(OpenGl_Context) & theCtx) const;
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_OcclusionQuery,
|
||||
Graphic3d_OcclusionQuery) // Type definition
|
||||
//! Check if the query results ready for retrive or not.
|
||||
Standard_EXPORT virtual int IsResultsReady(const Handle(OpenGl_Context) & theCtx) const;
|
||||
|
||||
//! Return the query results based on query type.
|
||||
Standard_EXPORT virtual int GetResults(const Handle(OpenGl_Context) & theCtx);
|
||||
|
||||
//! Return is the query in use or not
|
||||
Standard_EXPORT bool IsInUse() { return inUse; }
|
||||
|
||||
//! Return Query ID
|
||||
Standard_EXPORT unsigned int GetID() const {return myID;};
|
||||
|
||||
//! Destroys query object.
|
||||
Standard_EXPORT virtual void Release (OpenGl_Context * theCtx) Standard_OVERRIDE;
|
||||
|
||||
//! Returns estimated GPU memory usage - not implemented.
|
||||
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
private:
|
||||
const Handle(OpenGl_Context) & aCtx;
|
||||
GLuint myID; //!< OpenGL query ID.
|
||||
GLenum myType; //!< OpenGL query Type.
|
||||
bool inUse; //!< store bool answer is the query still inprogress or finished.
|
||||
bool started; //!< bool answer is the query stated before or this the first time.
|
||||
};
|
||||
|
||||
#endif // _OpenGl_View_Header
|
||||
#endif // _OpenGl_OcclusionQuery_Header
|
||||
|
@ -103,7 +103,8 @@ OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& th
|
||||
myInstancedStructure (NULL),
|
||||
myIsRaytracable (Standard_False),
|
||||
myModificationState (0),
|
||||
myIsMirrored (Standard_False)
|
||||
myIsMirrored (Standard_False),
|
||||
myQuery(new OpenGl_OcclusionQuery())
|
||||
{
|
||||
updateLayerTransformation();
|
||||
}
|
||||
@ -636,6 +637,33 @@ void OpenGl_Structure::RenderOccluder(const Handle(OpenGl_Workspace)& theWorkspa
|
||||
aCtx->ApplyModelViewMatrix();
|
||||
renderBoundingBox(theWorkspace);
|
||||
}
|
||||
// =======================================================================
|
||||
// function : OcclusionTest
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Structure::UpdateOcclusion(const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const Handle(OpenGl_Context) &aCtx = theWorkspace->GetGlContext();
|
||||
if (myQuery->GetID()==0)
|
||||
myQuery->Create(aCtx, GL_ANY_SAMPLES_PASSED);
|
||||
|
||||
if(myQuery->IsResultsReady(aCtx))
|
||||
{
|
||||
int aResult = myQuery->GetResults(aCtx);
|
||||
const Standard_Integer aViewId = theWorkspace->View()->Identification();
|
||||
if (aResult<=0)
|
||||
SetOccluionSate(aViewId, Standard_False);
|
||||
else
|
||||
SetOccluionSate(aViewId, Standard_True);
|
||||
}
|
||||
|
||||
if(!myQuery->IsInUse())
|
||||
{
|
||||
myQuery->Begin(aCtx);
|
||||
RenderOccluder(theWorkspace);
|
||||
myQuery->End(aCtx);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Release
|
||||
@ -658,6 +686,8 @@ void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCt
|
||||
{
|
||||
aGroupIter.ChangeValue()->Release (theGlCtx);
|
||||
}
|
||||
|
||||
myQuery->Release(theGlCtx.get());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_Group.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_OcclusionQuery.hxx>
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
|
||||
@ -96,8 +97,11 @@ public:
|
||||
//! Renders the structure.
|
||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Render Occluder presenation of this structure
|
||||
//! Renders occluder presenation of the structure
|
||||
Standard_EXPORT void RenderOccluder(const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Peforms occlusion test for the strcuture
|
||||
Standard_EXPORT void UpdateOcclusion(const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Releases structure resources.
|
||||
Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
|
||||
@ -168,12 +172,14 @@ protected:
|
||||
protected:
|
||||
|
||||
OpenGl_Structure* myInstancedStructure;
|
||||
Graphic3d_Mat4 myRenderTrsf; //!< transformation, actually used for rendering (includes Local Origin shift)
|
||||
Graphic3d_Mat4 myRenderTrsf; //!< transformation, actually used for rendering (includes Local Origin shift)
|
||||
|
||||
mutable Standard_Boolean myIsRaytracable;
|
||||
mutable Standard_Size myModificationState;
|
||||
|
||||
Standard_Boolean myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order.
|
||||
Standard_Boolean myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order.
|
||||
|
||||
Handle(OpenGl_OcclusionQuery) myQuery; //! test the occlusion status of the structure;
|
||||
|
||||
};
|
||||
|
||||
|
@ -2542,11 +2542,9 @@ void OpenGl_View::InvalidateBVHData (const Graphic3d_ZLayerId theLayerId)
|
||||
//function : updateOcclusionState
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::updateOcclusion(OpenGl_FrameBuffer* theReadDrawFbo,
|
||||
OpenGl_FrameBuffer* theOitAccumFbo,
|
||||
const Standard_Boolean theToDrawImmediate)
|
||||
void OpenGl_View::UpdateOcclusion()
|
||||
{
|
||||
myZLayers.UpdateOcclusion(myWorkspace, theToDrawImmediate,theReadDrawFbo, theOitAccumFbo);
|
||||
myZLayers.UpdateOcclusion(myWorkspace);
|
||||
|
||||
// re-validate occlusion results
|
||||
myRenderParams.OcculsionQueryState = Graphic3d_RenderingParams::OcculsionQuery_On;
|
||||
@ -2573,7 +2571,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
|
||||
|
||||
// update occlusion here after update culling to ensure the frusrum culling updated
|
||||
if (myRenderParams.OcculsionQueryState == Graphic3d_RenderingParams::OcculsionQuery_NoUpdate)
|
||||
updateOcclusion(theReadDrawFbo, theOitAccumFbo, theToDrawImmediate);
|
||||
UpdateOcclusion();
|
||||
|
||||
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
|
||||
Standard_Boolean toRenderGL = theToDrawImmediate ||
|
||||
|
@ -183,6 +183,9 @@ public:
|
||||
//! Returns additional buffers for depth peeling OIT.
|
||||
const Handle(OpenGl_DepthPeeling)& DepthPeelingFbos() const { return myDepthPeelingFbos; }
|
||||
|
||||
//! Perform occlusion test for the set of structures presented in the view
|
||||
Standard_EXPORT virtual void UpdateOcclusion() Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns gradient background fill colors.
|
||||
@ -380,14 +383,6 @@ protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
|
||||
Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
Graphic3d_Camera::Projection theProjection);
|
||||
|
||||
//! Update occlusion state for the set of structures presented in the view
|
||||
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
|
||||
//! @param theOitAccumFbo [in] the framebuffer for accumulating color and coverage for OIT process.
|
||||
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
|
||||
Standard_EXPORT virtual void updateOcclusion(OpenGl_FrameBuffer* theReadDrawFbo,
|
||||
OpenGl_FrameBuffer* theOitAccumFbo,
|
||||
const Standard_Boolean theToDrawImmediate);
|
||||
|
||||
//! Render set of structures presented in the view.
|
||||
//! @param theProjection [in] the projection that is used for rendering.
|
||||
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
|
||||
|
@ -14045,11 +14045,11 @@ static Standard_Integer VNbOccluded(Draw_Interpretor & /*theDi*/,
|
||||
Handle(V3d_View) aView = ViewerTest_myViews.Find1(anIter.Value());
|
||||
aView->ChangeRenderingParams().OcculsionQueryState = Graphic3d_RenderingParams::OcculsionQuery_NoUpdate;
|
||||
aView->Redraw();
|
||||
|
||||
aView->View()->UpdateOcclusion();
|
||||
Graphic3d_MapOfStructure aOcculdedStructs;
|
||||
aView->View()->OccludedStructures(aOcculdedStructs);
|
||||
|
||||
printf("No Occluded Objects in view id: %d --> %d\n",
|
||||
printf("Occluded objects in view: %d = %d\n",
|
||||
aView->View()->Identification(), aOcculdedStructs.Extent());
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ box c 12 0 0 10 10 10
|
||||
# check left side
|
||||
vinit name=View1
|
||||
vsetdispmode 1
|
||||
vdisplay b c
|
||||
vdisplay c b
|
||||
vright
|
||||
vfit
|
||||
vzoom 0.5
|
||||
@ -20,7 +20,7 @@ vzoom 0.5
|
||||
# check front side
|
||||
vinit name=View2
|
||||
vsetdispmode 1
|
||||
vdisplay b c
|
||||
vdisplay c b
|
||||
vfront
|
||||
vfit
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user