Adds and subtracts from mass from connections and disconnections
| 400 | |
| 401 | // Adds and subtracts from mass from connections and disconnections |
| 402 | static void AttachPropagateMass(object *child, bool f_attach = true) { |
| 403 | object *new_parent; |
| 404 | |
| 405 | if (!child) |
| 406 | return; |
| 407 | |
| 408 | do { |
| 409 | new_parent = ObjGet(child->attach_parent_handle); |
| 410 | ASSERT(new_parent); |
| 411 | if (!new_parent) { |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | float mass; |
| 416 | |
| 417 | mass = Object_info[child->id].phys_info.mass; |
| 418 | |
| 419 | if (mass < 0.0f) |
| 420 | mass = 0.0f; |
| 421 | |
| 422 | ASSERT(new_parent->mtype.phys_info.mass >= 0.0f && mass >= 0.0f); |
| 423 | |
| 424 | if (f_attach) |
| 425 | new_parent->mtype.phys_info.mass += mass; |
| 426 | else |
| 427 | new_parent->mtype.phys_info.mass -= mass; |
| 428 | |
| 429 | if (new_parent->mtype.phys_info.mass < 0.0f) { |
| 430 | new_parent->mtype.phys_info.mass = 0.0f; |
| 431 | } |
| 432 | |
| 433 | child = new_parent; |
| 434 | |
| 435 | ASSERT(new_parent->mtype.phys_info.mass >= 0.0f); |
| 436 | } while (child->flags & OF_ATTACHED); |
| 437 | } |
| 438 | |
| 439 | static inline void ComputeUltimateAttachParent(object *child) { |
| 440 | object *cur_obj = child; |
no test coverage detected