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
17 changes: 13 additions & 4 deletions Scripts/Editor/Scene/RealtimeCSGTarget.FixedExtrude.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand All @@ -22,9 +22,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -35,4 +44,4 @@ private void FixedExtrude_Rebuild()
}
}

#endif
#endif
17 changes: 13 additions & 4 deletions Scripts/Editor/Scene/RealtimeCSGTarget.LinearStaircase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand Down Expand Up @@ -33,9 +33,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -46,4 +55,4 @@ private void LinearStaircase_Rebuild()
}
}

#endif
#endif
17 changes: 13 additions & 4 deletions Scripts/Editor/Scene/RealtimeCSGTarget.RevolveChopped.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand Down Expand Up @@ -35,9 +35,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -48,4 +57,4 @@ private void RevolveChopped_Rebuild()
}
}

#endif
#endif
17 changes: 13 additions & 4 deletions Scripts/Editor/Scene/RealtimeCSGTarget.RevolveExtrude.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand Down Expand Up @@ -42,9 +42,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -55,4 +64,4 @@ private void RevolveExtrude_Rebuild()
}
}

#endif
#endif
17 changes: 13 additions & 4 deletions Scripts/Editor/Scene/RealtimeCSGTarget.ScaledExtrude.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand Down Expand Up @@ -30,9 +30,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -43,4 +52,4 @@ private void ScaledExtrude_Rebuild()
}
}

#endif
#endif
19 changes: 14 additions & 5 deletions Scripts/Editor/Scene/RealtimeCSGTarget.SplineExtrude.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR

using UnityEngine;

Expand Down Expand Up @@ -30,9 +30,18 @@ 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);
// try the direct PolygonMesh -> brush path first
var brush = ExternalRealtimeCSG.CreateBrushFromPolygonMesh(parent, "Shape Editor Brush", polygonMesh);
if (brush != null)
{
brush.transform.SetParent(parent, false);
continue;
}

// fall back to plane-based brush creation
var planes = polygonMesh.ToMaterialPlanes();
brush = ExternalRealtimeCSG.CreateBrushFromPlanes("Shape Editor Brush", planes.planes, GetMaterials(planes.materials), polygonMesh.booleanOperator);
if (brush != null)
brush.transform.SetParent(parent, false);
}
Expand All @@ -53,12 +62,12 @@ private MathEx.Spline3 GetSpline3()
private Vector3[] GetLocalChildPoints()
{
int childCount = transform.childCount;
Vector3[] points = new Vector3[childCount];
var points = new Vector3[childCount];
for (int i = 0; i < childCount; i++)
points[i] = transform.GetChild(i).localPosition;
return points;
}
}
}

#endif
#endif
Loading