|
12 | 12 | #include "momentum/character/parameter_transform.h" |
13 | 13 | #include "momentum/character/skeleton.h" |
14 | 14 | #include "momentum/common/log.h" |
| 15 | +#include "momentum/common/string.h" |
| 16 | +#include "momentum/io/skeleton/utility.h" |
15 | 17 | #include "momentum/math/constants.h" |
16 | 18 | #include "momentum/math/utility.h" |
17 | 19 |
|
@@ -609,23 +611,30 @@ void parseEllipsoid(const std::string& jointName, ParameterLimits& pl, Tokenizer |
609 | 611 |
|
610 | 612 | } // namespace |
611 | 613 |
|
| 614 | +// Internal overload that accepts SectionContent |
612 | 615 | ParameterLimits parseParameterLimits( |
613 | | - const std::string& data, |
| 616 | + const io_detail::SectionContent& content, |
614 | 617 | const Skeleton& skeleton, |
615 | 618 | const ParameterTransform& parameterTransform) { |
616 | 619 | ParameterLimits pl; |
617 | 620 |
|
618 | | - std::istringstream f(data); |
| 621 | + auto iterator = content.begin(); |
619 | 622 | std::string line; |
620 | | - size_t lineIndex = 0; |
621 | | - while (std::getline(f, line)) { |
622 | | - ++lineIndex; |
| 623 | + while (iterator.getline(line)) { |
| 624 | + const size_t lineIndex = iterator.currentLine(); |
623 | 625 |
|
624 | 626 | // erase all comments |
625 | 627 | line = line.substr(0, line.find_first_of('#')); |
626 | 628 |
|
| 629 | + // Skip empty lines |
| 630 | + if (trim(line).empty()) { |
| 631 | + continue; |
| 632 | + } |
| 633 | + |
627 | 634 | // ignore everything but limits |
628 | 635 | if (line.find("limit") != 0) { |
| 636 | + MT_LOGW( |
| 637 | + "Ignoring invalid line under [ParameterLimits] section at line {}: {}", lineIndex, line); |
629 | 638 | continue; |
630 | 639 | } |
631 | 640 |
|
@@ -672,6 +681,19 @@ ParameterLimits parseParameterLimits( |
672 | 681 | return pl; |
673 | 682 | } |
674 | 683 |
|
| 684 | +// Public API wrapper for backward compatibility |
| 685 | +ParameterLimits parseParameterLimits( |
| 686 | + const std::string& data, |
| 687 | + const Skeleton& skeleton, |
| 688 | + const ParameterTransform& parameterTransform, |
| 689 | + size_t lineOffset) { |
| 690 | + io_detail::SectionContent content; |
| 691 | + if (!data.empty()) { |
| 692 | + content.addSegment(data, lineOffset); |
| 693 | + } |
| 694 | + return parseParameterLimits(content, skeleton, parameterTransform); |
| 695 | +} |
| 696 | + |
675 | 697 | namespace { |
676 | 698 |
|
677 | 699 | std::string vecToString(Eigen::Ref<const Eigen::VectorXf> vec) { |
|
0 commit comments