Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 8 -> main #1029

Merged
merged 15 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

### Gazebo Rendering 8.X

### Gazebo Rendering 8.2.0

1. Backport: Adding cone primitives.
* [Pull request #1003](https://github.com/gazebosim/gz-rendering/pull/1003)

1. Fixes deleter passed to the std::shared_ptr<void>
* [Pull request #1009](https://github.com/gazebosim/gz-rendering/pull/1009)

1. ogre2: Set custom projection matrix for other types of cameras
* [Pull request #1002](https://github.com/gazebosim/gz-rendering/pull/1002)

1. Fix gz-cmake declaration on package.xml (Fix windows builds)
* [Pull request #1005](https://github.com/gazebosim/gz-rendering/pull/1005)

1. Add package.xml
* [Pull request #981](https://github.com/gazebosim/gz-rendering/pull/981)

1. Workaround on warnings for Ubuntu Noble
* [Pull request #995](https://github.com/gazebosim/gz-rendering/pull/995)

1. Ogre2RenderEngine: on Windows if useCurrentGLContext is specified, set the externalWindowsHandle ogre-next option
* [Pull request #992](https://github.com/gazebosim/gz-rendering/pull/992)

### Gazebo Rendering 8.1.1 (2024-04-10)

1. Use relative install paths for plugin shared libraries and media files
Expand Down
19 changes: 11 additions & 8 deletions examples/simple_demo_qml/GzRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,20 @@ void GzRenderer::InitialiseOnMainThread()
//////////////////////////////////////////////////
void GzRenderer::Render()
{
// pre-render may regenerate textureId if the size changes
this->camera->PreRender();
this->textureId = this->camera->RenderTextureGLId();

// render to texture
this->camera->Update();

GLuint texIdSrgb = this->camera->RenderTextureGLId();

if (this->textureId != texIdSrgb)
{
glBindTexture(GL_TEXTURE_2D, texIdSrgb);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
}

this->textureId = texIdSrgb;

// Move camera
this->UpdateCamera();
}
Expand Down Expand Up @@ -278,10 +285,6 @@ void GzRenderer::InitEngine()
// quick check on sizing...
gzmsg << "imageW: " << this->camera->ImageWidth() << "\n";
gzmsg << "imageH: " << this->camera->ImageHeight() << "\n";

// pre-render will force texture creation and may update texture id
this->camera->PreRender();
this->textureId = this->camera->RenderTextureGLId();
}

//////////////////////////////////////////////////
Expand Down
9 changes: 6 additions & 3 deletions examples/simple_demo_qml/ThreadRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,22 +321,25 @@ void TextureNode::NewTexture(int _id, const QSize &_size)
void TextureNode::PrepareNode()
{
this->mutex.lock();
// new render engine texture ID
int newId = this->id;
QSize size = this->size;
QSize newSize = this->size;
this->id = 0;
this->mutex.unlock();

if (newId)
{
delete this->texture;
this->texture = nullptr;
// note: include QQuickWindow::TextureHasAlphaChannel if the rendered content
// has alpha.

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# endif
this->texture = this->window->createTextureFromId(newId, size);
this->texture = this->window->createTextureFromId(newId, newSize);
# ifndef _WIN32
# pragma GCC diagnostic pop
# endif
Expand All @@ -346,7 +349,7 @@ void TextureNode::PrepareNode()
QQuickWindow::NativeObjectTexture,
static_cast<void *>(&newId),
0,
size);
newSize);
#endif
this->setTexture(this->texture);

Expand Down
15 changes: 9 additions & 6 deletions ogre/src/OgreDistortionPass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ void OgreDistortionPass::CreateRenderPass()
distortedLocation,
newDistortedCoordinates,
currDistortedCoordinates;
unsigned int distortedIdx,
distortedCol,
unsigned int distortedIdx;
int distortedCol,
distortedRow;
double normalizedColLocation, normalizedRowLocation;

Expand All @@ -223,9 +223,9 @@ void OgreDistortionPass::CreateRenderPass()
focalLength);

// compute the index in the distortion map
distortedCol = static_cast<unsigned int>(round(distortedLocation.X() *
distortedCol = static_cast<int>(round(distortedLocation.X() *
this->dataPtr->distortionTexWidth));
distortedRow = static_cast<unsigned int>(round(distortedLocation.Y() *
distortedRow = static_cast<int>(round(distortedLocation.Y() *
this->dataPtr->distortionTexHeight));

// Note that the following makes sure that, for significant distortions,
Expand All @@ -235,8 +235,11 @@ void OgreDistortionPass::CreateRenderPass()
// nonlegacy distortion modes.

// Make sure the distorted pixel is within the texture dimensions
if (distortedCol < this->dataPtr->distortionTexWidth &&
distortedRow < this->dataPtr->distortionTexHeight)
if (distortedCol >= 0 && distortedRow >= 0 &&
static_cast<unsigned int>(distortedCol) <
this->dataPtr->distortionTexWidth &&
static_cast<unsigned int>(distortedRow) <
this->dataPtr->distortionTexHeight)
{
distortedIdx = distortedRow * this->dataPtr->distortionTexWidth +
distortedCol;
Expand Down
6 changes: 5 additions & 1 deletion ogre/src/OgreWideAngleCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@ void OgreWideAngleCamera::CreateWideAngleTexture()

double vfov = 2.0 * atan(tan(this->HFOV().Radian() / 2.0) / ratio);
this->dataPtr->ogreCamera->setAspectRatio(ratio);
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(vfov));
// Setting the fov is likely not necessary for the ogreCamera but
// clamp to max fov supported by ogre to avoid issues with building the
// frustum
this->dataPtr->ogreCamera->setFOVy(Ogre::Radian(
Ogre::Real(std::clamp(vfov, 0.0, GZ_PI))));

// create the env cameras and textures
this->CreateEnvCameras();
Expand Down
13 changes: 11 additions & 2 deletions ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ set(engine_name "ogre2")
gz_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre2_target)

set(OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
# On non-Windows, we need to convert the CMake list delimited (;) to the
# list delimiter used in list of paths in code (:)
# On Windows, the list delimiter in code is already ;, not need to change it to :
if(NOT WIN32)
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
endif()

set_property(
SOURCE Ogre2RenderEngine.cc
PROPERTY COMPILE_DEFINITIONS
Expand Down Expand Up @@ -65,7 +71,10 @@ if (TARGET OpenGL::EGL)
add_definitions(-DHAVE_EGL=1)
endif()

target_compile_definitions(${ogre2_target} PRIVATE $<$<CONFIG:Debug>:DEBUG=1 _DEBUG=1>)
# You might need to uncomment the following `target_compile_definitions`
# if you've built Ogre from source in Debug mode
# https://github.com/OGRECave/ogre-next/blob/003f51a0a90d1cf93fbea3c7302565b07c4f87b0/OgreMain/include/OgrePlatform.h#L350-L372
# target_compile_definitions(${ogre2_target} PRIVATE $<$<CONFIG:Debug>:DEBUG=1 _DEBUG=1>)


set (versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand Down
28 changes: 7 additions & 21 deletions ogre2/src/Ogre2DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ class Ogre2DepthGaussianNoisePass : public Ogre2GaussianNoisePass
/// \brief Private data for the Ogre2DepthCamera class
class gz::rendering::Ogre2DepthCameraPrivate
{
/// \brief The depth buffer
/// \brief The depth buffer - also the outgoing point cloud data used
/// by newRgbPointCloud event
public: float *depthBuffer = nullptr;

/// \brief Outgoing depth data, used by newDepthFrame event.
public: float *depthImage = nullptr;

/// \brief Outgoing point cloud data, used by newRgbPointCloud event.
public: float *pointCloudImage = nullptr;

/// \brief maximum value used for data outside sensor range
public: float dataMaxVal = gz::math::INF_D;

Expand Down Expand Up @@ -316,12 +314,6 @@ void Ogre2DepthCamera::Destroy()
this->dataPtr->depthImage = nullptr;
}

if (this->dataPtr->pointCloudImage)
{
delete [] this->dataPtr->pointCloudImage;
this->dataPtr->pointCloudImage = nullptr;
}

if (!this->ogreCamera)
return;

Expand Down Expand Up @@ -1195,10 +1187,6 @@ void Ogre2DepthCamera::PostRender()
{
this->dataPtr->depthImage = new float[len];
}
if (!this->dataPtr->pointCloudImage)
{
this->dataPtr->pointCloudImage = new float[len * channelCount];
}

// fill depth data
for (unsigned int i = 0; i < height; ++i)
Expand All @@ -1216,10 +1204,8 @@ void Ogre2DepthCamera::PostRender()
// point cloud data
if (this->dataPtr->newRgbPointCloud.ConnectionCount() > 0u)
{
memcpy(this->dataPtr->pointCloudImage,
this->dataPtr->depthBuffer, len * channelCount * sizeof(float));
this->dataPtr->newRgbPointCloud(
this->dataPtr->pointCloudImage, width, height, channelCount,
this->dataPtr->depthBuffer, width, height, channelCount,
"PF_FLOAT32_RGBA");

// Uncomment to debug color output
Expand All @@ -1229,7 +1215,7 @@ void Ogre2DepthCamera::PostRender()
// for (unsigned int j = 0; j < width; ++j)
// {
// float color =
// this->dataPtr->pointCloudImage[step + j*channelCount + 3];
// this->dataPtr->depthBuffer[step + j*channelCount + 3];
// // unpack rgb data
// uint32_t *rgba = reinterpret_cast<uint32_t *>(&color);
// unsigned int r = *rgba >> 24 & 0xFF;
Expand All @@ -1246,9 +1232,9 @@ void Ogre2DepthCamera::PostRender()
// {
// for (unsigned int j = 0; j < width; ++j)
// {
// gzdbg << "[" << this->dataPtr->pointCloudImage[i*width*4+j*4] << "]"
// << "[" << this->dataPtr->pointCloudImage[i*width*4+j*4+1] << "]"
// << "[" << this->dataPtr->pointCloudImage[i*width*4+j*4+2] << "],";
// gzdbg << "[" << this->dataPtr->depthBuffer[i*width*4+j*4] << "]"
// << "[" << this->dataPtr->depthBuffer[i*width*4+j*4+1] << "]"
// << "[" << this->dataPtr->depthBuffer[i*width*4+j*4+2] << "],";
// }
// gzdbg << std::endl;
// }
Expand Down
Loading
Loading