Skip to content

Commit

Permalink
Merge pull request #584 from gazebosim/merge_5_main_20240313
Browse files Browse the repository at this point in the history
Merge 5 -> main
  • Loading branch information
iche033 authored Mar 13, 2024
2 parents 37d6360 + 38dd565 commit e390fff
Show file tree
Hide file tree
Showing 24 changed files with 463 additions and 66 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Ubuntu CI

on: [push, pull_request]
on:
pull_request:
push:
branches:
- 'ign-common[0-9]'
- 'gz-common[0-9]'
- 'main'

jobs:
jammy-ci:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ jobs:
with:
project-url: https://github.com/orgs/gazebosim/projects/7
github-token: ${{ secrets.TRIAGE_TOKEN }}

3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ gz_find_package(
# Find GDAL
gz_find_package(GDAL VERSION 3.0
PKGCONFIG gdal
PKGCONFIG_VER_COMPARISON >=
PRIVATE_FOR geospatial
REQUIRED_BY geospatial)

Expand Down Expand Up @@ -117,7 +118,7 @@ configure_file("${PROJECT_SOURCE_DIR}/cppcheck.suppress.in"
${PROJECT_BINARY_DIR}/cppcheck.suppress)

gz_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS av events geospatial graphics io profiler testing)
COMPONENTS av events graphics geospatial io profiler testing)

#============================================================================
# Create package information
Expand Down
98 changes: 98 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,58 @@

## Gazebo Common 5.x

## Gazebo Common 5.5.0 (2024-02-26)

