| 455 | const uint8_t ChestLegsSortOrder[21] = {255, 14, 8, 2, 0, 15, 9, 3, 1, 4, 5, 6, 7, 10, 11, 12, 13, 16, 17, 18, 19}; |
| 456 | |
| 457 | void Humanoid::refreshWearables(Fashion& fashion) { |
| 458 | bool wornHeadsChanged = fashion.wornHeadsChanged; |
| 459 | bool wornChestsLegsChanged = fashion.wornChestsLegsChanged; |
| 460 | bool wornBacksChanged = fashion.wornBacksChanged; |
| 461 | bool helmetMasksChanged = fashion.helmetMasksChanged; |
| 462 | if (!wornHeadsChanged && !wornChestsLegsChanged && !wornBacksChanged && !helmetMasksChanged) |
| 463 | return; |
| 464 | |
| 465 | if (wornHeadsChanged) |
| 466 | fashion.wornHeads.fill(0); |
| 467 | if (wornChestsLegsChanged) |
| 468 | fashion.wornChestsLegs.fill(0); |
| 469 | if (wornBacksChanged) |
| 470 | fashion.wornBacks.fill(0); |
| 471 | if (helmetMasksChanged) |
| 472 | fashion.helmetMaskDirectivesGroup.clear(); |
| 473 | uint8_t headI = 0, chestsLegsI = 0, backsI = 0; |
| 474 | for (uint8_t i = 0; i != fashion.wearables.size(); ++i) { |
| 475 | auto& wearable = fashion.wearables[i]; |
| 476 | if (!wearable) |
| 477 | continue; |
| 478 | else if (auto head = wearable.ptr<WornHead>()) { |
| 479 | if (helmetMasksChanged) |
| 480 | fashion.helmetMaskDirectivesGroup += head->maskDirectives; |
| 481 | if (wornHeadsChanged) |
| 482 | fashion.wornHeads[headI++] = i + 1; |
| 483 | } else if (wearable.is<WornChest>() || wearable.is<WornLegs>()) { |
| 484 | if (wornChestsLegsChanged) |
| 485 | fashion.wornChestsLegs[chestsLegsI++] = i + 1; |
| 486 | } else if (wearable.is<WornBack>()) { |
| 487 | if (wornBacksChanged) |
| 488 | fashion.wornBacks[backsI++] = i + 1; |
| 489 | } |
| 490 | } |
| 491 | if (wornChestsLegsChanged) { |
| 492 | sort(fashion.wornChestsLegs, [](uint8_t a, uint8_t b) { |
| 493 | return ChestLegsSortOrder[a] < ChestLegsSortOrder[b]; |
| 494 | }); |
| 495 | } |
| 496 | fashion.wornHeadsChanged = fashion.wornChestsLegsChanged = fashion.wornBacksChanged = fashion.helmetMasksChanged = false; |
| 497 | } |
| 498 | |
| 499 | const Directives nullDirectives = {}; |
| 500 | const String nullFrameset = ""; |
no test coverage detected