1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0027952: Visualization - do not reset RayTracing state on changing structures not in main Z-Layer

This commit is contained in:
kgv 2016-10-11 22:55:25 +03:00 committed by apn
parent bbbca107a2
commit bd6a845441
5 changed files with 40 additions and 19 deletions

View File

@ -27,9 +27,11 @@
//======================================================================= //=======================================================================
OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities) OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
: myNbPriorities (theNbPriorities), : myDefaultLayerIndex (0),
myNbPriorities (theNbPriorities),
myNbStructures (0), myNbStructures (0),
myImmediateNbStructures (0) myImmediateNbStructures (0),
myModifStateOfRaytraceable (0)
{ {
// insert default priority layers // insert default priority layers
myLayers.Append (OpenGl_Layer (myNbPriorities)); myLayers.Append (OpenGl_Layer (myNbPriorities));
@ -46,6 +48,8 @@ OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
myLayers.Append (OpenGl_Layer (myNbPriorities)); myLayers.Append (OpenGl_Layer (myNbPriorities));
myLayerIds.Bind (Graphic3d_ZLayerId_TopOSD, myLayers.Upper()); myLayerIds.Bind (Graphic3d_ZLayerId_TopOSD, myLayers.Upper());
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
} }
//======================================================================= //=======================================================================
@ -116,13 +120,14 @@ void OpenGl_LayerList::RemoveLayer (const Graphic3d_ZLayerId theLayerId)
myLayerIds.UnBind (theLayerId); myLayerIds.UnBind (theLayerId);
// updated sequence indexes in map // updated sequence indexes in map
OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds); for (OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds); aMapIt.More(); aMapIt.Next())
for ( ; aMapIt.More (); aMapIt.Next ())
{ {
Standard_Integer& aSeqIdx = aMapIt.ChangeValue (); Standard_Integer& aSeqIdx = aMapIt.ChangeValue();
if (aSeqIdx > aRemovePos) if (aSeqIdx > aRemovePos)
aSeqIdx--; aSeqIdx--;
} }
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
} }
//======================================================================= //=======================================================================
@ -179,9 +184,10 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
--myImmediateNbStructures; --myImmediateNbStructures;
} }
if (theStructure->IsRaytracable()) if (aLayerId == Graphic3d_ZLayerId_Default
&& theStructure->IsRaytracable())
{ {
++myModificationState; ++myModifStateOfRaytraceable;
} }
return; return;
@ -205,9 +211,10 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
--myImmediateNbStructures; --myImmediateNbStructures;
} }
if (theStructure->IsRaytracable()) if (aSeqId == myDefaultLayerIndex
&& theStructure->IsRaytracable())
{ {
++myModificationState; ++myModifStateOfRaytraceable;
} }
return; return;
} }
@ -244,6 +251,12 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
// if the structure is not found there, scan through all other layers // if the structure is not found there, scan through all other layers
if (aLayer.Remove (theStructure, aPriority, Standard_False)) if (aLayer.Remove (theStructure, aPriority, Standard_False))
{ {
if (theOldLayerId == Graphic3d_ZLayerId_Default
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
}
--myNbStructures; --myNbStructures;
if (aLayer.LayerSettings().IsImmediate) if (aLayer.LayerSettings().IsImmediate)
{ {
@ -269,6 +282,12 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
OpenGl_Layer& aLayerEx = anIts.ChangeValue(); OpenGl_Layer& aLayerEx = anIts.ChangeValue();
if (aLayerEx.Remove (theStructure, aPriority, Standard_True)) if (aLayerEx.Remove (theStructure, aPriority, Standard_True))
{ {
if (aSeqId == myDefaultLayerIndex
&& theStructure->IsRaytracable())
{
++myModifStateOfRaytraceable;
}
--myNbStructures; --myNbStructures;
if (aLayerEx.LayerSettings().IsImmediate) if (aLayerEx.LayerSettings().IsImmediate)
{ {
@ -367,20 +386,20 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
aCtx->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &aDefaultSettings.DepthFunc); aCtx->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &aDefaultSettings.DepthFunc);
aCtx->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask); aCtx->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask);
Standard_Integer aSeqId = myLayers.Lower(), aMainId = myLayerIds.Find (Graphic3d_ZLayerId_Default); Standard_Integer aSeqId = myLayers.Lower();
for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next(), ++aSeqId) for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next(), ++aSeqId)
{ {
if (theLayersToProcess == OpenGl_LF_Bottom) if (theLayersToProcess == OpenGl_LF_Bottom)
{ {
if (aSeqId >= aMainId) continue; if (aSeqId >= myDefaultLayerIndex) continue;
} }
else if (theLayersToProcess == OpenGl_LF_Upper) else if (theLayersToProcess == OpenGl_LF_Upper)
{ {
if (aSeqId <= aMainId) continue; if (aSeqId <= myDefaultLayerIndex) continue;
} }
else if (theLayersToProcess == OpenGl_LF_Default) else if (theLayersToProcess == OpenGl_LF_Default)
{ {
if (aSeqId != aMainId) continue; if (aSeqId != myDefaultLayerIndex) continue;
} }
const OpenGl_Layer& aLayer = anIts.Value(); const OpenGl_Layer& aLayer = anIts.Value();

View File

@ -27,6 +27,7 @@ class OpenGl_Structure;
typedef NCollection_Sequence<OpenGl_Layer> OpenGl_SequenceOfLayers; typedef NCollection_Sequence<OpenGl_Layer> OpenGl_SequenceOfLayers;
typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds; typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
//! Class defining the list of layers.
class OpenGl_LayerList class OpenGl_LayerList
{ {
public: public:
@ -101,19 +102,20 @@ public:
void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId); void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId);
//! Returns structure modification state (for ray-tracing). //! Returns structure modification state (for ray-tracing).
Standard_Size ModificationState() const { return myModificationState; } Standard_Size ModificationStateOfRaytracable() const { return myModifStateOfRaytraceable; }
protected: protected:
// number of structures temporary put to default layer // number of structures temporary put to default layer
OpenGl_SequenceOfLayers myLayers; OpenGl_SequenceOfLayers myLayers;
OpenGl_LayerSeqIds myLayerIds; OpenGl_LayerSeqIds myLayerIds;
Standard_Integer myDefaultLayerIndex; //!< index of Graphic3d_ZLayerId_Default layer in myLayers sequence
Standard_Integer myNbPriorities; Standard_Integer myNbPriorities;
Standard_Integer myNbStructures; Standard_Integer myNbStructures;
Standard_Integer myImmediateNbStructures; //!< number of structures within immediate layers Standard_Integer myImmediateNbStructures; //!< number of structures within immediate layers
mutable Standard_Size myModificationState; mutable Standard_Size myModifStateOfRaytraceable;
public: public:

View File

@ -81,7 +81,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myIsRaytraceDataValid (Standard_False), myIsRaytraceDataValid (Standard_False),
myIsRaytraceWarnTextures (Standard_False), myIsRaytraceWarnTextures (Standard_False),
myToUpdateEnvironmentMap (Standard_False), myToUpdateEnvironmentMap (Standard_False),
myLayerListState (0) myRaytraceLayerListState (0)
{ {
myWorkspace = new OpenGl_Workspace (this, NULL); myWorkspace = new OpenGl_Workspace (this, NULL);

View File

@ -1029,7 +1029,7 @@ protected: //! @name fields related to ray-tracing
Standard_Boolean myToUpdateEnvironmentMap; Standard_Boolean myToUpdateEnvironmentMap;
//! State of OpenGL layer list. //! State of OpenGL layer list.
Standard_Size myLayerListState; Standard_Size myRaytraceLayerListState;
//! Number of accumulated frames (for progressive rendering). //! Number of accumulated frames (for progressive rendering).
Standard_Integer myAccumFrames; Standard_Integer myAccumFrames;

View File

@ -49,7 +49,7 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
// modifications. This is light-weight procedure performed on each frame // modifications. This is light-weight procedure performed on each frame
if (theMode == OpenGl_GUM_CHECK) if (theMode == OpenGl_GUM_CHECK)
{ {
if (myLayerListState != myZLayers.ModificationState()) if (myRaytraceLayerListState != myZLayers.ModificationStateOfRaytracable())
{ {
return updateRaytraceGeometry (OpenGl_GUM_PREPARE, theViewId, theGlContext); return updateRaytraceGeometry (OpenGl_GUM_PREPARE, theViewId, theGlContext);
} }
@ -185,7 +185,7 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
} }
// Actualize OpenGL layer list state // Actualize OpenGL layer list state
myLayerListState = myZLayers.ModificationState(); myRaytraceLayerListState = myZLayers.ModificationStateOfRaytracable();
// Rebuild two-level acceleration structure // Rebuild two-level acceleration structure
myRaytraceGeometry.ProcessAcceleration(); myRaytraceGeometry.ProcessAcceleration();