1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0032758: Visualization, TKOpenGl - disable shadow-map from transform-persistence objects

OpenGl_View::renderShadowMap() now skips transform-persistent objects.
OpenGl_ShadowMap::UpdateCamera() - removed redundant Z-range expansion for non-rendered objects.
Improved syntax of vdrawtext command.
This commit is contained in:
kgv 2021-12-30 16:41:09 +03:00 committed by smoskvin
parent 6cb968fd6f
commit d925497360
7 changed files with 133 additions and 134 deletions

View File

@ -52,7 +52,11 @@ public:
} }
//! Return TRUE if group contains primitives with transform persistence. //! Return TRUE if group contains primitives with transform persistence.
bool HasPersistence() const { return myStructure != NULL && !myStructure->TransformPersistence().IsNull(); } bool HasPersistence() const
{
return !myTrsfPers.IsNull()
|| (myStructure != NULL && !myStructure->TransformPersistence().IsNull());
}
//! Update aspect. //! Update aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE; Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;

View File

@ -26,6 +26,8 @@ enum OpenGl_RenderFilter
OpenGl_RenderFilter_NonRaytraceableOnly = 0x004, //!< render only non-raytraceable elements OpenGl_RenderFilter_NonRaytraceableOnly = 0x004, //!< render only non-raytraceable elements
OpenGl_RenderFilter_FillModeOnly = 0x008, //!< render only filled elements OpenGl_RenderFilter_FillModeOnly = 0x008, //!< render only filled elements
OpenGl_RenderFilter_SkipTrsfPersistence = 0x010, //!< render only normal 3D objects without transformation persistence
}; };
#endif #endif

View File

