| 299 | octree_insert(n->children[o], idx, x, y, z, mass, depth + 1); |
| 300 | } |
| 301 | static void octree_repulse(octree_node_t *n, float px, float py, float pz, float mm, int si, |
| 302 | float kr, float *fx, float *fy, float *fz) { |
| 303 | if (!n || n->total_mass == 0.0f || n->body_index == si) |
| 304 | return; |
| 305 | float dx = px - n->cx, dy = py - n->cy, dz = pz - n->cz; |
| 306 | float d = sqrtf(dx * dx + dy * dy + dz * dz); |
| 307 | if (n->body_index >= 0 || (n->half_size * 2.0f / (d + 0.001f)) < BH_THETA) { |
| 308 | if (d < 0.01f) |
| 309 | d = 0.01f; |
| 310 | float f = kr * mm * n->total_mass / d; |
| 311 | *fx += f * dx / d; |
| 312 | *fy += f * dy / d; |
| 313 | *fz += f * dz / d; |
| 314 | return; |
| 315 | } |
| 316 | for (int i = 0; i < 8; i++) |
| 317 | octree_repulse(n->children[i], px, py, pz, mm, si, kr, fx, fy, fz); |
| 318 | } |
| 319 | |
| 320 | /* ── Body with anchor — cbm_layout_cbm_layout_body_t in layout_internal.h ── */ |
| 321 |
no outgoing calls
no test coverage detected