static UShortVector3 ReadUShortVector3(BinaryReader br)
        {
            var vec = new UShortVector3();

            vec.X = br.ReadUInt16();
            vec.Y = br.ReadUInt16();
            vec.Z = br.ReadUInt16();
            return(vec);
        }
        public static IndexedVector3 Unquantize(
            ref UShortVector3 vecIn,
            ref IndexedVector3 offset,
            ref IndexedVector3 bvhQuantization)
        {
            IndexedVector3 vecOut = new IndexedVector3(
                (float)(vecIn[0]) / (bvhQuantization.X),
                (float)(vecIn[1]) / (bvhQuantization.Y),
                (float)(vecIn[2]) / (bvhQuantization.Z));

            vecOut += offset;
            return(vecOut);
        }
Beispiel #3
0
 public bool TestQuantizedBoxOverlapp(ref UShortVector3 quantizedMin, ref UShortVector3 quantizedMax)
 {
     if (m_quantizedAabbMin.X > quantizedMax.X ||
         m_quantizedAabbMax.X < quantizedMin.X ||
         m_quantizedAabbMin.Y > quantizedMax.Y ||
         m_quantizedAabbMax.Y < quantizedMin.Y ||
         m_quantizedAabbMin.Z > quantizedMax.Z ||
         m_quantizedAabbMax.Z < quantizedMin.Z)
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        //This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360)
        public static bool TestQuantizedAabbAgainstQuantizedAabb(ref UShortVector3 aabbMin1, ref UShortVector3 aabbMax1, ref UShortVector3 aabbMin2, ref UShortVector3 aabbMax2)
        {
            //return ((aabbMin1[0] <= aabbMax2[0]) && (aabbMax1[0] >= aabbMin2[0])
            //    & (aabbMin1[2] <= aabbMax2[2]) && (aabbMax1[2] >= aabbMin2[2])
            //    & (aabbMin1[1] <= aabbMax2[1]) && (aabbMax1[1] >= aabbMin2[1]));
            //return (MathUtil.select(val,1, 0));

            // MAN - Not sure why this version isn't just replaced by anding all of the above, it's still not conditional as theres a quick ref.
            bool overlap = true;

            overlap = (aabbMin1.X > aabbMax2.X || aabbMax1.X < aabbMin2.X) ? false : overlap;
            overlap = (aabbMin1.Z > aabbMax2.Z || aabbMax1.Z < aabbMin2.Z) ? false : overlap;
            overlap = (aabbMin1.Y > aabbMax2.Y || aabbMax1.Y < aabbMin2.Y) ? false : overlap;
            return(overlap);
        }
        public static void QuantizeClamp(out UShortVector3 output,
                                         ref IndexedVector3 point,
                                         ref IndexedVector3 min_bound,
                                         ref IndexedVector3 max_bound,
                                         ref IndexedVector3 bvhQuantization)
        {
            IndexedVector3 clampedPoint = point;

            MathUtil.VectorMax(ref min_bound, ref clampedPoint);
            MathUtil.VectorMin(ref max_bound, ref clampedPoint);

            IndexedVector3 v = (clampedPoint - min_bound) * bvhQuantization;

            output    = new UShortVector3();
            output[0] = (ushort)(v.X + 0.5f);
            output[1] = (ushort)(v.Y + 0.5f);
            output[2] = (ushort)(v.Z + 0.5f);
        }
Beispiel #6
0
 public bool TestQuantizedBoxOverlap(int node_index, ref UShortVector3 quantizedMin, ref UShortVector3 quantizedMax)
 {
     return(m_node_array[node_index].TestQuantizedBoxOverlapp(ref quantizedMin, ref quantizedMax));
 }
Beispiel #7
0
 public void QuantizePoint(out UShortVector3 quantizedpoint, ref IndexedVector3 point)
 {
     GImpactQuantization.QuantizeClamp(out quantizedpoint, ref point, ref m_global_bound.m_min, ref m_global_bound.m_max, ref m_bvhQuantization);
 }
Beispiel #8
0
 public void max(ref UShortVector3 a)
 {
     if (X < a.X) X = a.X;
     if (Y < a.Y) Y = a.Y;
     if (Z < a.Z) Z = a.Z;
 }
Beispiel #9
0
 public void min(ref UShortVector3 a)
 {
     if (X > a.X) X = a.X;
     if (Y > a.Y) Y = a.Y;
     if (Z > a.Z) Z = a.Z;
 }
 static void WriteUShortVector3(UShortVector3 vector, BinaryWriter bw)
 {
     bw.Write(vector.X);
     bw.Write(vector.Y);
     bw.Write(vector.Z);
 }