Skip to content

Commit 48cf8a1

Browse files
committed
abi compatibility changes, add test
Signed-off-by: Ian Chen <[email protected]>
1 parent 8eddd04 commit 48cf8a1

File tree

13 files changed

+219
-67
lines changed

13 files changed

+219
-67
lines changed

examples/frustum_visual/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
22
project(gz-rendering-frustum-visual)
3-
find_package(gz-rendering10 REQUIRED)
3+
find_package(gz-rendering9 REQUIRED)
44

55
find_package(GLUT REQUIRED)
66
include_directories(SYSTEM ${GLUT_INCLUDE_DIRS})

examples/frustum_visual/Main.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ NodePtr createMainNode(ScenePtr _scene)
9292
root->AddChild(box);
9393

9494
// create frustum visual and attach to main node
95-
FrustumVisualPtr frustumVisual = _scene->CreateFrustumVisual();
95+
// \todo(iche033) Commented out for ABI compatibility. Uncomment in
96+
// gz-rendering10.
97+
// \todo(iche033) uncomment and use official API in gz-rendering10
98+
// FrustumVisualPtr frustumVisual = scene->CreateFrustumVisual();
99+
FrustumVisualPtr frustumVisual = std::dynamic_pointer_cast<FrustumVisual>(
100+
_scene->Extension()->CreateExt("frustum_visual"));
96101
frustumVisual->SetNearClipPlane(1);
97102
frustumVisual->SetFarClipPlane(5);
98103
frustumVisual->SetHFOV(0.7);

include/gz/rendering/FrustumVisual.hh

-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
#define GZ_RENDERING_FRUSTUMVISUAL_HH_
1919

2020
#include <gz/math/Angle.hh>
21-
#include <gz/math/AxisAlignedBox.hh>
2221
#include <gz/math/Plane.hh>
2322
#include <gz/math/Pose3.hh>
2423
#include <gz/utils/ImplPtr.hh>
2524
#include "gz/rendering/config.hh"
2625
#include "gz/rendering/Visual.hh"
2726
#include "gz/rendering/Object.hh"
2827
#include "gz/rendering/RenderTypes.hh"
29-
#include "gz/rendering/Marker.hh"
3028

3129
namespace gz
3230
{

include/gz/rendering/Scene.hh

+17-7
Original file line numberDiff line numberDiff line change
@@ -1108,34 +1108,44 @@ namespace gz
11081108
public: virtual LidarVisualPtr CreateLidarVisual(
11091109
unsigned int _id, const std::string &_name) = 0;
11101110

1111+
/// \cond PRIVATE
11111112
/// \brief Create new frusum visual. A unique ID and name will
11121113
/// automatically be assigned to the frustum visual.
11131114
/// \return The created frustum visual
1114-
public: virtual FrustumVisualPtr CreateFrustumVisual() = 0;
1115+
/// \todo(iche033) Commented out for ABI compatibility. Uncomment in
1116+
/// gz-rendering10
1117+
/// public: virtual FrustumVisualPtr CreateFrustumVisual() = 0;
11151118

11161119
/// \brief Create new frustum visual with the given ID. A unique name
11171120
/// will automatically be assigned to the frustum visual. If the given
11181121
/// ID is already in use, NULL will be returned.
11191122
/// \param[in] _id ID of the new frustum visual
11201123
/// \return The created frustum visual
1121-
public: virtual FrustumVisualPtr CreateFrustumVisual(
1122-
unsigned int _id) = 0;
1124+
/// \todo(iche033) Commented out for ABI compatibility. Uncomment in
1125+
/// gz-rendering10
1126+
/// public: virtual FrustumVisualPtr CreateFrustumVisual(
1127+
/// unsigned int _id) = 0;
11231128

11241129
/// \brief Create new frustum visual with the given name. A unique ID
11251130
/// will automatically be assigned to the frustum visual. If the given
11261131
/// name is already in use, NULL will be returned.
11271132
/// \param[in] _name Name of the new frustum visual
11281133
/// \return The created frustum visual
1129-
public: virtual FrustumVisualPtr CreateFrustumVisual(
1130-
const std::string &_name) = 0;
1134+
/// \todo(iche033) Commented out for ABI compatibility. Uncomment in
1135+
/// gz-rendering10
1136+
/// public: virtual FrustumVisualPtr CreateFrustumVisual(
1137+
/// const std::string &_name) = 0;
11311138

11321139
/// \brief Create new frustum visual with the given name. If either
11331140
/// the given ID or name is already in use, NULL will be returned.
11341141
/// \param[in] _id ID of the frustum visual.
11351142
/// \param[in] _name Name of the new frustum visual.
11361143
/// \return The created frustum visual
1137-
public: virtual FrustumVisualPtr CreateFrustumVisual(
1138-
unsigned int _id, const std::string &_name) = 0;
1144+
/// \todo(iche033) Commented out for ABI compatibility. Uncomment in
1145+
/// gz-rendering10
1146+
/// public: virtual FrustumVisualPtr CreateFrustumVisual(
1147+
/// unsigned int _id, const std::string &_name) = 0;
1148+
/// \endcond
11391149

11401150
/// \brief Create new heightmap geomerty. The rendering::Heightmap will be
11411151
/// created from the given HeightmapDescriptor.

include/gz/rendering/base/BaseScene.hh

+24-9
Original file line numberDiff line numberDiff line change
@@ -538,19 +538,23 @@ namespace gz
538538
const std::string &_name) override;
539539

