Skip to content

Commit 5d29a22

Browse files
Refactoring. Updated change log
1 parent 3939510 commit 5d29a22

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88

99
### Bug Fixes
1010

11+
- [case: 1324374] Fixed incorrect vertex/edge/face rect selection when mesh's parent is rotated and/or scaled.
1112
- [case: 1324399] Fixing errors when building with prefabs in scene.
1213
- [case: 1323666] Preventing to assign an empty mesh as MeshCollider.
1314
- [case: 1322032] Fixing wrong ProBuilderMesh colors on domain reload when null.

Runtime/Core/InternalUtility.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ public static GameObject EmptyGameObjectWithTransform(Transform t)
5050
return go;
5151
}
5252

53+
public static GameObject MeshGameObjectWithTransform(string name, Transform t, Mesh mesh, Material mat, bool inheritParent)
54+
{
55+
GameObject go = InternalUtility.EmptyGameObjectWithTransform(t);
56+
go.name = name;
57+
go.AddComponent<MeshFilter>().sharedMesh = mesh;
58+
go.AddComponent<MeshRenderer>().sharedMaterial = mat;
59+
go.hideFlags = HideFlags.HideAndDontSave;
60+
61+
if (inheritParent)
62+
go.transform.SetParent(t.parent, false);
63+
64+
return go;
65+
}
66+
5367
public static T NextEnumValue<T>(this T current) where T : IConvertible
5468
{
5569
Assert.IsTrue(current is Enum);

Runtime/Core/SelectionPickerRenderer.cs

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,6 @@ static GameObject[] GenerateFacePickingObjects(
540540
{
541541
var pb = selection[i];
542542

543-
GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform);
544-
go.name = pb.name + " (Face Depth Test)";
545-
546543
Mesh m = new Mesh();
547544
m.vertices = pb.positionsInternal;
548545
m.triangles = pb.facesInternal.SelectMany(x => x.indexesInternal).ToArray();
@@ -559,10 +556,8 @@ static GameObject[] GenerateFacePickingObjects(
559556

560557
m.colors32 = colors;
561558

562-
go.AddComponent<MeshFilter>().sharedMesh = m;
563-
go.AddComponent<MeshRenderer>().sharedMaterial = BuiltinMaterials.facePickerMaterial;
564-
go.hideFlags = HideFlags.HideAndDontSave;
565-
go.transform.SetParent(pb.transform.parent, false);
559+
GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Face Depth Test)", pb.transform, m,
560+
BuiltinMaterials.facePickerMaterial, true);
566561

567562
pickerObjects[i] = go;
568563
}
@@ -589,12 +584,10 @@ static void GenerateVertexPickingObjects(
589584
{
590585
// build vertex billboards
591586
var pb = selection[i];
592-
GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform);
593-
go.name = pb.name + " (Vertex Billboards)";
594-
go.AddComponent<MeshFilter>().sharedMesh = BuildVertexMesh(pb, map, ref index);
595-
go.AddComponent<MeshRenderer>().sharedMaterial = BuiltinMaterials.vertexPickerMaterial;
596-
go.hideFlags = HideFlags.HideAndDontSave;
597-
go.transform.SetParent(pb.transform.parent, false);
587+
588+
var mesh = BuildVertexMesh(pb, map, ref index);
589+
GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Vertex Billboards)", pb.transform, mesh,
590+
BuiltinMaterials.vertexPickerMaterial, true);
598591

599592
pickerObjects[i] = go;
600593
}
@@ -607,12 +600,9 @@ static void GenerateVertexPickingObjects(
607600
for (int i = 0; i < selectionCount; i++)
608601
{
609602
var pb = selection[i];
610-
GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform);
611-
go.name = pb.name + " (Depth Mask)";
612-
go.AddComponent<MeshFilter>().sharedMesh = pb.mesh;
613-
go.AddComponent<MeshRenderer>().sharedMaterial = BuiltinMaterials.facePickerMaterial;
614-
go.hideFlags = HideFlags.HideAndDontSave;
615-
go.transform.SetParent(pb.transform.parent, false);
603+
604+
GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Depth Mask)", pb.transform, pb.mesh,
605+
BuiltinMaterials.facePickerMaterial, true);
616606

617607
depthObjects[i] = go;
618608
}
@@ -640,12 +630,10 @@ static void GenerateEdgePickingObjects(
640630
{
641631
// build edge billboards
642632
var pb = selection[i];
643-
GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform);
644-
go.name = pb.name + " (Edge Billboards)";
645-
go.AddComponent<MeshFilter>().sharedMesh = BuildEdgeMesh(pb, map, ref index);
646-
go.AddComponent<MeshRenderer>().sharedMaterial = BuiltinMaterials.edgePickerMaterial;
647-
go.hideFlags = HideFlags.HideAndDontSave;
648-
go.transform.SetParent(pb.transform.parent, false);
633+
634+
var mesh = BuildEdgeMesh(pb, map, ref index);
635+
GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Edge Billboards)", pb.transform, mesh,
636+
BuiltinMaterials.edgePickerMaterial, true);
649637

650638
pickerObjects[i] = go;
651639
}
@@ -657,14 +645,11 @@ static void GenerateEdgePickingObjects(
657645
for (int i = 0; i < selectionCount; i++)
658646
{
659647
var pb = selection[i];
648+
660649
// copy the select gameobject just for z-write
661-
GameObject go = InternalUtility.EmptyGameObjectWithTransform(pb.transform);
662-
go.name = pb.name + " (Depth Mask)";
663-
go.AddComponent<MeshFilter>().sharedMesh = pb.mesh;
664-
go.AddComponent<MeshRenderer>().sharedMaterial = BuiltinMaterials.facePickerMaterial;
665-
go.hideFlags = HideFlags.HideAndDontSave;
666-
go.transform.SetParent(pb.transform.parent, false);
667-
650+
GameObject go = InternalUtility.MeshGameObjectWithTransform(pb.name + " (Depth Mask)", pb.transform, pb.mesh,
651+
BuiltinMaterials.facePickerMaterial, true);
652+
668653
depthObjects[i] = go;
669654
}
670655
}

0 commit comments

Comments
 (0)