Skip to content

Commit

Permalink
All texture coordinates should be multiples of 16
Browse files Browse the repository at this point in the history
  • Loading branch information
df-ferital committed Apr 8, 2019
1 parent 119578d commit f46bfbe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Assets/Scripts/API/Arch3dFile.cs
Expand Up @@ -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;
}

/// <summary>
/// Read mesh data to record array.
/// </summary>
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f46bfbe

Please sign in to comment.