Ejemplo n.º 1
0
	    public virtual void	GetBroadphaseAabb(ref Vector3 aabbMin,ref Vector3 aabbMax)
        {
	        DbvtAabbMm bounds = new DbvtAabbMm();

	        if(!m_sets[0].Empty())
            {
		        if(!m_sets[1].Empty())
                {
                    DbvtAabbMm.Merge(ref m_sets[0].m_root.volume,ref m_sets[1].m_root.volume,ref bounds);
                }
		        else
                {
			        bounds=m_sets[0].m_root.volume;
                }
            }
	        else if(!m_sets[1].Empty())
            {
                bounds=m_sets[1].m_root.volume;
            }
	        else
            {
                Vector3 temp = Vector3.Zero;
		        bounds=DbvtAabbMm.FromCR(ref temp,0);
            }
	        aabbMin=bounds.Mins();
	        aabbMax=bounds.Maxs();

        }
Ejemplo n.º 2
0
        //public static bool Intersect(ref DbvtAabbMm a, ref DbvtAabbMm b)
        //{
        //    Vector3 amin = a.Mins();
        //    Vector3 amax = a.Maxs();
        //    Vector3 bmin = b.Mins();
        //    Vector3 bmax = b.Maxs();
        //    return ((amin.X <= bmin.X) &&
        //        (amin.Y <= bmax.Y) &&
        //        (amin.Z <= bmax.Z) &&
        //        (amax.X >= bmin.X) &&
        //        (amax.Y >= bmin.Y) &&
        //        (amax.Z >= bmin.Z));
        //}



        //public static bool Intersect(ref DbvtAabbMm a, ref Vector3 b)
        //{
        //    Vector3 amin = a.Mins();
        //    Vector3 amax = a.Maxs();

        //    return ((b.X >= amin.X) &&
        //            (b.Y >= amin.Y) &&
        //            (b.Z >= amin.Z) &&
        //            (b.X <= amax.X) &&
        //            (b.Y <= amax.Y) &&
        //            (b.Z <= amax.Z));
        //}



        public static bool Intersect(ref DbvtAabbMm a, ref Vector3 org, ref Vector3 invdir, int[] signs)
        {
            Vector3 amin = a.Mins();
            Vector3 amax = a.Maxs();

            Vector3[] bounds = new Vector3[] { amin, amax };
            float txmin = (bounds[signs[0]].X - org.X) * invdir.X;
            float txmax = (bounds[1 - signs[0]].X - org.X) * invdir.X;
            float tymin = (bounds[signs[1]].Y - org.Y) * invdir.Y;
            float tymax = (bounds[1 - signs[1]].Y - org.Y) * invdir.Y;
            if ((txmin > tymax) || (tymin > txmax)) return (false);
            if (tymin > txmin) txmin = tymin;
            if (tymax < txmax) txmax = tymax;
            float tzmin = (bounds[signs[2]].Z - org.Z) * invdir.Z;
            float tzmax = (bounds[1 - signs[2]].Z - org.Z) * invdir.Z;
            if ((txmin > tzmax) || (tzmin > txmax)) return (false);
            if (tzmin > txmin) txmin = tzmin;
            if (tzmax < txmax) txmax = tzmax;
            return (txmax > 0);
        }