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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
/*
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
package javax.media.j3d;
import java.util.ArrayList;
/**
* SetLiveState is used to encapsulate all state needed when a branch
* group is added to the scene graph
*/
class SetLiveState extends Object {
// The VirtualUniverse for this branch group
VirtualUniverse universe = null;
// The Locale for this Branch Graph
Locale locale = null;
// The transforms used to update state
Transform3D[][] currentTransforms = new Transform3D[1][];
int[][] currentTransformsIndex = new int[1][];
// The keys used when dealing with SharedGroups
HashKey[] keys = null;
// flags for detecting what we are under
boolean inSharedGroup = false;
boolean inBackgroundGroup = false;
boolean inViewSpecificGroup = false;
/**
* The list of nodes added/removed during setLive/clearLive
*/
ArrayList nodeList = new ArrayList();
/**
* List of nodes that are viewScoped. Note that all nodes
* except Shape3D nodes can be in viewScopedNodeList, shape3D
* nodes will always be in the nodeList regardless of scoped
* or not. Also, only renderbin and renderingEnv structure is
* interested in viewScopedNodeList
*/
ArrayList<NodeRetained> viewScopedNodeList = null;
/**
* Parallel list to viewScopedNodeList containing a list of views
* that the viewScopedNode is scoped to
*/
ArrayList<ArrayList<View>> scopedNodesViewList = null;
// Threads to notify after setLive/clearLive
int notifyThreads = 0;
// The current list of leaf nodes for transform targets
Targets[] transformTargets = null;
// List of transform level, one per shared path
int transformLevels[] = new int[]{-1};
// List of scoped lights
ArrayList<ArrayList<LightRetained>> lights = null;
// List of scoped fogs
ArrayList<ArrayList<FogRetained>> fogs = null;
// List of scoped modelClips
ArrayList<ArrayList<ModelClipRetained>> modelClips = null;
// List of scoped alt app
ArrayList<ArrayList<AlternateAppearanceRetained>> altAppearances = null;
// List of viewes scoped to this Group, for all subclasses
// of group, except ViewSpecificGroup its a pointer to closest
// ViewSpecificGroup parent
// viewList for this node, if inSharedGroup is
// false then only viewList(0) is valid
ArrayList<ArrayList<View>> viewLists = null;
ArrayList<ViewSpecificGroupRetained> changedViewGroup = null;
ArrayList<ArrayList<View>> changedViewList = null;
int[] keyList = null;
// The current bitmask of types in transformTragets
//int transformTargetThreads = 0;
ArrayList<OrderedPath> orderedPaths = null;
ArrayList<OrderedGroupRetained> ogList = new ArrayList<OrderedGroupRetained>(5);
ArrayList<Integer> ogChildIdList = new ArrayList<Integer>(5);
ArrayList<Integer> ogOrderedIdList = new ArrayList<Integer>(5);
// ogCIOList contains a list of OG with affected child index order.
ArrayList<OrderedGroupRetained> ogCIOList = new ArrayList<OrderedGroupRetained>(5);
// ogCIOTableList contains a list of affected child index order.
ArrayList<int[]> ogCIOTableList = new ArrayList<int[]>(5);
/**
* List of BranchGroup from this node to the root of tree This is used by
* BranchGroupRetained to construct BranchGroup lists for picking.
*
* @see NodeRetained.branchGroupPaths
*/
ArrayList<BranchGroupRetained[]> branchGroupPaths = null;
ArrayList<BranchGroupRetained[]> parentBranchGroupPaths = null;
/**
* List of Pickable flags, one for each share path.
* This flag is true when all the NodeRetained.pickable is true
* along the path except current node.
*/
boolean pickable[] = new boolean[]{true};
/**
* List of collidable flags, one for each share path.
* This flag is true when all the NodeRetained.pickable is true
* along the path except current node.
*/
boolean collidable[] = new boolean[]{true};
// reference count use in set/clear Live to remember how
// many references of the original branch that attach()/detach()
int refCount = 1;
// background node whose geometry branch contains this node
BackgroundRetained geometryBackground = null;
// behavior nodes
ArrayList<BehaviorRetained> behaviorNodes = new ArrayList<BehaviorRetained>(1);
// The current list of child transform group nodes or link nodes
// under a transform group
ArrayList<NodeRetained> childTransformLinks = null;
// closest parent which is a TransformGroupRetained or sharedGroupRetained
GroupRetained parentTransformLink = null;
// switch Level, start from -1, increment by one for each SwitchNode
// encounter in a branch, one per key
int switchLevels[] = new int[]{-1};
// closest switch parent, one per key
SwitchRetained closestSwitchParents[] = new SwitchRetained[]{null};
// the child id from the closest switch parent, one per key
int closestSwitchIndices[] = new int[]{-1};
// The current list of leaf nodes for switch targets
Targets[] switchTargets = null;
// The current list of closest child switch nodes or
// link nodes under a switch node
ArrayList<NodeRetained> childSwitchLinks = null;
// closest parent which is a SwitchRetained or sharedGroupRetained
GroupRetained parentSwitchLink = null;
SharedGroupRetained lastSharedGroup = null;
int traverseFlags = 0;
// Use for set live.
Transform3D[][] localToVworld = null;
int[][] localToVworldIndex = null;
HashKey[] localToVworldKeys = null;
// cached hashkey index to eliminate duplicate hash key index search
// currently used by Switch, can be extended for other node types
int[] hashkeyIndex = null;
ArrayList<SwitchState> switchStates = null;
SetLiveState(VirtualUniverse u) {
universe = u;
}
void reset(Locale l) {
locale = l;
clear();
}
void clear() {
inSharedGroup = false;
inBackgroundGroup = false;
inViewSpecificGroup = false;
nodeList.clear();
viewScopedNodeList = null;
scopedNodesViewList = null;
notifyThreads = 0;
transformTargets = null;
lights = null;
fogs = null;
modelClips = null;
altAppearances = null;
viewLists = null;
changedViewGroup = null;
changedViewList = null;
keyList = null;
behaviorNodes.clear();
traverseFlags = 0;
ogList.clear();
ogChildIdList.clear();
ogOrderedIdList.clear();
ogCIOList.clear();
ogCIOTableList.clear();
pickable = new boolean[]{true};
collidable = new boolean[]{true};
refCount = 1;
geometryBackground = null;
transformLevels = new int[]{-1};
childTransformLinks = null;
parentTransformLink = null;
switchTargets = null;
switchLevels = new int[]{-1};
switchStates = null;
closestSwitchIndices = new int[]{-1};
closestSwitchParents = new SwitchRetained[]{null};
childSwitchLinks = null;
parentSwitchLink = null;
lastSharedGroup = null;
keys = null;
currentTransforms = new Transform3D[1][];
currentTransformsIndex = new int[1][];
localToVworld = null;
localToVworldIndex = null;
localToVworldKeys = null;
// XXXX: optimization for targetThreads computation, require
// cleanup in GroupRetained.doSetLive()
//transformTargetThreads = 0;
hashkeyIndex = null;
// Fix for issue 75
parentBranchGroupPaths = null;
branchGroupPaths = null;
orderedPaths = null;
}
}
|