Skip to content

Commit 2a9282a

Browse files
author
stgatilov
committed
#6557. Fixed incorrect implementation of idBox::PlaneDistance and PlaneSide.
They used to ignore coordinate system / matrix of the oriented box. Now it is used to transform the plane normal. git-svn-id: http://svn.thedarkmod.com/svn/darkmod_src/trunk@10826 49c82d7f-2e2a-0410-a16f-ae8f201b507f
1 parent 43cb0b1 commit 2a9282a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

idlib/bv/Box.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,14 @@ idBox::PlaneDistance
324324
================
325325
*/
326326
float idBox::PlaneDistance( const idPlane &plane ) const {
327-
float d1, d2;
327+
idVec3 localNormal( plane.Normal() * axis[0], plane.Normal() * axis[1], plane.Normal() * axis[2] );
328328

329-
d1 = plane.Distance( center );
330-
d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
331-
idMath::Fabs( extents[1] * plane.Normal()[1] ) +
332-
idMath::Fabs( extents[2] * plane.Normal()[2] );
329+
float d1 = plane.Distance( center );
330+
float d2 = (
331+
idMath::Fabs( extents.x * localNormal.x ) +
332+
idMath::Fabs( extents.y * localNormal.y ) +
333+
idMath::Fabs( extents.z * localNormal.z )
334+
);
333335

334336
if ( d1 - d2 > 0.0f ) {
335337
return d1 - d2;
@@ -346,12 +348,14 @@ idBox::PlaneSide
346348
================
347349
*/
348350
int idBox::PlaneSide( const idPlane &plane, const float epsilon ) const {
349-
float d1, d2;
350-
351-
d1 = plane.Distance( center );
352-
d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
353-
idMath::Fabs( extents[1] * plane.Normal()[1] ) +
354-
idMath::Fabs( extents[2] * plane.Normal()[2] );
351+
idVec3 localNormal( plane.Normal() * axis[0], plane.Normal() * axis[1], plane.Normal() * axis[2] );
352+
353+
float d1 = plane.Distance( center );
354+
float d2 = (
355+
idMath::Fabs( extents.x * localNormal.x ) +
356+
idMath::Fabs( extents.y * localNormal.y ) +
357+
idMath::Fabs( extents.z * localNormal.z )
358+
);
355359

356360
if ( d1 - d2 > epsilon ) {
357361
return PLANESIDE_FRONT;

0 commit comments

Comments
 (0)