@ -89,7 +89,7 @@ bool OpenGl_ShadowMap::UpdateCamera (const Graphic3d_CView& theView,
const gp_XYZ* theOrigin) const gp_XYZ* theOrigin)
{ {
const Bnd_Box aMinMaxBox = theOrigin == NULL ? theView.MinMaxValues (false) : Bnd_Box(); // applicative min max boundaries const Bnd_Box aMinMaxBox = theOrigin == NULL ? theView.MinMaxValues (false) : Bnd_Box(); // applicative min max boundaries
const Bnd_Box aGraphicBox = theOrigin == NULL ? theView.MinMaxValues (true) : Bnd_Box(); // real graphical boundaries (not accounting infinite flag) const Bnd_Box aGraphicBox = aMinMaxBox;
switch (myShadowLight->Type()) switch (myShadowLight->Type())
{ {

View File

@ -2162,7 +2162,9 @@ void OpenGl_View::renderShadowMap (const Handle(OpenGl_ShadowMap)& theShadowMap)
aCtx->core11fwd->glClearDepth (1.0); aCtx->core11fwd->glClearDepth (1.0);
aCtx->core11fwd->glClear (GL_DEPTH_BUFFER_BIT); aCtx->core11fwd->glClear (GL_DEPTH_BUFFER_BIT);
myWorkspace->SetRenderFilter (myWorkspace->RenderFilter() | OpenGl_RenderFilter_SkipTrsfPersistence);
renderScene (Graphic3d_Camera::Projection_Orthographic, aShadowBuffer.get(), NULL, false); renderScene (Graphic3d_Camera::Projection_Orthographic, aShadowBuffer.get(), NULL, false);
myWorkspace->SetRenderFilter (myWorkspace->RenderFilter() & ~(Standard_Integer )OpenGl_RenderFilter_SkipTrsfPersistence);
aCtx->SetColorMask (true); aCtx->SetColorMask (true);
myWorkspace->ResetAppliedAspect(); myWorkspace->ResetAppliedAspect();

View File

@ -423,6 +423,14 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement, bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement,
const OpenGl_Group* theGroup) const OpenGl_Group* theGroup)
{ {
if ((myRenderFilter & OpenGl_RenderFilter_SkipTrsfPersistence) != 0)
{
if (theGroup->HasPersistence())
{
return false;
}
}
// render only non-raytracable elements when RayTracing is enabled // render only non-raytracable elements when RayTracing is enabled
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0) if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
{ {

View File

@ -2378,15 +2378,10 @@ static int VDrawText (Draw_Interpretor& theDI,
{ {
continue; continue;
} }
else if (aParam == "-pos" else if ((aParam == "-pos"
|| aParam == "-position") || aParam == "-position")
&& anArgIt + 3 < theArgsNb)
{ {
if (anArgIt + 3 >= theArgsNb)
{
Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
aPos.SetX (Draw::Atof (theArgVec[++anArgIt])); aPos.SetX (Draw::Atof (theArgVec[++anArgIt]));
aPos.SetY (Draw::Atof (theArgVec[++anArgIt])); aPos.SetY (Draw::Atof (theArgVec[++anArgIt]));
aPos.SetZ (Draw::Atof (theArgVec[++anArgIt])); aPos.SetZ (Draw::Atof (theArgVec[++anArgIt]));
@ -2406,59 +2401,70 @@ static int VDrawText (Draw_Interpretor& theDI,
anArgIt += aNbParsed; anArgIt += aNbParsed;
aTextPrs->SetColor (aColor); aTextPrs->SetColor (aColor);
} }
else if (aParam == "-halign") else if ((aParam == "-halign"
|| aParam == "-valign"
|| aParam == "-align")
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) TCollection_AsciiString aType (theArgVec[++anArgIt]);
{
Message::SendFail() << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'";
return 1;
}
TCollection_AsciiString aType (theArgVec[anArgIt]);
aType.LowerCase(); aType.LowerCase();
if (aType == "left") if (aType == "left")
{ {
aTextPrs->SetHJustification (Graphic3d_HTA_LEFT); aTextPrs->SetHJustification (Graphic3d_HTA_LEFT);
if (aParam == "-valign")
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
return 1;
}
} }
else if (aType == "center") else if (aType == "center")
{ {
aTextPrs->SetHJustification (Graphic3d_HTA_CENTER); if (aParam == "-halign"
|| aParam == "-align")
{
aTextPrs->SetHJustification (Graphic3d_HTA_CENTER);
}
if (aParam == "-valign"
|| aParam == "-align")
{
aTextPrs->SetVJustification (Graphic3d_VTA_CENTER);
}
} }
else if (aType == "right") else if (aType == "right")
{ {
aTextPrs->SetHJustification (Graphic3d_HTA_RIGHT); aTextPrs->SetHJustification (Graphic3d_HTA_RIGHT);
if (aParam == "-valign")
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
return 1;
}
} }
else else if (aType == "top")
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
return 1;
}
}
else if (aParam == "-valign")
{
if (++anArgIt >= theArgsNb)
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
TCollection_AsciiString aType (theArgVec[anArgIt]);
aType.LowerCase();
if (aType == "top")
{ {
aTextPrs->SetVJustification (Graphic3d_VTA_TOP); aTextPrs->SetVJustification (Graphic3d_VTA_TOP);
} if (aParam == "-halign")
else if (aType == "center") {
{ Message::SendFail() << "Syntax error at '" << aParam << "'";
aTextPrs->SetVJustification (Graphic3d_VTA_CENTER); return 1;
}
} }
else if (aType == "bottom") else if (aType == "bottom")
{ {
aTextPrs->SetVJustification (Graphic3d_VTA_BOTTOM); aTextPrs->SetVJustification (Graphic3d_VTA_BOTTOM);
if (aParam == "-halign")
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
return 1;
}
} }
else if (aType == "topfirstline") else if (aType == "topfirstline")
{ {
aTextPrs->SetVJustification (Graphic3d_VTA_TOPFIRSTLINE); aTextPrs->SetVJustification (Graphic3d_VTA_TOPFIRSTLINE);
if (aParam == "-halign")
{
Message::SendFail() << "Syntax error at '" << aParam << "'";
return 1;
}
} }
else else
{ {
@ -2466,59 +2472,37 @@ static int VDrawText (Draw_Interpretor& theDI,
return 1; return 1;
} }
} }
else if (aParam == "-angle") else if (aParam == "-angle"
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) aTextPrs->SetAngle (Draw::Atof (theArgVec[++anArgIt]) * (M_PI / 180.0));
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
aTextPrs->SetAngle (Draw::Atof (theArgVec[anArgIt]) * (M_PI / 180.0));
} }
else if (aParam == "-zoom") else if (aParam == "-zoom"
|| aParam == "-nozoom"
|| aParam == "-zoomable"
|| aParam == "-nonzoomable")
{ {
if (++anArgIt >= theArgsNb) const bool isZoomable = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIt);
{ aTextPrs->SetZoomable (isZoomable);
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
aTextPrs->SetZoomable (Draw::Atoi (theArgVec[anArgIt]) == 1);
} }
else if (aParam == "-height") else if (aParam == "-height"
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) aTextPrs->SetHeight (Draw::Atof(theArgVec[++anArgIt]));
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
aTextPrs->SetHeight (Draw::Atof(theArgVec[anArgIt]));
} }
else if (aParam == "-wrapping") else if (aParam == "-wrapping"
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb)
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
if (aTextFormatter.IsNull()) if (aTextFormatter.IsNull())
{ {
aTextFormatter = new Font_TextFormatter(); aTextFormatter = new Font_TextFormatter();
} }
aTextFormatter->SetWrapping ((Standard_ShortReal)Draw::Atof(theArgVec[anArgIt])); aTextFormatter->SetWrapping ((Standard_ShortReal)Draw::Atof(theArgVec[++anArgIt]));
} }
else if (aParam == "-aspect") else if (aParam == "-aspect"
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) TCollection_AsciiString anOption (theArgVec[++anArgIt]);
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
TCollection_AsciiString anOption (theArgVec[anArgIt]);
anOption.LowerCase(); anOption.LowerCase();
Font_FontAspect aFontAspect = Font_FA_Undefined; Font_FontAspect aFontAspect = Font_FA_Undefined;
if (!parseFontStyle (anOption, aFontAspect)) if (!parseFontStyle (anOption, aFontAspect))
@ -2528,71 +2512,49 @@ static int VDrawText (Draw_Interpretor& theDI,
} }
aTextPrs->SetFontAspect (aFontAspect); aTextPrs->SetFontAspect (aFontAspect);
} }
else if (aParam == "-font") else if (aParam == "-font"
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) aTextPrs->SetFont (theArgVec[++anArgIt]);
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
aTextPrs->SetFont (theArgVec[anArgIt]);
} }
else if (aParam == "-plane") else if (aParam == "-plane"
&& anArgIt + 6 < theArgsNb)
{ {
if (anArgIt + 6 >= theArgsNb) aNormal.SetCoord (Draw::Atof (theArgVec[anArgIt + 1]),
{ Draw::Atof (theArgVec[anArgIt + 2]),
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'"; Draw::Atof (theArgVec[anArgIt + 3]));
return 1; aDirection.SetCoord (Draw::Atof (theArgVec[anArgIt + 4]),
} Draw::Atof (theArgVec[anArgIt + 5]),
Draw::Atof (theArgVec[anArgIt + 6]));
Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
aNormal.SetCoord (aX, aY, aZ);
aX = Draw::Atof (theArgVec[++anArgIt]);
aY = Draw::Atof (theArgVec[++anArgIt]);
aZ = Draw::Atof (theArgVec[++anArgIt]);
aDirection.SetCoord (aX, aY, aZ);
aHasPlane = Standard_True; aHasPlane = Standard_True;
anArgIt += 6;
} }
else if (aParam == "-flipping") else if (aParam == "-flipping"
|| aParam == "-noflipping"
|| aParam == "-flip"
|| aParam == "-noflip")
{ {
aTextPrs->SetFlipping (Standard_True); const bool toFlip = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIt);
aTextPrs->SetFlipping (toFlip);
} }
else if (aParam == "-ownanchor") else if (aParam == "-ownanchor"
|| aParam == "-noownanchor")
{ {
if (++anArgIt >= theArgsNb) const bool isOwnAnchor = Draw::ParseOnOffNoIterator (theArgsNb, theArgVec, anArgIt);
{ aTextPrs->SetOwnAnchorPoint (isOwnAnchor);
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
return 1;
}
aTextPrs->SetOwnAnchorPoint (Draw::Atoi (theArgVec[anArgIt]) == 1);
} }
else if (aParam == "-disptype" else if ((aParam == "-disptype"
|| aParam == "-displaytype") || aParam == "-displaytype")
&& anArgIt + 1 < theArgsNb)
{ {
if (++anArgIt >= theArgsNb) TCollection_AsciiString aType (theArgVec[++anArgIt]);
{
Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
return 1;
}
TCollection_AsciiString aType (theArgVec[anArgIt]);
aType.LowerCase(); aType.LowerCase();
if (aType == "subtitle") if (aType == "subtitle") { aDisplayType = Aspect_TODT_SUBTITLE; }
aDisplayType = Aspect_TODT_SUBTITLE; else if (aType == "decal") { aDisplayType = Aspect_TODT_DEKALE; }
else if (aType == "decal") else if (aType == "blend") { aDisplayType = Aspect_TODT_BLEND; }
aDisplayType = Aspect_TODT_DEKALE; else if (aType == "dimension") { aDisplayType = Aspect_TODT_DIMENSION; }
else if (aType == "blend") else if (aType == "normal") { aDisplayType = Aspect_TODT_NORMAL; }
aDisplayType = Aspect_TODT_BLEND; else if (aType == "shadow") { aDisplayType = Aspect_TODT_SHADOW; }
else if (aType == "dimension")
aDisplayType = Aspect_TODT_DIMENSION;
else if (aType == "normal")
aDisplayType = Aspect_TODT_NORMAL;
else if (aType == "shadow")
aDisplayType = Aspect_TODT_SHADOW;
else else
{ {
Message::SendFail() << "Syntax error: wrong display type '" << aType << "'"; Message::SendFail() << "Syntax error: wrong display type '" << aType << "'";

View File

@ -0,0 +1,21 @@
puts "========"
puts "0032758: Visualization, TKOpenGl - disable shadow-map from transform-persistence objects"
puts "========"
pload MODELING VISUALIZATION
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }
vinit View1
vcamera -persp
vviewparams -scale 1.1 -proj 0.57 -0.57 0.57 -up -0.4 0.4 0.8
vrenderparams -shadows
vlight headlight -castShadows 1 -head 0 -dir -1 -1 -1
vtrihedron trih
box g -250 -250 0 500 500 0 -preview
vdisplay -dispMode 1 g
vaspects g -color GRAY60
box b 20 10 50
vdisplay -dispMode 1 b -trsfPers ZOOM -trsfPersPos 0 0 0
vdump $::imagedir/${::casename}.png