Skip to content
Open
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
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.FixedExtrude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ private void FixedExtrude_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -35,4 +31,4 @@ private void FixedExtrude_Rebuild()
}
}

#endif
#endif
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.LinearStaircase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ private void LinearStaircase_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -46,4 +42,4 @@ private void LinearStaircase_Rebuild()
}
}

#endif
#endif
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.RevolveChopped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ private void RevolveChopped_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -48,4 +44,4 @@ private void RevolveChopped_Rebuild()
}
}

#endif
#endif
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.RevolveExtrude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ private void RevolveExtrude_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -55,4 +51,4 @@ private void RevolveExtrude_Rebuild()
}
}

#endif
#endif
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.ScaledExtrude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ private void ScaledExtrude_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -43,4 +39,4 @@ private void ScaledExtrude_Rebuild()
}
}

#endif
#endif
8 changes: 2 additions & 6 deletions Scripts/Editor/Scene/RealtimeCSGTarget.SplineExtrude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ private void SplineExtrude_Rebuild()
for (int i = 0; i < polygonMeshesCount; i++)
{
var polygonMesh = polygonMeshes[i];
var planes = polygonMesh.ToMaterialPlanes();

var brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
CreateBrushFromPolygonMesh(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand All @@ -61,4 +57,4 @@ private Vector3[] GetLocalChildPoints()
}
}

#endif
#endif
16 changes: 15 additions & 1 deletion Scripts/Editor/Scene/RealtimeCSGTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ private Material[] GetMaterials(int[] materialIndices)
return result;
}

private void CreateBrushFromPolygonMesh(Transform parent, PolygonMesh polygonMesh)
{
var materialPlanes = polygonMesh.ToMaterialPlanes();
var materials = GetMaterials(materialPlanes.materials);
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh, materials);

if (brush == null)
{
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", materialPlanes.planes, materials, polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
}

private void OnDrawGizmosSelected()
{
if (targetMode == RealtimeCSGTargetMode.SplineExtrude)
Expand Down Expand Up @@ -197,4 +211,4 @@ private Vector3[] GetChildPointsAndDrawGizmos(out int hash)
}
}

#endif
#endif
Loading