Esempio n. 1
0
        public static Boolean IsInRange(this Int32 value, Int32 min, Int32 max, RangeCheck rangeCheck)
        {
            if (min > max)
            throw new ArgumentOutOfRangeExceptionFmt(Properties.Resources.MathUtils_MinGreaterThanMax, min, max);

              switch (rangeCheck)
              {
            case RangeCheck.Exclusive:
              return ((value > min) && (value < max));
            case RangeCheck.Inclusive:
              return ((value >= min) && (value <= max));
            default:
              throw new ArgumentOutOfRangeExceptionFmt(Properties.Resources.MathUtils_BadRangeCheckValue, rangeCheck);
              }
        }
    void BuildRangeChecks()
    {
        int idx = 0;

        for (int i = 0; i < settings.flockSize; i++)
        {
            Vector3 thisPos = agents [i].position;
            for (int j = i + 1; j < settings.flockSize; j++)
            {
                Vector3    thatPos   = agents [j].position;
                RangeCheck thisRange = new RangeCheck(i, j, thisPos, thatPos);
                checkArray [idx++] = thisRange;
            }
        }
    }
Esempio n. 3
0
        public static Boolean IsInRange(this Int32 value, Int32 min, Int32 max, RangeCheck rangeCheck)
        {
            if (min > max)
            {
                throw new ArgumentOutOfRangeExceptionFmt(Properties.Resources.MathUtils_MinGreaterThanMax, min, max);
            }

            switch (rangeCheck)
            {
            case RangeCheck.Exclusive:
                return((value > min) && (value < max));

            case RangeCheck.Inclusive:
                return((value >= min) && (value <= max));

            default:
                throw new ArgumentOutOfRangeExceptionFmt(Properties.Resources.MathUtils_BadRangeCheckValue, rangeCheck);
            }
        }
Esempio n. 4
0
    // Update is called once per frame
    void LateUpdate()
    {
        int pCount = pSystem.particleCount;

        if (pCount > 1)
        {
            particles = new ParticleSystem.Particle[pCount];
            pSystem.GetParticles(particles);
            checkArray = new RangeCheck[halfMatrixCount(pCount)];
            int idx = 0;
            for (int i = 0; i < pCount; i++)
            {
                Vector3 thisPos = particles [i].position;
                for (int j = i + 1; j < pCount; j++)
                {
                    Vector3 thatPos = particles [j].position;

                    RangeCheck thisRange = new RangeCheck();
                    thisRange.p1_id   = i;
                    thisRange.p2_id   = j;
                    thisRange.pos1    = thisPos;
                    thisRange.pos2    = thatPos;
                    thisRange.inRange = 0;

                    checkArray[idx++] = thisRange;
                }
            }

            if (pCount % 10 > 0)
            {
                pCount += 10 - pCount % 10;
            }

            particleBuffer = new ComputeBuffer(checkArray.Length, sizeof(float) * 6 +
                                               sizeof(int) * 3,
                                               ComputeBufferType.Default);

            particleBuffer.SetData(checkArray);
            ComputeStepFrame();
        }
    }