diff --git a/examples/text_geom/CMakeLists.txt b/examples/text_geom/CMakeLists.txt index aa4523b09..5ffe32f22 100644 --- a/examples/text_geom/CMakeLists.txt +++ b/examples/text_geom/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) project(ignition-rendering-text-geom) find_package(ignition-rendering3) +find_package(ignition-common3) find_package(GLUT REQUIRED) include_directories(SYSTEM ${GLUT_INCLUDE_DIRS}) @@ -26,5 +27,5 @@ target_link_libraries(text_geom ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${IGNITION-RENDERING_LIBRARIES} + ${IGNITION-COMMON_LIBRARIES} ) - diff --git a/ogre2/src/Ogre2Camera.cc b/ogre2/src/Ogre2Camera.cc index fb5ba3777..2d5f21d08 100644 --- a/ogre2/src/Ogre2Camera.cc +++ b/ogre2/src/Ogre2Camera.cc @@ -233,8 +233,17 @@ VisualPtr Ogre2Camera::VisualAt(const math::Vector2i &_mousePos) ////////////////////////////////////////////////// RenderWindowPtr Ogre2Camera::CreateRenderWindow() { - // TODO(anyone) - return RenderWindowPtr(); + RenderWindowPtr base = this->scene->CreateRenderWindow(); + Ogre2RenderWindowPtr renderWindow = + std::dynamic_pointer_cast(base); + renderWindow->SetWidth(this->ImageWidth()); + renderWindow->SetHeight(this->ImageHeight()); + renderWindow->SetDevicePixelRatio(1); + renderWindow->SetCamera(this->ogreCamera); + renderWindow->SetBackgroundColor(this->scene->BackgroundColor()); + + this->renderTexture = renderWindow; + return base; } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Grid.cc b/ogre2/src/Ogre2Grid.cc index 08493253a..a2f2c49ac 100644 --- a/ogre2/src/Ogre2Grid.cc +++ b/ogre2/src/Ogre2Grid.cc @@ -43,11 +43,14 @@ Ogre2Grid::Ogre2Grid() ////////////////////////////////////////////////// Ogre2Grid::~Ogre2Grid() { + BaseGrid::Destroy(); } ////////////////////////////////////////////////// void Ogre2Grid::PreRender() { + BaseGrid::PreRender(); + if (this->gridDirty) { this->Create(); diff --git a/ogre2/src/Ogre2Marker.cc b/ogre2/src/Ogre2Marker.cc index 0f95fa7db..ae0579d62 100644 --- a/ogre2/src/Ogre2Marker.cc +++ b/ogre2/src/Ogre2Marker.cc @@ -58,12 +58,15 @@ Ogre2Marker::~Ogre2Marker() ////////////////////////////////////////////////// void Ogre2Marker::PreRender() { + BaseMarker::PreRender(); this->dataPtr->dynamicRenderable->Update(); } ////////////////////////////////////////////////// void Ogre2Marker::Destroy() { + BaseMarker::Destroy(); + if (!this->Scene()) return; @@ -192,6 +195,7 @@ MaterialPtr Ogre2Marker::Material() const void Ogre2Marker::SetPoint(unsigned int _index, const math::Vector3d &_value) { + BaseMarker::SetPoint(_index, _value); this->dataPtr->dynamicRenderable->SetPoint(_index, _value); } @@ -199,12 +203,14 @@ void Ogre2Marker::SetPoint(unsigned int _index, void Ogre2Marker::AddPoint(const math::Vector3d &_pt, const math::Color &_color) { + BaseMarker::AddPoint(_pt, _color); this->dataPtr->dynamicRenderable->AddPoint(_pt, _color); } ////////////////////////////////////////////////// void Ogre2Marker::ClearPoints() { + BaseMarker::ClearPoints(); this->dataPtr->dynamicRenderable->Clear(); } diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 970df9f74..049f7e07e 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -92,6 +92,7 @@ Ogre2RenderEngine::Ogre2RenderEngine() : ////////////////////////////////////////////////// Ogre2RenderEngine::~Ogre2RenderEngine() { + this->Fini(); } ////////////////////////////////////////////////// @@ -141,7 +142,7 @@ void Ogre2RenderEngine::Destroy() ////////////////////////////////////////////////// bool Ogre2RenderEngine::IsEnabled() const { - return this->initialized; + return BaseRenderEngine::IsEnabled(); } ////////////////////////////////////////////////// diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index 379b5e22f..e87b7e90a 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -406,11 +406,12 @@ RenderTexturePtr Ogre2Scene::CreateRenderTextureImpl(unsigned int _id, } ////////////////////////////////////////////////// -RenderWindowPtr Ogre2Scene::CreateRenderWindowImpl(unsigned int /*_id*/, - const std::string &/*_name*/) +RenderWindowPtr Ogre2Scene::CreateRenderWindowImpl(unsigned int _id, + const std::string &_name) { - // TODO(anyone) - return RenderWindowPtr(); + Ogre2RenderWindowPtr renderWindow(new Ogre2RenderWindow); + bool result = this->InitObject(renderWindow, _id, _name); + return (result) ? renderWindow : nullptr; } ////////////////////////////////////////////////// diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index 358b55438..a5a42091e 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -115,6 +115,8 @@ void MarkerTest::Marker(const std::string &_renderEngine) // exercise point api EXPECT_NO_THROW(marker->AddPoint(math::Vector3d(0, 1, 2), math::Color::White)); + EXPECT_NO_THROW(marker->AddPoint(-2, -1, 0, math::Color::White)); + EXPECT_NO_THROW(marker->SetPoint(0, math::Vector3d(3, 1, 2))); EXPECT_NO_THROW(marker->ClearPoints()); diff --git a/src/MeshDescriptor_TEST.cc b/src/MeshDescriptor_TEST.cc index 7a41e8aba..ed3d5c285 100644 --- a/src/MeshDescriptor_TEST.cc +++ b/src/MeshDescriptor_TEST.cc @@ -53,6 +53,12 @@ void MeshDescriptorTest::Descriptor(const std::string &_renderEngine) ScenePtr scene = engine->CreateScene("scene"); ASSERT_TRUE(scene != nullptr); + MeshDescriptor failDescriptor; + failDescriptor.Load(); + + MeshDescriptor failDescriptor2("non_existing_mesh"); + failDescriptor2.Load(); + // empty constructor MeshDescriptor emptyDescriptor; EXPECT_TRUE(emptyDescriptor.meshName.empty()); diff --git a/src/Mesh_TEST.cc b/src/Mesh_TEST.cc index c2cf2f431..e8164cb6b 100644 --- a/src/Mesh_TEST.cc +++ b/src/Mesh_TEST.cc @@ -79,6 +79,11 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine) EXPECT_FALSE(mesh->HasSkeleton()); + std::map skinFrames; + mesh->SetSkeletonLocalTransforms(skinFrames); + auto skeletonLocalTransforms = mesh->SkeletonLocalTransforms(); + EXPECT_EQ(0u, skeletonLocalTransforms.size()); + // test submesh API MaterialPtr mat = submesh->Material(); ASSERT_TRUE(mat != nullptr); @@ -90,6 +95,8 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine) EXPECT_EQ(matClone, submesh->Material()); EXPECT_NE(mat, submesh->Material()); + submesh->SetMaterial(MaterialPtr(), false); + submesh->SetMaterial("Default/White", false); EXPECT_EQ("Default/White", submesh->Material()->Name()); @@ -181,6 +188,9 @@ void MeshTest::MeshSkeleton(const std::string &_renderEngine) mesh->SetSkeletonLocalTransforms(skinFrames); } + auto skeletonLocalTransforms = mesh->SkeletonLocalTransforms(); + EXPECT_EQ(31u, skeletonLocalTransforms.size()); + // Clean up engine->DestroyScene(scene); unloadEngine(engine->Name()); diff --git a/src/MoveToHelper_TEST.cc b/src/MoveToHelper_TEST.cc index 75cb8d28a..c386bbaca 100644 --- a/src/MoveToHelper_TEST.cc +++ b/src/MoveToHelper_TEST.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -111,6 +112,11 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine) NodePtr target = scene->NodeByName("center"); + moveToHelper.SetInitCameraPose(math::Pose3d()); + + // This call should return, there is no camera + moveToHelper.AddTime(0.1); + moveToHelper.MoveTo(camera, target, 0.5, std::bind(&MoveToHelperTest::OnMoveToComplete, this)); EXPECT_FALSE(moveToHelper.Idle()); @@ -136,6 +142,22 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine) EXPECT_EQ(math::Vector3d(0.0, -1, 0.0), camera->LocalPosition()); EXPECT_EQ(math::Quaterniond(0.0, -0.785398, 1.5708), camera->LocalRotation()); + moveToHelper.LookDirection(camera, + math::Vector3d::Zero, lookAt, + 0.5, std::bind(&MoveToHelperTest::OnMoveToComplete, this)); + EXPECT_FALSE(moveToHelper.Idle()); + checkIsCompleted(0.5); + EXPECT_TRUE(moveToHelper.Idle()); + EXPECT_EQ(math::Vector3d(0.0, 0, 0.0), camera->LocalPosition()); + EXPECT_EQ(math::Quaterniond(0.0, 0, 0), camera->LocalRotation()); + + moveToHelper.MoveTo(camera, math::Pose3d(INFINITY, 0.0, 0.0, 0, 0, 0), 0.5, + std::bind(&MoveToHelperTest::OnMoveToComplete, this)); + EXPECT_FALSE(moveToHelper.Idle()); + checkIsCompleted(0.5); + EXPECT_EQ(math::Vector3d(0.0, 0, 0.0), camera->LocalPosition()); + EXPECT_TRUE(moveToHelper.Idle()); + engine->DestroyScene(scene); unloadEngine(engine->Name()); } diff --git a/src/OrbitViewController.cc b/src/OrbitViewController.cc index 794b9586a..6a63b1732 100644 --- a/src/OrbitViewController.cc +++ b/src/OrbitViewController.cc @@ -28,14 +28,6 @@ class ignition::rendering::OrbitViewControllerPrivate /// \brief Target point for camera movements public: math::Vector3d target; - - /// \brief Keep yaw within limits - /// \return Normalized yaw - public: double NormalizeYaw(double _yaw); - - /// \brief Keep pitch within limits - /// \return Normalized pitch - public: double NormalizePitch(double _pitch); }; using namespace ignition; @@ -178,26 +170,3 @@ void OrbitViewController::Orbit(const math::Vector2d &_value) this->dataPtr->camera->SetWorldPosition( this->dataPtr->camera->WorldPosition() + this->dataPtr->target); } - -////////////////////////////////////////////////// -double OrbitViewControllerPrivate::NormalizeYaw(double _yaw) -{ - _yaw = fmod(_yaw, IGN_PI*2); - if (_yaw < 0.0f) - { - _yaw = IGN_PI * 2 + _yaw; - } - - return _yaw; -} - -////////////////////////////////////////////////// -double OrbitViewControllerPrivate::NormalizePitch(double _pitch) -{ - if (_pitch < PITCH_LIMIT_LOW) - _pitch = PITCH_LIMIT_LOW; - else if (_pitch > PITCH_LIMIT_HIGH) - _pitch = PITCH_LIMIT_HIGH; - - return _pitch; -} diff --git a/src/OrbitViewController_TEST.cc b/src/OrbitViewController_TEST.cc index 1d06777de..2e611bd11 100644 --- a/src/OrbitViewController_TEST.cc +++ b/src/OrbitViewController_TEST.cc @@ -35,6 +35,10 @@ class OrbitViewControllerTest : public testing::Test, /// \brief Test basic api public: void OrbitViewControl(const std::string &_renderEngine); + /// \brief Test basic api + public: void OrbitViewControlCameraConstructor( + const std::string &_renderEngine); + /// \brief test zoom, pan, orbit public: void Control(const std::string &_renderEngine); }; @@ -83,6 +87,43 @@ void OrbitViewControllerTest::OrbitViewControl(const std::string &_renderEngine) unloadEngine(engine->Name()); } +///////////////////////////////////////////////// +void OrbitViewControllerTest::OrbitViewControlCameraConstructor( + const std::string &_renderEngine) +{ + RenderEngine *engine = rendering::engine(_renderEngine); + if (!engine) + { + igndbg << "Engine '" << _renderEngine + << "' is not supported" << std::endl; + return; + } + ScenePtr scene = engine->CreateScene("scene"); + EXPECT_NE(scene, nullptr); + + CameraPtr camera = scene->CreateCamera("camera"); + EXPECT_NE(camera, nullptr); + + OrbitViewController viewControl(camera); + + // verify intial values + EXPECT_EQ(camera, viewControl.Camera()); + EXPECT_EQ(math::Vector3d::Zero, viewControl.Target()); + + // test setting target + math::Vector3d target(1, 0, 0); + viewControl.SetTarget(target); + EXPECT_EQ(target, viewControl.Target()); + + target.Set(-0.3, -5, 1); + viewControl.SetTarget(target); + EXPECT_EQ(target, viewControl.Target()); + + // Clean up + engine->DestroyScene(scene); + unloadEngine(engine->Name()); +} + ///////////////////////////////////////////////// void OrbitViewControllerTest::Control(const std::string &_renderEngine) { @@ -107,6 +148,10 @@ void OrbitViewControllerTest::Control(const std::string &_renderEngine) OrbitViewController viewControl; + viewControl.Zoom(0); + viewControl.Pan(math::Vector2d(0, 0)); + viewControl.Orbit(math::Vector2d(0, 0)); + // test setting camera viewControl.SetCamera(camera); EXPECT_EQ(camera, viewControl.Camera()); @@ -229,6 +274,12 @@ TEST_P(OrbitViewControllerTest, OrbitViewController) OrbitViewControl(GetParam()); } +///////////////////////////////////////////////// +TEST_P(OrbitViewControllerTest, OrbitViewControllerCameraConstructor) +{ + OrbitViewControlCameraConstructor(GetParam()); +} + ///////////////////////////////////////////////// TEST_P(OrbitViewControllerTest, Control) { diff --git a/src/PixelFormat_TEST.cc b/src/PixelFormat_TEST.cc index ab95b89b2..ee6e8c05f 100644 --- a/src/PixelFormat_TEST.cc +++ b/src/PixelFormat_TEST.cc @@ -31,26 +31,47 @@ TEST(PixelFormatTest, PixelUtil) EXPECT_EQ(3u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(1u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(3072u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("R8G8B8", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("R8G8B8")); format = PF_FLOAT32_R; EXPECT_EQ(4u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(4096u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_R", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_R")); format = PF_FLOAT32_RGB; EXPECT_EQ(12u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(12288u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_RGB", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_RGB")); format = PF_FLOAT32_RGBA; EXPECT_EQ(16u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(4u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(16384u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("FLOAT32_RGBA", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("FLOAT32_RGBA")); format = PF_L16; EXPECT_EQ(2u, PixelUtil::BytesPerPixel(format)); EXPECT_EQ(2u, PixelUtil::BytesPerChannel(format)); EXPECT_EQ(2048u, PixelUtil::MemorySize(format, 32, 32)); + EXPECT_EQ("L16", PixelUtil::Name(format)); + EXPECT_EQ(format, PixelUtil::Enum("L16")); +} + +///////////////////////////////////////////////// +TEST(PixelFormatTest, PixelUtilInvalid) +{ + PixelFormat format = static_cast(16); + + EXPECT_EQ(PF_UNKNOWN, PixelUtil::Sanitize(format)); + EXPECT_EQ("UNKNOWN", PixelUtil::Name(format)); + + EXPECT_EQ(PF_UNKNOWN, PixelUtil::Enum("invalid")); } int main(int argc, char **argv) diff --git a/src/RenderEngineManager_TEST.cc b/src/RenderEngineManager_TEST.cc new file mode 100644 index 000000000..0ea1b9e8b --- /dev/null +++ b/src/RenderEngineManager_TEST.cc @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include + +#include + +#include "test_config.h" // NOLINT(build/include) + +#include "ignition/rendering/RenderingIface.hh" +#include "ignition/rendering/RenderEngine.hh" +#include "ignition/rendering/RenderEngineManager.hh" + +using namespace ignition; +using namespace rendering; + +class RenderEngineManagerTest : public testing::Test, + public testing::WithParamInterface +{ + public: void RenderEngineManager(const std::string &_renderEngine); +}; + +///////////////////////////////////////////////// +void RenderEngineManagerTest::RenderEngineManager( + const std::string &_renderEngine) +{ + // Tested missing APIs + EXPECT_FALSE(RenderEngineManager::Instance()->HasEngine("invalid")); + EXPECT_EQ(nullptr, RenderEngineManager::Instance()->Engine("invalid")); + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngine("invalid")); + + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngineAt(100)); + + RenderEngineManager::Instance()->RegisterEngine("invalid", nullptr); + + auto engine = rendering::engine(_renderEngine); + RenderEngineManager::Instance()->RegisterEngine("ogre2", engine); + + RenderEngineManager::Instance()->UnregisterEngine(engine); + EXPECT_FALSE(RenderEngineManager::Instance()->UnloadEngineAt(0)); + + std::list paths = {"path1", "path2"}; + RenderEngineManager::Instance()->SetPluginPaths(paths); +} + +///////////////////////////////////////////////// +TEST_P(RenderEngineManagerTest, RenderEngineManager) +{ + RenderEngineManager(GetParam()); +} + +INSTANTIATE_TEST_CASE_P(RenderEngineManager, RenderEngineManagerTest, + RENDER_ENGINE_VALUES, + PrintToStringParam()); + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/RenderEngine_TEST.cc b/src/RenderEngine_TEST.cc index b6d1bccab..fd05abc7b 100644 --- a/src/RenderEngine_TEST.cc +++ b/src/RenderEngine_TEST.cc @@ -48,6 +48,7 @@ void RenderEngineTest::RenderEngine(const std::string &_renderEngine) EXPECT_EQ(_renderEngine, engine->Name()); EXPECT_TRUE(engine->IsEnabled()); + EXPECT_TRUE(engine->IsLoaded()); engine->AddResourcePath("none"); diff --git a/src/Scene_TEST.cc b/src/Scene_TEST.cc index edbdae43c..c825f3fe9 100644 --- a/src/Scene_TEST.cc +++ b/src/Scene_TEST.cc @@ -45,6 +45,10 @@ class SceneTest : public testing::Test, /// \brief Test creating and destroying materials public: void Materials(const std::string &_renderEngine); + + public: const std::string TEST_MEDIA_PATH = + common::joinPaths(std::string(PROJECT_SOURCE_PATH), + "test", "media", "skeleton"); }; ///////////////////////////////////////////////// @@ -72,7 +76,7 @@ void SceneTest::Scene(const std::string &_renderEngine) // TODO(anyone) gradient background color and render window only supported // by ogre - if (_renderEngine == "ogre") + if (_renderEngine == "ogre2") { EXPECT_FALSE(scene->IsGradientBackgroundColor()); @@ -441,7 +445,81 @@ void SceneTest::DestroyNodes(const std::string &_renderEngine) EXPECT_FALSE(scene->HasVisual(childB)); EXPECT_FALSE(scene->HasVisual(childAA)); + auto gizmoVisual = scene->CreateGizmoVisual("gizmo_visual"); + auto planeVisual = scene->CreatePlane(); + auto meshVisual = scene->CreateMesh( + common::joinPaths(TEST_MEDIA_PATH, "walk.dae")); + + common::MeshPtr mesh(new common::Mesh()); + meshVisual = scene->CreateMesh(mesh.get()); + + scene->DestroyVisuals(); + + common::Material mat(math::Color(1.0f, 0.5f, 0.2f, 1.0f)); + auto materialVisual = scene->CreateMaterial(mat); + scene->DestroyMaterial(materialVisual); + scene->DestroyMaterial(MaterialPtr()); + + auto depthCameraSensor = scene->CreateDepthCamera(); + scene->DestroySensors(); + depthCameraSensor = scene->CreateDepthCamera("camera_depth"); + scene->DestroySensorByName("camera_depth"); + depthCameraSensor = scene->CreateDepthCamera("camera_depth"); + EXPECT_FALSE(scene->HasSensor(ConstSensorPtr())); + EXPECT_FALSE(scene->HasSensorId(8)); + EXPECT_FALSE(scene->HasSensorName("invalid")); + EXPECT_TRUE(scene->HasSensorName("camera_depth")); + + auto dCSensor = scene->SensorByName("camera_depth"); + EXPECT_TRUE(scene->HasSensor(dCSensor)); + EXPECT_TRUE(scene->HasSensorName("camera_depth")); + scene->DestroySensor(dCSensor, false); + + depthCameraSensor = scene->CreateDepthCamera(76); + dCSensor = scene->SensorById(76); + EXPECT_TRUE(scene->HasSensor(dCSensor)); + EXPECT_TRUE(scene->HasSensorId(76)); + scene->DestroySensor(dCSensor, true); + + depthCameraSensor = scene->CreateDepthCamera(76); + scene->DestroySensorById(76); + + depthCameraSensor = scene->CreateDepthCamera(); + scene->DestroySensorByIndex(0); + + // lights + auto spotLight = scene->CreateSpotLight(); + auto pointLight = scene->CreatePointLight("point_light"); + auto directionalLight = scene->CreateDirectionalLight(99); + + auto directionalLight2 = scene->LightById(99); + EXPECT_EQ(directionalLight, directionalLight2); + + auto directionalLight3 = scene->CreateDirectionalLight("directional_light"); + + auto pointLight2 = scene->LightByName("point_light"); + EXPECT_EQ(pointLight, pointLight2); + + scene->DestroyLightByIndex(0); + scene->DestroyLight(pointLight, true); + scene->DestroyLights(); + + spotLight = scene->CreateSpotLight(); + scene->DestroyNodeByIndex(0); + + spotLight = scene->CreateSpotLight("light_node"); + scene->DestroyNodeByName("light_node"); + + spotLight = scene->CreateSpotLight(56); + scene->DestroyNodeById(56); + EXPECT_EQ(0u, scene->VisualCount()); + EXPECT_EQ(0u, scene->SensorCount()); + EXPECT_EQ(0u, scene->LightCount()); + + EXPECT_DOUBLE_EQ(0.0, scene->SimTime().Double()); + scene->SetSimTime(common::Time(3.55)); + EXPECT_DOUBLE_EQ(3.55, scene->SimTime().Double()); // Clean up engine->DestroyScene(scene); diff --git a/src/ShaderParams_TEST.cc b/src/ShaderParams_TEST.cc index 3b824a0cf..01b84a8c6 100644 --- a/src/ShaderParams_TEST.cc +++ b/src/ShaderParams_TEST.cc @@ -73,6 +73,30 @@ TEST(ShaderParams, ConstRangeForLoopDoesNotDirty) EXPECT_FALSE(params.IsDirty()); } +///////////////////////////////////////////////// +TEST(ShaderParams, Iterator) +{ + ShaderParams params; + params["some_parameter"] = 4.0f; + params["some_parameter2"] = 4.1f; + auto iterator = params.begin(); + auto iteratorCopy = iterator; + EXPECT_TRUE(iterator == params.begin()); + EXPECT_EQ(iteratorCopy->first, iterator->first); + EXPECT_EQ("some_parameter2", iterator->first); + EXPECT_EQ(ShaderParam::PARAM_FLOAT, iterator->second.Type()); + float val; + EXPECT_TRUE(iterator->second.Value(&val)); + EXPECT_FLOAT_EQ(4.1f, val); + + iterator++; + EXPECT_EQ("some_parameter", iterator->first); + EXPECT_EQ(ShaderParam::PARAM_FLOAT, iterator->second.Type()); + EXPECT_TRUE(iterator->second.Value(&val)); + EXPECT_FLOAT_EQ(4.0f, val); +} + + ////////////////////////////////////////////////// int main(int argc, char **argv) {