/// <summary> /// EXPERIMENTAL: Primary UNSAFE WritePacked Method. /// </summary> /// <param name="countbits"></param> public unsafe static void WritePackedBits(ulong *uPtr, ulong value, ref int bitposition, int bits) { if (bits == 0) { return; } int valuebits = value.UsedBitCount(); int sizebits = bits.UsedBitCount(); ArraySerializeUnsafe.Write(uPtr, (uint)(valuebits), ref bitposition, sizebits); ArraySerializeUnsafe.Write(uPtr, value, ref bitposition, valuebits); //UnityEngine.Debug.Log("Write Unsafe PBits " + value + " = " + sizebits + " : " + valuebits); }
/// <summary> /// EXPERIMENTAL: Primary UNSAFE Write Method. /// </summary> public unsafe static void WritePackedBytes(ulong *uPtr, ulong value, ref int bitposition, int bits) { if (bits == 0) { return; } int bytes = (bits + 7) >> 3; int sizebits = bytes.UsedBitCount(); int valuebytes = value.UsedByteCount(); ArraySerializeUnsafe.Write(uPtr, (uint)(valuebytes), ref bitposition, (int)sizebits); ArraySerializeUnsafe.Write(uPtr, value, ref bitposition, valuebytes << 3); //UnityEngine.Debug.Log(value + " buff:" + buffer + "bytes " + bytes + // " = [" + (int)sizebits + " : " + (valuebytes << 3) + "] total bits: " + ((int)sizebits + (valuebytes << 3))); }