Skip to content

Commit 95261ea

Browse files
Configurable anti-aliasing for MinimalScene (#723) (#727)
(cherry picked from commit a71c5e6) Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com> Co-authored-by: Maksim Derbasov <ntfs.hard@gmail.com>
1 parent f8e007e commit 95261ea

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/plugins/minimal_scene/MinimalScene.cc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi)
775775
this->dataPtr->camera->SetImageHeight(this->textureSize.height());
776776
this->dataPtr->camera->SetImageFormat(this->dataPtr->camera->ImageFormat(),
777777
true);
778-
this->dataPtr->camera->SetAntiAliasing(8);
778+
this->dataPtr->camera->SetAntiAliasing(this->cameraAntiAliasing);
779779
this->dataPtr->camera->SetHFOV(this->cameraHFOV);
780780
// setting the size and calling PreRender should cause the render texture to
781781
// be rebuilt
@@ -1346,6 +1346,12 @@ void RenderWindowItem::SetCameraFarClip(double _far)
13461346
this->dataPtr->renderThread->gzRenderer.cameraFarClip = _far;
13471347
}
13481348

1349+
/////////////////////////////////////////////////
1350+
void RenderWindowItem::SetAntiAliasing(unsigned int _aa)
1351+
{
1352+
this->dataPtr->renderThread->gzRenderer.cameraAntiAliasing = _aa;
1353+
}
1354+
13491355
/////////////////////////////////////////////////
13501356
void RenderWindowItem::SetSkyEnabled(const bool &_sky)
13511357
{
@@ -1486,6 +1492,24 @@ void MinimalScene::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
14861492
}
14871493
}
14881494

1495+
elem = _pluginElem->FirstChildElement("anti_aliasing");
1496+
if (nullptr != elem && nullptr != elem->GetText())
1497+
{
1498+
unsigned int aa{};
1499+
std::stringstream aaStr(std::string(elem->GetText()));
1500+
aaStr >> aa;
1501+
if (aaStr.fail())
1502+
{
1503+
gzerr << "Unable to set anti-aliasing <anti_aliasing> to '"
1504+
<< elem->GetText()
1505+
<< "' using default value" << std::endl;
1506+
}
1507+
else
1508+
{
1509+
renderWindow->SetAntiAliasing(aa);
1510+
}
1511+
}
1512+
14891513
elem = _pluginElem->FirstChildElement("sky");
14901514
if (nullptr != elem && nullptr != elem->GetText())
14911515
{

src/plugins/minimal_scene/MinimalScene.hh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace gz::gui::plugins
6262
/// * \<sky\> : If present, sky is enabled.
6363
/// * \<horizontal_fov\> : Horizontal FOV of the user camera in degrees,
6464
/// defaults to 90
65+
/// * \<anti_aliasing> : Optional level of anti-aliasing, default is 8
6566
/// * \<graphics_api\> : Optional graphics API name. Valid choices are:
6667
/// 'opengl', 'metal'. Defaults to 'opengl'.
6768
/// * \<view_controller> : Set the view controller (InteractiveViewControl
@@ -220,6 +221,9 @@ namespace gz::gui::plugins
220221
/// \brief Default camera far clipping plane distance
221222
public: double cameraFarClip = 1000.0;
222223

224+
/// \brief Default camera anit-aliasing level
225+
public: unsigned int cameraAntiAliasing = 8;
226+
223227
/// \brief Scene background color
224228
public: math::Color backgroundColor = math::Color::Black;
225229

@@ -353,6 +357,10 @@ namespace gz::gui::plugins
353357
/// \param[in] _far Far clipping plane distance
354358
public: void SetCameraFarClip(double _far);
355359

360+
/// \brief Set the render window camera's anti-aliasing level
361+
/// \param[in] _aa Anti-aliasing level
362+
public: void SetAntiAliasing(unsigned int _aa);
363+
356364
/// \brief Called when the mouse hovers to a new position.
357365
/// \param[in] _hoverPos 2D coordinates of the hovered mouse position on
358366
/// the render window.

0 commit comments

Comments
 (0)