From a6a10509463a42513e1f4e5f88abe3dfb4c4ceb3 Mon Sep 17 00:00:00 2001 From: Alfredo Tupone Date: Wed, 1 May 2024 16:23:24 +0200 Subject: [PATCH] Another divide by zero avoided --- src/geometry/WallSceneNode.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/geometry/WallSceneNode.cxx b/src/geometry/WallSceneNode.cxx index fd04fd35db..d1a350b788 100644 --- a/src/geometry/WallSceneNode.cxx +++ b/src/geometry/WallSceneNode.cxx @@ -75,10 +75,14 @@ void WallSceneNode::setNumLODs(int num, float* areas) void WallSceneNode::setPlane(const GLfloat _plane[4]) { - // get normalization factor - const float n = 1.0f / sqrtf((_plane[0] * _plane[0]) + - (_plane[1] * _plane[1]) + - (_plane[2] * _plane[2])); + float n = 1.0f; + if (_plane[0] || _plane[1] || _plane[2]) + { + // get normalization factor + n = 1.0f / sqrtf((_plane[0] * _plane[0]) + + (_plane[1] * _plane[1]) + + (_plane[2] * _plane[2])); + } // store normalized plane equation plane[0] = n * _plane[0];