Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions source/OpenBveApi/Objects/ObjectTypes/StaticObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace OpenBveApi.Objects
public class StaticObject : UnifiedObject
{
/// <summary>Whether the object is optimized</summary>
private bool isOptimized;
public bool Optimized;
/// <summary>The mesh of the object</summary>
public Mesh Mesh;
/// <summary>The starting track position, for static objects only.</summary>
Expand Down Expand Up @@ -47,7 +47,7 @@ public StaticObject(HostInterface host)
EndingTrackDistance = EndingTrackDistance,
Dynamic = Dynamic,
Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]},
isOptimized = isOptimized
Optimized = Optimized
};
// vertices
for (int j = 0; j < Mesh.Vertices.Length; j++)
Expand Down Expand Up @@ -89,7 +89,7 @@ public override UnifiedObject Clone()
EndingTrackDistance = EndingTrackDistance,
Dynamic = Dynamic,
Mesh = {Vertices = new VertexTemplate[Mesh.Vertices.Length]},
isOptimized = isOptimized
Optimized = Optimized
};
// vertices
for (int j = 0; j < Mesh.Vertices.Length; j++)
Expand Down Expand Up @@ -136,7 +136,7 @@ public override UnifiedObject Mirror()
}
mirrorResult.Mesh.Faces[i].Flip();
}
mirrorResult.isOptimized = isOptimized;
mirrorResult.Optimized = Optimized;
return mirrorResult;
}

Expand Down Expand Up @@ -589,11 +589,11 @@ public override void CreateObject(Vector3 position, Transformation worldTransfor
/// <inheritdoc />
public override void OptimizeObject(bool preserveVerticies, int faceThreshold, bool vertexCulling)
{
if (isOptimized)
if (Optimized)
{
return;
}
isOptimized = true;
Optimized = true;
int m = Mesh.Materials.Length;
int f = Mesh.Faces.Length;

Expand Down
6 changes: 6 additions & 0 deletions source/Plugins/Formats.OpenBve/Enums/CSVB3D/CSVB3DKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public enum CSVB3DKey
/// <summary>Adds a new 1-sided face</summary>
Face,
AddFace = Face,
/// <summary>Adds a new 1-sided face consisting of triangles</summary>
TriFace,
AddTriFace = TriFace,
/// <summary>Adds a new 2-sided face</summary>
Face2,
AddFace2 = Face2,
/// <summary>Adds a new 2-sided face consisting of triangles</summary>
TriFace2,
AddTriFace2 = TriFace2,
/// <summary>Sets the color of all preceding faces in the MeshBuilder</summary>
Color,
SetColor = Color,
Expand Down
9 changes: 9 additions & 0 deletions source/Plugins/Object.CsvB3d/Plugin.NewParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ internal static StaticObject ReadObject(string fileName, Encoding textEncoding)
currentMeshBuilder.Vertices.Add(subBlock.GetNextVertex(out Vector3 currentNormal));
currentNormals.Add(currentNormal);
break;
case CSVB3DKey.TriFace:
case CSVB3DKey.TriFace2:
case CSVB3DKey.Face:
case CSVB3DKey.Face2:
if (subBlock.TryGetNextVertexIndexArray(out int[] faceVertices, Plugin.enabledHacks.BveTsHacks))
Expand Down Expand Up @@ -100,6 +102,13 @@ internal static StaticObject ReadObject(string fileName, Encoding textEncoding)
(f.Vertices[l - 2], f.Vertices[l - 1]) = (f.Vertices[l - 1], f.Vertices[l - 2]);
}

if (key == CSVB3DKey.TriFace || key == CSVB3DKey.TriFace2)
{
// if we're using TriFace, assume the exporter has optimised
f.Flags |= FaceFlags.Triangles;
staticObject.Optimized = true;
}

if (key == CSVB3DKey.Face2)
{
f.Flags |= FaceFlags.Face2Mask;
Expand Down