summaryrefslogtreecommitdiffstats
path: root/src/bones.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bones.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bones.cpp b/src/bones.cpp
index abcaac6..12c7406 100644
--- a/src/bones.cpp
+++ b/src/bones.cpp
@@ -460,3 +460,35 @@ bool head_position(int idx, Vector &out) {
460 } 460 }
461 return false; 461 return false;
462} 462}
463
464// Collect world-space aim points for the selected hit groups (HITGROUP_*).
465// Group 1 (head) uses head_position for its bone fallback; other groups are
466// the hitbox centers. The caller picks the point nearest to the crosshair.
467int aim_points(int idx, unsigned group_mask, Vector *out, int max) {
468 if (!out || max <= 0)
469 return 0;
470 BoneEntry *e = find_entry(idx);
471 if (!e || !e->valid || !e->hdr)
472 return 0;
473 int n = 0;
474 if ((group_mask & (1u << 1)) && n < max) {
475 Vector head;
476 if (head_position(idx, head))
477 out[n++] = head;
478 }
479 const HitboxSet *s = hitbox_set0(e->hdr);
480 if (!s)
481 return n;
482 const Hitbox *boxes = hitboxes(s);
483 for (int i = 0; i < s->numhitboxes && n < max; i++) {
484 int g = boxes[i].group;
485 if (g <= 1 || g > 7)
486 continue;
487 if (!(group_mask & (1u << g)))
488 continue;
489 Vector p;
490 if (hitbox_world(e, boxes[i], p))
491 out[n++] = p;
492 }
493 return n;
494}