ikpil / UniRecast

UniRecast - navigation mesh toolset for Unity3D using DotRecast
MIT License
57 stars 11 forks source link

can not read the correct data #9

Open hunter3900 opened 3 months ago

hunter3900 commented 3 months ago

I use this method to read the data self.navMesh = reader.Read32Bit(br, 6);

DtMeshSetWriter.WriteTiles : tileHeader.tileRef(281474976710656) : tileHeader.dataSize(344)

DtMeshSetReader.ReadTiles : is32Bit(True) : header.numTiles(121) : tileHeader.tileRef(0) : tileHeader.dataSize(65536)

ikpil commented 3 months ago

The tile reference appears to be 64-bit. However, in this code, it seems to be reading and writing as 32-bit. This might be causing the tile reference value to be displayed incorrectly. To resolve this issue, the code needs to be modified to correctly read and write the data as 64-bit.

ikpil commented 3 months ago
    public void Test()
    {
        const long tileRef = 281474976710656L;
        const int dataSize = 344;

        byte[] actual;

        {
            using MemoryStream ms = new MemoryStream();
            using BinaryWriter bw = new BinaryWriter(ms);

            RcIO.Write(bw, tileRef, RcByteOrder.LITTLE_ENDIAN);
            RcIO.Write(bw, dataSize, RcByteOrder.LITTLE_ENDIAN);

            bw.Flush();
            actual= ms.ToArray();
        }

        {
            using MemoryStream ms = new MemoryStream(actual);
            using BinaryReader br = new BinaryReader(ms);
            var byteBuffer = RcIO.ToByteBuffer(br);
            byteBuffer.Order(RcByteOrder.LITTLE_ENDIAN);

            Assert.That(byteBuffer.GetLong(), Is.EqualTo(tileRef));
            Assert.That(byteBuffer.GetInt(), Is.EqualTo(dataSize));
        }
    }
hunter3900 commented 3 months ago

still can not run

ikpil commented 3 months ago

Is there a way for me to check?