增加摄像机

This commit is contained in:
2026-04-23 13:11:36 +08:00
parent a78b290920
commit 974946cee4
12 changed files with 1134 additions and 23 deletions

View File

@@ -45,6 +45,28 @@ QPointF sampledOriginForTool(const core::Project::Tool& t,
return core::sampleLocation(t.locationKeys, localFrame, t.originWorld, core::KeyInterpolation::Linear);
}
QPointF sampledCenterForCamera(const core::Project::Camera& c,
const core::Project::AnimationClip* clipOrNull,
int localFrame) {
if (clipOrNull && clipOrNull->cameraLocationKeys.contains(c.id)) {
const auto& keys = clipOrNull->cameraLocationKeys.value(c.id);
return core::sampleLocation(keys, localFrame, c.centerWorld, core::KeyInterpolation::Linear);
}
return core::sampleLocation(c.locationKeys, localFrame, c.centerWorld, core::KeyInterpolation::Linear);
}
double sampledViewScaleForCamera(const core::Project::Camera& c,
const core::Project::AnimationClip* clipOrNull,
int localFrame) {
if (clipOrNull && clipOrNull->cameraScaleKeys.contains(c.id)) {
const auto& keys = clipOrNull->cameraScaleKeys.value(c.id);
if (!keys.isEmpty()) {
return core::sampleUserScale(keys, localFrame, c.viewScale, core::KeyInterpolation::Linear);
}
}
return core::sampleUserScale(c.scaleKeys, localFrame, c.viewScale, core::KeyInterpolation::Linear);
}
QPointF sampledRelativeForTool(const core::Project::Tool& t,
const core::Project::AnimationClip* clipOrNull,
int localFrame) {
@@ -201,8 +223,10 @@ ResolvedProjectFrame evaluateAtFrame(const core::Project& project, int frame, in
ResolvedProjectFrame out;
const auto& ents = project.entities();
const auto& tools = project.tools();
const auto& cams = project.cameras();
out.entities.reserve(ents.size());
out.tools.reserve(tools.size());
out.cameras.reserve(cams.size());
const StripEvalCtx ctx = resolveStripCtx(project, frame);
const int localFrame = ctx.localFrame;
@@ -324,6 +348,13 @@ ResolvedProjectFrame evaluateAtFrame(const core::Project& project, int frame, in
out.tools.push_back(ResolvedTool{t, op});
}
for (const auto& c : cams) {
core::Project::Camera cam = c;
cam.centerWorld = sampledCenterForCamera(c, clip, localFrame);
cam.viewScale = sampledViewScaleForCamera(c, clip, localFrame);
out.cameras.push_back(ResolvedCamera{std::move(cam)});
}
return out;
}