forked from DevilboxGames/ReincarnationTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_TJunctionSplitter.ms
More file actions
174 lines (151 loc) · 4.26 KB
/
Copy pathTest_TJunctionSplitter.ms
File metadata and controls
174 lines (151 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
--dllpath = GetFilenamePath CarmaSettings.GibbedTools
--maxsScriptHelpersAssembly = dotnet.loadAssembly (dllpath+"MaxScriptTools.dll");
numfaces = getnumfaces $
facesToDetach = #{}
threadNum=0
numThreads = 7
facesPerThread = numFaces / numThreads
fn TJunctionDoWork sender evt =
(
thisThreadNum = threadNum
threadNum += 1
startIndex = thisThreadNum * facesPerThread + 1
endIndex = startIndex + facesPerThread
if endIndex > numFaces then
endIndex = numFaces
else if i == numThreads and endIndex < numFaces then
endIndex = numFaces
textinfo = (thisThreadNum as string)+": "+(startIndex as string)+" to "+(endIndex as string)+"\n"
format textinfo
for i = startIndex to endIndex do
(
edges = meshop.GetEdgesUsingFace $ i
--format "\tEdges: %\n" edges
for edgeNum in edges do
(
--format "%: \t\tCurrent edge: %\n" thisTheadNum edgeNum
connectedEdge = meshop.getEdgesReverseEdge $ edgeNum
--format "%: \t\t\tFirst connected edge: %\n" thisTheadNum connectedEdge
firstConnection = true
itterations = 0
while connectedEdge.numberset > 0 and connectedEdge[edgeNum] == false do
(
--format "\t\t\tCurrent connected edge: %\n" connectedEdge
if firstConnection == true then
(
firstConnection = false
)
else
(
--format "%: \t\t\tCurrent connected edge: %\n" thisTheadNum connectedEdge
facesFound = meshop.getFacesUsingEdge $ connectedEdge
--format "%: \t\t\tAdding faces to be removed: %\n" thisTheadNum facesFound
facesToDetach += facesFound
)
connectedEdge = meshop.getEdgesReverseEdge $ connectedEdge
--format "\t\t\tCurrent connected edge: %\n" connectedEdge
if connectedEdge[edgeNum] == true then
(
--format "Back to the original edge!\n"
exit
)
itterations += 1
if itterations > 10 then
(
--format "%: Loop going on for fucking ages, breaking!\n" thisTheadNum
exit
)
)
)
)
)
fn TJunctionDoWork2 sender evt=
(
format "Blah % - % - %\n" sender evt 0
)
fn DoDetachFaces =
(
format "Detacing Faces...\n"
--for face in facesToDetach do
--(
--format "%\n" face
--)
meshop.detachFaces $ facesToDetach delete:true asMesh:false
)
fn WorkCompleted send evt =
(
format "Finished a thread!\n"
threadsStillRunning = false
for i=1 to threadlist.count do
(
threadsStillRunning = threadsStillRunning or threadList[i].IsBusy
)
if threadsStillRunning == false then
(
DoDetachFaces()
)
)
(
format "Num faces: %\n" numfaces
/*for i=1 to numfaces do
(
--format "\tCurrent face: %\n" i
edges = meshop.GetEdgesUsingFace $ i
--format "\tEdges: %\n" edges
for edgeNum in edges do
(
--format "\t\tCurrent edge: %\n" edgeNum
connectedEdge = meshop.getEdgesReverseEdge $ edgeNum
--format "\t\t\tCurrent connected edge: %\n" connectedEdge
firstConnection = true
itterations = 0
while connectedEdge.numberset > 0 and connectedEdge[edgeNum] == false do
(
--format "\t\t\tCurrent connected edge: %\n" connectedEdge
if firstConnection == true then
(
firstConnection = false
)
else
(
format "\t\t\tCurrent connected edge: %\n" connectedEdge
facesFound = meshop.getFacesUsingEdge $ connectedEdge
format "\t\t\tAdding faces to be removed: %\n" facesFound
facesToDetach += facesFound
)
connectedEdge = meshop.getEdgesReverseEdge $ connectedEdge
--format "\t\t\tCurrent connected edge: %\n" connectedEdge
if connectedEdge[edgeNum] == true then
(
--format "Back to the original edge!\n"
exit
)
itterations += 1
if itterations > 10 then
(
format "Loop going on for fucking ages, breaking!\n"
exit
)
)
)
--if i > 20 then exit
)
*/
global threadList = #()
for i = 1 to numThreads do
(
thisTheadNum = i-1
startIndex = thisTheadNum * facesPerThread + 1
endIndex = startIndex + facesPerThread
if endIndex > numFaces then
endIndex = numFaces
else if i == numThreads and endIndex < numFaces then
endIndex = numFaces
bgw = DotNetObject "System.ComponentModel.BackgroundWorker"
dotnet.AddEventHandler bgw "DoWork" TJunctionDoWork
dotnet.AddEventHandler bgw "RunWorkerCompleted" WorkCompleted
bgw.WorkerSupportsCancellation = true
bgw.RunWorkerAsync()
append threadList bgw
)
)