Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bb4920

Browse files
committed
further improvements
1 parent 311a1ec commit 9bb4920

File tree

2 files changed

+72
-61
lines changed

2 files changed

+72
-61
lines changed

Assets/Scenes/pond_testing.unity

+12-51
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ MonoBehaviour:
922922
m_Name:
923923
m_EditorClassIdentifier:
924924
CubeHalfSize: 0.5
925-
DistanceToCount: 0.5
925+
DistanceToCount: 0.25
926926
IsoSurfaceLevel: 0
927927
DebugCubeIndex: 0
928928
CubeIndexBatchSize: 256
@@ -940,60 +940,21 @@ MonoBehaviour:
940940
ChaosOffSet: 0
941941
Experimental: 0
942942
Cells:
943-
- Vert0: 0
944-
Vert1: 0
945-
Vert2: 0
946-
Vert3: 0
947-
Vert4: 0
948-
Vert5: 0
949-
Vert6: 0
950-
Vert7: 0
951-
Pos:
943+
- Pos:
952944
x: 13
953945
y: -2.25
954946
z: -2
955-
CubeIndex: 0
956-
- Vert0: 0
957-
Vert1: 0
958-
Vert2: 0
959-
Vert3: 0
960-
Vert4: 0
961-
Vert5: 0
962-
Vert6: 0
963-
Vert7: 0
964-
Pos:
965-
x: 13.5
966-
y: -2.25
967-
z: -2
968-
CubeIndex: 0
969-
- Vert0: 0
970-
Vert1: 0
971-
Vert2: 0
972-
Vert3: 0
973-
Vert4: 0
974-
Vert5: 0
975-
Vert6: 0
976-
Vert7: 0
977-
Pos:
978-
x: 14
979-
y: -2.25
980-
z: -2
981-
CubeIndex: 0
982-
- Vert0: 0
983-
Vert1: 0
984-
Vert2: 0
985-
Vert3: 0
986-
Vert4: 0
987-
Vert5: 0
988-
Vert6: 0
989-
Vert7: 0
990-
Pos:
991-
x: 14.5
992-
y: -2.25
993-
z: -2
994-
CubeIndex: 0
995947
debug: 0
996948
ChaosMultiplier: 0.5
949+
HandleSize: 0.2
950+
HandlePosition:
951+
x: 0
952+
y: 0.75
953+
z: 0
954+
DuplicationExtraPosition:
955+
x: 0
956+
y: 0.5
957+
z: 0
997958
MeshRenderer: {fileID: 644154722}
998959
--- !u!4 &644154720
999960
Transform:
@@ -3130,7 +3091,7 @@ GameObject:
31303091
m_Icon: {fileID: 0}
31313092
m_NavMeshLayer: 0
31323093
m_StaticEditorFlags: 0
3133-
m_IsActive: 1
3094+
m_IsActive: 0
31343095
--- !u!199 &1663408938
31353096
ParticleSystemRenderer:
31363097
serializedVersion: 6

Assets/Scripts/FlexStuff/IsoSurfaceExtractor.cs

+60-10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class IsoSurfaceExtractor : MonoBehaviour
3333
public Cell[] Cells;
3434
public bool debug = false;
3535
public float ChaosMultiplier = 1;
36+
public float HandleSize = 1;
37+
public float3 HandlePosition;
38+
public float3 DuplicationExtraPosition;
3639

3740
static readonly int[] edgeTable = {
3841
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
@@ -617,16 +620,17 @@ public class IsoSurfaceExtractor : MonoBehaviour
617620
[Serializable]
618621
public struct Cell
619622
{
620-
public int Vert0;
621-
public int Vert1;
622-
public int Vert2;
623-
public int Vert3;
624-
public int Vert4;
625-
public int Vert5;
626-
public int Vert6;
627-
public int Vert7;
623+
[NonSerialized] public int Vert0;
624+
[NonSerialized] public int Vert1;
625+
[NonSerialized] public int Vert2;
626+
[NonSerialized] public int Vert3;
627+
[NonSerialized] public int Vert4;
628+
[NonSerialized] public int Vert5;
629+
[NonSerialized] public int Vert6;
630+
[NonSerialized] public int Vert7;
628631
public float3 Pos;
629-
public int CubeIndex;
632+
[NonSerialized] public int CubeIndex;
633+
//remove all NonSerialized attributes if you need to debug these variables!
630634
}
631635

632636
public MeshFilter MeshRenderer;
@@ -1004,4 +1008,50 @@ public unsafe void FullCubesEmptiness()
10041008
// ContentPosition = EditorGUI.PrefixLabel(position, label);
10051009
// EditorGUI.PropertyField(ContentPosition, property.FindPropertyRelative("CubeIndex"));
10061010
// }
1007-
//}
1011+
//}
1012+
1013+
#if UNITY_EDITOR
1014+
[CustomEditor(typeof(IsoSurfaceExtractor))]
1015+
public class IsoSurfaceExtractorEditor : Editor
1016+
{
1017+
public void OnSceneGUI()
1018+
{
1019+
//Debug.Log("somethingworking?");
1020+
var LO = target as IsoSurfaceExtractor;
1021+
SerializedProperty SCells = serializedObject.FindProperty("Cells");
1022+
1023+
Handles.color = Color.blue;
1024+
1025+
for(int i = 0; i < SCells.arraySize; i++)
1026+
{
1027+
float3 CurrentPos = new float3(
1028+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("x").floatValue,
1029+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("y").floatValue,
1030+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("z").floatValue);
1031+
CurrentPos = Handles.PositionHandle(CurrentPos, quaternion.identity);
1032+
1033+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("x").floatValue = CurrentPos.x;
1034+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("y").floatValue = CurrentPos.y;
1035+
SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").FindPropertyRelative("z").floatValue = CurrentPos.z;
1036+
1037+
var test = Handles.Button(CurrentPos+LO.HandlePosition, quaternion.identity, LO.HandleSize, LO.HandleSize * 2, Handles.SphereHandleCap);
1038+
1039+
if (test)
1040+
{
1041+
Debug.Log("buttonpressed");
1042+
1043+
//SCells.arraySize++;
1044+
SCells.InsertArrayElementAtIndex(i);
1045+
//SCells.GetArrayElementAtIndex(i+1) = SCells.GetArrayElementAtIndex(i);
1046+
//SCells.GetArrayElementAtIndex(i + 1).FindPropertyRelative("Pos").vector3Value = SCells.GetArrayElementAtIndex(i).FindPropertyRelative("Pos").vector3Value;
1047+
1048+
SCells.GetArrayElementAtIndex(i + 1).FindPropertyRelative("Pos").FindPropertyRelative("x").floatValue += LO.DuplicationExtraPosition.x;
1049+
SCells.GetArrayElementAtIndex(i + 1).FindPropertyRelative("Pos").FindPropertyRelative("y").floatValue += LO.DuplicationExtraPosition.y;
1050+
SCells.GetArrayElementAtIndex(i + 1).FindPropertyRelative("Pos").FindPropertyRelative("z").floatValue += LO.DuplicationExtraPosition.z;
1051+
}
1052+
}
1053+
//LinkedObject.Size = Handles.ScaleHandle(LinkedObject.Size, LinkedObject.transform.position, LinkedObject.transform.rotation, HandleUtility.GetHandleSize(LinkedObject.transform.position) * 1.5f);
1054+
serializedObject.ApplyModifiedProperties();
1055+
}
1056+
}
1057+
#endif

0 commit comments

Comments
 (0)