Compare commits
3 Commits
accf378f94
...
cf52b345dc
| Author | SHA1 | Date | |
|---|---|---|---|
| cf52b345dc | |||
| dc6de38b46 | |||
| a544348789 |
@ -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;
|
||||
|
||||
@ -118,6 +118,10 @@ void PlayManagerMenu::OnWorkspaceChange(WorkSpace* workSpace) {
|
||||
}
|
||||
workSpace_ = workSpace;
|
||||
connect(workSpace, &WorkSpace::TimestepChanged, this, &PlayManagerMenu::OnTimestepChanged);
|
||||
// 若当前 workspace 已有 timestep,则立即刷新一次 UI
|
||||
if (auto* timestep = workSpace->GetTimestep()) {
|
||||
OnTimestepChanged(timestep);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayManagerMenu::OnTimestepChanged(Timestep* timestep) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user