/****************************************************************************** libx42pp - skinned vertex animation library (C++ API) Copyright (C) 2007 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #include "local.h" namespace x42 { namespace geom { aabb aabb::operator | ( const vec3 &v ) const { aabb ret = *this; ret |= v; return ret; } aabb& aabb::operator |= ( const vec3 &v ) { if( is_empty() ) { mins = v; maxs = v; } else { mins = min( mins, v ); maxs = max( maxs, v ); } return *this; } aabb aabb::operator | ( const aabb &b ) const { aabb ret = *this; ret |= b; return ret; } aabb& aabb::operator |= ( const aabb &b ) { if( is_empty() ) { mins = b.mins; maxs = b.maxs; } else if( !b.is_empty() ) { mins = min( mins, b.mins ); maxs = max( maxs, b.maxs ); } //else *this = *this return *this; } aabb aabb::operator & ( const aabb &b ) const { aabb ret = *this; ret &= b; return ret; } aabb& aabb::operator &= ( const aabb &b ) { if( is_empty() || b.is_empty() ) { *this = aabb::empty(); } else { mins = max( mins, b.mins ); maxs = min( maxs, b.maxs ); } return *this; } bool aabb::is_empty( void ) const { return mins.x > maxs.x || mins.y > maxs.y || mins.z > maxs.z; } bool aabb::contains( const vec3 &v ) const { return (mins.x <= v.x && maxs.x >= v.x) && (mins.y <= v.y && maxs.y >= v.y) && (mins.z <= v.z && maxs.z >= v.z); } }; };