Updates the position of all the subobjects off the ultimate attach parent
| 583 | |
| 584 | // Updates the position of all the subobjects off the ultimate attach parent |
| 585 | void AttachUpdateSubObjects(object *parent) { |
| 586 | poly_model *parent_pm = &Poly_models[parent->rtype.pobj_info.model_num]; |
| 587 | int i; |
| 588 | |
| 589 | #ifdef _DEBUG |
| 590 | if (!Game_update_attach) |
| 591 | return; |
| 592 | #endif |
| 593 | |
| 594 | if (parent->attach_children == NULL) |
| 595 | return; |
| 596 | |
| 597 | for (i = 0; i < parent_pm->n_attach; i++) { |
| 598 | object *child; |
| 599 | |
| 600 | if ((child = ObjGet(parent->attach_children[i])) != NULL) { |
| 601 | ASSERT(child->flags & OF_ATTACHED); |
| 602 | |
| 603 | child->mtype.phys_info.velocity = parent->mtype.phys_info.velocity; |
| 604 | child->mtype.phys_info.rotvel = parent->mtype.phys_info.rotvel; |
| 605 | |
| 606 | switch (child->attach_type) { |
| 607 | case AT_UNALIGNED: |
| 608 | AttachDoPosOrient(parent, i, child, child->attach_index, false); |
| 609 | break; |
| 610 | case AT_ALIGNED: |
| 611 | AttachDoPosOrient(parent, i, child, child->attach_index, false); |
| 612 | break; |
| 613 | case AT_RAD: { |
| 614 | vector attach_pos; |
| 615 | vector attach_fvec; |
| 616 | |
| 617 | if (AttachPointPos(parent, i, true, &attach_pos, true, &attach_fvec)) { |
| 618 | vector new_child_pos = attach_pos + attach_fvec * child->attach_dist; |
| 619 | |
| 620 | int room = parent->roomnum; |
| 621 | if (ROOMNUM_OUTSIDE(room)) |
| 622 | room = GetTerrainRoomFromPos(&new_child_pos); |
| 623 | |
| 624 | ObjSetPos(child, &new_child_pos, room, NULL, false); |
| 625 | } else { |
| 626 | Int3(); // Get chris |
| 627 | } |
| 628 | } break; |
| 629 | default: |
| 630 | Int3(); // Non-supported attach type - Get Chris |
| 631 | } |
| 632 | |
| 633 | AttachUpdateSubObjects(child); |
| 634 | } |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | // Unattaches an object from its parent |
| 639 | bool UnattachFromParent(object *child) { |
no test coverage detected