Skip to content

Commit f208f9c

Browse files
authored
Merge pull request #347 from ignitionrobotics/merge_3_4_061721
3 -> 4
2 parents 97891ac + 0551b74 commit f208f9c

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

ogre2/src/Ogre2RenderTarget.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ void Ogre2RenderTarget::UpdateRenderPassChain(
331331
ogre2RenderPass->OgreCompositorNodeDefinitionName());
332332

333333
// check if we need to create all nodes or just update the connections.
334-
// if node does not exist then it means it has not been added to the
335-
// chain yet, in which case, we need to recreate the nodes and
336-
// connections
337-
if (!node)
334+
// if node does not exist then it means it either has not been added to
335+
// the chain yet or it was removed because it was disabled.
336+
// In both cases, we need to recreate the nodes and connections
337+
if (!node && ogre2RenderPass->IsEnabled())
338338
{
339339
_recreateNodes = true;
340340
}

ogre2/src/Ogre2SelectionBuffer.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ void Ogre2SelectionBuffer::CreateRTTBuffer()
175175
const_cast<Ogre::CompositorPassSceneDef *>(scenePass)->mVisibilityMask =
176176
IGN_VISIBILITY_SELECTABLE;
177177

178-
// buffer to store render texture data
179-
size_t bufferSize = Ogre::PixelUtil::getMemorySize(width, height, 1, format);
178+
// buffer to store render texture data. Ensure it's at least 4 bytes
179+
size_t bufferSize = std::max<size_t>(
180+
Ogre::PixelUtil::getMemorySize(width, height, 1, format),
181+
4u);
180182
this->dataPtr->buffer = new uint8_t[bufferSize];
183+
memset(this->dataPtr->buffer, 0, 4u);
181184
this->dataPtr->pixelBox = new Ogre::PixelBox(width,
182185
height, 1, format, this->dataPtr->buffer);
183186
}

ogre2/src/media/materials/programs/depth_camera_final_fs.glsl

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@ uniform float far;
3131
uniform float min;
3232
uniform float max;
3333

34+
uniform vec4 texResolution;
35+
3436
void main()
3537
{
3638
float tolerance = 1e-6;
37-
vec4 p = texture(inputTexture, inPs.uv0);
39+
40+
// Note: We use texelFetch because p.a contains an uint32 and sampling
41+
// (even w/ point filtering) causes p.a to loss information (e.g.
42+
// values close to 0 get rounded to 0)
43+
//
44+
// See https://github.com/ignitionrobotics/ign-rendering/issues/332
45+
vec4 p = texelFetch(inputTexture, ivec2(inPs.uv0 *texResolution.xy), 0);
3846

3947
vec3 point = p.xyz;
4048

ogre2/src/media/materials/scripts/depth_camera.material

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ fragment_program DepthCameraFinalFS glsl
8888
default_params
8989
{
9090
param_named inputTexture int 0
91+
92+
param_named_auto texResolution texture_size 0
9193
}
9294
}
9395

src/GaussianNoisePass_TEST.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ void GaussianNoisePassTest::GaussianNoise(const std::string &_renderEngine)
8585
double biasStdDev = 0.007;
8686
noisePass->SetBiasStdDev(biasStdDev);
8787
// expect bias to be within 3-sigma
88-
EXPECT_LE(std::fabs(noisePass->Bias()), biasMean + biasStdDev*3);
89-
EXPECT_GE(std::fabs(noisePass->Bias()), biasMean - biasStdDev*3);
88+
// Note, tol relaxed to 4-sigma to fix flaky test
89+
EXPECT_LE(std::fabs(noisePass->Bias()), biasMean + biasStdDev*4);
90+
EXPECT_GE(std::fabs(noisePass->Bias()), biasMean - biasStdDev*4);
9091
}
9192

9293
/////////////////////////////////////////////////

src/Image.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
using namespace ignition;
2020
using namespace rendering;
2121

22+
//////////////////////////////////////////////////
23+
template <class T>
24+
struct ArrayDeleter
25+
{
26+
void operator () (T const * p)
27+
{
28+
delete [] p;
29+
}
30+
};
31+
2232
//////////////////////////////////////////////////
2333
Image::Image(unsigned int _width, unsigned int _height,
2434
PixelFormat _format) :
@@ -27,7 +37,7 @@ Image::Image(unsigned int _width, unsigned int _height,
2737
{
2838
this->format = PixelUtil::Sanitize(_format);
2939
unsigned int size = this->MemorySize();
30-
this->data = DataPtr(new unsigned char[size]);
40+
this->data = DataPtr(new unsigned char[size], ArrayDeleter<unsigned char>());
3141
}
3242

3343
//////////////////////////////////////////////////

test/integration/depth_camera.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ void DepthCameraTest::DepthCameraBoxes(
254254
unsigned int ma = *mrgba >> 0 & 0xFF;
255255
EXPECT_EQ(0u, mr);
256256
EXPECT_EQ(0u, mg);
257+
// Note: If it fails here, it may be this problem again:
258+
// https://github.com/ignitionrobotics/ign-rendering/issues/332
259+
#ifndef __APPLE__
257260
EXPECT_GT(mb, 0u);
261+
#endif
258262

259263
// Far left and right points should be red (background color)
260264
float lc = pointCloudData[pcLeft + 3];
@@ -453,7 +457,11 @@ void DepthCameraTest::DepthCameraBoxes(
453457
unsigned int a = *rgba >> 0 & 0xFF;
454458
EXPECT_EQ(0u, r);
455459
EXPECT_EQ(0u, g);
460+
// Note: If it fails here, it may be this problem again:
461+
// https://github.com/ignitionrobotics/ign-rendering/issues/332
462+
#ifndef __APPLE__
456463
EXPECT_GT(b, 0u);
464+
#endif
457465
EXPECT_EQ(255u, a);
458466
}
459467
}
@@ -762,20 +770,12 @@ void DepthCameraTest::DepthCameraParticles(
762770
ignition::rendering::unloadEngine(engine->Name());
763771
}
764772

765-
#ifdef __APPLE__
766-
TEST_P(DepthCameraTest, DISABLED_DepthCameraBoxes)
767-
#else
768773
TEST_P(DepthCameraTest, DepthCameraBoxes)
769-
#endif
770774
{
771775
DepthCameraBoxes(GetParam());
772776
}
773777

774-
#ifdef __APPLE__
775-
TEST_P(DepthCameraTest, DISABLED_DepthCameraParticles)
776-
#else
777778
TEST_P(DepthCameraTest, DepthCameraParticles)
778-
#endif
779779
{
780780
DepthCameraParticles(GetParam());
781781
}

0 commit comments

Comments
 (0)