diff options
Diffstat (limited to '')
| -rw-r--r-- | src/bones.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/bones.cpp b/src/bones.cpp index d1e25cb..f33a4b2 100644 --- a/src/bones.cpp +++ b/src/bones.cpp | |||
| @@ -371,16 +371,20 @@ int bone_parent(int idx, int bone) { | |||
| 371 | 371 | ||
| 372 | bool bone_is_skeleton_core(int idx, int bone) { | 372 | bool bone_is_skeleton_core(int idx, int bone) { |
| 373 | BoneEntry *e = find_entry(idx); | 373 | BoneEntry *e = find_entry(idx); |
| 374 | if (!e || !e->valid || !e->humanoid || bone < 0 || bone >= e->count) | 374 | if (!e || !e->valid || bone < 0 || bone >= e->count) |
| 375 | return false; | 375 | return false; |
| 376 | if (!e->humanoid) | ||
| 377 | return true; // non-humanoid: draw its full bone tree | ||
| 376 | return e->core[bone]; | 378 | return e->core[bone]; |
| 377 | } | 379 | } |
| 378 | 380 | ||
| 379 | int bone_nearest_core_parent(int idx, int bone) { | 381 | int bone_nearest_core_parent(int idx, int bone) { |
| 380 | BoneEntry *e = find_entry(idx); | 382 | BoneEntry *e = find_entry(idx); |
| 381 | if (!e || !e->valid || !e->humanoid || bone < 0 || bone >= e->count) | 383 | if (!e || !e->valid || bone < 0 || bone >= e->count) |
| 382 | return -1; | 384 | return -1; |
| 383 | int p = bone_at(e->hdr, bone)->parent; | 385 | int p = bone_at(e->hdr, bone)->parent; |
| 386 | if (!e->humanoid) | ||
| 387 | return (p >= 0 && p < e->count) ? p : -1; | ||
| 384 | for (int guard = 0; p >= 0 && p < e->count && guard < 64; guard++) { | 388 | for (int guard = 0; p >= 0 && p < e->count && guard < 64; guard++) { |
| 385 | if (e->core[p]) | 389 | if (e->core[p]) |
| 386 | return p; | 390 | return p; |
| @@ -389,6 +393,11 @@ int bone_nearest_core_parent(int idx, int bone) { | |||
| 389 | return -1; | 393 | return -1; |
| 390 | } | 394 | } |
| 391 | 395 | ||
| 396 | bool bones_is_humanoid(int idx) { | ||
| 397 | BoneEntry *e = find_entry(idx); | ||
| 398 | return e && e->valid && e->humanoid; | ||
| 399 | } | ||
| 400 | |||
| 392 | bool bone_pos(int idx, int bone, Vector &out) { | 401 | bool bone_pos(int idx, int bone, Vector &out) { |
| 393 | BoneEntry *e = find_entry(idx); | 402 | BoneEntry *e = find_entry(idx); |
| 394 | if (!e || !e->valid || bone < 0 || bone >= e->count) | 403 | if (!e || !e->valid || bone < 0 || bone >= e->count) |
