Exemplo n.º 1
0
        protected override void CalculateDragValues()
        {
            Camera focusCamera = RTFocusCamera.Get.TargetCamera;

            _relativeDragOffset = Vector3.zero;

            if (_destinationObjects.Count != 0 && _settings.CanSnapToObjectVerts)
            {
                Vector3 worldDestPos;
                if (GetWorldPointClosestToInputDevice(focusCamera, _destinationObjects, out worldDestPos))
                {
                    _relativeDragOffset = worldDestPos - _snapPivot;
                }
            }
            else
            if (_settings.CanSnapToGrid)
            {
                Ray          ray     = RTInputDevice.Get.Device.GetRay(focusCamera);
                XZGridRayHit gridHit = RTScene.Get.RaycastSceneGridIfVisible(ray);
                if (gridHit != null)
                {
                    XZGridCell     gridCell          = RTSceneGrid.Get.CellFromWorldPoint(gridHit.HitPoint);
                    List <Vector3> centersAndCorners = gridCell.GetCenterAndCorners();
                    int            closestPtIndex    = Vector3Ex.GetPointClosestToPoint(centersAndCorners, gridHit.HitPoint);
                    if (closestPtIndex >= 0)
                    {
                        _relativeDragOffset = centersAndCorners[closestPtIndex] - _snapPivot;
                    }
                }
            }

            _snapPivot       += _relativeDragOffset;
            _totalDragOffset += _relativeDragOffset;
        }
Exemplo n.º 2
0
        public SceneRaycastHit Raycast(Ray ray, SceneRaycastPrecision rtRaycastPrecision, SceneRaycastFilter raycastFilter)
        {
            List <GameObjectRayHit> allObjectHits    = RaycastAllObjectsSorted(ray, rtRaycastPrecision, raycastFilter);
            GameObjectRayHit        closestObjectHit = allObjectHits.Count != 0 ? allObjectHits[0] : null;
            XZGridRayHit            gridRayHit       = RaycastSceneGridIfVisible(ray);

            return(new SceneRaycastHit(closestObjectHit, gridRayHit));
        }
        public SceneRaycastHit Raycast(Ray ray, SceneRaycastPrecision rtRaycastPrecision, SceneRaycastFilter raycastFilter)
        {
            RaycastAllObjectsSorted(ray, rtRaycastPrecision, raycastFilter, _objectHitBuffer);
            GameObjectRayHit closestObjectHit = _objectHitBuffer.Count != 0 ? _objectHitBuffer[0] : null;
            XZGridRayHit     gridRayHit       = RaycastSceneGridIfVisible(ray);

            return(new SceneRaycastHit(closestObjectHit, gridRayHit));
        }
Exemplo n.º 4
0
 public SceneRaycastHit(GameObjectRayHit objectRayHit, XZGridRayHit gridRayHit)
 {
     _objectHit = objectRayHit;
     _gridHit   = gridRayHit;
 }