Link Copied
typedef uint32 OcclStackItem;
struct StackItem
{
/*! Copy operator */
StackItem& operator=(const StackItem& other) { all = other.all; return *this; }
/*! Sort a stack item by distance. */
static __forceinline void sort(StackItem& a, StackItem& b) { if (a.all < b.all) std::swap(a,b); }
union {
struct { uint32 ofs; float dist; };
int64 all;
};
};
/*! Sort 3 stack items. */
__forceinline void sort(StackItem& a, StackItem& b, StackItem& c)
{
int64 s1 = a.all;
int64 s2 = b.all;
int64 s3 = c.all;
if (s2 < s1) std::swap(s2,s1);
if (s3 < s2) std::swap(s3,s2);
if (s2 < s1) std::swap(s2,s1);
a.all = s1;
b.all = s2;
c.all = s3;
}
/*! Sort 4 stack items. */
__forceinline void sort(StackItem& a, StackItem& b, StackItem& c, StackItem& d)
{
int64 s1 = a.all;
int64 s2 = b.all;
int64 s3 = c.all;
int64 s4 = d.all;
if (s2 < s1) std::swap(s2,s1);
if (s4 < s3) std::swap(s4,s3);
if (s3 < s1) std::swap(s3,s1);
if (s4 < s2) std::swap(s4,s2);
if (s3 < s2) std::swap(s3,s2);
a.all = s1;
b.all = s2;
c.all = s3;
d.all = s4;
}
For more complete information about compiler optimizations, see our Optimization Notice.