Normand Briere
2019-08-28 547c9203ab5d8e4bee36d1cbb453dfa36bbec4ef
RandomNode.java
....@@ -5,7 +5,7 @@
55
66 RandomNode()
77 {
8
- this("Random");
8
+ this("Switch");
99 }
1010
1111 RandomNode(String name)
....@@ -25,9 +25,14 @@
2525 // return 1;
2626 // }
2727
28
+ boolean IsSwitch()
29
+ {
30
+ return CameraPane.SWITCH && !this.link2master;
31
+ }
32
+
2833 public int size()
2934 {
30
- if (CameraPane.RANDOM)
35
+ if (IsSwitch())
3136 {
3237 if (super.size() > 0)
3338 return 1;
....@@ -38,7 +43,7 @@
3843 return super.size();
3944 }
4045
41
- int rnd = -1;
46
+ int rndIndex = -1;
4247
4348 static int globalseed = 0;
4449 static int globalseed2 = 0; // mocap frames???
....@@ -54,20 +59,49 @@
5459 super.ResetRandom();
5560 }
5661
62
+ int damp;
63
+ transient int countdamp;
64
+ transient int globaloffset;
65
+
66
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
67
+ {
68
+ if (live && Globals.isLIVE() && (display.DrawMode() == display.SHADOW || !Globals.RENDERSHADOW) &&
69
+ currentframe != Globals.framecount)
70
+ {
71
+ currentframe = Globals.framecount;
72
+
73
+ if (countdamp <= 0)
74
+ {
75
+ countdamp = damp;
76
+
77
+ globaloffset += 1;
78
+ }
79
+ else
80
+ {
81
+ if (CameraPane.FAST)
82
+ countdamp -= CameraPane.STEP;
83
+ else
84
+ countdamp--;
85
+ }
86
+ }
87
+
88
+ super.DrawNode(display, root, selected);
89
+ }
90
+
5791 int firstchoice = 0;
5892 // int currentpass = 0;
5993
6094 public Object3D reserve(int i)
6195 {
62
- if (!CameraPane.RANDOM)
96
+ if (!IsSwitch())
6397 return super.reserve(i);
6498
6599 //assert(rnd == -1);
66100 // if (!link2master && rnd != -1)
67101 // new Exception().printStackTrace();
68102
69
- if (!random && rnd != -1) // freeze current value
70
- return super.reserve(rnd);
103
+ if (!random && rndIndex != -1) // freeze current value
104
+ return super.reserve(rndIndex);
71105
72106 if (firstchoice == 0)
73107 firstchoice = (int)(Math.random()*super.Size()) + 1;
....@@ -91,11 +125,11 @@
91125 }
92126 //int tabarnak = super.Size();
93127
94
- rnd = gcount%super.Size(); //
128
+ rndIndex = gcount%super.Size(); //
95129
96130 //(int)(Math.random()*super.size());
97131 //globalcount++;
98
- gcount += GrafreeD.mix3(rnd+12345,firstchoice*12345,gcount);
132
+ gcount += Grafreed.mix3(rndIndex+12345,firstchoice*12345,gcount);
99133
100134 gcount &= 0x7fffffff;
101135
....@@ -105,12 +139,17 @@
105139 globalseed = gcount;
106140
107141 if (!random) // aout 2013 link2master)
108
- rnd = whatevercount++;
142
+ rndIndex = whatevercount++;
109143
110
- rnd %= super.Size();
144
+ if (live) // aout 2019
145
+ {
146
+ rndIndex += globaloffset;
147
+ }
148
+
149
+ rndIndex %= super.Size();
111150
112151 //GraphreeD.tracein("RESERVE " + this + " = ", i);
113
- Object3D child = super.get(rnd);
152
+ Object3D child = super.get(rndIndex);
114153 //Applet3D.tracein("RESERVE ", child);
115154
116155 child.count--;
....@@ -126,7 +165,7 @@
126165
127166 public void release(int i)
128167 {
129
- if (!CameraPane.RANDOM)
168
+ if (!IsSwitch())
130169 {
131170 super.release(i);
132171 return;
....@@ -139,11 +178,11 @@
139178
140179 // globalcount--;
141180
142
- super.get(rnd).count++;
181
+ super.get(rndIndex).count++;
143182 //assert (child.count >= 0);
144183
145184 if (random) // volatile value
146
- rnd = -1;
185
+ rndIndex = -1;
147186 }
148187
149188 void createEditWindow(GroupEditor callee, boolean newWindow)