1. Be louder when graphics is missing for geospatial
* [Pull request #573](https://github.com/gazebosim/gz-common/pull/573)

1. Multiple memory cleanup fixes
* [Pull request #571](https://github.com/gazebosim/gz-common/pull/571)

1. Clarify GDAL version requirement
* [Pull request #574](https://github.com/gazebosim/gz-common/pull/574)

1. 🎈 3.17.0
* [Pull request #567](https://github.com/gazebosim/gz-common/pull/567)

1. Update CI badges in README
* [Pull request #566](https://github.com/gazebosim/gz-common/pull/566)

1. Backwards compatible assimp texture name fix
* [Pull request #565](https://github.com/gazebosim/gz-common/pull/565)

1. Fix error output when creating directories
* [Pull request #561](https://github.com/gazebosim/gz-common/pull/561)

1. Update github action workflows
* [Pull request #558](https://github.com/gazebosim/gz-common/pull/558)

1. Fix segfault in case of no write access to log dir
* [Pull request #546](https://github.com/gazebosim/gz-common/pull/546)

1. ign -> gz
* [Pull request #547](https://github.com/gazebosim/gz-common/pull/547)

1. Support loading glb with compressed jpeg textures
* [Pull request #545](https://github.com/gazebosim/gz-common/pull/545)

1. Fix glTF / glb root node transform
* [Pull request #543](https://github.com/gazebosim/gz-common/pull/543)

1. EnumIface: suppress deprecation warning
* [Pull request #540](https://github.com/gazebosim/gz-common/pull/540)

1. Prevent loading lightmaps if mesh is a glb file that has an occlusion-metallic-roughness texture
* [Pull request #538](https://github.com/gazebosim/gz-common/pull/538)

1. 🎈 3.16.0
* [Pull request #519](https://github.com/gazebosim/gz-common/pull/519)

1. Fix cstdint with GCC 13
* [Pull request #528](https://github.com/gazebosim/gz-common/pull/528)
* [Pull request #517](https://github.com/gazebosim/gz-common/pull/517)
* [Pull request #513](https://github.com/gazebosim/gz-common/pull/513)

## Gazebo Common 5.4.2 (2023-09-26)

1. Documentation fixes
Expand Down Expand Up @@ -673,6 +725,52 @@

## Gazebo Common 3.x

## Gazebo Common 3.17.0 (2024-01-05)

1. Fix error output when creating directories
* [Pull request #561](https://github.com/gazebosim/gz-common/pull/561)

1. Update github action workflows
* [Pull request #558](https://github.com/gazebosim/gz-common/pull/558)

1. Fix segfault in case of no write access to log dir
* [Pull request #546](https://github.com/gazebosim/gz-common/pull/546)

## Gazebo Common 3.16.0 (2023-06-05)

1. Include cstdint to build with GCC 13
* [Pull request #517](https://github.com/gazebosim/gz-common/pull/517)

1. Fix missing cstdint header in latest gcc build
* [Pull request #513](https://github.com/gazebosim/gz-common/pull/513)

1. Fix for ffmpeg v6
* [Pull request #497](https://github.com/gazebosim/gz-common/pull/497)

1. Include cstring for memcpy
* [Pull request #501](https://github.com/gazebosim/gz-common/pull/501)

1. Fixed MeshManager Singleton
* [Pull request #451](https://github.com/gazebosim/gz-common/pull/451)

1. Rename COPYING to LICENSE
* [Pull request #494](https://github.com/gazebosim/gz-common/pull/494)

1. Add marcoag as codeowner
* [Pull request #493](https://github.com/gazebosim/gz-common/pull/493)

1. CI workflow: use checkout v3
* [Pull request #490](https://github.com/gazebosim/gz-common/pull/490)

1. Improved coverage remotery
* [Pull request #467](https://github.com/gazebosim/gz-common/pull/467)

1. Added BVH and STL loader tests
* [Pull request #466](https://github.com/gazebosim/gz-common/pull/466)

1. Increased Image coverage
* [Pull request #465](https://github.com/gazebosim/gz-common/pull/465)

## Gazebo Common 3.15.1 (2022-10-11)

1. Fix build on case-insensitive filesystems
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

Build | Status
-- | --
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-common/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-common)
Ubuntu Focal | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_common-ci-main-focal-amd64)](https://build.osrfoundation.org/job/ignition_common-ci-main-focal-amd64)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=ignition_common-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/ignition_common-ci-main-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/job/ign_common-ci-win/badge/icon)](https://build.osrfoundation.org/job/ign_common-ci-win/)
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common5/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common5)
Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common5-jammy-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common5-jammy-amd64)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common5-homebrew-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common5-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/job/gz_common-5-win/badge/icon)](https://build.osrfoundation.org/job/gz_common-5-win/)

Gazebo Common, a component of [Gazebo](https://gazebosim.org), provides a set of libraries that
cover many different use cases. An audio-visual library supports
Expand Down
45 changes: 24 additions & 21 deletions geospatial/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
gz_get_libsources_and_unittests(sources gtest_sources)
if (TARGET ${PROJECT_LIBRARY_TARGET_NAME}-graphics)
gz_get_libsources_and_unittests(sources gtest_sources)
gz_add_component(geospatial
SOURCES ${sources}
DEPENDS_ON_COMPONENTS graphics
GET_TARGET_NAME geospatial_target)

gz_add_component(geospatial
SOURCES ${sources}
DEPENDS_ON_COMPONENTS graphics
GET_TARGET_NAME geospatial_target)
target_link_libraries(${geospatial_target}
PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}-graphics
gz-math${GZ_MATH_VER}::gz-math${GZ_MATH_VER}
gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER}
PRIVATE
${GDAL_LIBRARY})

target_link_libraries(${geospatial_target}
PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}-graphics
gz-math${GZ_MATH_VER}::gz-math${GZ_MATH_VER}
gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER}
PRIVATE
${GDAL_LIBRARY})
target_include_directories(${geospatial_target}
PRIVATE
${GDAL_INCLUDE_DIR})

target_include_directories(${geospatial_target}
PRIVATE
${GDAL_INCLUDE_DIR})

gz_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS
${geospatial_target}
gz-common${GZ_COMMON_VER}-testing
)
gz_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS
${geospatial_target}
gz-common${GZ_COMMON_VER}-testing
)
else()
message(WARNING "Skipping component [geospatial]: Missing component [graphics].\n ^~~~~ Set SKIP_geospatial=true in cmake to suppress this warning.")
endif()
6 changes: 5 additions & 1 deletion graphics/include/gz/common/Image.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ namespace gz
BAYER_GBRG8,
BAYER_GRBG8,
COMPRESSED_PNG,
PIXEL_FORMAT_COUNT
PIXEL_FORMAT_COUNT,
// \todo(iche033) COMPRESSED_JPEG is added at the end to
// preserve ABI compatibility. Move this enum up when merging
// forward to main
COMPRESSED_JPEG
};


Expand Down
105 changes: 89 additions & 16 deletions graphics/src/AssimpLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ class AssimpLoader::Implementation
/// calculated from the "old" parent model transform.
/// \param[in] _skeleton the skeleton to work on
public: void ApplyInvBindTransform(SkeletonPtr _skeleton) const;

/// Get the updated root node transform. The function updates the original
/// transform by setting the rotation to identity if requested.
/// \param[in] _scene Scene with axes info stored in meta data
/// \param[in] _useIdentityRotation Whether to set rotation to identity.
/// Note: This is currently set to false for glTF / glb meshes.
/// \return Updated transform
public: aiMatrix4x4 UpdatedRootNodeTransform(const aiScene *_scene,
bool _useIdentityRotation = true);
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -348,8 +357,26 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial(
}
float opacity = 1.0;
ret = assimpMat->Get(AI_MATKEY_OPACITY, opacity);
mat->SetTransparency(1.0 - opacity);
mat->SetBlendFactors(opacity, 1.0 - opacity);
if (ret == AI_SUCCESS)
{
mat->SetTransparency(1.0 - opacity);
mat->SetBlendFactors(opacity, 1.0 - opacity);
}

#ifndef GZ_ASSIMP_PRE_5_1_0
// basic support for transmission - currently just overrides opacity
// \todo(iche033) The transmission factor can be used with volume
// material extension to simulate effects like refraction
// so consider also extending support for other properties like
// AI_MATKEY_VOLUME_THICKNESS_FACTOR
float transmission = 0.0;
ret = assimpMat->Get(AI_MATKEY_TRANSMISSION_FACTOR, transmission);
if (ret == AI_SUCCESS)
{
mat->SetTransparency(transmission);
}
#endif

// TODO(luca) more than one texture, Gazebo assumes UV index 0
Pbr pbr;
aiString texturePath(_path.c_str());
Expand Down Expand Up @@ -542,26 +569,49 @@ std::pair<ImagePtr, ImagePtr>
ImagePtr AssimpLoader::Implementation::LoadEmbeddedTexture(
const aiTexture* _texture) const
{
auto img = std::make_shared<Image>();
if (_texture->mHeight == 0)
{
Image::PixelFormatType format = Image::PixelFormatType::UNKNOWN_PIXEL_FORMAT;
if (_texture->CheckFormat("png"))
{
img->SetFromCompressedData((unsigned char*)_texture->pcData,
_texture->mWidth, Image::PixelFormatType::COMPRESSED_PNG);
format = Image::PixelFormatType::COMPRESSED_PNG;
}
else if (_texture->CheckFormat("jpg"))
{
format = Image::PixelFormatType::COMPRESSED_JPEG;
}
if (format != Image::PixelFormatType::UNKNOWN_PIXEL_FORMAT)
{
auto img = std::make_shared<Image>();
img->SetFromCompressedData(
reinterpret_cast<unsigned char *>(_texture->pcData),
_texture->mWidth, format);
return img;
}
else
{
gzerr << "Unable to load embedded texture. "
<< "Unsupported compressed image format"
<< std::endl;
}
}
return img;
return ImagePtr();
}

//////////////////////////////////////////////////
std::string AssimpLoader::Implementation::GenerateTextureName(
const aiScene* _scene, aiMaterial* _mat, const std::string& _type) const
{
return ToString(_scene->mRootNode->mName) + "_" + ToString(_mat->GetName()) +
#ifdef GZ_ASSIMP_PRE_5_2_0
auto rootName = _scene->mRootNode->mName;
#else
auto rootName = _scene->mName;
#endif
return ToString(rootName) + "_" + ToString(_mat->GetName()) +
"_" + _type;
}

//////////////////////////////////////////////////
SubMesh AssimpLoader::Implementation::CreateSubMesh(
const aiMesh* _assimpMesh, const math::Matrix4d& _transform) const
{
Expand Down Expand Up @@ -645,16 +695,15 @@ Mesh *AssimpLoader::Load(const std::string &_filename)
}
auto& rootNode = scene->mRootNode;
auto rootName = ToString(rootNode->mName);
auto transform = scene->mRootNode->mTransformation;
aiVector3D rootScaling, rootAxis, rootPos;
float angle;
transform.Decompose(rootScaling, rootAxis, angle, rootPos);
// drop rotation, but keep scaling and position
// TODO(luca) it seems imported assets are rotated by 90 degrees
// as documented here https://github.com/assimp/assimp/issues/849
// remove workaround when fixed
transform = aiMatrix4x4(rootScaling, aiQuaternion(), rootPos);

// compute assimp root node transform
std::string extension = _filename.substr(_filename.rfind(".") + 1,
_filename.size());
std::transform(extension.begin(), extension.end(),
extension.begin(), ::tolower);
bool useIdentityRotation = (extension != "glb" && extension != "glTF");
auto transform = this->dataPtr->UpdatedRootNodeTransform(scene,
useIdentityRotation);
auto rootTransform = this->dataPtr->ConvertTransform(transform);

// Add the materials first
Expand Down Expand Up @@ -756,5 +805,29 @@ void AssimpLoader::Implementation::ApplyInvBindTransform(
}
}

/////////////////////////////////////////////////
aiMatrix4x4 AssimpLoader::Implementation::UpdatedRootNodeTransform(
const aiScene *_scene, bool _useIdentityRotation)
{
// Some assets apear to be rotated by 90 degrees as documented here
// https://github.com/assimp/assimp/issues/849.
auto transform = _scene->mRootNode->mTransformation;
if (_useIdentityRotation)
{
// drop rotation, but keep scaling and position
aiVector3D rootScaling, rootAxis, rootPos;
float angle;
transform.Decompose(rootScaling, rootAxis, angle, rootPos);
transform = aiMatrix4x4(rootScaling, aiQuaternion(), rootPos);
}
// for glTF / glb meshes, it was found that the transform is needed to
// produce a result that is consistent with other engines / glTF viewers.
else
{
transform = _scene->mRootNode->mTransformation;
}
return transform;
}

}
}
Loading

0 comments on commit e390fff

Please sign in to comment.