@@ -58,7 +58,7 @@ namespace Forth
5858 int id = stack.top ();
5959 stack.pop ();
6060
61- Node n = Nodes[id];
61+ Node & n = Nodes[id];
6262
6363 if (IsIntersecting (aabb, n.aabb ))
6464 {
@@ -93,7 +93,7 @@ namespace Forth
9393 if (id == -1 )
9494 continue ;
9595
96- Node n = Nodes[id];
96+ Node & n = Nodes[id];
9797 if (!n.aabb .Raycast (p0, p1))
9898 continue ;
9999
@@ -120,13 +120,13 @@ namespace Forth
120120 // Find the closest leaf
121121
122122 Vector4 c = Nodes[id].aabb .center ();
123- Node N = Nodes[Root], R, L, P ;
123+ Node & N = Nodes[Root];
124124 int n = Root, r, l, p;
125125
126126 while (N.height > 0 )
127127 {
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 ];
130130 if (Compare (c, L.aabb , R.aabb ) >= 0 )
131131 {
132132 N = L;
@@ -140,7 +140,7 @@ namespace Forth
140140 }
141141
142142 {
143- P = Nodes[p = AllocateNode ()];
143+ Node & P = Nodes[p = AllocateNode ()];
144144 int tmp;
145145 // Make P becomes parent of N and ID
146146 SWAP (P.left , N.left , tmp)
@@ -168,10 +168,10 @@ namespace Forth
168168 return ;
169169 }
170170
171- Node N = Nodes[id], P = Nodes[N.parent ], S ;
171+ Node & N = Nodes[id], & P = Nodes[N.parent ];
172172 int s = (P.left == id) ? P.right : P.left , p = N.parent , tmp;
173173
174- S = Nodes[s];
174+ Node & S = Nodes[s];
175175 // Make S become part of grandparent N, detach N & P
176176 SWAP (S.parent , P.parent , tmp)
177177
@@ -192,7 +192,7 @@ namespace Forth
192192 {
193193 while (index != -1 )
194194 {
195- Node n = Nodes[index];
195+ Node & n = Nodes[index];
196196
197197 n.height = Max (Nodes[n.left ].height , Nodes[n.right ].height ) + 1 ;
198198 n.aabb = Combine (Nodes[n.left ].aabb , Nodes[n.right ].aabb );
@@ -202,7 +202,7 @@ namespace Forth
202202 }
203203 int DynamicTree::AllocateNode ()
204204 {
205- Node F = Nodes[FreeNode];
205+ Node & F = Nodes[FreeNode];
206206 int f = FreeNode;
207207
208208 if (F.next == NodesCap)
@@ -256,6 +256,6 @@ namespace Forth
256256 right = r;
257257 }
258258 DynamicTree::Node::Node () {}
259- DynamicTree::Node::Node (int next) { this ->next = next; }
259+ DynamicTree::Node::Node (int next) : Node() { this ->next = next; }
260260 } // namespace Physics
261261} // namespace Forth
0 commit comments