ultimate-unreal-engine-mcp 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -208,51 +208,24 @@ static FString TakeScreenshotToFile(int32 Width, int32 Height)
|
|
|
208
208
|
return FString();
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
// Enable realtime rendering so the viewport
|
|
211
|
+
// Enable realtime rendering so the viewport continuously renders frames.
|
|
212
212
|
// Without this, the editor viewport only renders when "dirty" and
|
|
213
|
-
//
|
|
214
|
-
const bool bWasRealtime = ViewportClient->IsRealtime();
|
|
213
|
+
// FScreenshotRequest never gets picked up on subsequent calls.
|
|
215
214
|
ViewportClient->SetRealtime(true);
|
|
216
215
|
|
|
217
|
-
// Force a full viewport redraw. Invalidate marks it dirty,
|
|
218
|
-
// then Draw executes the render pipeline synchronously.
|
|
219
|
-
ViewportClient->Viewport->Invalidate();
|
|
220
|
-
ViewportClient->Viewport->Draw();
|
|
221
|
-
FlushRenderingCommands();
|
|
222
|
-
|
|
223
|
-
// Read pixels from the viewport framebuffer.
|
|
224
|
-
TArray<FColor> Pixels;
|
|
225
|
-
const bool bReadOk = ViewportClient->Viewport->ReadPixels(Pixels);
|
|
226
|
-
|
|
227
|
-
// Restore previous realtime state.
|
|
228
|
-
if (!bWasRealtime)
|
|
229
|
-
{
|
|
230
|
-
ViewportClient->SetRealtime(false);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (!bReadOk)
|
|
234
|
-
{
|
|
235
|
-
return FString();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const int32 VPWidth = ViewportClient->Viewport->GetSizeXY().X;
|
|
239
|
-
const int32 VPHeight = ViewportClient->Viewport->GetSizeXY().Y;
|
|
240
|
-
|
|
241
|
-
if (Pixels.Num() != VPWidth * VPHeight || VPWidth == 0 || VPHeight == 0)
|
|
242
|
-
{
|
|
243
|
-
return FString();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Compress to PNG.
|
|
247
|
-
TArray64<uint8> PngData;
|
|
248
|
-
FImageUtils::PNGCompressImageArray(VPWidth, VPHeight, Pixels, PngData);
|
|
249
|
-
|
|
250
|
-
// Write to file.
|
|
251
216
|
const FString Timestamp = FDateTime::Now().ToString(TEXT("%Y%m%d_%H%M%S_%s"));
|
|
252
217
|
const FString FileName = FString::Printf(TEXT("mcp_screenshot_%s.png"), *Timestamp);
|
|
253
218
|
const FString FilePath = FPaths::Combine(GetMCPScreenshotDir(), FileName);
|
|
254
219
|
|
|
255
|
-
|
|
220
|
+
GScreenshotResolutionX = Width;
|
|
221
|
+
GScreenshotResolutionY = Height;
|
|
222
|
+
|
|
223
|
+
// Invalidate to ensure the viewport redraws with current camera state.
|
|
224
|
+
ViewportClient->Viewport->Invalidate();
|
|
225
|
+
|
|
226
|
+
// Request screenshot to a specific file path. With realtime enabled,
|
|
227
|
+
// the renderer will process this on the next frame.
|
|
228
|
+
FScreenshotRequest::RequestScreenshot(FilePath, false /* bShowUI */, false /* bAddFilenameSuffix */);
|
|
256
229
|
|
|
257
230
|
return FilePath;
|
|
258
231
|
}
|
|
@@ -361,7 +334,7 @@ void RegisterViewportCommands(FMCPCommandRouter& Router)
|
|
|
361
334
|
Data->SetStringField(TEXT("file_path"), FilePath);
|
|
362
335
|
Data->SetNumberField(TEXT("width"), static_cast<double>(Width));
|
|
363
336
|
Data->SetNumberField(TEXT("height"), static_cast<double>(Height));
|
|
364
|
-
Data->SetBoolField(TEXT("
|
|
337
|
+
Data->SetBoolField(TEXT("async"), true);
|
|
365
338
|
|
|
366
339
|
SendResponse(BuildViewportSuccessResponse(CorrId, Data) + TEXT("\n"));
|
|
367
340
|
});
|