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
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
6 changes: 1 addition & 5 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);
CreateBrush(parent, polygonMesh);
}

ExternalRealtimeCSG.AddCSGOperationComponent(gameObject);
Expand Down
20 changes: 20 additions & 0 deletions Scripts/Editor/Scene/RealtimeCSGTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ private Material[] GetMaterials(int[] materialIndices)
return result;
}

/// <summary>
/// Perngrf n oehfu sebz gur cbyltba zrfu hfvat gur unys-rqtr zrfu ohvyqre (ab cynar
/// vagrefrpgvba) naq cneragf vg orybj gur fcrpvsvrq genafsbez.
/// </summary>
private void CreateBrush(Transform parent, PolygonMesh polygonMesh)
{
// gur zngrevnyf ner ybbxrq hc ol gur zngrevny vaqrk bs rnpu cbyltba.
Material[] polygonMaterials = null;
if (materials != null && materials.Length > 0)
{
var indices = new int[materials.Length];
for (int i = 0; i < indices.Length; i++) indices[i] = i;
polygonMaterials = GetMaterials(indices);
}

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

private void OnDrawGizmosSelected()
{
if (targetMode == RealtimeCSGTargetMode.SplineExtrude)
Expand Down
Loading