Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
Chamfer now assigns materials to new polygons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry00IS committed Oct 28, 2018
1 parent 8a61f46 commit 6bc097b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Scripts/Core/PolygonFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ internal static bool ChamferPolygons(List<Polygon> polygons, List<Edge> edges, f
{
// list of clipping planes.
List<Plane> clippingPlanes = new List<Plane>();
List<Material> clippingPlaneMaterials = new List<Material>();

// iterate through all edges and calculate the clipping planes.
for (int e = 0; e < edges.Count; e++)
Expand Down Expand Up @@ -577,6 +578,9 @@ internal static bool ChamferPolygons(List<Polygon> polygons, List<Edge> edges, f
p2,
p1 + (v1 - v2).normalized
));
// find the most likely material we should be using for this chamfer.
// an attempt is made to ignore the default material.
clippingPlaneMaterials.Add(matchingPolygons[0].Material != null ? matchingPolygons[0].Material : matchingPolygons[1].Material);
}
}

Expand All @@ -590,6 +594,10 @@ internal static bool ChamferPolygons(List<Polygon> polygons, List<Edge> edges, f
List<Polygon> polygonsBack;
if (SplitPolygonsByPlane(resultPolygons, clippingPlanes[i], false, out polygonsFront, out polygonsBack))
resultPolygons = polygonsFront;
// assign the most likely material to the new polygons.
for (int j = 0; j < resultPolygons.Count; j++)
if (resultPolygons[j].Plane.normal.EqualsWithEpsilonLower3(clippingPlanes[i].normal))
resultPolygons[j].Material = clippingPlaneMaterials[i];
}

return true;
Expand Down

0 comments on commit 6bc097b

Please sign in to comment.