Some minor fixing
This commit is contained in:
1 parent
001077a1d6
commit
efb85f7328
13 files changed
+126849
-25718
No files matched your search
@@ -149,6 +149,8 @@ CutsceneLine DialogueDatabase::parseCutsceneLine(const json& j) {
|
||||
line.portrait = j.value("portrait", "");
|
||||
line.sfx = j.value("sfx", "");
|
||||
line.background = j.value("background", "");
|
||||
line.backgroundWidth = j.value("backgroundWidth", 0);
|
||||
line.backgroundHeight = j.value("backgroundHeight", 0);
|
||||
line.durationMs = j.value("durationMs", 0);
|
||||
line.waitForConfirm = j.value("waitForConfirm", false);
|
||||
return line;
|
||||
@@ -194,6 +196,8 @@ StaticCutsceneDefinition DialogueDatabase::parseCutscene(const json& j) {
|
||||
StaticCutsceneDefinition cutscene;
|
||||
cutscene.id = j.value("id", "");
|
||||
cutscene.background = j.value("background", "");
|
||||
cutscene.backgroundWidth = j.value("backgroundWidth", 1280);
|
||||
cutscene.backgroundHeight = j.value("backgroundHeight", 720);
|
||||
cutscene.music = j.value("music", "");
|
||||
cutscene.skippable = j.value("skippable", true);
|
||||
cutscene.durationMs = j.value("durationMs", 0);
|
||||
|
||||
@@ -408,14 +408,17 @@ void DialogueOverlay::drawCutscene(Renderer& renderer, const PresentationModel&
|
||||
continue;
|
||||
}
|
||||
|
||||
const float texW = static_cast<float>(texture->getWidth());
|
||||
const float texH = static_cast<float>(texture->getHeight());
|
||||
// Logical content dimensions for camera and UV math.
|
||||
// backgroundWidth/backgroundHeight define the coordinate space the camera track was authored in;
|
||||
// the texture is assumed to fill this space entirely regardless of its actual pixel dimensions.
|
||||
const float imgW = (model.backgroundWidth > 0) ? static_cast<float>(model.backgroundWidth) : static_cast<float>(texture->getWidth());
|
||||
const float imgH = (model.backgroundHeight > 0) ? static_cast<float>(model.backgroundHeight) : static_cast<float>(texture->getHeight());
|
||||
|
||||
ResolvedViewport layerViewport{};
|
||||
|
||||
if (model.cutsceneCamera.active) {
|
||||
const ResolvedViewport fromViewport = resolveViewportPose(model.cutsceneCamera.from, texW, texH, W, H);
|
||||
const ResolvedViewport toViewport = resolveViewportPose(model.cutsceneCamera.to, texW, texH, W, H);
|
||||
const ResolvedViewport fromViewport = resolveViewportPose(model.cutsceneCamera.from, imgW, imgH, W, H);
|
||||
const ResolvedViewport toViewport = resolveViewportPose(model.cutsceneCamera.to, imgW, imgH, W, H);
|
||||
layerViewport = blendViewport(
|
||||
fromViewport,
|
||||
toViewport,
|
||||
@@ -423,7 +426,7 @@ void DialogueOverlay::drawCutscene(Renderer& renderer, const PresentationModel&
|
||||
);
|
||||
}
|
||||
else {
|
||||
layerViewport = resolveViewportPose(CutsceneCameraPose{}, texW, texH, W, H);
|
||||
layerViewport = resolveViewportPose(CutsceneCameraPose{}, imgW, imgH, W, H);
|
||||
}
|
||||
|
||||
const float halfW = layerViewport.widthPx * 0.5f;
|
||||
@@ -440,7 +443,7 @@ void DialogueOverlay::drawCutscene(Renderer& renderer, const PresentationModel&
|
||||
};
|
||||
};
|
||||
|
||||
// Source viewport corners in image pixel space (origin = bottom-left)
|
||||
// Source viewport corners in logical image space, then converted to UV via actual texture size.
|
||||
const Eigen::Vector2f srcBL = rotatePoint(-halfW, -halfH);
|
||||
const Eigen::Vector2f srcTL = rotatePoint(-halfW, +halfH);
|
||||
const Eigen::Vector2f srcTR = rotatePoint(+halfW, +halfH);
|
||||
@@ -448,8 +451,8 @@ void DialogueOverlay::drawCutscene(Renderer& renderer, const PresentationModel&
|
||||
|
||||
auto toUV = [&](const Eigen::Vector2f& p) -> Eigen::Vector2f {
|
||||
return {
|
||||
std::clamp(p.x() / max(texW, 1.0f), 0.0f, 1.0f),
|
||||
std::clamp(p.y() / max(texH, 1.0f), 0.0f, 1.0f)
|
||||
std::clamp(p.x() / max(imgW, 1.0f), 0.0f, 1.0f),
|
||||
std::clamp(p.y() / max(imgH, 1.0f), 0.0f, 1.0f)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -689,6 +689,8 @@ void DialogueRuntime::refreshCutscenePresentation() {
|
||||
|
||||
presentation.mode = PresentationMode::Cutscene;
|
||||
presentation.backgroundPath = activeCutscene->background;
|
||||
presentation.backgroundWidth = activeCutscene->backgroundWidth;
|
||||
presentation.backgroundHeight = activeCutscene->backgroundHeight;
|
||||
presentation.cutsceneCamera = evaluateCutsceneCameraBlend();
|
||||
presentation.cutsceneImages = evaluateCutsceneImages();
|
||||
presentation.cutsceneSkippable = activeCutscene->skippable;
|
||||
@@ -748,9 +750,11 @@ void DialogueRuntime::refreshCutscenePresentation() {
|
||||
const CutsceneLine& line = activeCutscene->lines[currentCutsceneLine];
|
||||
|
||||
|
||||
if (!line.background.empty()) {
|
||||
currentCutsceneBackground = line.background;
|
||||
}
|
||||
if (!line.background.empty()) {
|
||||
currentCutsceneBackground = line.background;
|
||||
if (line.backgroundWidth > 0) presentation.backgroundWidth = line.backgroundWidth;
|
||||
if (line.backgroundHeight > 0) presentation.backgroundHeight = line.backgroundHeight;
|
||||
}
|
||||
|
||||
presentation.mode = PresentationMode::Cutscene;
|
||||
presentation.speaker = line.speaker;
|
||||
|
||||
@@ -110,6 +110,8 @@ struct CutsceneLine {
|
||||
std::string portrait;
|
||||
std::string sfx;
|
||||
std::string background;
|
||||
int backgroundWidth = 0; // 0 = inherit from cutscene
|
||||
int backgroundHeight = 0; // 0 = inherit from cutscene
|
||||
int durationMs = 0;
|
||||
bool waitForConfirm = false;
|
||||
};
|
||||
@@ -146,6 +148,8 @@ struct CutsceneImageCue {
|
||||
struct StaticCutsceneDefinition {
|
||||
std::string id;
|
||||
std::string background;
|
||||
int backgroundWidth = 1280;
|
||||
int backgroundHeight = 720;
|
||||
std::string music;
|
||||
bool skippable = true;
|
||||
int durationMs = 0;
|
||||
@@ -201,6 +205,8 @@ struct PresentationModel {
|
||||
std::vector<PresentedCutsceneImage> cutsceneImages;
|
||||
float cutsceneGlobalFadeAlpha = 1.0f;
|
||||
float cutsceneBlackAlpha = 0.0f;
|
||||
int backgroundWidth = 1280;
|
||||
int backgroundHeight = 720;
|
||||
};
|
||||
|
||||
struct SaveState {
|
||||
|
||||
Reference in new issue
Block a user