/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #ifndef CRYINCLUDE_CRYAISYSTEM_NAVIGATION_MNM_FIXEDAABB_H #define CRYINCLUDE_CRYAISYSTEM_NAVIGATION_MNM_FIXEDAABB_H #pragma once namespace MNM { template struct FixedAABB { typedef FixedVec3 value_type; value_type min; value_type max; struct init_empty {}; inline FixedAABB() { } inline FixedAABB(const init_empty&) : min(value_type::value_type::max()) , max(value_type::value_type::min()) { } inline FixedAABB(const value_type& _min, const value_type& _max) : min(_min) , max(_max) { } template inline FixedAABB(const FixedAABB& other) : min(value_type(other.min)) , max(value_type(other.max)) { } bool empty() const { return min.x > max.x; } value_type size() const { return (max - min).abs(); } value_type center() const { return (max + min) * value_type::value_type::fraction(1, 2); } template bool overlaps(const FixedAABB& other) { if ((min.x > typename value_type::value_type(other.max.x)) || (min.y > typename value_type::value_type(other.max.y)) || (min.z > typename value_type::value_type(other.max.z)) || (max.x < typename value_type::value_type(other.min.x)) || (max.y < typename value_type::value_type(other.min.y)) || (max.z < typename value_type::value_type(other.min.z))) { return false; } return true; } template inline FixedAABB& operator+=(const FixedVec3& other) { min = value_type::minimize(min, other); max = value_type::maximize(max, other); return *this; } template inline FixedAABB operator+(const FixedVec3& other) const { FixedAABB r(*this); r += other; return r; } template inline FixedAABB& operator+=(const FixedAABB& other) { min = value_type::minimize(min, other.min); max = value_type::maximize(max, other.max); return *this; } template inline FixedAABB operator+(const FixedAABB& other) const { FixedAABB r(*this); r += other; return r; } template inline FixedAABB& operator*=(const fixed_t& x) { min *= x; max *= x; return *this; } template inline FixedAABB operator*(const fixed_t& other) const { FixedAABB r(*this); r *= other; return r; } AUTO_STRUCT_INFO }; } #endif // CRYINCLUDE_CRYAISYSTEM_NAVIGATION_MNM_FIXEDAABB_H