From 14730a89be3e2e517a88fde43b4f97cadd61bf48 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 Apr 2012 17:33:43 +0000 Subject: [PATCH] - changed calculation of soundorg for triangular sectors. In many cases the center of the bounding box won't be inside the sector but on one of the outer lines so something different is needed SVN r3517 (trunk) --- src/p_setup.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 3558e5af3..f38213d71 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3114,6 +3114,35 @@ static void P_GroupLines (bool buildmap) // set the soundorg to the middle of the bounding box sector->soundorg[0] = bbox.Right()/2 + bbox.Left()/2; sector->soundorg[1] = bbox.Top()/2 + bbox.Bottom()/2; + + // For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical + if (sector->linecount == 3) + { + vertex_t *Triangle[2]; + Triangle[0] = sector->lines[0]->v1; + Triangle[1] = sector->lines[0]->v2; + if (sector->linecount > 1) + { + fixed_t dx = Triangle[1]->x - Triangle[0]->x; + fixed_t dy = Triangle[1]->y - Triangle[0]->y; + // Find another point in the sector that does not lie + // on the same line as the first two points. + for (j = 0; j < 2; ++j) + { + vertex_t *v; + + v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2; + if (DMulScale32 (v->y - Triangle[0]->y, dx, + Triangle[0]->x - v->x, dy) != 0) + { + sector->soundorg[0] = Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3; + sector->soundorg[1] = Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3; + break; + } + } + } + } + } delete[] linesDoneInEachSector; times[3].Unclock();