Exemple #1
0
        private List <GameObjectRayHit> GetObjectRayHitInstances()
        {
            Ray ray            = GetWorldRay();
            var gameObjectHits = new List <GameObjectRayHit>();

            RaycastAllTerrainObjects(ray, gameObjectHits);
            RaycastAllObjectsNoTerrains(ray, gameObjectHits);

            ObjectMask activeObjectMask = ObjectMask;

            if (activeObjectMask != null && IsObjectMaskEnabled)
            {
                gameObjectHits.RemoveAll(item => activeObjectMask.IsGameObjectMasked(item.HitObject));
            }
            gameObjectHits.RemoveAll(item => !item.HitObject.activeSelf);

            SortObjectRayHitListByHitDistanceFromCamera(gameObjectHits);

            Vector3 cameraLook = SceneViewCamera.Camera.transform.forward;

            while (gameObjectHits.Count > 0)
            {
                if (gameObjectHits[0].WasBoxHit && gameObjectHits[0].HitObject.HasMesh())
                {
                    GameObjectRayHit meshHit;
                    if (gameObjectHits[0].HitObject.RaycastMesh(ray, out meshHit))
                    {
                        float dot = Vector3.Dot(meshHit.HitNormal, cameraLook);
                        if (dot > 0.0f)
                        {
                            gameObjectHits.RemoveAt(0);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    float dot = Vector3.Dot(gameObjectHits[0].HitNormal, cameraLook);
                    if (dot > 0.0f)
                    {
                        gameObjectHits.RemoveAt(0);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(gameObjectHits);
        }
        public void AcquireCursorRayHit(ObjectMask objectMask, MouseCursorObjectPickFlags cursorPickMaskFlags)
        {
            MouseCursor.Instance.PushObjectMask(objectMask);
            MouseCursor.Instance.PushObjectPickMaskFlags(cursorPickMaskFlags);

            _cursorRayHit = MouseCursor.Instance.GetRayHit();

            MouseCursor.Instance.PopObjectMask();
            MouseCursor.Instance.PopObjectPickMaskFlags();
        }
Exemple #3
0
        private List <GameObjectRayHit> GetObjectRayHitInstances()
        {
            Ray ray            = GetWorldRay();
            var gameObjectHits = new List <GameObjectRayHit>();

            RaycastAllTerrainObjects(ray, gameObjectHits);
            RaycastAllObjectsNoTerrains(ray, gameObjectHits);

            ObjectMask activeObjectMask = ObjectMask;

            if (activeObjectMask != null && IsObjectMaskEnabled)
            {
                gameObjectHits.RemoveAll(item => activeObjectMask.IsGameObjectMasked(item.HitObject));
            }
            gameObjectHits.RemoveAll(item => !item.HitObject.activeSelf);

            SortObjectRayHitListByHitDistanceFromCamera(gameObjectHits);

            return(gameObjectHits);
        }
        private GameObjectRayHit FindClosestHitObjectWhichCanBeUsedAsPaintSurface(MouseCursorRayHit cursorRayHit)
        {
            ObjectMask decorPaintMask = DecorPaintObjectPlacement.Get().DecorPaintMask;

            List <GameObjectRayHit> gameObjectHits = cursorRayHit.SortedObjectRayHits;

            for (int hitIndex = 0; hitIndex < gameObjectHits.Count; ++hitIndex)
            {
                GameObject hitObject = gameObjectHits[hitIndex].HitObject;

                if (!hitObject.HasMesh() && !hitObject.HasTerrain() && !hitObject.IsSprite())
                {
                    continue;
                }
                if (decorPaintMask.IsGameObjectMasked(hitObject))
                {
                    continue;
                }

                return(gameObjectHits[hitIndex]);
            }

            return(null);
        }
        private GameObjectRayHit FindClosestHitObjectWhichCanBeUsedAsSnapSurface(MouseCursorRayHit cursorRayHit)
        {
            ObjectMask objectSnapMask = ObjectSnapping.Get().ObjectSnapMask;

            List <GameObjectRayHit> gameObjectHits = cursorRayHit.SortedObjectRayHits;

            for (int hitIndex = 0; hitIndex < gameObjectHits.Count; ++hitIndex)
            {
                GameObject hitObject = gameObjectHits[hitIndex].HitObject;

                if (!hitObject.HasMesh())
                {
                    continue;
                }
                if (objectSnapMask.IsGameObjectMasked(hitObject))
                {
                    continue;
                }

                return(gameObjectHits[hitIndex]);
            }

            return(null);
        }
Exemple #6
0
 public ObjectMaskView(ObjectMask mask)
 {
     _mask = mask;
 }
Exemple #7
0
 public void PushObjectMask(ObjectMask objectMask)
 {
     _objectMaskStack.Push(objectMask);
 }