Пример #1
0
        public void AssignUnion(AABB box)
        {
            Min.x = VMath.Min(Min.x, box.Min.x);
            Min.y = VMath.Min(Min.y, box.Min.y);
            Min.z = VMath.Min(Min.z, box.Min.z);

            Max.x = VMath.Max(Max.x, box.Max.x);
            Max.y = VMath.Max(Max.y, box.Max.y);
            Max.z = VMath.Max(Max.z, box.Max.z);
        }
Пример #2
0
        public void AssignUnion(Vector3D pt)
        {
            Min.x = VMath.Min(Min.x, pt.x);
            Min.y = VMath.Min(Min.y, pt.y);
            Min.z = VMath.Min(Min.z, pt.z);

            Max.x = VMath.Max(Max.x, pt.x);
            Max.y = VMath.Max(Max.y, pt.y);
            Max.z = VMath.Max(Max.z, pt.z);
        }
Пример #3
0
        public Mesh(Polygon[] polygons)
        {
            Vector3 min = polygons[0].V1.pos;
            Vector3 max = polygons[0].V1.pos;

            foreach (var poly in polygons)
            {
                foreach (var v in poly.vertices)
                {
                    min = VMath.Min(min, v.pos);
                    max = VMath.Max(max, v.pos);
                }
            }
            AABB = new AABoundingBox(min, max);

            OctagonalNode = new OctagonalNode(AABB);
            OctagonalNode.Polygons.AddRange(polygons);
            OctagonalNode.InitPolygons(0, 9, 10000);
        }
Пример #4
0
        public void SerializeStreams()
        {
            var init = TypeIdentity.Instance;

            var context = Setup();
            var orig    = new Message("Test");

            var ms = new MemoryStream(Encoding.ASCII.GetBytes("vvvv"));

            orig.Init("r", ms, new MemoryStream(), ms);
            orig.Init("r1", new MemoryStream());

            var serializer = MessagePackSerializer.Get <Message>(context);

            var stream = new MemoryStream();

            serializer.Pack(stream, orig);

            stream.Position = 0;
            var copy = serializer.Unpack(stream);


            foreach (var fieldName in orig.Fields)
            {
                var origBin = orig[fieldName] as Bin <Stream>;
                var copyBin = copy[fieldName] as Bin <Stream>;

                for (int i = 0; i < VMath.Max(origBin.Count, copyBin.Count); i++)
                {
                    byte[] origRaw = new byte[origBin[i].Length];
                    origBin[i].Read(origRaw, 0, origRaw.Length);

                    byte[] copyRaw = new byte[copyBin[i].Length];
                    copyBin[i].Read(copyRaw, 0, copyRaw.Length);

                    Assert.AreEqual(Encoding.ASCII.GetString(origRaw), Encoding.ASCII.GetString(copyRaw));
                }
            }


            // Assert.AreEqual(orig, copy);  //fails because of Stream not being deep-checkable
        }
Пример #5
0
        private void UpdateAABB()
        {
            Vector3 min = new Vector3(1, 1, 1) * 1E+6F;
            Vector3 max = new Vector3(1, 1, 1) * -1E+6F;

            foreach (var poly in Polygons)
            {
                foreach (var v in poly.vertices)
                {
                    min = VMath.Min(min, v.pos);
                    max = VMath.Max(max, v.pos);
                }
            }

            foreach (var child in Childs)
            {
                min = VMath.Min(min, child.AABB.PosMin);
                max = VMath.Max(max, child.AABB.PosMax);
            }

            AABB = new AABoundingBox(min, max);
        }
Пример #6
0
            void UpdateHairTrigger()
            {
                hairTriggerPrevState = hairTriggerState;
                var value = state.rAxis1.x; // trigger

                hairTriggerValue = value;
                if (hairTriggerState)
                {
                    if (value < hairTriggerLimit - hairTriggerDelta || value <= 0.0f)
                    {
                        hairTriggerState = false;
                    }
                }
                else
                {
                    if (value > hairTriggerLimit + hairTriggerDelta || value >= 1.0f)
                    {
                        hairTriggerState = true;
                    }
                }
                hairTriggerLimit = hairTriggerState ? (float)VMath.Max(hairTriggerLimit, value) : (float)VMath.Min(hairTriggerLimit, value);
            }
Пример #7
0
 public AABoundingBox(Vector3 pos1, Vector3 pos2)
 {
     PosMin = VMath.Min(pos1, pos2);
     PosMax = VMath.Max(pos1, pos2);
 }