From f46bfbefeea73188e98710f96511f742b0e39d69 Mon Sep 17 00:00:00 2001 From: Ferital Date: Mon, 8 Apr 2019 14:32:50 +0200 Subject: [PATCH] All texture coordinates should be multiples of 16 --- Assets/Scripts/API/Arch3dFile.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/API/Arch3dFile.cs b/Assets/Scripts/API/Arch3dFile.cs index 58b40019ba..44917eb680 100644 --- a/Assets/Scripts/API/Arch3dFile.cs +++ b/Assets/Scripts/API/Arch3dFile.cs @@ -572,6 +572,16 @@ private void ReadHeader(BinaryReader reader, int record) records[record].Header.PlaneListOffset = reader.ReadInt32(); } + private static int NearestMultipleOf16(int val) + { + int multSup = val - 1; + multSup = multSup >> 4; + ++multSup; + multSup = multSup << 4; + int multInf = multSup - 16; + return val - multInf < multSup - val ? multInf : multSup; + } + /// /// Read mesh data to record array. /// @@ -644,8 +654,8 @@ private bool ReadMesh(int record) int pointOffset = reader.ReadInt32(); // Read UV data - int u = reader.ReadInt16(); - int v = reader.ReadInt16(); + int u = NearestMultipleOf16(reader.ReadInt16()); + int v = NearestMultipleOf16(reader.ReadInt16()); // Fix some UV coordinates (process only the first 3 points as // coordinates from point 4 and above are ignored)