Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
RandomNode.java
....@@ -5,7 +5,7 @@
55
66 RandomNode()
77 {
8
- this("Random");
8
+ this("Switch");
99 }
1010
1111 RandomNode(String name)
....@@ -27,7 +27,7 @@
2727
2828 public int size()
2929 {
30
- if (CameraPane.RANDOM)
30
+ if (CameraPane.SWITCH)
3131 {
3232 if (super.size() > 0)
3333 return 1;
....@@ -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,20 +54,49 @@
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
6089 public Object3D reserve(int i)
6190 {
62
- if (!CameraPane.RANDOM)
91
+ if (!CameraPane.SWITCH)
6392 return super.reserve(i);
6493
6594 //assert(rnd == -1);
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--;
....@@ -126,7 +160,7 @@
126160
127161 public void release(int i)
128162 {
129
- if (!CameraPane.RANDOM)
163
+ if (!CameraPane.SWITCH)
130164 {
131165 super.release(i);
132166 return;
....@@ -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)