modify pathcomponts
This commit is contained in:
parent
a544348789
commit
dc6de38b46
@ -17,7 +17,7 @@
|
||||
PathComponent::PathComponent(SceneComponent* parent)
|
||||
: SceneComponent(parent) {
|
||||
animationPath_ = new osg::AnimationPath();
|
||||
animationPath_->setLoopMode(osg::AnimationPath::SWING);
|
||||
animationPath_->setLoopMode(osg::AnimationPath::NO_LOOPING);
|
||||
}
|
||||
|
||||
PathComponent::~PathComponent() {
|
||||
@ -70,16 +70,18 @@ void PathComponent::Begin() {
|
||||
if (hasPathTimes) {
|
||||
const auto& times = transformPath_->GetTimes();
|
||||
if (timeStep_->HasManualRange()) {
|
||||
// 将路径文件时间列线性映射到用户指定的手动区间,保证相对时间关系不变
|
||||
double srcMin = times.front();
|
||||
double srcMax = times.back();
|
||||
// 使用文件时间为主:仅截取手动范围内的原始时间点
|
||||
double dstMin = timeStep_->GetManualStart();
|
||||
double dstMax = timeStep_->GetManualEnd();
|
||||
double srcSpan = std::max(1e-9, srcMax - srcMin);
|
||||
mappedSteps.reserve(times.size());
|
||||
for (double t : times) {
|
||||
double alpha = (t - srcMin) / srcSpan;
|
||||
mappedSteps.push_back(dstMin + alpha * (dstMax - dstMin));
|
||||
if (t >= dstMin && t <= dstMax) {
|
||||
mappedSteps.push_back(t);
|
||||
}
|
||||
}
|
||||
// 若截取后为空,回退为原始时间列,避免动画路径为空
|
||||
if (mappedSteps.empty()) {
|
||||
mappedSteps = times;
|
||||
}
|
||||
} else {
|
||||
mappedSteps = times;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user