Objects with transform persistence are detected as non ray-tracable and redered using the rasterization approach.
The renderFiltered() method moved to the OpenGl_Group class.
v3d/raytrace/bug27130: test case added
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
theWorkspace->SetAspects (thePlane->AspectFace());
theWorkspace->SetRenderFilter (aPrevFilter);
- if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
+ if (!theWorkspace->ShouldRender (&thePlane->Primitives(), aGroupIter.Value()))
{
continue;
}
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
-namespace
-{
- //! Render element if it passes the filtering procedure. This method should
- //! be used for elements which can be used in scope of rendering algorithms.
- //! E.g. elements of groups during recursive rendering.
- //! If render filter is null, pure rendering is performed.
- //! @param theWorkspace [in] the rendering workspace.
- //! @param theFilter [in] the rendering filter to check whether the element
- //! should be rendered or not.
- //! @return True if element passes the check and renders,
- static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
- OpenGl_Element* theElement)
- {
- if (!theWorkspace->ShouldRender (theElement))
- {
- return false;
- }
-
- theElement->Render (theWorkspace);
- return true;
- }
-}
-
// =======================================================================
// function : OpenGl_Group
// purpose :
(myLast? myLast->next : myFirst) = aNode;
myLast = aNode;
- if (OpenGl_Raytrace::IsRaytracedElement (aNode))
+ if (OpenGl_Raytrace::IsRaytracedElement (aNode) && !HasPersistence())
{
myIsRaytracable = Standard_True;
}
}
+// =======================================================================
+// function : renderFiltered
+// purpose :
+// =======================================================================
+bool OpenGl_Group::renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
+ OpenGl_Element* theElement) const
+{
+ if (!theWorkspace->ShouldRender (theElement, this))
+ {
+ return false;
+ }
+
+ theElement->Render (theWorkspace);
+ return true;
+}
+
// =======================================================================
// function : Render
// purpose :
: Handle(Graphic3d_Aspects)();
}
+ //! Return TRUE if group contains primitives with transform persistence.
+ bool HasPersistence() const { return myStructure != NULL && !myStructure->TransformPersistence().IsNull(); }
+
//! Update aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
Standard_EXPORT virtual ~OpenGl_Group();
+private:
+
+ //! Render element if it passes the filtering procedure.
+ //! This method should be used for elements which can be used in scope of rendering algorithms.
+ //! E.g. elements of groups during recursive rendering.
+ //! If render filter is null, pure rendering is performed.
+ //! @param theWorkspace [in] the rendering workspace
+ //! @param theFilter [in] the rendering filter to check whether the element should be rendered or not
+ //! @return True if element passes the check and renders
+ Standard_EXPORT bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
+ OpenGl_Element* theElement) const;
+
protected:
OpenGl_Aspects* myAspects;
// =======================================================================
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
{
+ if (theGroup->HasPersistence())
+ {
+ return Standard_False;
+ }
+
for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
{
if (IsRaytracedElement (aNode))
// =======================================================================
void OpenGl_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
+ if ((myTrsfPers.IsNull() || theTrsfPers.IsNull()) && myTrsfPers != theTrsfPers)
+ {
+ ++myModificationState;
+ }
myTrsfPers = theTrsfPers;
updateLayerTransformation();
}
Standard_Boolean OpenGl_Structure::IsRaytracable() const
{
if (!myGroups.IsEmpty()
- && myIsRaytracable)
+ && myIsRaytracable
+ && myTrsfPers.IsNull())
{
return Standard_True;
}
// function : ShouldRender
// purpose :
// =======================================================================
-bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
+bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement,
+ const OpenGl_Group* theGroup)
{
// render only non-raytracable elements when RayTracing is enabled
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
{
- if (OpenGl_Raytrace::IsRaytracedElement (theElement))
+ if (!theGroup->HasPersistence() && OpenGl_Raytrace::IsRaytracedElement (theElement))
{
return false;
}
//! Checks whether the element can be rendered or not.
//! @param theElement [in] the element to check
+ //! @param theGroup [in] the group containing the element
//! @return True if element can be rendered
- bool ShouldRender (const OpenGl_Element* theElement);
+ bool ShouldRender (const OpenGl_Element* theElement, const OpenGl_Group* theGroup);
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
//! @sa OpenGl_LayerList::Render()
--- /dev/null
+puts "============"
+puts "0027130: Visualization, Ray tracing - skip structures with transformation persistence flag"
+puts "============"
+puts ""
+
+pload VISUALIZATION MODELING
+
+vinit View1
+vsetdispmode 1
+
+restore [locate_data_file face1.brep] f
+vdisplay f
+box b1 25 25 25
+vdisplay b1 -trsfPers zoom -trsfPersPos 0 0 0
+
+vraytrace 1
+vfit
+vdump ${imagedir}/${casename}.png