Exemplo n.º 1
0
        public IActionResult Login(string code, string pwd)
        {
            #region https://www.cnblogs.com/wyt007/p/11459547.html
            //User loginUser = TemporaryData.GetUser(code);
            //if (null != loginUser && loginUser.Password.Equals(pwd))
            //{
            //    return Ok(tokenHelper.CreateToken(user));
            //}
            //return BadRequest();
            #endregion

            #region MyRegion
            User loginUser = TemporaryData.GetUser(code);

            //这里应该是需要去连接数据库做数据校验,为了方便所有用户名和密码写死了
            if (null != loginUser && loginUser.Password.Equals(pwd))//应该数据库
            {
                //var _role = loginUser.rool;//可以从数据库获取角色
                Token token = _iJWTService.GetToken(loginUser);
                return(new JsonResult(new
                {
                    result = true,
                    token
                }));
            }

            return(Unauthorized("Not Register!!!"));

            #endregion
        }
Exemplo n.º 2
0
 public async Task OnStart(string username, string tech, List <string> concepts)
 {
     temp = new TemporaryData(tech, concepts);
     methods.OnStart(temp, username);
     methods.GetQuestionsBatch(username, tech, concepts);
     await Clients.Caller.SendAsync("Temporary Object Created");
 }
Exemplo n.º 3
0
        public override void Rollback()
        {
            Data = Memo;
            Memo = Clone();

            //回退需要取消掉被刷新过的内容
            using (var transaction = new Transaction(Storage, nameof(MemorableDetail) + nameof(Rollback)))
            {
                transaction.Start();
                try
                {
                    for (int i = TemporaryData.Count() - 1; i >= 0; i--)
                    {
                        var data      = TemporaryData[i];
                        var element   = Storage.GetElement(new ElementId(data.ElementId));
                        var parameter = element.GetParameters(data.ParameterName).First();
                        parameter.Set(data.ParameterValue);
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.RollBack();
                    throw new NotImplementedException(ex.Message);
                }
            }
        }
Exemplo n.º 4
0
        public IActionResult Get(string code, string pwd)
        {
            var user = TemporaryData.GetUser(code);

            if (user != null && user.Password == pwd)
            {
                return(Ok(tokenHelper.CreateToken(user)));
            }
            return(BadRequest());
        }
        public IActionResult Get(string code, string pwd)
        {
            User user = TemporaryData.GetUser(code);

            if (null != user && user.Password.Equals(pwd))
            {
                return(Ok(tokenHelper.CreateToken(user)));
            }
            return(BadRequest());
        }
Exemplo n.º 6
0
        public IActionResult Get(string code, string psw)
        {
            var user = TemporaryData.GetUser(code, psw);

            if (user != null)
            {
                return(new JsonResult(tokenHelper.GetToken(user)));
            }
            return(BadRequest());
        }
Exemplo n.º 7
0
    private void Awake()
    {
        if (isSecretSkin)
        {
            if (PersistentData.VirusSkin.SecretSkin.IsUnlocked())
            {
                PersistentData.VirusSkin.Unlock(skinNumber);

                foreach (GameObject gameObject in classIcons)
                {
                    gameObject.SetActive(true);
                }

                for (int i = 0; i <= 1; i++)
                {
                    snakeSprites[i] = secretVirusSkin[i];
                }

                buttonIcon.sprite = secretVirusSkin[2];
            }
        }

        if (skinNumber != 0)
        {
            isBought = PersistentData.VirusSkin.IsUnlocked(skinNumber);
        }

        if (PersistentData.VirusSkin.CurrentSelectedSkin.Get() == skinNumber)
        {
            selectIcon.enabled = true;
            TemporaryData.SetSnakeSkin(this);
        }

        costText.text = cost.ToString();

        if (isBought)
        {
            costGameObject.SetActive(false);
            skinMaxLevel.SetActive(true);

            lockIcon.enabled = false;

            skinMaxLevelInt = PersistentData.VirusSkin.Level.Get(skinNumber);

            skinMaxLevel.GetComponentInChildren <Text>().text = skinMaxLevelInt.ToString();
        }

        else
        {
            skinMaxLevel.SetActive(false);
            lockIcon.enabled = true;
        }
    }
Exemplo n.º 8
0
        public Token RefreshToken(ClaimsPrincipal claimsPrincipal)
        {
            var code = claimsPrincipal.Claims.FirstOrDefault(m => m.Type.Equals(ClaimTypes.NameIdentifier));

            if (null != code)
            {
                return(CreateAccessToken(TemporaryData.GetUser(code.Value.ToString())));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
    // Generate mesh and return the map world minimum pos for info
    public Vector2 GenerateMesh(byte[,] map, float squareSize)
    {
        GetReferences();
        tempData = new TemporaryData();

        tempData.mapSquareSize = squareSize;
        SquareGrid squareGrid = new SquareGrid(map, squareSize);
        int        width      = squareGrid.squares.GetLength(0);
        int        height     = squareGrid.squares.GetLength(1);

        int   nodesX         = map.GetLength(0);
        int   nodesY         = map.GetLength(1);
        float halfSquareSize = squareSize * 0.5f;
        float mapXstart      = -squareSize * nodesX * 0.5f + halfSquareSize;
        float mapYstart      = -squareSize * nodesY * 0.5f + halfSquareSize;

        tempData.mapWorldMin = new Vector2(mapXstart, mapYstart);
        tempData.mapWorldMax = new Vector2((width - 1) * squareSize + mapXstart, (height - 1) * squareSize + mapYstart);

        // estimate min capacity required
        // vertices are shared but also along midpoints, max 5 unique, min 2
        tempData.vertices = new List <Vector3>(width * height * 3);
        // 2 triangles average?
        tempData.triangles = new List <int>(width * height * 6);
        // Vertices -> triangle map same capacity as vertices
        tempData.vertexEdgeNeighbourMap = new Dictionary <int, int>(tempData.vertices.Capacity);
        tempData.verticesOutlineDone    = new List <bool>(tempData.vertices.Capacity);


        TriangulateGrid(squareGrid);
        ExpandBoundaryVertices();

        Mesh mesh = new Mesh();

        mesh.vertices  = tempData.vertices.ToArray();
        mesh.triangles = tempData.triangles.ToArray();
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            Undo.RecordObject(meshFilter, "Change mesh");
        }
#endif
        meshFilter.mesh = mesh;

        CreateEdges();

        Vector2 ret = tempData.mapWorldMin;
        // Free temp data
        tempData = null;
        return(ret);
    }
Exemplo n.º 10
0
        private static Cluster CalculateNdviInnerForTemporaryData(TemporaryData currentTemporaryData, int row, int col)
        {
            var currentValues = new[]
            {
                currentTemporaryData.Buffers.Channels[Landsat8Channel.Channel4][row, col],
                currentTemporaryData.Buffers.Channels[Landsat8Channel.Channel5][row, col]
            };

            var perfectCluster = currentTemporaryData.Clusters
                                 .OrderBy(z => MathHelper.EuclideanDistance(currentValues, z.CenterCluster))
                                 .First();

            return(perfectCluster);
        }
Exemplo n.º 11
0
    //private void Start()
    //{
    //if (LvlSkin && prevSkinLvl.isBought == false)
    //{
    //    lockIcon.enabled = true;
    //    costGameObject.SetActive(false);
    //}
    //}

    public void SetSprites()
    {
        shopPanel.preview.ShowSkinOnPreviewTable(this);

        if (!isBought && isSelected)
        {
            //if (LvlSkin)
            //{
            //    if (prevSkinLvl.isBought)
            //        SellSkin();

            //    else
            //        prevSkinLvl.SingOnCost();
            //}

            //else
            //{
            SellSkin();
            //}
        }

        shopPanel.UpdateCurrentSelectedButton(this);

        if (isBought)
        {
            TemporaryData.SetSnakeSkin(this);

            selectEvent.Invoke();

            TemporaryData.IsSecretSkinSelected = isSecretSkin ? true : false;

            FindObjectOfType <MainMenuVirus>().UpdateSprites(this);

            switch (modificationType)
            {
            case ModificationType.None:
                TemporaryData.IsSpeedButtonEnabled           = false;
                TemporaryData.IsSplashButtonEnabled          = false;
                TemporaryData.IsSplashAndSpeedButtonsEnabled = false;
                break;

            case ModificationType.Splash:
                TemporaryData.IsSpeedButtonEnabled           = false;
                TemporaryData.IsSplashButtonEnabled          = true;
                TemporaryData.IsSplashAndSpeedButtonsEnabled = false;
                break;

            case ModificationType.SpeedUp:
                TemporaryData.IsSpeedButtonEnabled           = true;
                TemporaryData.IsSplashButtonEnabled          = false;
                TemporaryData.IsSplashAndSpeedButtonsEnabled = false;
                break;

            case ModificationType.SplashAndSpeedUp:
                TemporaryData.IsSpeedButtonEnabled           = false;
                TemporaryData.IsSplashButtonEnabled          = false;
                TemporaryData.IsSplashAndSpeedButtonsEnabled = true;

                break;
            }

            TemporaryData.CurrentSplashColorNumber = splashColorNumber;
            TemporaryData.SplashIncreaseSpeed      = splashIncreaseSpeed;
            TemporaryData.VirusBoostedSpeed        = boostedVirusSpeed;
            TemporaryData.BoostIncreaseSpeed       = boostIncreaseSpeed;
            TemporaryData.BoostDecreaseSpeed       = boostDecreaseSpeed;
            TemporaryData.IsParticlesEnabled       = isParticlesEnabled;
        }
    }
Exemplo n.º 12
0
        private bool StartCullingIfVisible(ScriptableRenderContext context, Camera cam)
        {
            if (m_frustumVertices == null)
            {
                return(false);
            }
            ScriptableCullingParameters cullingParameters = new ScriptableCullingParameters();

            if (!cam.TryGetCullingParameters(IsStereoEnabled(cam), out cullingParameters))
            {
                return(false);
            }
            if (m_temporaryData == null)
            {
                m_temporaryData = new TemporaryData();
            }
            uint  flags   = 0xff;
            ulong flags64 = 0;

            for (int i = 0; i < 8; ++i)
            {
                Vector3 v = m_temporaryData.m_vertices[i] = transform.TransformPoint(m_frustumVertices[i]);
                uint    f = 0;
                for (int j = 0; j < cullingParameters.cullingPlaneCount; ++j)
                {
                    Plane plane = cullingParameters.GetCullingPlane(j);
                    if (plane.GetDistanceToPoint(v) < 0)
                    {
                        f |= (1U << j);
                    }
                }
                flags   &= f;
                flags64 |= (((ulong)f) << (8 * i));
            }
            if (flags != 0)
            {
                // projector is not visible from the camera
                return(false);
            }
            if (!m_requiresCullingResult)
            {
                return(true);
            }
            uint cameraPlanes = 0;
            int  planeCount   = 0;

            // -x
            flags = (uint)((flags64 >> 0) & (flags64 >> 8) & (flags64 >> 32) & (flags64 >> 40)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[1], m_temporaryData.m_vertices[4]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // +x
            flags = (uint)((flags64 >> 16) & (flags64 >> 24) & (flags64 >> 48) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[3], m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[7]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // -y
            flags = (uint)((flags64 >> 0) & (flags64 >> 16) & (flags64 >> 32) & (flags64 >> 48)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[6]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // +y
            flags = (uint)((flags64 >> 8) & (flags64 >> 24) & (flags64 >> 40) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[1], m_temporaryData.m_vertices[3], m_temporaryData.m_vertices[5]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // near
            flags = (uint)((flags64 >> 0) & (flags64 >> 8) & (flags64 >> 16) & (flags64 >> 24)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[1]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // far
            flags = (uint)((flags64 >> 32) & (flags64 >> 40) & (flags64 >> 48) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[4], m_temporaryData.m_vertices[5], m_temporaryData.m_vertices[6]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            int maxPlaneCount = ScriptableCullingParameters.maximumCullingPlaneCount;

            for (int i = 0; i < cullingParameters.cullingPlaneCount && planeCount < maxPlaneCount; ++i)
            {
                if ((cameraPlanes & (1U << i)) != 0)
                {
                    m_temporaryData.m_clipPlanes[planeCount++] = cullingParameters.GetCullingPlane(i);
                }
            }
            cullingParameters.cullingPlaneCount = planeCount;
            for (int i = 0; i < planeCount; ++i)
            {
                cullingParameters.SetCullingPlane(i, m_temporaryData.m_clipPlanes[i]);
            }
#if DEBUG
            // To avoid the error: Assertion failed on expression: 'params.cullingPlaneCount == kPlaneFrustumNum'
            cullingParameters.cullingPlaneCount = 6;
#endif
            cullingParameters.cullingOptions &= ~(CullingOptions.NeedsReflectionProbes | CullingOptions.ShadowCasters);
            CullingResults cullingResults = context.Cull(ref cullingParameters);
            m_cullingResults.Add(cam, cullingResults);
            return(true);
        }
        public bool Proccess()
        {
            //если невалидно, то говорим пользователю о том, что невозможно обнаружить явление и подсчитать его характеристики.
            _logger.Info($"Сервис обнаружения явления. Статус: валидация облачности.");
            var isValidCloudy = ValidationHelper.CloudValidation(_dataFolders, _polygon, _pathToCloudMaskTiffFile,
                                                                 _pathToCloudMaskPngFile);

            if (!isValidCloudy)
            {
                _logger.Info($"Сервис обнаружения явления. Статус: валидация на облачность не пройдена. Явление не обнаружено.");
            }

            var clusteringManager = new ClusteringManager();

            List <TemporaryData> temporaryDatas = new List <TemporaryData>();

            foreach (var folder in _dataFolders)
            {
                List <string> necessaryDataFiles = new List <string>();

                var landsatData = new LandsatDataDescription(folder);

                //  if (_phenomenon == PhenomenonType.ForestPlantationsDeseases)
                //  {
                //пока 5 6
                necessaryDataFiles.AddRange(
                    new[] { landsatData.Channel4.Normalized, landsatData.Channel5.Normalized });
                // }

                using (var isodataPointsReader = new LandsatIsodataPointsReader(necessaryDataFiles.ToArray()))
                {
                    List <Cluster> clusters             = new List <Cluster>();
                    var            jsonClustersFilename = string.Empty;

                    //if (_phenomenon == PhenomenonType.ForestPlantationsDeseases)
                    //{
                    jsonClustersFilename = FilenamesConstants.B4B5Clusters;
                    // }

                    if (landsatData.ClustersJson.Any())
                    {
                        var fullPathToClustersJson =
                            landsatData.ClustersJson.FirstOrDefault(f => f.Contains(jsonClustersFilename));

                        if (!string.IsNullOrEmpty(fullPathToClustersJson))
                        {
                            clusters = JsonHelper.Deserialize <List <Cluster> >(fullPathToClustersJson);
                        }
                    }
                    else
                    {
                        _pathToClustersFolder = $@"{folder}{FilenamesConstants.PathToClustersFolder}";
                        _logger.Info($"Сервис обнаружения явления. Текущее действие: кластеризация данных {string.Join(",", necessaryDataFiles)}");
                        clusters = clusteringManager.Process(isodataPointsReader, new NdviIsodataProfile());
                        JsonHelper.Serialize($"{_pathToClustersFolder}{jsonClustersFilename}", clusters);
                        _logger.Info($"Сервис обнаружения явления. Текущее действие: данные прошли кластеризацию. Кол-во кластеров: {clusters.Count}");
                    }

                    var temporaryData = new TemporaryData
                    {
                        Clusters        = clusters,
                        DataDescription = landsatData
                    };
                    temporaryDatas.Add(temporaryData);
                }
            }

            var cloudMask = Helper.GetCloudMaskFromFile(_pathToCloudMaskTiffFile);

            return(CalculateDynamic(temporaryDatas, cloudMask, _phenomenon));
        }
Exemplo n.º 14
0
		public static void Init(TextRenderer targetText)
		{
			CommentGuy.targetText = targetText;
			CommentGuy.schedule = new List<Comment>();

			// Load permanent data, if existing
			if (permanentMind == null)
			{
				string mindPath = Path.Combine(Path.GetDirectoryName(DualityApp.UserDataPath), "mind.dat");
				if (File.Exists(mindPath))
				{
					try
					{
						using (FileStream stream = File.OpenRead(mindPath))
						{
							using (Formatter formatter = Formatter.Create(stream))
							{
								permanentMind = formatter.ReadObject() as PermanentData;
							}
						}
					}
					catch (Exception e)
					{
						Log.Game.WriteError("Error loading permanent data: {0}", Log.Exception(e));
					}
				}
			}

			// Create new permanent data, if not
			if (permanentMind == null) permanentMind = new PermanentData();
			if (temporaryMind == null) temporaryMind = new TemporaryData();
			
			// Only do once what is behind this line.
			if (initialized) return;
			initialized = true;

			DualityApp.Terminating += (s, e) => Terminate();
			temporaryMind.TimeSinceLastMet = DateTime.Now - permanentMind.TimeShutdown;
		}
Exemplo n.º 15
0
        private bool StartCullingIfVisible(ScriptableRenderContext context, Camera cam)
        {
            if (m_frustumVertices == null)
            {
                return(false);
            }
            ScriptableCullingParameters cullingParameters = new ScriptableCullingParameters();

            if (!cam.TryGetCullingParameters(IsStereoEnabled(cam), out cullingParameters))
            {
                return(false);
            }
            if (m_temporaryData == null)
            {
                m_temporaryData = new TemporaryData();
            }
            uint  flags   = 0xff;
            ulong flags64 = 0;

            for (int i = 0; i < 8; ++i)
            {
                Vector3 v = m_temporaryData.m_vertices[i] = transform.TransformPoint(m_frustumVertices[i]);
                uint    f = 0;
                for (int j = 0; j < cullingParameters.cullingPlaneCount; ++j)
                {
                    Plane plane = cullingParameters.GetCullingPlane(j);
                    if (plane.GetDistanceToPoint(v) < 0)
                    {
                        f |= (1U << j);
                    }
                }
                flags   &= f;
                flags64 |= (((ulong)f) << (8 * i));
            }
            if (flags != 0)
            {
                // projector is not visible from the camera
                return(false);
            }
            if (!m_requiresCullingResult)
            {
                return(true);
            }
            uint cameraPlanes = 0;
            int  planeCount   = 0;

            // -x
            flags = (uint)((flags64 >> 0) & (flags64 >> 8) & (flags64 >> 32) & (flags64 >> 40)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[1], m_temporaryData.m_vertices[4]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // +x
            flags = (uint)((flags64 >> 16) & (flags64 >> 24) & (flags64 >> 48) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[3], m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[7]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // -y
            flags = (uint)((flags64 >> 0) & (flags64 >> 16) & (flags64 >> 32) & (flags64 >> 48)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[6]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // +y
            flags = (uint)((flags64 >> 8) & (flags64 >> 24) & (flags64 >> 40) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[1], m_temporaryData.m_vertices[3], m_temporaryData.m_vertices[5]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // near
            flags = (uint)((flags64 >> 0) & (flags64 >> 8) & (flags64 >> 16) & (flags64 >> 24)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[0], m_temporaryData.m_vertices[2], m_temporaryData.m_vertices[1]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            // far
            flags = (uint)((flags64 >> 32) & (flags64 >> 40) & (flags64 >> 48) & (flags64 >> 56)) & 0xFF;
            if (flags == 0)
            {
                m_temporaryData.m_clipPlanes[planeCount++] = new Plane(m_temporaryData.m_vertices[4], m_temporaryData.m_vertices[5], m_temporaryData.m_vertices[6]);
            }
            else
            {
                cameraPlanes |= flags;
            }
            int maxPlaneCount = ScriptableCullingParameters.maximumCullingPlaneCount;

            Debug.Assert(cullingParameters.cullingPlaneCount == 6);
            const int farPlaneIndex     = 5;
            uint      addedCameraPlanes = 0;

            for (int i = 0; i < cullingParameters.cullingPlaneCount && planeCount < maxPlaneCount; ++i)
            {
                if ((cameraPlanes & (1U << i)) != 0)
                {
                    addedCameraPlanes |= 1U << i;
                    m_temporaryData.m_clipPlanes[planeCount++] = cullingParameters.GetCullingPlane(i);
                }
            }
            if (farPlaneIndex < planeCount)
            {
                // keep the camera far clip plane unchanged so that Layer Culling Distances can be handled correctly.
                if ((addedCameraPlanes & (1U << farPlaneIndex)) != 0)
                {
                    // already have the camera far clip plane in m_temporaryData.m_clipPlanes[planeCount - 1]
                    int currentFarPlaneIndex = planeCount - 1;
                    // we need the following lines between #else and #endif if farPlaneIndex != 5
#if true
                    Debug.Assert(farPlaneIndex == cullingParameters.cullingPlaneCount - 1);
#else
                    uint cameraPlaneFlags = addedCameraPlanes >> (farPlaneIndex + 1);
                    while (cameraPlaneFlags != 0)
                    {
                        if ((cameraPlaneFlags & 1U) == 1U)
                        {
                            --currentFarPlaneIndex;
                        }
                    }
#endif
                    if (currentFarPlaneIndex != farPlaneIndex)
                    {
                        Plane farPlane = m_temporaryData.m_clipPlanes[currentFarPlaneIndex];
                        m_temporaryData.m_clipPlanes[currentFarPlaneIndex] = m_temporaryData.m_clipPlanes[farPlaneIndex];
                        m_temporaryData.m_clipPlanes[farPlaneIndex]        = farPlane;
                    }
                }
                else
                {
                    // check if we really need to care abount Layer Culling Distances
                    bool    useLayerCullingDistances = false;
                    Vector3 cameraForward            = cam.transform.forward;
                    float   defaultCullingDistance   = cam.farClipPlane + Vector3.Dot(cameraForward, cam.transform.position);
                    defaultCullingDistance *= 0.9999f;
                    float maxCullingDistance = Vector3.Dot(m_temporaryData.m_vertices[0], cameraForward);
                    for (int i = 1; i < 8; ++i)
                    {
                        maxCullingDistance = Mathf.Max(maxCullingDistance, Vector3.Dot(m_temporaryData.m_vertices[i], cameraForward));
                    }
                    maxCullingDistance = Mathf.Min(maxCullingDistance, defaultCullingDistance);
                    int layerMask = cam.cullingMask & ~projector.ignoreLayers;
                    for (int i = 0, endi = ScriptableCullingParameters.layerCount; i < endi && layerMask != 0; ++i, layerMask >>= 1)
                    {
                        if ((layerMask & 1) != 0)
                        {
                            float layerCullingDistance = cullingParameters.GetLayerCullingDistance(i);
                            if (layerCullingDistance < maxCullingDistance)
                            {
                                useLayerCullingDistances = true;
                                break;
                            }
                        }
                    }
                    if (useLayerCullingDistances)
                    {
                        // we need to care about Layer Culling Distances. so keep far plane unchanged
                        // otherwise, projector might be drawn on invisible objects.
                        if (planeCount < ScriptableCullingParameters.maximumCullingPlaneCount)
                        {
                            m_temporaryData.m_clipPlanes[planeCount++] = m_temporaryData.m_clipPlanes[farPlaneIndex];
                        }
                        else
                        {
                            m_temporaryData.m_clipPlanes[planeCount - 1] = m_temporaryData.m_clipPlanes[farPlaneIndex];
                        }
                        m_temporaryData.m_clipPlanes[farPlaneIndex] = cullingParameters.GetCullingPlane(farPlaneIndex);
                    }
                    else
                    {
                        // we don't need to care abount Layer Culling Distances, but need to SetCullingDistance
                        // so that culling can work correctly.
                        Vector3 farPlaneNormal = m_temporaryData.m_clipPlanes[farPlaneIndex].normal;
                        float   maxDistance    = Vector3.Dot(farPlaneNormal, m_temporaryData.m_vertices[0]);
                        for (int i = 1; i < 8; ++i)
                        {
                            maxDistance = Mathf.Min(maxDistance, Vector3.Dot(m_temporaryData.m_vertices[i], farPlaneNormal));
                        }
                        maxDistance = -maxDistance;
                        for (int i = 0, endi = ScriptableCullingParameters.layerCount; i < endi; ++i)
                        {
                            cullingParameters.SetLayerCullingDistance(i, maxDistance);
                        }
                    }
                }
            }
#if DEBUG
            // make sure that farPlaneIndex is correct.
            Plane farClipPlane    = cullingParameters.GetCullingPlane(farPlaneIndex);
            float farClipDistance = farClipPlane.GetDistanceToPoint(cam.transform.position);
            float error           = Mathf.Abs(farClipDistance - cam.farClipPlane);
            float dirError        = Vector3.Dot(farClipPlane.normal, cam.transform.forward) + 1.0f;
            for (int i = 0; i < 6; ++i)
            {
                if (i != farPlaneIndex)
                {
                    Plane plane = cullingParameters.GetCullingPlane(i);
                    Debug.Assert(error < Mathf.Abs(cam.farClipPlane - plane.GetDistanceToPoint(cam.transform.position)));
                    Debug.Assert(dirError < Vector3.Dot(plane.normal, cam.transform.forward) + 1.0f);
                }
            }
            // To avoid the error: Assertion failed on expression: 'params.cullingPlaneCount == kPlaneFrustumNum'
            while (planeCount < 6)
            {
                m_temporaryData.m_clipPlanes[planeCount] = cullingParameters.GetCullingPlane(planeCount);
                ++planeCount;
            }
            planeCount = 6;
#endif
            cullingParameters.cullingPlaneCount = planeCount;
            for (int i = 0; i < planeCount; ++i)
            {
                cullingParameters.SetCullingPlane(i, m_temporaryData.m_clipPlanes[i]);
            }
            cullingParameters.cullingOptions &= ~(CullingOptions.NeedsReflectionProbes | CullingOptions.ShadowCasters);
            if (terrainsToBeFilteredWithRenderFlags != null && 0 < terrainsToBeFilteredWithRenderFlags.Length)
            {
                if (m_originalTerrainRenderFlags == null || m_originalTerrainRenderFlags.Length < terrainsToBeFilteredWithRenderFlags.Length)
                {
                    m_originalTerrainRenderFlags = new TerrainRenderFlags[terrainsToBeFilteredWithRenderFlags.Length];
                }
                for (int i = 0; i < terrainsToBeFilteredWithRenderFlags.Length; ++i)
                {
                    if (terrainsToBeFilteredWithRenderFlags[i] != null)
                    {
                        m_originalTerrainRenderFlags[i] = terrainsToBeFilteredWithRenderFlags[i].editorRenderFlags;
                        terrainsToBeFilteredWithRenderFlags[i].editorRenderFlags &= terrainRenderFlags;
                    }
                }
            }
            CullingResults cullingResults = context.Cull(ref cullingParameters);
            if (terrainsToBeFilteredWithRenderFlags != null && 0 < terrainsToBeFilteredWithRenderFlags.Length)
            {
                for (int i = 0; i < terrainsToBeFilteredWithRenderFlags.Length; ++i)
                {
                    if (terrainsToBeFilteredWithRenderFlags[i] != null)
                    {
                        terrainsToBeFilteredWithRenderFlags[i].editorRenderFlags = m_originalTerrainRenderFlags[i];
                    }
                }
            }
            m_cullingResults.Add(cam, cullingResults);
            return(true);
        }
Exemplo n.º 16
0
 public void OnStart(TemporaryData temp, string username)
 {
     TemporaryQuizData.data[username] = temp;
 }
Exemplo n.º 17
0
        public static double CalculateNdviForCurrentTemporaryPoint(TemporaryData currentTemporaryData, int row, int col)
        {
            var perfectCluster = CalculateNdviInnerForTemporaryData(currentTemporaryData, row, col);

            return(CalculateNdvi(perfectCluster.CenterCluster[0], perfectCluster.CenterCluster[1]));
        }