Normand Briere
2019-08-17 d5d6485126da83b06645e90e3e4ce66659a56009
RandomNode.java
....@@ -5,7 +5,7 @@
55
66 RandomNode()
77 {
8
- this("Random");
8
+ this("Switch");
99 }
1010
1111 RandomNode(String name)
....@@ -38,7 +38,7 @@
3838 return super.size();
3939 }
4040
41
- int rnd = -1;
41
+ int rndIndex = -1;
4242
4343 static int globalseed = 0;
4444 static int globalseed2 = 0; // mocap frames???
....@@ -54,6 +54,35 @@
5454 super.ResetRandom();
5555 }
5656
57
+ int damp;
58
+ transient int countdamp;
59
+ transient int globaloffset;
60
+
61
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
62
+ {
63
+ if (live && Globals.isLIVE() && (display.DrawMode() == display.SHADOW || !Globals.RENDERSHADOW) &&
64
+ currentframe != Globals.framecount)
65
+ {
66
+ currentframe = Globals.framecount;
67
+
68
+ if (countdamp <= 0)
69
+ {
70
+ countdamp = damp;
71
+
72
+ globaloffset += 1;
73
+ }
74
+ else
75
+ {
76
+ if (CameraPane.FAST)
77
+ countdamp -= CameraPane.STEP;
78
+ else
79
+ countdamp--;
80
+ }
81
+ }
82
+
83
+ super.DrawNode(display, root, selected);
84
+ }
85
+
5786 int firstchoice = 0;
5887 // int currentpass = 0;
5988
....@@ -66,8 +95,8 @@
6695 // if (!link2master && rnd != -1)
6796 // new Exception().printStackTrace();
6897
69
- if (!random && rnd != -1) // freeze current value
70
- return super.reserve(rnd);
98
+ if (!random && rndIndex != -1) // freeze current value
99
+ return super.reserve(rndIndex);
71100
72101 if (firstchoice == 0)
73102 firstchoice = (int)(Math.random()*super.Size()) + 1;
....@@ -91,11 +120,11 @@
91120 }
92121 //int tabarnak = super.Size();
93122
94
- rnd = gcount%super.Size(); //
123
+ rndIndex = gcount%super.Size(); //
95124
96125 //(int)(Math.random()*super.size());
97126 //globalcount++;
98
- gcount += GrafreeD.mix3(rnd+12345,firstchoice*12345,gcount);
127
+ gcount += Grafreed.mix3(rndIndex+12345,firstchoice*12345,gcount);
99128
100129 gcount &= 0x7fffffff;
101130
....@@ -105,12 +134,17 @@
105134 globalseed = gcount;
106135
107136 if (!random) // aout 2013 link2master)
108
- rnd = whatevercount++;
137
+ rndIndex = whatevercount++;
109138
110
- rnd %= super.Size();
139
+ if (live) // aout 2019
140
+ {
141
+ rndIndex += globaloffset;
142
+ }
143
+
144
+ rndIndex %= super.Size();
111145
112146 //GraphreeD.tracein("RESERVE " + this + " = ", i);
113
- Object3D child = super.get(rnd);
147
+ Object3D child = super.get(rndIndex);
114148 //Applet3D.tracein("RESERVE ", child);
115149
116150 child.count--;
....@@ -139,11 +173,11 @@
139173
140174 // globalcount--;
141175
142
- super.get(rnd).count++;
176
+ super.get(rndIndex).count++;
143177 //assert (child.count >= 0);
144178
145179 if (random) // volatile value
146
- rnd = -1;
180
+ rndIndex = -1;
147181 }
148182
149183 void createEditWindow(GroupEditor callee, boolean newWindow)