Skip to content

Commit 9e2a23b

Browse files
committed
New method mrpt::opengl::CPointCloudColoured::setAllPointsAlpha()
1 parent 0a2022d commit 9e2a23b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

doc/source/doxygen-docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
\page changelog Change Log
22

3+
# Version 2.14.12: UNRELEASED
4+
- Changes in libraries:
5+
- \ref mrpt_opengl_grp
6+
- New method mrpt::opengl::CPointCloudColoured::setAllPointsAlpha().
7+
38
# Version 2.14.11: Released May 31rd, 2025
49
- BUG FIXES:
510
- Fix build against all tf2 versions in all active ROS 2 distributions.

libs/opengl/include/mrpt/opengl/CPointCloudColoured.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@
1717

1818
namespace mrpt::opengl
1919
{
20-
/** A cloud of points, each one with an individual colour (R,G,B). The alpha
21-
* component is shared by all the points and is stored in the base member
22-
* m_color_A.
20+
/** A cloud of points, each one with an individual color (R,G,B,A).
2321
*
2422
* To load from a points-map, CPointCloudColoured::loadFromPointsMap().
2523
*
26-
* This class uses smart optimizations while rendering to efficiently draw
27-
* clouds of millions of points, using octrees.
28-
*
2924
* ![mrpt::opengl::CPointCloudColoured](preview_CPointCloudColoured.png)
3025
*
3126
* \sa opengl::Scene, opengl::CPointCloud
@@ -143,6 +138,15 @@ class CPointCloudColoured :
143138
m_point_colors[index].B = b;
144139
m_point_colors[index].A = a;
145140
}
141+
/** Overwrites the alpha (transparency) channel for all existing points */
142+
void setAllPointsAlpha(uint8_t alpha_channel)
143+
{
144+
std::unique_lock<std::shared_mutex> wfWriteLock(CRenderizableShaderPoints::m_pointsMtx.data);
145+
for (auto& pt : m_point_colors)
146+
{
147+
pt.A = alpha_channel;
148+
}
149+
}
146150
/** Like \c getPointColor but without checking for out-of-index errors */
147151
void getPointColor_fast(size_t index, float& R, float& G, float& B) const
148152
{

0 commit comments

Comments
 (0)