コード例 #1
0
        //GG
        public override VInt3 RandomPointOnSurface()
        {
            // Find a random point inside the triangle
            // This generates uniformly distributed trilinear coordinates
            // See http://mathworld.wolfram.com/TrianglePointPicking.html

            /*float r1;
             *          float r2;
             *
             *          do {
             *                  r1 = Random.value;
             *                  r2 = Random.value;
             *          } while (r1+r2 > 1);*/
            //GG
            int r1;
            int r2;

            do
            {
                r1 = VRandom.Random(0, 1000);
                r2 = VRandom.Random(0, 1000);
            } while (r1 + r2 > 1000);

            var holder = GetNavmeshHolder(GraphIndex);

            // Pick the point corresponding to the trilinear coordinate
            //GG
            //return ((Vector3)(holder.GetVertex(v1)-holder.GetVertex(v0)))*r1 + ((Vector3)(holder.GetVertex(v2)-holder.GetVertex(v0)))*r2 + (Vector3)holder.GetVertex(v0);
            return(((holder.GetVertex(v1) - holder.GetVertex(v0))) * r1 / 1000 + ((holder.GetVertex(v2) - holder.GetVertex(v0))) * r2 / 1000 + holder.GetVertex(v0));
        }
コード例 #2
0
        //GG
        //public override Vector3 RandomPointOnSurface () {
        public override VInt3 RandomPointOnSurface()
        {
            GridGraph gg = GridNode.GetGridGraph(GraphIndex);

            //GG
            //var graphSpacePosition = gg.transform.InverseTransform((Vector3)position);
            var graphSpacePosition = gg.transform.InverseTransform(position);

            //GG
            //return gg.transform.Transform(graphSpacePosition + new Vector3(Random.value - 0.5f, 0, Random.value - 0.5f));
            return(gg.transform.Transform(graphSpacePosition + new VInt3(VRandom.Random(1, 1000) - 500, 0, VRandom.Random(1, 1000) - 500)));
        }
コード例 #3
0
        void Reset()
        {
            // Create a new random 64 bit value (62 bit actually because we skip negative numbers, but that's still enough by a huge margin)

            /*var rnd1 = (ulong)Random.Range(0, int.MaxValue);
             *          var rnd2 = ((ulong)Random.Range(0, int.MaxValue) << 32);*/
            //GG
            var rnd1 = (ulong)VRandom.Random(0, int.MaxValue);
            var rnd2 = ((ulong)VRandom.Random(0, int.MaxValue) << 32);

            uniqueID          = rnd1 | rnd2;
            usedIDs[uniqueID] = this;
        }