Skip to content

Commit 565476f

Browse files
committed
FIX: Error in CPointCloudColoured
1 parent 763577b commit 565476f

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
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.16: UNRELEASED
4+
- BUG FIXES:
5+
- Fix build building deprecated warnings in WorkerThreadsPool.
6+
- Fix mrpt::opengl::CPointCloudColoured throwing if the source cloud map may have color and color/intensity channels are actually empty.
7+
38
# Version 2.14.15: Released Sep 29th, 2025
49
- BUG FIXES:
510
- Fix regression in OpenGL application crashing after last update.

libs/maps/include/mrpt/maps/CPointsMapXYZI.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ class CPointsMapXYZI : public CPointsMap
163163
/** Like \c getPointColor but without checking for out-of-index errors */
164164
inline float getPointIntensity_fast(size_t index) const { return m_intensity[index]; }
165165

166+
bool hasIntensityField() const { return !m_intensity.empty(); }
167+
166168
/** Returns true if the point map has a color field for each point */
167-
bool hasColorPoints() const override { return true; }
169+
bool hasColorPoints() const override { return hasIntensityField(); }
168170

169171
/** Override of the default 3D scene builder to account for the individual
170172
* points' color.

libs/maps/include/mrpt/maps/CPointsMapXYZIRT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class CPointsMapXYZIRT : public CPointsMap
224224
inline float getPointIntensity_fast(size_t index) const { return m_intensity[index]; }
225225

226226
/** Returns true if the point map has a color field for each point */
227-
bool hasColorPoints() const override { return true; }
227+
bool hasColorPoints() const override { return hasIntensityField(); }
228228

229229
/** Override of the default 3D scene builder to account for the individual
230230
* points' color.

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,20 +399,22 @@ void CPointCloudColoured::loadFromPointsMap(const POINTSMAP* themap)
399399
const mrpt::opengl::PointCloudAdapter<POINTSMAP> pc_src(*themap);
400400
const size_t N = pc_src.size();
401401
pc_dst.resize(N);
402+
const bool isColorFilled = themap->hasColorPoints();
402403
for (size_t i = 0; i < N; i++)
403404
{
404405
if constexpr (mrpt::opengl::PointCloudAdapter<POINTSMAP>::HAS_RGB)
405406
{
406-
float x, y, z, r, g, b, a;
407-
pc_src.getPointXYZ_RGBAf(i, x, y, z, r, g, b, a);
408-
pc_dst.setPointXYZ_RGBAf(i, x, y, z, r, g, b, a);
409-
}
410-
else
411-
{
412-
float x, y, z;
413-
pc_src.getPointXYZ(i, x, y, z);
414-
pc_dst.setPointXYZ_RGBAf(i, x, y, z, 0, 0, 0, 1);
407+
if (isColorFilled)
408+
{
409+
float x, y, z, r, g, b, a;
410+
pc_src.getPointXYZ_RGBAf(i, x, y, z, r, g, b, a);
411+
pc_dst.setPointXYZ_RGBAf(i, x, y, z, r, g, b, a);
412+
continue;
413+
}
415414
}
415+
float x, y, z;
416+
pc_src.getPointXYZ(i, x, y, z);
417+
pc_dst.setPointXYZ_RGBAf(i, x, y, z, 0, 0, 0, 1);
416418
}
417419
}
418420
} // namespace mrpt::opengl

0 commit comments

Comments
 (0)