We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b46e681 commit f220063Copy full SHA for f220063
1 file changed
src/gravity/octree.h
@@ -2,8 +2,15 @@
2
#include "../struct/particle.h"
3
#include <vector>
4
5
+// Forward declaration so bhForce() can accept Octree*
6
+struct Octree;
7
+
8
+// Function declaration
9
void bhForce(Octree* node, Particle& p, real theta, real dt);
10
11
+// =========================
12
+// Octree definition
13
14
struct Octree {
15
real cx, cy, cz; // center of mass
16
real m; // total mass
@@ -14,7 +21,8 @@ struct Octree {
21
Octree* child[8] = {nullptr};
22
23
Octree(real X, real Y, real Z, real S)
17
- : x(X), y(Y), z(Z), size(S), m(0), cx(0), cy(0), cz(0) {}
24
+ : cx(0), cy(0), cz(0), m(0),
25
+ x(X), y(Y), z(Z), size(S) {}
18
26
19
27
~Octree() {
20
28
for (auto c : child) delete c;
@@ -87,6 +95,9 @@ struct Octree {
87
95
}
88
96
};
89
97
98
99
+// Barnes–Hut force function
100
90
101
inline void bhForce(Octree* node, Particle& p, real theta, real dt)
91
102
{
92
103
if (!node || node->m == 0) return;
0 commit comments