@@ -58,7 +58,7 @@ namespace Forth
58
58
int id = stack.top ();
59
59
stack.pop ();
60
60
61
- Node n = Nodes[id];
61
+ Node & n = Nodes[id];
62
62
63
63
if (IsIntersecting (aabb, n.aabb ))
64
64
{
@@ -93,7 +93,7 @@ namespace Forth
93
93
if (id == -1 )
94
94
continue ;
95
95
96
- Node n = Nodes[id];
96
+ Node & n = Nodes[id];
97
97
if (!n.aabb .Raycast (p0, p1))
98
98
continue ;
99
99
@@ -120,13 +120,13 @@ namespace Forth
120
120
// Find the closest leaf
121
121
122
122
Vector4 c = Nodes[id].aabb .center ();
123
- Node N = Nodes[Root], R, L, P ;
123
+ Node & N = Nodes[Root];
124
124
int n = Root, r, l, p;
125
125
126
126
while (N.height > 0 )
127
127
{
128
- R = Nodes[r = N.right ];
129
- L = Nodes[l = N.left ];
128
+ Node & R = Nodes[r = N.right ];
129
+ Node & L = Nodes[l = N.left ];
130
130
if (Compare (c, L.aabb , R.aabb ) >= 0 )
131
131
{
132
132
N = L;
@@ -140,7 +140,7 @@ namespace Forth
140
140
}
141
141
142
142
{
143
- P = Nodes[p = AllocateNode ()];
143
+ Node & P = Nodes[p = AllocateNode ()];
144
144
int tmp;
145
145
// Make P becomes parent of N and ID
146
146
SWAP (P.left , N.left , tmp)
@@ -168,10 +168,10 @@ namespace Forth
168
168
return ;
169
169
}
170
170
171
- Node N = Nodes[id], P = Nodes[N.parent ], S ;
171
+ Node & N = Nodes[id], & P = Nodes[N.parent ];
172
172
int s = (P.left == id) ? P.right : P.left , p = N.parent , tmp;
173
173
174
- S = Nodes[s];
174
+ Node & S = Nodes[s];
175
175
// Make S become part of grandparent N, detach N & P
176
176
SWAP (S.parent , P.parent , tmp)
177
177
@@ -192,7 +192,7 @@ namespace Forth
192
192
{
193
193
while (index != -1 )
194
194
{
195
- Node n = Nodes[index];
195
+ Node & n = Nodes[index];
196
196
197
197
n.height = Max (Nodes[n.left ].height , Nodes[n.right ].height ) + 1 ;
198
198
n.aabb = Combine (Nodes[n.left ].aabb , Nodes[n.right ].aabb );
@@ -202,7 +202,7 @@ namespace Forth
202
202
}
203
203
int DynamicTree::AllocateNode ()
204
204
{
205
- Node F = Nodes[FreeNode];
205
+ Node & F = Nodes[FreeNode];
206
206
int f = FreeNode;
207
207
208
208
if (F.next == NodesCap)
@@ -256,6 +256,6 @@ namespace Forth
256
256
right = r;
257
257
}
258
258
DynamicTree::Node::Node () {}
259
- DynamicTree::Node::Node (int next) { this ->next = next; }
259
+ DynamicTree::Node::Node (int next) : Node() { this ->next = next; }
260
260
} // namespace Physics
261
261
} // namespace Forth
0 commit comments