From e87a67194205c61298188d1c4a100210dc6d93b0 Mon Sep 17 00:00:00 2001 From: Fahim Imaduddin Dalvi Date: Mon, 17 Jan 2022 22:13:38 +0300 Subject: [PATCH] WS20: Object mask bug fix for random lights The random lights placement algorithm was using the incorrect channel from the object mask image, (red instead of blue as mentioned in Docs/README.materials). This commit rectifies the mismatch. --- simgear/scene/tgdb/SGNodeTriangles.hxx | 4 ++-- simgear/scene/tgdb/SGTexturedTriangleBin.hxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/simgear/scene/tgdb/SGNodeTriangles.hxx b/simgear/scene/tgdb/SGNodeTriangles.hxx index 128b242d..799240b0 100644 --- a/simgear/scene/tgdb/SGNodeTriangles.hxx +++ b/simgear/scene/tgdb/SGNodeTriangles.hxx @@ -267,12 +267,12 @@ public: SGVec2f texCoord = a*t0 + b*t1 + c*t2; // Check this random point against the object mask - // red channel. + // blue channel. osg::Image* img = object_mask->getImage(); unsigned int x = (int) (img->s() * texCoord.x()) % img->s(); unsigned int y = (int) (img->t() * texCoord.y()) % img->t(); - if (mt_rand(&seed) < img->getColor(x, y).r()) { + if (mt_rand(&seed) < img->getColor(x, y).b()) { points.push_back(randomPoint); } } else { diff --git a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx index b39ead0a..bdf33eec 100644 --- a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx +++ b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx @@ -192,12 +192,12 @@ public: SGVec2f texCoord = a*t0 + b*t1 + c*t2; // Check this random point against the object mask - // red channel. + // blue channel. osg::Image* img = object_mask->getImage(); unsigned int x = (int) (img->s() * texCoord.x()) % img->s(); unsigned int y = (int) (img->t() * texCoord.y()) % img->t(); - if (mt_rand(&seed) < img->getColor(x, y).r()) { + if (mt_rand(&seed) < img->getColor(x, y).b()) { points.push_back(randomPoint); } } else {