#pragma once
#include "vec2.h"
#include "vec3.h"
namespace embree
{
namespace internal {
template <typename T> __forceinline T divideByTwo(const T& v) { … }
template <> __forceinline float divideByTwo<float>(const float& v) { … }
template <> __forceinline double divideByTwo<double>(const double& v) { … }
}
template<typename T>
struct BBox
{ … };
template<> __forceinline bool BBox<float>::empty() const { … }
#if defined(__SSE__) || defined(__ARM_NEON)
template<> __forceinline bool BBox<Vec3fa>::empty() const { … }
template<> __forceinline bool BBox<Vec3fx>::empty() const { … }
#endif
__forceinline bool isvalid( const BBox<Vec3fa>& v ) { … }
__forceinline bool isvalid_non_empty( const BBox<Vec3fa>& v ) { … }
__forceinline bool is_finite( const BBox<Vec3fa>& b) { … }
__forceinline bool inside ( const BBox<Vec3fa>& b, const Vec3fa& p ) { … }
template<typename T> __forceinline const T center2(const BBox<T>& box) { … }
template<typename T> __forceinline const T center (const BBox<T>& box) { … }
__forceinline float volume ( const BBox<Vec3fa>& b ) { … }
__forceinline float safeVolume( const BBox<Vec3fa>& b ) { … }
__forceinline float volume( const BBox<Vec3f>& b ) { … }
template<typename T> __forceinline const T area( const BBox<Vec2<T> >& b ) { … }
template<typename T> __forceinline const T halfArea( const BBox<Vec3<T> >& b ) { … }
template<typename T> __forceinline const T area( const BBox<Vec3<T> >& b ) { … }
__forceinline float halfArea( const BBox<Vec3fa>& b ) { … }
__forceinline float area( const BBox<Vec3fa>& b ) { … }
__forceinline float halfArea( const BBox<Vec3fx>& b ) { … }
__forceinline float area( const BBox<Vec3fx>& b ) { … }
template<typename Vec> __forceinline float safeArea( const BBox<Vec>& b ) { … }
template<typename T> __forceinline float expectedApproxHalfArea(const BBox<T>& box) { … }
template<typename T> __forceinline const BBox<T> merge( const BBox<T>& a, const T& b ) { … }
template<typename T> __forceinline const BBox<T> merge( const T& a, const BBox<T>& b ) { … }
template<typename T> __forceinline const BBox<T> merge( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline const BBox<T> merge( const BBox<T>& a, const BBox<T>& b, const BBox<T>& c ) { … }
template<typename T> __forceinline BBox<T> merge(const BBox<T>& a, const BBox<T>& b, const BBox<T>& c, const BBox<T>& d) { … }
template<typename T> __forceinline bool operator==( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline bool operator!=( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline BBox<T> operator *( const float& a, const BBox<T>& b ) { … }
template<typename T> __forceinline BBox<T> operator *( const T& a, const BBox<T>& b ) { … }
template<typename T> __forceinline BBox<T> operator +( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline BBox<T> operator -( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline BBox<T> operator +( const BBox<T>& a, const T & b ) { … }
template<typename T> __forceinline BBox<T> operator -( const BBox<T>& a, const T & b ) { … }
template<typename T> __forceinline BBox<T> enlarge(const BBox<T>& a, const T& b) { … }
template<typename T> __forceinline const BBox<T> intersect( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __forceinline const BBox<T> intersect( const BBox<T>& a, const BBox<T>& b, const BBox<T>& c ) { … }
template<typename T> __forceinline const BBox<T> intersect( const BBox<T>& a, const BBox<T>& b, const BBox<T>& c, const BBox<T>& d ) { … }
template<typename T> __forceinline void subtract(const BBox<T>& a, const BBox<T>& b, BBox<T>& c, BBox<T>& d)
{ … }
template<typename T> __inline bool disjoint( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __inline bool disjoint( const BBox<T>& a, const T& b ) { … }
template<typename T> __inline bool disjoint( const T& a, const BBox<T>& b ) { … }
template<typename T> __inline bool conjoint( const BBox<T>& a, const BBox<T>& b ) { … }
template<typename T> __inline bool conjoint( const BBox<T>& a, const T& b ) { … }
template<typename T> __inline bool conjoint( const T& a, const BBox<T>& b ) { … }
template<typename T> __inline bool subset( const BBox<T>& a, const BBox<T>& b )
{ … }
template<> __inline bool subset( const BBox<Vec3fa>& a, const BBox<Vec3fa>& b ) { … }
template<> __inline bool subset( const BBox<Vec3fx>& a, const BBox<Vec3fx>& b ) { … }
template<typename T>
__forceinline BBox<T> lerp(const BBox<T>& b0, const BBox<T>& b1, const float t) { … }
template<typename T> __forceinline embree_ostream operator<<(embree_ostream cout, const BBox<T>& box) { … }
BBox1f;
BBox2f;
BBox2fa;
BBox3f;
BBox3fa;
BBox3fx;
BBox3ff;
}
#if defined (__SSE__) || defined(__ARM_NEON)
#include "../simd/sse.h"
#endif
#if defined (__AVX__)
#include "../simd/avx.h"
#endif
#if defined(__AVX512F__)
#include "../simd/avx512.h"
#endif
namespace embree
{
template<int N>
__forceinline BBox<Vec3<vfloat<N>>> transpose(const BBox3fa* bounds);
template<>
__forceinline BBox<Vec3<vfloat4>> transpose<4>(const BBox3fa* bounds)
{ … }
#if defined(__AVX__)
template<>
__forceinline BBox<Vec3<vfloat8>> transpose<8>(const BBox3fa* bounds)
{
BBox<Vec3<vfloat8>> dest;
transpose((vfloat4&)bounds[0].lower,
(vfloat4&)bounds[1].lower,
(vfloat4&)bounds[2].lower,
(vfloat4&)bounds[3].lower,
(vfloat4&)bounds[4].lower,
(vfloat4&)bounds[5].lower,
(vfloat4&)bounds[6].lower,
(vfloat4&)bounds[7].lower,
dest.lower.x,
dest.lower.y,
dest.lower.z);
transpose((vfloat4&)bounds[0].upper,
(vfloat4&)bounds[1].upper,
(vfloat4&)bounds[2].upper,
(vfloat4&)bounds[3].upper,
(vfloat4&)bounds[4].upper,
(vfloat4&)bounds[5].upper,
(vfloat4&)bounds[6].upper,
(vfloat4&)bounds[7].upper,
dest.upper.x,
dest.upper.y,
dest.upper.z);
return dest;
}
#endif
template<int N>
__forceinline BBox3fa merge(const BBox3fa* bounds);
template<>
__forceinline BBox3fa merge<4>(const BBox3fa* bounds)
{ … }
#if defined(__AVX__)
template<>
__forceinline BBox3fa merge<8>(const BBox3fa* bounds)
{
const Vec3fa lower = min(min(min(bounds[0].lower,bounds[1].lower),min(bounds[2].lower,bounds[3].lower)),
min(min(bounds[4].lower,bounds[5].lower),min(bounds[6].lower,bounds[7].lower)));
const Vec3fa upper = max(max(max(bounds[0].upper,bounds[1].upper),max(bounds[2].upper,bounds[3].upper)),
max(max(bounds[4].upper,bounds[5].upper),max(bounds[6].upper,bounds[7].upper)));
return BBox3fa(lower,upper);
}
#endif
}