540540
// Documentation inherited.
541-
public: virtual FrustumVisualPtr CreateFrustumVisual() override;
541+
// \todo(iche033) commented out for ABI compatibility
542+
// public: virtual FrustumVisualPtr CreateFrustumVisual() override;
542543

543544
// Documentation inherited.
544-
public: virtual FrustumVisualPtr CreateFrustumVisual(
545-
unsigned int _id) override;
545+
// \todo(iche033) commented out for ABI compatibility
546+
// public: virtual FrustumVisualPtr CreateFrustumVisual(
547+
// unsigned int _id) override;
546548

547549
// Documentation inherited.
548-
public: virtual FrustumVisualPtr CreateFrustumVisual(
549-
const std::string &_name) override;
550+
// \todo(iche033) commented out for ABI compatibility
551+
// public: virtual FrustumVisualPtr CreateFrustumVisual(
552+
// const std::string &_name) override;
550553

551554
// Documentation inherited.
552-
public: virtual FrustumVisualPtr CreateFrustumVisual(unsigned int _id,
553-
const std::string &_name) override;
555+
// \todo(iche033) commented out for ABI compatibility
556+
// public: virtual FrustumVisualPtr CreateFrustumVisual(unsigned int _id,
557+
// const std::string &_name) override;
554558

555559
// Documentation inherited.
556560
public: virtual HeightmapPtr CreateHeightmap(
@@ -843,12 +847,23 @@ namespace gz
843847
protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id,
844848
const std::string &_name) = 0;
845849

850+
/// \cond PRIVATE
846851
/// \brief Implementation for creating a frustum visual
847852
/// \param[in] _id unique object id.
848853
/// \param[in] _name unique object name.
849854
/// \return Pointer to a frustum visual
850-
protected: virtual FrustumVisualPtr CreateFrustumVisualImpl(
851-
unsigned int _id, const std::string &_name) = 0;
855+
/// \todo(iche033) Commented out for ABI compatibility. Uncomment in
856+
/// gz-rendering10
857+
/// protected: virtual FrustumVisualPtr CreateFrustumVisualImpl(
858+
/// unsigned int _id, const std::string &_name)
859+
/// {
860+
/// (void)_id;
861+
/// (void)_name;
862+
/// gzerr << "FrustumVisual not supported by: "
863+
/// << this->Engine()->Name() << std::endl;
864+
/// return FrustumVisualPtr();
865+
/// }
866+
/// \endcond
852867

853868
/// \brief Implementation for creating a heightmap geometry
854869
/// \param[in] _id Unique object id.

