コード例 #1
0
ファイル: Box.cs プロジェクト: kf6kjg/halcyon
        bool Intersects(Box other)
        {
            float test, test2;
            
            test = this.Center.X - (this.Size.X / 2.0f);
            test2 = other.Center.X - (other.Size.X / 2.0f);
            if ((test+Size.X < test2) || (test > test2+other.Size.X))
                return false;

            test = this.Center.Y - (this.Size.Y / 2.0f);
            test2 = other.Center.Y - (other.Size.Y / 2.0f);
            if ((test+Size.Y < test2) || (test > test2+other.Size.Y))
                return false;

            test = this.Center.Z - (this.Size.Z / 2.0f);
            test2 = other.Center.Z - (other.Size.Z / 2.0f);
            if ((test+Size.Z < test2) || (test > test2+other.Size.Z))
                return false;

            return true;
        }
コード例 #2
0
ファイル: Box.cs プロジェクト: kf6kjg/halcyon
 public Box(Box other)
 {
     _center = other._center;
     _size = other._size;
     _rotation = other._rotation;
 }
コード例 #3
0
        public bool IsAtTarget(Vector3 target, float tolerance)
        {
            Box shell = this.GetBoundingBox(false);
            Vector3 size = shell.Size;
            size.X += tolerance;
            size.Y += tolerance;
            size.Z += tolerance;
            shell = new Box(shell.Center, size);

            return shell.ContainsPoint(target);
        }
コード例 #4
0
ファイル: SceneObjectGroup.cs プロジェクト: zwagoth/halcyon
        private Box CalculateBoundingBox()
        {
            // This method always recalcs the BB. To use the cached version, call BoundingBox.
            Box returnBox;
            List<Box> boundingBoxes = new List<Box>();
            // lock m_parts and then _bbLock (leaf) when needed
            lock (m_parts)
            {
                PhysicsActor physActor = m_rootPart.PhysActor;
                if ((physActor != null) && (physActor.IsPhysical))
                {
                    // For physical objects, save the pos/rot used for BB calc.
                    _bbPos = physActor.Position;
                    _bbRot = physActor.Rotation;
                }
                foreach (SceneObjectPart part in m_parts.Values)
                {
                    boundingBoxes.Add(part.BoundingBox);
                }

                lock (_bbLock)
                {
                    // update _calculatedBoundingBox inside the lock
                    _calculatedBoundingBox = Box.CalculateBoundingBox(boundingBoxes);
                    returnBox = _calculatedBoundingBox;
                }
            }
            return returnBox;
        }
コード例 #5
0
ファイル: SceneObjectGroup.cs プロジェクト: zwagoth/halcyon
 public void ClearBoundingBoxCache()
 {
     lock (_bbLock)
     {
         _calculatedBoundingBox = null;
     }
 }
コード例 #6
0
ファイル: SceneObjectGroup.cs プロジェクト: kf6kjg/halcyon
        private Box CalculateBoundingBox()
        {
            // This method always recalcs the BB. To use the cached version, call BoundingBox.
            Box returnBox;
            List<Box> boundingBoxes = new List<Box>();

            PhysicsActor physActor = m_rootPart.PhysActor;
            if ((physActor != null) && (physActor.IsPhysical))
            {
                // For physical objects, save the pos/rot used for BB calc.
                _bbPos = physActor.Position;
                _bbRot = physActor.Rotation;
            }

            m_childParts.ForEachPart((SceneObjectPart part) => {
                boundingBoxes.Add(part.BoundingBox);
            });

            lock (_bbLock)
            {
                // update _calculatedBoundingBox inside the lock
                _calculatedBoundingBox = Box.CalculateBoundingBox(boundingBoxes);
                returnBox = _calculatedBoundingBox;
            }
            
            return returnBox;
        }