Skip to content

Commit

Permalink
Fix: Partial revert of b606b7c
Browse files Browse the repository at this point in the history
Closes #971
  • Loading branch information
leezer3 committed Dec 4, 2023
1 parent 318bb96 commit 6a27b7a
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions source/LibRender2/Objects/ObjectLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,29 @@ public void ShowObject(ObjectState State, ObjectType Type)
{
if (State.Prototype.Mesh.Materials[face.Material].WrapMode == null)
{
if (State.Prototype.Mesh.Vertices.Length < 5000)
/*
* If the object does not have a stored wrapping mode determine it now. However:
* https://github.com/leezer3/OpenBVE/issues/971
*
* Unfortunately, there appear to be X objects in the wild which expect a non-default wrapping mode
* which means the best fast exit we can do is to check for RepeatRepeat....
*
*/
foreach (VertexTemplate vertex in State.Prototype.Mesh.Vertices)
{
// If the object does not have a stored wrapping mode and has a sensible number of verticies to check, determine it now
foreach (VertexTemplate vertex in State.Prototype.Mesh.Vertices)
if (vertex.TextureCoordinates.X < 0.0f || vertex.TextureCoordinates.X > 1.0f)
{
if (vertex.TextureCoordinates.X < 0.0f || vertex.TextureCoordinates.X > 1.0f)
{
wrap |= OpenGlTextureWrapMode.RepeatClamp;
}
wrap |= OpenGlTextureWrapMode.RepeatClamp;
}

if (vertex.TextureCoordinates.Y < 0.0f || vertex.TextureCoordinates.Y > 1.0f)
{
wrap |= OpenGlTextureWrapMode.ClampRepeat;
}
if (vertex.TextureCoordinates.Y < 0.0f || vertex.TextureCoordinates.Y > 1.0f)
{
wrap |= OpenGlTextureWrapMode.ClampRepeat;
}

if (wrap == OpenGlTextureWrapMode.RepeatRepeat)
{
break;
}
}
State.Prototype.Mesh.Materials[face.Material].WrapMode = wrap;
Expand Down

0 comments on commit 6a27b7a

Please sign in to comment.