コード例 #1
0
 private void ShellSort(ParticleSort[] inputArray, int length)
 {
     for (int num = length / 2; num > 0; num = ((num / 2 == 0) ? ((num != 1) ? 1 : 0) : (num / 2)))
     {
         for (int i = 0; i < length; i++)
         {
             int          num2         = i;
             ParticleSort particleSort = inputArray[i];
             while (num2 >= num && inputArray[num2 - num].distance > particleSort.distance)
             {
                 inputArray[num2] = inputArray[num2 - num];
                 num2            -= num;
             }
             inputArray[num2] = particleSort;
         }
     }
 }
コード例 #2
0
    private void BuildMesh(int start, int end, ThreadParams tp)
    {
        Vector3[]       verts = tp.verts;
        Color32[]       cols  = tp.cols;
        List <CloudBox> list  = new List <CloudBox>();

        lock (CloudBox.cloudLock)
        {
            for (int i = 0; i < CloudBox.all.Count; i++)
            {
                list.Add(CloudBox.all[i]);
            }
        }
        int num = Mathf.Clamp(tp.vpCount - maxMeshParticles, 0, tp.vpCount);

        for (int j = start; j < end; j++)
        {
            if (j >= tp.vpCount)
            {
                verts[j * 4] = (verts[j * 4 + 1] = (verts[j * 4 + 2] = (verts[j * 4 + 3] = Vector3.zero)));
                continue;
            }
            ParticleSort particleSort = tp.psort[j + num];
            int          index        = particleSort.index;
            CloudSystem.CloudParticleData cloudParticleData = CloudSystem.instance.particlesData[index];
            float   size     = cloudParticleData.size;
            float   angle    = cloudParticleData.angle;
            Color   color    = cloudParticleData.color;
            Vector3 worldPos = particleSort.worldPos;
            float   distance = 0f - particleSort.distance;
            FastSinCos(angle, out float sin, out float cos);
            float   num2    = (sin + cos) * size;
            float   num3    = (cos - sin) * size;
            Vector3 vector  = new Vector3(tp.camX.x * num3 + tp.camY.x * num2, tp.camX.y * num3 + tp.camY.y * num2, tp.camX.z * num3 + tp.camY.z * num2);
            Vector3 vector2 = new Vector3(tp.camX.x * num2 - tp.camY.x * num3, tp.camX.y * num2 - tp.camY.y * num3, tp.camX.z * num2 - tp.camY.z * num3);
            float   a       = color.a;
            a = CloudSystem.instance.DistanceClipAlpha(a, distance);
            int num4 = 0;
            while (a > 0.01f && num4 < list.Count)
            {
                a *= list[num4].GetAlpha(worldPos);
                num4++;
            }
            color.a = a;
            if (a > 0.01f)
            {
                verts[j * 4]     = new Vector3(worldPos.x - vector.x, worldPos.y - vector.y, worldPos.z - vector.z);
                verts[j * 4 + 1] = new Vector3(worldPos.x - vector2.x, worldPos.y - vector2.y, worldPos.z - vector2.z);
                verts[j * 4 + 2] = new Vector3(worldPos.x + vector.x, worldPos.y + vector.y, worldPos.z + vector.z);
                verts[j * 4 + 3] = new Vector3(worldPos.x + vector2.x, worldPos.y + vector2.y, worldPos.z + vector2.z);
            }
            else
            {
                verts[j * 4]     = worldPos;
                verts[j * 4 + 1] = worldPos;
                verts[j * 4 + 2] = worldPos;
                verts[j * 4 + 3] = worldPos;
            }
            cols[j * 4] = (cols[j * 4 + 1] = (cols[j * 4 + 2] = (cols[j * 4 + 3] = color)));
        }
    }