示例#1
0
        /// <summary>Reads a Manifold value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static Manifold ReadManifold(this IReadablePacket packet)
        {
            var result = new Manifold();

            packet
            .Read(out result.Points.Item1)
            .Read(out result.Points.Item2)
            .Read(out result.LocalNormal)
            .Read(out result.LocalPoint);
            result.Type = (Manifold.ManifoldType)packet.ReadByte();
            packet.Read(out result.PointCount);
            return(result);
        }
示例#2
0
        public void PostDepacketize(IReadablePacket packet)
        {
            if (_depacketizer == null)
            {
                throw new InvalidOperationException("No deserializer specified.");
            }

            _cells.Clear();
            var cellCount = packet.ReadInt32();

            for (var i = 0; i < cellCount; ++i)
            {
                var cellId = packet.ReadUInt64();
                var tree   = new Collections.DynamicQuadTree <T>(
                    _maxEntriesPerNode,
                    _minNodeBounds,
                    _boundExtension,
                    _movingBoundMultiplier,
                    _packetizer,
                    _depacketizer);
                packet.ReadPacketizableInto(tree);
                _cells.Add(cellId, tree);
            }

            _entryBounds.Clear();
            var entryCount = packet.ReadInt32();

            for (var i = 0; i < entryCount; ++i)
            {
                var        key = _depacketizer(packet);
                TRectangle value;
                packet.Read(out value);
                _entryBounds[key] = value;
            }
        }
示例#3
0
 /// <summary>Reads a ManifoldPoint value.</summary>
 /// <param name="packet">The packet.</param>
 /// <param name="result">The read value.</param>
 /// <returns>The packet, for call chaining.</returns>
 /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
 private static IReadablePacket Read(this IReadablePacket packet, out ManifoldPoint result)
 {
     result.Id.Feature = new ContactFeature();
     return(packet
            .Read(out result.LocalPoint)
            .Read(out result.NormalImpulse)
            .Read(out result.TangentImpulse)
            .Read(out result.Id.Key));
 }
示例#4
0
        /// <summary>Reads a sweep value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static Sweep ReadSweep(this IReadablePacket packet)
        {
            Sweep result;

            packet.Read(out result.LocalCenter);
            packet.Read(out result.CenterOfMass0);
            packet.Read(out result.CenterOfMass);
            packet.Read(out result.Angle0);
            packet.Read(out result.Angle);
            packet.Read(out result.Alpha0);
            return(result);
        }