ogre/include/gz/rendering/ogre/OgreScene.hh

+3-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ namespace gz
181181
const std::string &_name) override;
182182

183183
// Documentation inherited
184-
protected: virtual FrustumVisualPtr CreateFrustumVisualImpl(
185-
unsigned int _id, const std::string &_name) override;
184+
// \todo(iche033) make this virtual in gz-rendering10
185+
protected: FrustumVisualPtr CreateFrustumVisualImpl(
186+
unsigned int _id, const std::string &_name);
186187

187188
// Documentation inherited
188189
protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,

ogre/src/OgreScene.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -781,22 +781,22 @@ OgreSceneExt::OgreSceneExt(Scene *_scene)
781781
ObjectPtr OgreSceneExt::CreateExt(const std::string &_type,
782782
const std::string &_name)
783783
{
784-
if (_type == "projector")
784+
if (_type == "frustum_visual")
785785
{
786786
OgreScene *ogreScene = dynamic_cast<OgreScene *>(this->scene);
787787
unsigned int objId = ogreScene->CreateObjectId();
788788
std::string objName = _name;
789789
if (objName.empty())
790790
{
791791
std::stringstream ss;
792-
ss << ogreScene->Name() << "::" << "Projector";
792+
ss << ogreScene->Name() << "::" << "FrustumVisual";
793793
ss << "(" << std::to_string(objId) << ")";
794794
objName = ss.str();
795795
}
796-
ProjectorPtr projector = ogreScene->CreateProjectorImpl(
796+
FrustumVisualPtr frustumVisual = ogreScene->CreateFrustumVisualImpl(
797797
objId, objName);
798-
bool result = ogreScene->Visuals()->Add(projector);
799-
return (result) ? projector : nullptr;
798+
bool result = ogreScene->Visuals()->Add(frustumVisual);
799+
return (result) ? frustumVisual : nullptr;
800800
}
801801

802802
return ObjectPtr();

ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh

+3-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ namespace gz
344344
const std::string &_name) override;
345345

346346
// Documentation inherited
347-
protected: virtual FrustumVisualPtr CreateFrustumVisualImpl(
348-
unsigned int _id, const std::string &_name) override;
347+
// \todo(iche033) make this virtual in gz-rendering10
348+
protected: FrustumVisualPtr CreateFrustumVisualImpl(
349+
unsigned int _id, const std::string &_name);
349350

350351
// Documentation inherited
351352
protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,

ogre2/src/Ogre2FrustumVisual.cc

-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class gz::rendering::Ogre2FrustumVisualPrivate
5858
/// \brief Frustum Ray DynamicLines Object to display
5959
public: std::vector<std::shared_ptr<Ogre2DynamicRenderable>> rayLines;
6060

61-
/// \brief Frustum visual type
62-
// public: FrustumVisualPlane frustumVisPlane =
63-
// FrustumVisualPlane::FRUSTUM_PLANE_TOP;
64-
6561
/// \brief The visibility of the visual
6662
public: bool visible = true;
6763

ogre2/src/Ogre2Scene.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1694,22 +1694,22 @@ Ogre2SceneExt::Ogre2SceneExt(Scene *_scene)
16941694
ObjectPtr Ogre2SceneExt::CreateExt(const std::string &_type,
16951695
const std::string &_name)
16961696
{
1697-
if (_type == "projector")
1697+
if (_type == "frustum_visual")
16981698
{
16991699
Ogre2Scene *ogreScene = dynamic_cast<Ogre2Scene *>(this->scene);
17001700
unsigned int objId = ogreScene->CreateObjectId();
17011701
std::string objName = _name;
17021702
if (objName.empty())
17031703
{
17041704
std::stringstream ss;
1705-
ss << ogreScene->Name() << "::" << "Projector";
1705+
ss << ogreScene->Name() << "::" << "FrustumVisual";
17061706
ss << "(" << std::to_string(objId) << ")";
17071707
objName = ss.str();
17081708
}
1709-
ProjectorPtr projector = ogreScene->CreateProjectorImpl(
1709+
FrustumVisualPtr frustumVisual = ogreScene->CreateFrustumVisualImpl(
17101710
objId, objName);
1711-
bool result = ogreScene->Visuals()->Add(projector);
1712-
return (result) ? projector : nullptr;
1711+
bool result = ogreScene->Visuals()->Add(frustumVisual);
1712+
return (result) ? frustumVisual : nullptr;
17131713
}
17141714

17151715
return ObjectPtr();

src/base/BaseScene.cc

+31-29
Original file line numberDiff line numberDiff line change
@@ -1263,35 +1263,37 @@ LidarVisualPtr BaseScene::CreateLidarVisual(unsigned int _id,
12631263
return (result) ? lidar : nullptr;
12641264
}
12651265

1266-
//////////////////////////////////////////////////
1267-
FrustumVisualPtr BaseScene::CreateFrustumVisual()
1268-
{
1269-
unsigned int objId = this->CreateObjectId();
1270-
return this->CreateFrustumVisual(objId);
1271-
}
1272-
1273-
//////////////////////////////////////////////////
1274-
FrustumVisualPtr BaseScene::CreateFrustumVisual(unsigned int _id)
1275-
{
1276-
const std::string objName = this->CreateObjectName(_id, "FrustumVisual");
1277-
return this->CreateFrustumVisual(_id, objName);
1278-
}
1279-
1280-
//////////////////////////////////////////////////
1281-
FrustumVisualPtr BaseScene::CreateFrustumVisual(const std::string &_name)
1282-
{
1283-
unsigned int objId = this->CreateObjectId();
1284-
return this->CreateFrustumVisual(objId, _name);
1285-
}
1286-
1287-
//////////////////////////////////////////////////
1288-
FrustumVisualPtr BaseScene::CreateFrustumVisual(unsigned int _id,
1289-
const std::string &_name)
1290-
{
1291-
FrustumVisualPtr frustum = this->CreateFrustumVisualImpl(_id, _name);
1292-
bool result = this->RegisterVisual(frustum);
1293-
return (result) ? frustum : nullptr;
1294-
}
1266+
// \todo(iche033) Commented out for ABI compatibility. Uncomment in
1267+
// gz-rendering10
1268+
// //////////////////////////////////////////////////
1269+
// FrustumVisualPtr BaseScene::CreateFrustumVisual()
1270+
// {
1271+
// unsigned int objId = this->CreateObjectId();
1272+
// return this->CreateFrustumVisual(objId);
1273+
// }
1274+
//
1275+
// //////////////////////////////////////////////////
1276+
// FrustumVisualPtr BaseScene::CreateFrustumVisual(unsigned int _id)
1277+
// {
1278+
// const std::string objName = this->CreateObjectName(_id, "FrustumVisual");
1279+
// return this->CreateFrustumVisual(_id, objName);
1280+
// }
1281+
//
1282+
// //////////////////////////////////////////////////
1283+
// FrustumVisualPtr BaseScene::CreateFrustumVisual(const std::string &_name)
1284+
// {
1285+
// unsigned int objId = this->CreateObjectId();
1286+
// return this->CreateFrustumVisual(objId, _name);
1287+
// }
1288+
//
1289+
// //////////////////////////////////////////////////
1290+
// FrustumVisualPtr BaseScene::CreateFrustumVisual(unsigned int _id,
1291+
// const std::string &_name)
1292+
// {
1293+
// FrustumVisualPtr frustum = this->CreateFrustumVisualImpl(_id, _name);
1294+
// bool result = this->RegisterVisual(frustum);
1295+
// return (result) ? frustum : nullptr;
1296+
// }
12951297

12961298
//////////////////////////////////////////////////
12971299
WireBoxPtr BaseScene::CreateWireBox()

test/common_test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(tests
88
Camera_TEST
99
Capsule_TEST
1010
COMVisual_TEST
11+
FrustumVisual_TEST
1112
GaussianNoisePass_TEST
1213
GizmoVisual_TEST
1314
GlobalIllumination_TEST

0 commit comments

Comments
 (0)