unreal-engine-mcp-server 0.5.4 → 0.5.6
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/CHANGELOG.md +350 -0
- package/dist/automation/bridge.d.ts.map +1 -0
- package/dist/automation/bridge.js +5 -4
- package/dist/automation/bridge.js.map +1 -0
- package/dist/automation/connection-manager.d.ts.map +1 -0
- package/dist/automation/connection-manager.js.map +1 -0
- package/dist/automation/handshake.d.ts.map +1 -0
- package/dist/automation/handshake.js.map +1 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/message-handler.d.ts.map +1 -0
- package/dist/automation/message-handler.js.map +1 -0
- package/dist/automation/request-tracker.d.ts.map +1 -0
- package/dist/automation/request-tracker.js.map +1 -0
- package/dist/automation/types.d.ts +7 -0
- package/dist/automation/types.d.ts.map +1 -0
- package/dist/automation/types.js.map +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +6 -4
- package/dist/cli.js.map +1 -0
- package/dist/config/class-aliases.d.ts.map +1 -0
- package/dist/config/class-aliases.js.map +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js.map +1 -0
- package/dist/graphql/loaders.d.ts.map +1 -0
- package/dist/graphql/loaders.js.map +1 -0
- package/dist/graphql/resolvers.d.ts +174 -69
- package/dist/graphql/resolvers.d.ts.map +1 -0
- package/dist/graphql/resolvers.js +82 -67
- package/dist/graphql/resolvers.js.map +1 -0
- package/dist/graphql/schema.d.ts.map +1 -0
- package/dist/graphql/schema.js.map +1 -0
- package/dist/graphql/server.d.ts.map +1 -0
- package/dist/graphql/server.js.map +1 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js.map +1 -0
- package/dist/handlers/resource-handlers.d.ts.map +1 -0
- package/dist/handlers/resource-handlers.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -9
- package/dist/index.js.map +1 -0
- package/dist/resources/actors.d.ts +7 -4
- package/dist/resources/actors.d.ts.map +1 -0
- package/dist/resources/actors.js +15 -12
- package/dist/resources/actors.js.map +1 -0
- package/dist/resources/assets.d.ts +43 -2
- package/dist/resources/assets.d.ts.map +1 -0
- package/dist/resources/assets.js +21 -12
- package/dist/resources/assets.js.map +1 -0
- package/dist/resources/levels.d.ts.map +1 -0
- package/dist/resources/levels.js +7 -5
- package/dist/resources/levels.js.map +1 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +4 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/parser.d.ts +20 -0
- package/dist/schemas/parser.d.ts.map +1 -0
- package/dist/schemas/parser.js +61 -0
- package/dist/schemas/parser.js.map +1 -0
- package/dist/schemas/primitives.d.ts +221 -0
- package/dist/schemas/primitives.d.ts.map +1 -0
- package/dist/schemas/primitives.js +115 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/responses.d.ts +362 -0
- package/dist/schemas/responses.d.ts.map +1 -0
- package/dist/schemas/responses.js +252 -0
- package/dist/schemas/responses.js.map +1 -0
- package/dist/server/resource-registry.d.ts.map +1 -0
- package/dist/server/resource-registry.js.map +1 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +22 -17
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/server-setup.d.ts.map +1 -0
- package/dist/server-setup.js.map +1 -0
- package/dist/services/health-monitor.d.ts +1 -1
- package/dist/services/health-monitor.d.ts.map +1 -0
- package/dist/services/health-monitor.js +4 -3
- package/dist/services/health-monitor.js.map +1 -0
- package/dist/services/metrics-server.d.ts.map +1 -0
- package/dist/services/metrics-server.js.map +1 -0
- package/dist/tools/actors.d.ts +27 -27
- package/dist/tools/actors.d.ts.map +1 -0
- package/dist/tools/actors.js +14 -10
- package/dist/tools/actors.js.map +1 -0
- package/dist/tools/animation.d.ts +15 -23
- package/dist/tools/animation.d.ts.map +1 -0
- package/dist/tools/animation.js +17 -13
- package/dist/tools/animation.js.map +1 -0
- package/dist/tools/assets.d.ts.map +1 -0
- package/dist/tools/assets.js +18 -12
- package/dist/tools/assets.js.map +1 -0
- package/dist/tools/audio.d.ts +10 -10
- package/dist/tools/audio.d.ts.map +1 -0
- package/dist/tools/audio.js.map +1 -0
- package/dist/tools/base-tool.d.ts.map +1 -0
- package/dist/tools/base-tool.js.map +1 -0
- package/dist/tools/behavior-tree.d.ts +24 -24
- package/dist/tools/behavior-tree.d.ts.map +1 -0
- package/dist/tools/behavior-tree.js.map +1 -0
- package/dist/tools/blueprint.d.ts +14 -3
- package/dist/tools/blueprint.d.ts.map +1 -0
- package/dist/tools/blueprint.js +5 -3
- package/dist/tools/blueprint.js.map +1 -0
- package/dist/tools/consolidated-tool-definitions.d.ts +32 -32
- package/dist/tools/consolidated-tool-definitions.d.ts.map +1 -0
- package/dist/tools/consolidated-tool-definitions.js.map +1 -0
- package/dist/tools/consolidated-tool-handlers.d.ts +1 -1
- package/dist/tools/consolidated-tool-handlers.d.ts.map +1 -0
- package/dist/tools/consolidated-tool-handlers.js +26 -21
- package/dist/tools/consolidated-tool-handlers.js.map +1 -0
- package/dist/tools/debug.d.ts +25 -7
- package/dist/tools/debug.d.ts.map +1 -0
- package/dist/tools/debug.js +3 -1
- package/dist/tools/debug.js.map +1 -0
- package/dist/tools/dynamic-handler-registry.d.ts +1 -1
- package/dist/tools/dynamic-handler-registry.d.ts.map +1 -0
- package/dist/tools/dynamic-handler-registry.js +3 -1
- package/dist/tools/dynamic-handler-registry.js.map +1 -0
- package/dist/tools/editor.d.ts.map +1 -0
- package/dist/tools/editor.js +8 -6
- package/dist/tools/editor.js.map +1 -0
- package/dist/tools/engine.d.ts +1 -1
- package/dist/tools/engine.d.ts.map +1 -0
- package/dist/tools/engine.js +4 -2
- package/dist/tools/engine.js.map +1 -0
- package/dist/tools/environment.d.ts.map +1 -0
- package/dist/tools/environment.js +4 -3
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/foliage.d.ts.map +1 -0
- package/dist/tools/foliage.js +8 -8
- package/dist/tools/foliage.js.map +1 -0
- package/dist/tools/handlers/actor-handlers.d.ts +2 -1
- package/dist/tools/handlers/actor-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/actor-handlers.js +56 -33
- package/dist/tools/handlers/actor-handlers.js.map +1 -0
- package/dist/tools/handlers/animation-handlers.d.ts +2 -1
- package/dist/tools/handlers/animation-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/animation-handlers.js +74 -67
- package/dist/tools/handlers/animation-handlers.js.map +1 -0
- package/dist/tools/handlers/argument-helper.d.ts +24 -4
- package/dist/tools/handlers/argument-helper.d.ts.map +1 -0
- package/dist/tools/handlers/argument-helper.js +139 -4
- package/dist/tools/handlers/argument-helper.js.map +1 -0
- package/dist/tools/handlers/asset-handlers.d.ts +2 -1
- package/dist/tools/handlers/asset-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/asset-handlers.js +155 -94
- package/dist/tools/handlers/asset-handlers.js.map +1 -0
- package/dist/tools/handlers/audio-handlers.d.ts +2 -1
- package/dist/tools/handlers/audio-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/audio-handlers.js +82 -80
- package/dist/tools/handlers/audio-handlers.js.map +1 -0
- package/dist/tools/handlers/blueprint-handlers.d.ts +3 -5
- package/dist/tools/handlers/blueprint-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/blueprint-handlers.js +150 -142
- package/dist/tools/handlers/blueprint-handlers.js.map +1 -0
- package/dist/tools/handlers/common-handlers.d.ts +2 -3
- package/dist/tools/handlers/common-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/common-handlers.js.map +1 -0
- package/dist/tools/handlers/editor-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/editor-handlers.js +12 -2
- package/dist/tools/handlers/editor-handlers.js.map +1 -0
- package/dist/tools/handlers/effect-handlers.d.ts +2 -1
- package/dist/tools/handlers/effect-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/effect-handlers.js +70 -68
- package/dist/tools/handlers/effect-handlers.js.map +1 -0
- package/dist/tools/handlers/environment-handlers.d.ts +2 -1
- package/dist/tools/handlers/environment-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/environment-handlers.js +86 -74
- package/dist/tools/handlers/environment-handlers.js.map +1 -0
- package/dist/tools/handlers/graph-handlers.d.ts +1 -1
- package/dist/tools/handlers/graph-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/graph-handlers.js +63 -2
- package/dist/tools/handlers/graph-handlers.js.map +1 -0
- package/dist/tools/handlers/input-handlers.d.ts +2 -5
- package/dist/tools/handlers/input-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/input-handlers.js +5 -4
- package/dist/tools/handlers/input-handlers.js.map +1 -0
- package/dist/tools/handlers/inspect-handlers.d.ts +2 -1
- package/dist/tools/handlers/inspect-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/inspect-handlers.js +61 -37
- package/dist/tools/handlers/inspect-handlers.js.map +1 -0
- package/dist/tools/handlers/level-handlers.d.ts +2 -2
- package/dist/tools/handlers/level-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/level-handlers.js +43 -39
- package/dist/tools/handlers/level-handlers.js.map +1 -0
- package/dist/tools/handlers/lighting-handlers.d.ts +12 -1
- package/dist/tools/handlers/lighting-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/lighting-handlers.js +90 -47
- package/dist/tools/handlers/lighting-handlers.js.map +1 -0
- package/dist/tools/handlers/performance-handlers.d.ts +2 -1
- package/dist/tools/handlers/performance-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/performance-handlers.js +55 -40
- package/dist/tools/handlers/performance-handlers.js.map +1 -0
- package/dist/tools/handlers/pipeline-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/pipeline-handlers.js.map +1 -0
- package/dist/tools/handlers/sequence-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/sequence-handlers.js.map +1 -0
- package/dist/tools/handlers/system-handlers.d.ts +3 -2
- package/dist/tools/handlers/system-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/system-handlers.js +105 -52
- package/dist/tools/handlers/system-handlers.js.map +1 -0
- package/dist/tools/input.d.ts.map +1 -0
- package/dist/tools/input.js +3 -1
- package/dist/tools/input.js.map +1 -0
- package/dist/tools/introspection.d.ts +14 -14
- package/dist/tools/introspection.d.ts.map +1 -0
- package/dist/tools/introspection.js +54 -45
- package/dist/tools/introspection.js.map +1 -0
- package/dist/tools/landscape.d.ts.map +1 -0
- package/dist/tools/landscape.js +15 -13
- package/dist/tools/landscape.js.map +1 -0
- package/dist/tools/level.d.ts.map +1 -0
- package/dist/tools/level.js +3 -2
- package/dist/tools/level.js.map +1 -0
- package/dist/tools/lighting.d.ts +32 -59
- package/dist/tools/lighting.d.ts.map +1 -0
- package/dist/tools/lighting.js +56 -19
- package/dist/tools/lighting.js.map +1 -0
- package/dist/tools/logs.d.ts.map +1 -0
- package/dist/tools/logs.js +2 -1
- package/dist/tools/logs.js.map +1 -0
- package/dist/tools/materials.d.ts +42 -14
- package/dist/tools/materials.d.ts.map +1 -0
- package/dist/tools/materials.js +15 -9
- package/dist/tools/materials.js.map +1 -0
- package/dist/tools/niagara.d.ts +63 -39
- package/dist/tools/niagara.d.ts.map +1 -0
- package/dist/tools/niagara.js +43 -33
- package/dist/tools/niagara.js.map +1 -0
- package/dist/tools/performance.d.ts +12 -11
- package/dist/tools/performance.d.ts.map +1 -0
- package/dist/tools/performance.js +3 -2
- package/dist/tools/performance.js.map +1 -0
- package/dist/tools/physics.d.ts +37 -20
- package/dist/tools/physics.d.ts.map +1 -0
- package/dist/tools/physics.js +37 -30
- package/dist/tools/physics.js.map +1 -0
- package/dist/tools/property-dictionary.d.ts.map +1 -0
- package/dist/tools/property-dictionary.js.map +1 -0
- package/dist/tools/sequence.d.ts +1 -1
- package/dist/tools/sequence.d.ts.map +1 -0
- package/dist/tools/sequence.js +8 -4
- package/dist/tools/sequence.js.map +1 -0
- package/dist/tools/tool-definition-utils.d.ts.map +1 -0
- package/dist/tools/tool-definition-utils.js.map +1 -0
- package/dist/tools/ui.d.ts +11 -11
- package/dist/tools/ui.d.ts.map +1 -0
- package/dist/tools/ui.js +7 -3
- package/dist/tools/ui.js.map +1 -0
- package/dist/types/automation-responses.d.ts.map +1 -0
- package/dist/types/automation-responses.js.map +1 -0
- package/dist/types/env.d.ts.map +1 -0
- package/dist/types/env.js.map +1 -0
- package/dist/types/handler-types.d.ts +112 -3
- package/dist/types/handler-types.d.ts.map +1 -0
- package/dist/types/handler-types.js.map +1 -0
- package/dist/types/tool-interfaces.d.ts +39 -21
- package/dist/types/tool-interfaces.d.ts.map +1 -0
- package/dist/types/tool-interfaces.js.map +1 -0
- package/dist/types/tool-types.d.ts +8 -8
- package/dist/types/tool-types.d.ts.map +1 -0
- package/dist/types/tool-types.js.map +1 -0
- package/dist/unreal-bridge.d.ts +8 -6
- package/dist/unreal-bridge.d.ts.map +1 -0
- package/dist/unreal-bridge.js +16 -3
- package/dist/unreal-bridge.js.map +1 -0
- package/dist/utils/command-validator.d.ts.map +1 -0
- package/dist/utils/command-validator.js.map +1 -0
- package/dist/utils/elicitation.d.ts +2 -5
- package/dist/utils/elicitation.d.ts.map +1 -0
- package/dist/utils/elicitation.js +3 -2
- package/dist/utils/elicitation.js.map +1 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/ini-reader.d.ts +1 -1
- package/dist/utils/ini-reader.d.ts.map +1 -0
- package/dist/utils/ini-reader.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -4
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/normalize.d.ts +2 -2
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js +4 -3
- package/dist/utils/normalize.js.map +1 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/response-factory.d.ts +2 -2
- package/dist/utils/response-factory.d.ts.map +1 -0
- package/dist/utils/response-factory.js +3 -1
- package/dist/utils/response-factory.js.map +1 -0
- package/dist/utils/response-validator.d.ts +4 -4
- package/dist/utils/response-validator.d.ts.map +1 -0
- package/dist/utils/response-validator.js +31 -23
- package/dist/utils/response-validator.js.map +1 -0
- package/dist/utils/result-helpers.d.ts.map +1 -0
- package/dist/utils/result-helpers.js.map +1 -0
- package/dist/utils/safe-json.d.ts.map +1 -0
- package/dist/utils/safe-json.js.map +1 -0
- package/dist/utils/unreal-command-queue.d.ts +2 -2
- package/dist/utils/unreal-command-queue.d.ts.map +1 -0
- package/dist/utils/unreal-command-queue.js +4 -3
- package/dist/utils/unreal-command-queue.js.map +1 -0
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/wasm/index.d.ts +2 -2
- package/dist/wasm/index.d.ts.map +1 -0
- package/dist/wasm/index.js +11 -7
- package/dist/wasm/index.js.map +1 -0
- package/package.json +12 -34
- package/server.json +2 -2
- package/.dockerignore +0 -57
- package/.env.example +0 -26
- package/.env.production +0 -61
- package/.eslintrc.json +0 -0
- package/.eslintrc.override.json +0 -8
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -94
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -56
- package/.github/copilot-instructions.md +0 -478
- package/.github/dependabot.yml +0 -19
- package/.github/labeler.yml +0 -24
- package/.github/labels.yml +0 -70
- package/.github/pull_request_template.md +0 -42
- package/.github/release-drafter-config.yml +0 -51
- package/.github/workflows/auto-merge.yml +0 -38
- package/.github/workflows/ci.yml +0 -38
- package/.github/workflows/dependency-review.yml +0 -17
- package/.github/workflows/gemini-issue-triage.yml +0 -172
- package/.github/workflows/greetings.yml +0 -27
- package/.github/workflows/labeler.yml +0 -17
- package/.github/workflows/links.yml +0 -80
- package/.github/workflows/pr-size-labeler.yml +0 -137
- package/.github/workflows/publish-mcp.yml +0 -79
- package/.github/workflows/release-drafter.yml +0 -24
- package/.github/workflows/release.yml +0 -112
- package/.github/workflows/semantic-pull-request.yml +0 -35
- package/.github/workflows/smoke-test.yml +0 -36
- package/.github/workflows/stale.yml +0 -28
- package/CONTRIBUTING.md +0 -140
- package/Dockerfile +0 -37
- package/GEMINI.md +0 -115
- package/Public/Plugin_setup_guide.mp4 +0 -0
- package/Public/icon.png +0 -0
- package/claude_desktop_config_example.json +0 -15
- package/dist/types/responses.d.ts +0 -249
- package/dist/types/responses.js +0 -2
- package/docs/GraphQL-API.md +0 -888
- package/docs/Migration-Guide-v0.5.0.md +0 -684
- package/docs/Roadmap.md +0 -53
- package/docs/WebAssembly-Integration.md +0 -628
- package/docs/editor-plugin-extension.md +0 -370
- package/docs/handler-mapping.md +0 -249
- package/docs/native-automation-progress.md +0 -128
- package/docs/testing-guide.md +0 -423
- package/eslint.config.mjs +0 -68
- package/mcp-config-example.json +0 -14
- package/plugins/McpAutomationBridge/Config/FilterPlugin.ini +0 -8
- package/plugins/McpAutomationBridge/McpAutomationBridge.uplugin +0 -64
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/McpAutomationBridge.Build.cs +0 -189
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.cpp +0 -22
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.h +0 -30
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeHelpers.h +0 -1983
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeModule.cpp +0 -72
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSettings.cpp +0 -46
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSubsystem.cpp +0 -846
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AnimationHandlers.cpp +0 -2393
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetQueryHandlers.cpp +0 -300
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetWorkflowHandlers.cpp +0 -2807
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AudioHandlers.cpp +0 -1087
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BehaviorTreeHandlers.cpp +0 -488
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.cpp +0 -643
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.h +0 -31
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintGraphHandlers.cpp +0 -1094
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers.cpp +0 -5750
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers_List.cpp +0 -152
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ControlHandlers.cpp +0 -2614
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_DebugHandlers.cpp +0 -42
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EditorFunctionHandlers.cpp +0 -1237
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EffectHandlers.cpp +0 -1725
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EnvironmentHandlers.cpp +0 -2265
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_FoliageHandlers.cpp +0 -954
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InputHandlers.cpp +0 -209
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InsightsHandlers.cpp +0 -41
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LandscapeHandlers.cpp +0 -1164
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LevelHandlers.cpp +0 -762
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LightingHandlers.cpp +0 -663
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LogHandlers.cpp +0 -136
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_MaterialGraphHandlers.cpp +0 -494
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraGraphHandlers.cpp +0 -278
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraHandlers.cpp +0 -625
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PerformanceHandlers.cpp +0 -401
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PipelineHandlers.cpp +0 -67
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ProcessRequest.cpp +0 -472
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp +0 -2634
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_RenderHandlers.cpp +0 -189
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.cpp +0 -917
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.h +0 -39
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequenceHandlers.cpp +0 -2706
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequencerHandlers.cpp +0 -519
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_TestHandlers.cpp +0 -38
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_UiHandlers.cpp +0 -668
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_WorldPartitionHandlers.cpp +0 -346
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.cpp +0 -1345
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.h +0 -149
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpConnectionManager.cpp +0 -782
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSettings.h +0 -115
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h +0 -796
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpConnectionManager.h +0 -117
- package/scripts/check-unreal-connection.mjs +0 -19
- package/scripts/clean-tmp.js +0 -23
- package/scripts/patch-wasm.js +0 -26
- package/scripts/run-all-tests.mjs +0 -136
- package/scripts/smoke-test.ts +0 -94
- package/scripts/sync-mcp-plugin.js +0 -143
- package/scripts/test-no-plugin-alternates.mjs +0 -113
- package/scripts/validate-server.js +0 -46
- package/scripts/verify-automation-bridge.js +0 -200
- package/src/automation/bridge.ts +0 -630
- package/src/automation/connection-manager.ts +0 -148
- package/src/automation/handshake.ts +0 -99
- package/src/automation/index.ts +0 -2
- package/src/automation/message-handler.ts +0 -192
- package/src/automation/request-tracker.ts +0 -155
- package/src/automation/types.ts +0 -108
- package/src/cli.ts +0 -34
- package/src/config/class-aliases.ts +0 -65
- package/src/config.ts +0 -73
- package/src/constants.ts +0 -29
- package/src/graphql/loaders.ts +0 -244
- package/src/graphql/resolvers.ts +0 -1008
- package/src/graphql/schema.ts +0 -452
- package/src/graphql/server.ts +0 -156
- package/src/graphql/types.ts +0 -10
- package/src/handlers/resource-handlers.ts +0 -186
- package/src/index.ts +0 -243
- package/src/resources/actors.ts +0 -127
- package/src/resources/assets.ts +0 -286
- package/src/resources/levels.ts +0 -68
- package/src/server/resource-registry.ts +0 -47
- package/src/server/tool-registry.ts +0 -354
- package/src/server-setup.ts +0 -114
- package/src/services/health-monitor.ts +0 -132
- package/src/services/metrics-server.ts +0 -176
- package/src/tools/actors.ts +0 -564
- package/src/tools/animation.ts +0 -941
- package/src/tools/assets.ts +0 -394
- package/src/tools/audio.ts +0 -499
- package/src/tools/base-tool.ts +0 -52
- package/src/tools/behavior-tree.ts +0 -45
- package/src/tools/blueprint.ts +0 -940
- package/src/tools/consolidated-tool-definitions.ts +0 -1256
- package/src/tools/consolidated-tool-handlers.ts +0 -302
- package/src/tools/debug.ts +0 -622
- package/src/tools/dynamic-handler-registry.ts +0 -33
- package/src/tools/editor.ts +0 -435
- package/src/tools/engine.ts +0 -43
- package/src/tools/environment.ts +0 -281
- package/src/tools/foliage.ts +0 -596
- package/src/tools/handlers/actor-handlers.ts +0 -244
- package/src/tools/handlers/animation-handlers.ts +0 -237
- package/src/tools/handlers/argument-helper.ts +0 -142
- package/src/tools/handlers/asset-handlers.ts +0 -550
- package/src/tools/handlers/audio-handlers.ts +0 -194
- package/src/tools/handlers/blueprint-handlers.ts +0 -380
- package/src/tools/handlers/common-handlers.ts +0 -108
- package/src/tools/handlers/editor-handlers.ts +0 -124
- package/src/tools/handlers/effect-handlers.ts +0 -224
- package/src/tools/handlers/environment-handlers.ts +0 -183
- package/src/tools/handlers/graph-handlers.ts +0 -117
- package/src/tools/handlers/input-handlers.ts +0 -28
- package/src/tools/handlers/inspect-handlers.ts +0 -450
- package/src/tools/handlers/level-handlers.ts +0 -253
- package/src/tools/handlers/lighting-handlers.ts +0 -151
- package/src/tools/handlers/performance-handlers.ts +0 -132
- package/src/tools/handlers/pipeline-handlers.ts +0 -194
- package/src/tools/handlers/sequence-handlers.ts +0 -438
- package/src/tools/handlers/system-handlers.ts +0 -564
- package/src/tools/input.ts +0 -160
- package/src/tools/introspection.ts +0 -689
- package/src/tools/landscape.ts +0 -649
- package/src/tools/level.ts +0 -989
- package/src/tools/lighting.ts +0 -1052
- package/src/tools/logs.ts +0 -219
- package/src/tools/materials.ts +0 -295
- package/src/tools/niagara.ts +0 -485
- package/src/tools/performance.ts +0 -661
- package/src/tools/physics.ts +0 -679
- package/src/tools/property-dictionary.ts +0 -98
- package/src/tools/sequence.ts +0 -385
- package/src/tools/tool-definition-utils.ts +0 -35
- package/src/tools/ui.ts +0 -452
- package/src/types/automation-responses.ts +0 -119
- package/src/types/env.ts +0 -17
- package/src/types/handler-types.ts +0 -442
- package/src/types/responses.ts +0 -355
- package/src/types/tool-interfaces.ts +0 -250
- package/src/types/tool-types.ts +0 -575
- package/src/unreal-bridge.ts +0 -693
- package/src/utils/command-validator.ts +0 -139
- package/src/utils/elicitation.ts +0 -132
- package/src/utils/error-handler.ts +0 -287
- package/src/utils/ini-reader.ts +0 -86
- package/src/utils/logger.ts +0 -35
- package/src/utils/normalize.test.ts +0 -162
- package/src/utils/normalize.ts +0 -146
- package/src/utils/path-security.ts +0 -43
- package/src/utils/response-factory.ts +0 -44
- package/src/utils/response-validator.ts +0 -395
- package/src/utils/result-helpers.ts +0 -195
- package/src/utils/safe-json.test.ts +0 -90
- package/src/utils/safe-json.ts +0 -70
- package/src/utils/unreal-command-queue.ts +0 -166
- package/src/utils/validation.test.ts +0 -184
- package/src/utils/validation.ts +0 -312
- package/src/wasm/index.ts +0 -838
- package/test-server.mjs +0 -100
- package/tests/test-animation.mjs +0 -369
- package/tests/test-asset-advanced.mjs +0 -82
- package/tests/test-asset-graph.mjs +0 -311
- package/tests/test-audio.mjs +0 -417
- package/tests/test-automation-timeouts.mjs +0 -98
- package/tests/test-behavior-tree.mjs +0 -444
- package/tests/test-blueprint-graph.mjs +0 -410
- package/tests/test-blueprint.mjs +0 -577
- package/tests/test-client-mode.mjs +0 -86
- package/tests/test-console-command.mjs +0 -56
- package/tests/test-control-actor.mjs +0 -425
- package/tests/test-control-editor.mjs +0 -112
- package/tests/test-graphql.mjs +0 -372
- package/tests/test-input.mjs +0 -349
- package/tests/test-inspect.mjs +0 -302
- package/tests/test-landscape.mjs +0 -316
- package/tests/test-lighting.mjs +0 -428
- package/tests/test-manage-asset.mjs +0 -438
- package/tests/test-manage-level.mjs +0 -89
- package/tests/test-materials.mjs +0 -356
- package/tests/test-niagara.mjs +0 -185
- package/tests/test-no-inline-python.mjs +0 -122
- package/tests/test-performance.mjs +0 -539
- package/tests/test-plugin-handshake.mjs +0 -82
- package/tests/test-runner.mjs +0 -993
- package/tests/test-sequence.mjs +0 -104
- package/tests/test-system.mjs +0 -96
- package/tests/test-wasm.mjs +0 -283
- package/tests/test-world-partition.mjs +0 -215
- package/tsconfig.json +0 -56
- package/vitest.config.ts +0 -35
- package/wasm/Cargo.lock +0 -363
- package/wasm/Cargo.toml +0 -42
- package/wasm/LICENSE +0 -21
- package/wasm/README.md +0 -253
- package/wasm/src/dependency_resolver.rs +0 -377
- package/wasm/src/lib.rs +0 -153
- package/wasm/src/property_parser.rs +0 -271
- package/wasm/src/transform_math.rs +0 -396
- package/wasm/tests/integration.rs +0 -109
|
@@ -1,1164 +0,0 @@
|
|
|
1
|
-
#include "McpAutomationBridgeGlobals.h"
|
|
2
|
-
#include "McpAutomationBridgeHelpers.h"
|
|
3
|
-
#include "McpAutomationBridgeSubsystem.h"
|
|
4
|
-
#include "Runtime/Launch/Resources/Version.h"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
#if WITH_EDITOR
|
|
8
|
-
#include "Async/Async.h"
|
|
9
|
-
#include "EditorAssetLibrary.h"
|
|
10
|
-
#include "Engine/World.h"
|
|
11
|
-
#include "Landscape.h"
|
|
12
|
-
#include "LandscapeComponent.h"
|
|
13
|
-
#include "LandscapeDataAccess.h"
|
|
14
|
-
#include "LandscapeEdit.h"
|
|
15
|
-
#include "LandscapeEditorObject.h"
|
|
16
|
-
#include "LandscapeEditorUtils.h"
|
|
17
|
-
#include "LandscapeGrassType.h"
|
|
18
|
-
#include "LandscapeInfo.h"
|
|
19
|
-
#include "LandscapeProxy.h"
|
|
20
|
-
#include "LandscapeStreamingProxy.h"
|
|
21
|
-
#include "Materials/Material.h"
|
|
22
|
-
#include "Materials/MaterialInstanceConstant.h"
|
|
23
|
-
#include "Misc/ScopedSlowTask.h"
|
|
24
|
-
#include "UObject/SavePackage.h"
|
|
25
|
-
|
|
26
|
-
#if __has_include("Subsystems/EditorActorSubsystem.h")
|
|
27
|
-
#include "Subsystems/EditorActorSubsystem.h"
|
|
28
|
-
#elif __has_include("EditorActorSubsystem.h")
|
|
29
|
-
#include "EditorActorSubsystem.h"
|
|
30
|
-
#endif
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
|
-
bool UMcpAutomationBridgeSubsystem::HandleEditLandscape(
|
|
34
|
-
const FString &RequestId, const FString &Action,
|
|
35
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
36
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
37
|
-
// Dispatch to specific edit operations implemented below
|
|
38
|
-
if (HandleModifyHeightmap(RequestId, Action, Payload, RequestingSocket))
|
|
39
|
-
return true;
|
|
40
|
-
if (HandlePaintLandscapeLayer(RequestId, Action, Payload, RequestingSocket))
|
|
41
|
-
return true;
|
|
42
|
-
if (HandleSculptLandscape(RequestId, Action, Payload, RequestingSocket))
|
|
43
|
-
return true;
|
|
44
|
-
if (HandleSetLandscapeMaterial(RequestId, Action, Payload, RequestingSocket))
|
|
45
|
-
return true;
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
bool UMcpAutomationBridgeSubsystem::HandleCreateLandscape(
|
|
50
|
-
const FString &RequestId, const FString &Action,
|
|
51
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
52
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
53
|
-
const FString Lower = Action.ToLower();
|
|
54
|
-
if (!Lower.Equals(TEXT("create_landscape"), ESearchCase::IgnoreCase)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
#if WITH_EDITOR
|
|
59
|
-
if (!Payload.IsValid()) {
|
|
60
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
61
|
-
TEXT("create_landscape payload missing"),
|
|
62
|
-
TEXT("INVALID_PAYLOAD"));
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Parse inputs (accept multiple shapes)
|
|
67
|
-
double X = 0.0, Y = 0.0, Z = 0.0;
|
|
68
|
-
if (!Payload->TryGetNumberField(TEXT("x"), X) ||
|
|
69
|
-
!Payload->TryGetNumberField(TEXT("y"), Y) ||
|
|
70
|
-
!Payload->TryGetNumberField(TEXT("z"), Z)) {
|
|
71
|
-
// Try location object { x, y, z }
|
|
72
|
-
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
73
|
-
if (Payload->TryGetObjectField(TEXT("location"), LocObj) && LocObj) {
|
|
74
|
-
(*LocObj)->TryGetNumberField(TEXT("x"), X);
|
|
75
|
-
(*LocObj)->TryGetNumberField(TEXT("y"), Y);
|
|
76
|
-
(*LocObj)->TryGetNumberField(TEXT("z"), Z);
|
|
77
|
-
} else {
|
|
78
|
-
// Try location as array [x,y,z]
|
|
79
|
-
const TArray<TSharedPtr<FJsonValue>> *LocArr = nullptr;
|
|
80
|
-
if (Payload->TryGetArrayField(TEXT("location"), LocArr) && LocArr &&
|
|
81
|
-
LocArr->Num() >= 3) {
|
|
82
|
-
X = (*LocArr)[0]->AsNumber();
|
|
83
|
-
Y = (*LocArr)[1]->AsNumber();
|
|
84
|
-
Z = (*LocArr)[2]->AsNumber();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
int32 ComponentsX = 8, ComponentsY = 8;
|
|
90
|
-
bool bHasCX = Payload->TryGetNumberField(TEXT("componentsX"), ComponentsX);
|
|
91
|
-
bool bHasCY = Payload->TryGetNumberField(TEXT("componentsY"), ComponentsY);
|
|
92
|
-
|
|
93
|
-
int32 ComponentCount = 0;
|
|
94
|
-
Payload->TryGetNumberField(TEXT("componentCount"), ComponentCount);
|
|
95
|
-
if (!bHasCX && ComponentCount > 0) {
|
|
96
|
-
ComponentsX = ComponentCount;
|
|
97
|
-
}
|
|
98
|
-
if (!bHasCY && ComponentCount > 0) {
|
|
99
|
-
ComponentsY = ComponentCount;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// If sizeX/sizeY provided (world units), derive a coarse components estimate
|
|
103
|
-
double SizeXUnits = 0.0, SizeYUnits = 0.0;
|
|
104
|
-
if (Payload->TryGetNumberField(TEXT("sizeX"), SizeXUnits) && SizeXUnits > 0 &&
|
|
105
|
-
!bHasCX) {
|
|
106
|
-
ComponentsX =
|
|
107
|
-
FMath::Max(1, static_cast<int32>(FMath::Floor(SizeXUnits / 1000.0)));
|
|
108
|
-
}
|
|
109
|
-
if (Payload->TryGetNumberField(TEXT("sizeY"), SizeYUnits) && SizeYUnits > 0 &&
|
|
110
|
-
!bHasCY) {
|
|
111
|
-
ComponentsY =
|
|
112
|
-
FMath::Max(1, static_cast<int32>(FMath::Floor(SizeYUnits / 1000.0)));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
int32 QuadsPerComponent = 63;
|
|
116
|
-
if (!Payload->TryGetNumberField(TEXT("quadsPerComponent"),
|
|
117
|
-
QuadsPerComponent)) {
|
|
118
|
-
// Accept quadsPerSection synonym from some clients
|
|
119
|
-
Payload->TryGetNumberField(TEXT("quadsPerSection"), QuadsPerComponent);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
int32 SectionsPerComponent = 1;
|
|
123
|
-
Payload->TryGetNumberField(TEXT("sectionsPerComponent"),
|
|
124
|
-
SectionsPerComponent);
|
|
125
|
-
|
|
126
|
-
FString MaterialPath;
|
|
127
|
-
Payload->TryGetStringField(TEXT("materialPath"), MaterialPath);
|
|
128
|
-
if (MaterialPath.IsEmpty()) {
|
|
129
|
-
// Default to simple WorldGridMaterial if none provided to ensure visibility
|
|
130
|
-
MaterialPath = TEXT("/Engine/EngineMaterials/WorldGridMaterial");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// ... inside HandleCreateLandscape ...
|
|
134
|
-
if (!GEditor || !GEditor->GetEditorWorldContext().World()) {
|
|
135
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
136
|
-
TEXT("Editor world not available"),
|
|
137
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
FString NameOverride;
|
|
142
|
-
if (!Payload->TryGetStringField(TEXT("name"), NameOverride) ||
|
|
143
|
-
NameOverride.IsEmpty()) {
|
|
144
|
-
Payload->TryGetStringField(TEXT("landscapeName"), NameOverride);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Capture parameters by value for the async task
|
|
148
|
-
const int32 CaptComponentsX = ComponentsX;
|
|
149
|
-
const int32 CaptComponentsY = ComponentsY;
|
|
150
|
-
const int32 CaptQuadsPerComponent = QuadsPerComponent;
|
|
151
|
-
const int32 CaptSectionsPerComponent = SectionsPerComponent;
|
|
152
|
-
const FVector CaptLocation(X, Y, Z);
|
|
153
|
-
const FString CaptMaterialPath = MaterialPath;
|
|
154
|
-
const FString CaptName = NameOverride;
|
|
155
|
-
|
|
156
|
-
// Debug log to confirm name capture
|
|
157
|
-
UE_LOG(LogMcpAutomationBridgeSubsystem, Display,
|
|
158
|
-
TEXT("HandleCreateLandscape: Captured name '%s' (from override '%s')"),
|
|
159
|
-
*CaptName, *NameOverride);
|
|
160
|
-
|
|
161
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
162
|
-
|
|
163
|
-
// Execute on Game Thread to ensure thread safety for Actor spawning and
|
|
164
|
-
// Landscape operations
|
|
165
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
166
|
-
RequestingSocket, CaptComponentsX,
|
|
167
|
-
CaptComponentsY, CaptQuadsPerComponent,
|
|
168
|
-
CaptSectionsPerComponent, CaptLocation,
|
|
169
|
-
CaptMaterialPath, CaptName]() {
|
|
170
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
171
|
-
if (!Subsystem)
|
|
172
|
-
return;
|
|
173
|
-
|
|
174
|
-
if (!GEditor)
|
|
175
|
-
return;
|
|
176
|
-
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
177
|
-
if (!World)
|
|
178
|
-
return;
|
|
179
|
-
|
|
180
|
-
FActorSpawnParameters SpawnParams;
|
|
181
|
-
SpawnParams.SpawnCollisionHandlingOverride =
|
|
182
|
-
ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
|
183
|
-
ALandscape *Landscape =
|
|
184
|
-
World->SpawnActor<ALandscape>(ALandscape::StaticClass(), CaptLocation,
|
|
185
|
-
FRotator::ZeroRotator, SpawnParams);
|
|
186
|
-
if (!Landscape) {
|
|
187
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
188
|
-
TEXT("Failed to spawn landscape actor"),
|
|
189
|
-
TEXT("SPAWN_FAILED"));
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (!CaptName.IsEmpty()) {
|
|
194
|
-
Landscape->SetActorLabel(CaptName);
|
|
195
|
-
} else {
|
|
196
|
-
Landscape->SetActorLabel(FString::Printf(
|
|
197
|
-
TEXT("Landscape_%dx%d"), CaptComponentsX, CaptComponentsY));
|
|
198
|
-
}
|
|
199
|
-
Landscape->ComponentSizeQuads = CaptQuadsPerComponent;
|
|
200
|
-
Landscape->SubsectionSizeQuads =
|
|
201
|
-
CaptQuadsPerComponent / CaptSectionsPerComponent;
|
|
202
|
-
Landscape->NumSubsections = CaptSectionsPerComponent;
|
|
203
|
-
|
|
204
|
-
if (!CaptMaterialPath.IsEmpty()) {
|
|
205
|
-
UMaterialInterface *Mat =
|
|
206
|
-
LoadObject<UMaterialInterface>(nullptr, *CaptMaterialPath);
|
|
207
|
-
if (Mat) {
|
|
208
|
-
Landscape->LandscapeMaterial = Mat;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// CRITICAL INITIALIZATION ORDER:
|
|
213
|
-
// 1. Set Landscape GUID first. CreateLandscapeInfo depends on this.
|
|
214
|
-
if (!Landscape->GetLandscapeGuid().IsValid()) {
|
|
215
|
-
Landscape->SetLandscapeGuid(FGuid::NewGuid());
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// 2. Create Landscape Info. This will register itself with the Landscape's
|
|
219
|
-
// GUID.
|
|
220
|
-
Landscape->CreateLandscapeInfo();
|
|
221
|
-
|
|
222
|
-
const int32 VertX = CaptComponentsX * CaptQuadsPerComponent + 1;
|
|
223
|
-
const int32 VertY = CaptComponentsY * CaptQuadsPerComponent + 1;
|
|
224
|
-
|
|
225
|
-
TArray<uint16> HeightArray;
|
|
226
|
-
HeightArray.Init(32768, VertX * VertY);
|
|
227
|
-
|
|
228
|
-
const int32 InMinX = 0;
|
|
229
|
-
const int32 InMinY = 0;
|
|
230
|
-
const int32 InMaxX = CaptComponentsX * CaptQuadsPerComponent;
|
|
231
|
-
const int32 InMaxY = CaptComponentsY * CaptQuadsPerComponent;
|
|
232
|
-
const int32 NumSubsections = CaptSectionsPerComponent;
|
|
233
|
-
const int32 SubsectionSizeQuads =
|
|
234
|
-
CaptQuadsPerComponent / FMath::Max(1, CaptSectionsPerComponent);
|
|
235
|
-
|
|
236
|
-
// 3. Use a valid GUID for Import call, but zero GUID for map keys.
|
|
237
|
-
// Analysis of Landscape.cpp shows:
|
|
238
|
-
// - Import() asserts InGuid.IsValid()
|
|
239
|
-
// - BUT Import() uses FGuid() (zero) to look up data in the maps:
|
|
240
|
-
// InImportHeightData.FindChecked(FinalLayerGuid) where FinalLayerGuid is
|
|
241
|
-
// default constructed.
|
|
242
|
-
const FGuid ImportGuid =
|
|
243
|
-
FGuid::NewGuid(); // Valid GUID for the function call
|
|
244
|
-
const FGuid DataKey; // Zero GUID for the map keys
|
|
245
|
-
|
|
246
|
-
// 3. Populate maps with FGuid() keys because ALandscape::Import uses
|
|
247
|
-
// default GUID to look up data regardless of the GUID passed to the
|
|
248
|
-
// function (which is used for the layer definition itself).
|
|
249
|
-
TMap<FGuid, TArray<uint16>> ImportHeightData;
|
|
250
|
-
ImportHeightData.Add(FGuid(), HeightArray);
|
|
251
|
-
|
|
252
|
-
TMap<FGuid, TArray<FLandscapeImportLayerInfo>> ImportLayerInfos;
|
|
253
|
-
ImportLayerInfos.Add(FGuid(), TArray<FLandscapeImportLayerInfo>());
|
|
254
|
-
|
|
255
|
-
TArray<FLandscapeLayer> EditLayers;
|
|
256
|
-
|
|
257
|
-
// Use a transaction to ensure undo/redo and proper notification
|
|
258
|
-
{
|
|
259
|
-
const FScopedTransaction Transaction(
|
|
260
|
-
FText::FromString(TEXT("Create Landscape")));
|
|
261
|
-
Landscape->Modify();
|
|
262
|
-
|
|
263
|
-
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 7
|
|
264
|
-
// UE 5.7+: The Import() function has a known issue with fresh landscapes.
|
|
265
|
-
// Use CreateDefaultLayer instead to initialize a valid landscape
|
|
266
|
-
// structure. Note: bCanHaveLayersContent is deprecated/removed in 5.7 as
|
|
267
|
-
// all landscapes use edit layers.
|
|
268
|
-
|
|
269
|
-
// Create default edit layer to enable modification
|
|
270
|
-
if (Landscape->GetLayersConst().Num() == 0) {
|
|
271
|
-
Landscape->CreateDefaultLayer();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Explicitly request layer initialization to ensure components are ready
|
|
275
|
-
// Landscape->RequestLayersInitialization(true, true); // Removed to
|
|
276
|
-
// prevent crash: LandscapeEditLayers.cpp confirms this resets init state
|
|
277
|
-
// which is unstable here
|
|
278
|
-
|
|
279
|
-
// Note: We bypass feeding ImportHeightData here because doing so via
|
|
280
|
-
// Import() is what causes the crash in 5.7. A flat empty landscape is
|
|
281
|
-
// created instead.
|
|
282
|
-
|
|
283
|
-
#else
|
|
284
|
-
// UE 5.6 and older: Use standard Import() workflow
|
|
285
|
-
Landscape->Import(FGuid::NewGuid(), 0, 0, CaptComponentsX - 1, CaptComponentsY - 1, CaptSectionsPerComponent, CaptQuadsPerComponent, ImportHeightData, nullptr, ImportLayerInfos, ELandscapeImportAlphamapType::Layered, TArrayView<const FLandscapeLayer>(EditLayers));
|
|
286
|
-
Landscape->CreateDefaultLayer();
|
|
287
|
-
#endif
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Initialize properties AFTER import to avoid conflicts during component
|
|
291
|
-
// creation
|
|
292
|
-
if (CaptName.IsEmpty()) {
|
|
293
|
-
Landscape->SetActorLabel(FString::Printf(
|
|
294
|
-
TEXT("Landscape_%dx%d"), CaptComponentsX, CaptComponentsY));
|
|
295
|
-
} else {
|
|
296
|
-
Landscape->SetActorLabel(CaptName);
|
|
297
|
-
UE_LOG(LogMcpAutomationBridgeSubsystem, Display,
|
|
298
|
-
TEXT("HandleCreateLandscape: Set ActorLabel to '%s'"), *CaptName);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (!CaptMaterialPath.IsEmpty()) {
|
|
302
|
-
UMaterialInterface *Mat =
|
|
303
|
-
LoadObject<UMaterialInterface>(nullptr, *CaptMaterialPath);
|
|
304
|
-
if (Mat) {
|
|
305
|
-
Landscape->LandscapeMaterial = Mat;
|
|
306
|
-
// Re-assign material effectively
|
|
307
|
-
Landscape->PostEditChange();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Register components if Import didn't do it (it usually does re-register)
|
|
312
|
-
if (Landscape->GetRootComponent() &&
|
|
313
|
-
!Landscape->GetRootComponent()->IsRegistered()) {
|
|
314
|
-
Landscape->RegisterAllComponents();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Register components if Import didn't do it (it usually does re-register)
|
|
318
|
-
if (Landscape->GetRootComponent() &&
|
|
319
|
-
!Landscape->GetRootComponent()->IsRegistered()) {
|
|
320
|
-
Landscape->RegisterAllComponents();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Only call PostEditChange if the landscape is still valid and not pending
|
|
324
|
-
// kill
|
|
325
|
-
if (IsValid(Landscape)) {
|
|
326
|
-
Landscape->PostEditChange();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
330
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
331
|
-
Resp->SetStringField(TEXT("landscapePath"), Landscape->GetPathName());
|
|
332
|
-
Resp->SetStringField(TEXT("actorLabel"), Landscape->GetActorLabel());
|
|
333
|
-
Resp->SetNumberField(TEXT("componentsX"), CaptComponentsX);
|
|
334
|
-
Resp->SetNumberField(TEXT("componentsY"), CaptComponentsY);
|
|
335
|
-
Resp->SetNumberField(TEXT("quadsPerComponent"), CaptQuadsPerComponent);
|
|
336
|
-
|
|
337
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
338
|
-
TEXT("Landscape created successfully"),
|
|
339
|
-
Resp, FString());
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
return true;
|
|
343
|
-
#else
|
|
344
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
345
|
-
TEXT("create_landscape requires editor build."),
|
|
346
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
347
|
-
return true;
|
|
348
|
-
#endif
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
bool UMcpAutomationBridgeSubsystem::HandleModifyHeightmap(
|
|
352
|
-
const FString &RequestId, const FString &Action,
|
|
353
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
354
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
355
|
-
const FString Lower = Action.ToLower();
|
|
356
|
-
if (!Lower.Equals(TEXT("modify_heightmap"), ESearchCase::IgnoreCase)) {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
#if WITH_EDITOR
|
|
361
|
-
if (!Payload.IsValid()) {
|
|
362
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
363
|
-
TEXT("modify_heightmap payload missing"),
|
|
364
|
-
TEXT("INVALID_PAYLOAD"));
|
|
365
|
-
return true;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
FString LandscapePath;
|
|
369
|
-
Payload->TryGetStringField(TEXT("landscapePath"), LandscapePath);
|
|
370
|
-
FString LandscapeName;
|
|
371
|
-
Payload->TryGetStringField(TEXT("landscapeName"), LandscapeName);
|
|
372
|
-
|
|
373
|
-
const TArray<TSharedPtr<FJsonValue>> *HeightDataArray = nullptr;
|
|
374
|
-
if (!Payload->TryGetArrayField(TEXT("heightData"), HeightDataArray) ||
|
|
375
|
-
!HeightDataArray || HeightDataArray->Num() == 0) {
|
|
376
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
377
|
-
TEXT("heightData array required"),
|
|
378
|
-
TEXT("INVALID_ARGUMENT"));
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Copy height data for async task
|
|
383
|
-
TArray<uint16> HeightValues;
|
|
384
|
-
for (const TSharedPtr<FJsonValue> &Val : *HeightDataArray) {
|
|
385
|
-
if (Val.IsValid() && Val->Type == EJson::Number) {
|
|
386
|
-
HeightValues.Add(
|
|
387
|
-
static_cast<uint16>(FMath::Clamp(Val->AsNumber(), 0.0, 65535.0)));
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
392
|
-
|
|
393
|
-
// Dispatch to Game Thread
|
|
394
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
395
|
-
RequestingSocket, LandscapePath,
|
|
396
|
-
LandscapeName,
|
|
397
|
-
HeightValues =
|
|
398
|
-
MoveTemp(HeightValues)]() {
|
|
399
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
400
|
-
if (!Subsystem)
|
|
401
|
-
return;
|
|
402
|
-
|
|
403
|
-
ALandscape *Landscape = nullptr;
|
|
404
|
-
if (!LandscapePath.IsEmpty()) {
|
|
405
|
-
Landscape = Cast<ALandscape>(
|
|
406
|
-
StaticLoadObject(ALandscape::StaticClass(), nullptr, *LandscapePath));
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Find landscape with fallback to single instance
|
|
410
|
-
if (!Landscape && GEditor) {
|
|
411
|
-
if (UEditorActorSubsystem *ActorSS =
|
|
412
|
-
GEditor->GetEditorSubsystem<UEditorActorSubsystem>()) {
|
|
413
|
-
TArray<AActor *> AllActors = ActorSS->GetAllLevelActors();
|
|
414
|
-
ALandscape *Fallback = nullptr;
|
|
415
|
-
int32 Count = 0;
|
|
416
|
-
|
|
417
|
-
for (AActor *A : AllActors) {
|
|
418
|
-
if (ALandscape *L = Cast<ALandscape>(A)) {
|
|
419
|
-
Count++;
|
|
420
|
-
Fallback = L;
|
|
421
|
-
if (!LandscapeName.IsEmpty() &&
|
|
422
|
-
L->GetActorLabel().Equals(LandscapeName,
|
|
423
|
-
ESearchCase::IgnoreCase)) {
|
|
424
|
-
Landscape = L;
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (!Landscape && Count == 1) {
|
|
431
|
-
Landscape = Fallback;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (!Landscape) {
|
|
436
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
437
|
-
TEXT("Failed to find landscape"),
|
|
438
|
-
TEXT("LOAD_FAILED"));
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
ULandscapeInfo *LandscapeInfo = Landscape->GetLandscapeInfo();
|
|
443
|
-
if (!LandscapeInfo) {
|
|
444
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
445
|
-
TEXT("Landscape has no info"),
|
|
446
|
-
TEXT("INVALID_LANDSCAPE"));
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
FScopedSlowTask SlowTask(2.0f,
|
|
451
|
-
FText::FromString(TEXT("Modifying heightmap...")));
|
|
452
|
-
SlowTask.MakeDialog();
|
|
453
|
-
|
|
454
|
-
int32 MinX, MinY, MaxX, MaxY;
|
|
455
|
-
if (!LandscapeInfo->GetLandscapeExtent(MinX, MinY, MaxX, MaxY)) {
|
|
456
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
457
|
-
TEXT("Failed to get landscape extent"),
|
|
458
|
-
TEXT("INVALID_LANDSCAPE"));
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
SlowTask.EnterProgressFrame(
|
|
463
|
-
1.0f, FText::FromString(TEXT("Writing heightmap data")));
|
|
464
|
-
|
|
465
|
-
const int32 SizeX = (MaxX - MinX + 1);
|
|
466
|
-
const int32 SizeY = (MaxY - MinY + 1);
|
|
467
|
-
|
|
468
|
-
if (HeightValues.Num() != SizeX * SizeY) {
|
|
469
|
-
Subsystem->SendAutomationError(
|
|
470
|
-
RequestingSocket, RequestId,
|
|
471
|
-
FString::Printf(TEXT("Height data size mismatch. Expected %d x %d = "
|
|
472
|
-
"%d values, got %d"),
|
|
473
|
-
SizeX, SizeY, SizeX * SizeY, HeightValues.Num()),
|
|
474
|
-
TEXT("INVALID_ARGUMENT"));
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
FLandscapeEditDataInterface LandscapeEdit(LandscapeInfo);
|
|
479
|
-
LandscapeEdit.SetHeightData(MinX, MinY, MaxX, MaxY, HeightValues.GetData(),
|
|
480
|
-
SizeX, true);
|
|
481
|
-
|
|
482
|
-
SlowTask.EnterProgressFrame(
|
|
483
|
-
1.0f, FText::FromString(TEXT("Rebuilding collision")));
|
|
484
|
-
LandscapeEdit.Flush();
|
|
485
|
-
Landscape->PostEditChange();
|
|
486
|
-
|
|
487
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
488
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
489
|
-
Resp->SetStringField(TEXT("landscapePath"), LandscapePath);
|
|
490
|
-
Resp->SetNumberField(TEXT("modifiedVertices"), HeightValues.Num());
|
|
491
|
-
|
|
492
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
493
|
-
TEXT("Heightmap modified successfully"),
|
|
494
|
-
Resp, FString());
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
return true;
|
|
498
|
-
#else
|
|
499
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
500
|
-
TEXT("modify_heightmap requires editor build."),
|
|
501
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
502
|
-
return true;
|
|
503
|
-
#endif
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
bool UMcpAutomationBridgeSubsystem::HandlePaintLandscapeLayer(
|
|
507
|
-
const FString &RequestId, const FString &Action,
|
|
508
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
509
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
510
|
-
const FString Lower = Action.ToLower();
|
|
511
|
-
if (!Lower.Equals(TEXT("paint_landscape_layer"), ESearchCase::IgnoreCase)) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
#if WITH_EDITOR
|
|
516
|
-
if (!Payload.IsValid()) {
|
|
517
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
518
|
-
TEXT("paint_landscape_layer payload missing"),
|
|
519
|
-
TEXT("INVALID_PAYLOAD"));
|
|
520
|
-
return true;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
FString LandscapePath;
|
|
524
|
-
Payload->TryGetStringField(TEXT("landscapePath"), LandscapePath);
|
|
525
|
-
FString LandscapeName;
|
|
526
|
-
Payload->TryGetStringField(TEXT("landscapeName"), LandscapeName);
|
|
527
|
-
|
|
528
|
-
FString LayerName;
|
|
529
|
-
if (!Payload->TryGetStringField(TEXT("layerName"), LayerName) ||
|
|
530
|
-
LayerName.IsEmpty()) {
|
|
531
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("layerName required"),
|
|
532
|
-
TEXT("INVALID_ARGUMENT"));
|
|
533
|
-
return true;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// Paint region (optional - if not specified, paint entire landscape)
|
|
537
|
-
int32 MinX = -1, MinY = -1, MaxX = -1, MaxY = -1;
|
|
538
|
-
const TSharedPtr<FJsonObject> *RegionObj = nullptr;
|
|
539
|
-
if (Payload->TryGetObjectField(TEXT("region"), RegionObj) && RegionObj) {
|
|
540
|
-
(*RegionObj)->TryGetNumberField(TEXT("minX"), MinX);
|
|
541
|
-
(*RegionObj)->TryGetNumberField(TEXT("minY"), MinY);
|
|
542
|
-
(*RegionObj)->TryGetNumberField(TEXT("maxX"), MaxX);
|
|
543
|
-
(*RegionObj)->TryGetNumberField(TEXT("maxY"), MaxY);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
double Strength = 1.0;
|
|
547
|
-
Payload->TryGetNumberField(TEXT("strength"), Strength);
|
|
548
|
-
Strength = FMath::Clamp(Strength, 0.0, 1.0);
|
|
549
|
-
|
|
550
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
551
|
-
|
|
552
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
553
|
-
RequestingSocket, LandscapePath,
|
|
554
|
-
LandscapeName, LayerName, MinX, MinY,
|
|
555
|
-
MaxX, MaxY, Strength]() {
|
|
556
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
557
|
-
if (!Subsystem)
|
|
558
|
-
return;
|
|
559
|
-
|
|
560
|
-
ALandscape *Landscape = nullptr;
|
|
561
|
-
if (!LandscapePath.IsEmpty()) {
|
|
562
|
-
Landscape = Cast<ALandscape>(
|
|
563
|
-
StaticLoadObject(ALandscape::StaticClass(), nullptr, *LandscapePath));
|
|
564
|
-
}
|
|
565
|
-
if (!Landscape && !LandscapeName.IsEmpty()) {
|
|
566
|
-
if (UEditorActorSubsystem *ActorSS =
|
|
567
|
-
GEditor->GetEditorSubsystem<UEditorActorSubsystem>()) {
|
|
568
|
-
TArray<AActor *> AllActors = ActorSS->GetAllLevelActors();
|
|
569
|
-
for (AActor *A : AllActors) {
|
|
570
|
-
if (A && A->IsA<ALandscape>() &&
|
|
571
|
-
A->GetActorLabel().Equals(LandscapeName,
|
|
572
|
-
ESearchCase::IgnoreCase)) {
|
|
573
|
-
Landscape = Cast<ALandscape>(A);
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
if (!Landscape) {
|
|
580
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
581
|
-
TEXT("Failed to find landscape"),
|
|
582
|
-
TEXT("LOAD_FAILED"));
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
ULandscapeInfo *LandscapeInfo = Landscape->GetLandscapeInfo();
|
|
587
|
-
if (!LandscapeInfo) {
|
|
588
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
589
|
-
TEXT("Landscape has no info"),
|
|
590
|
-
TEXT("INVALID_LANDSCAPE"));
|
|
591
|
-
return;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
ULandscapeLayerInfoObject *LayerInfo = nullptr;
|
|
595
|
-
for (const FLandscapeInfoLayerSettings &Layer : LandscapeInfo->Layers) {
|
|
596
|
-
if (Layer.LayerName == FName(*LayerName)) {
|
|
597
|
-
LayerInfo = Layer.LayerInfoObj;
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (!LayerInfo) {
|
|
603
|
-
Subsystem->SendAutomationError(
|
|
604
|
-
RequestingSocket, RequestId,
|
|
605
|
-
FString::Printf(TEXT("Layer '%s' not found. Create layer first using "
|
|
606
|
-
"landscape editor."),
|
|
607
|
-
*LayerName),
|
|
608
|
-
TEXT("LAYER_NOT_FOUND"));
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
FScopedSlowTask SlowTask(
|
|
613
|
-
1.0f, FText::FromString(TEXT("Painting landscape layer...")));
|
|
614
|
-
SlowTask.MakeDialog();
|
|
615
|
-
|
|
616
|
-
int32 PaintMinX = MinX;
|
|
617
|
-
int32 PaintMinY = MinY;
|
|
618
|
-
int32 PaintMaxX = MaxX;
|
|
619
|
-
int32 PaintMaxY = MaxY;
|
|
620
|
-
if (PaintMinX < 0 || PaintMaxX < 0) {
|
|
621
|
-
LandscapeInfo->GetLandscapeExtent(PaintMinX, PaintMinY, PaintMaxX,
|
|
622
|
-
PaintMaxY);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
FLandscapeEditDataInterface LandscapeEdit(LandscapeInfo);
|
|
626
|
-
const uint8 PaintValue = static_cast<uint8>(Strength * 255.0);
|
|
627
|
-
const int32 RegionSizeX = (PaintMaxX - PaintMinX + 1);
|
|
628
|
-
const int32 RegionSizeY = (PaintMaxY - PaintMinY + 1);
|
|
629
|
-
|
|
630
|
-
TArray<uint8> AlphaData;
|
|
631
|
-
AlphaData.Init(PaintValue, RegionSizeX * RegionSizeY);
|
|
632
|
-
|
|
633
|
-
LandscapeEdit.SetAlphaData(LayerInfo, PaintMinX, PaintMinY, PaintMaxX,
|
|
634
|
-
PaintMaxY, AlphaData.GetData(), RegionSizeX);
|
|
635
|
-
LandscapeEdit.Flush();
|
|
636
|
-
Landscape->PostEditChange();
|
|
637
|
-
|
|
638
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
639
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
640
|
-
Resp->SetStringField(TEXT("landscapePath"), LandscapePath);
|
|
641
|
-
Resp->SetStringField(TEXT("layerName"), LayerName);
|
|
642
|
-
Resp->SetNumberField(TEXT("strength"), Strength);
|
|
643
|
-
|
|
644
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
645
|
-
TEXT("Layer painted successfully"), Resp,
|
|
646
|
-
FString());
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
return true;
|
|
650
|
-
#else
|
|
651
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
652
|
-
TEXT("paint_landscape_layer requires editor build."),
|
|
653
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
654
|
-
return true;
|
|
655
|
-
#endif
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
bool UMcpAutomationBridgeSubsystem::HandleSculptLandscape(
|
|
659
|
-
const FString &RequestId, const FString &Action,
|
|
660
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
661
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
662
|
-
const FString Lower = Action.ToLower();
|
|
663
|
-
if (!Lower.Equals(TEXT("sculpt_landscape"), ESearchCase::IgnoreCase)) {
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
#if WITH_EDITOR
|
|
668
|
-
if (!Payload.IsValid()) {
|
|
669
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
670
|
-
TEXT("sculpt_landscape payload missing"),
|
|
671
|
-
TEXT("INVALID_PAYLOAD"));
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
FString LandscapePath;
|
|
676
|
-
Payload->TryGetStringField(TEXT("landscapePath"), LandscapePath);
|
|
677
|
-
FString LandscapeName;
|
|
678
|
-
Payload->TryGetStringField(TEXT("landscapeName"), LandscapeName);
|
|
679
|
-
|
|
680
|
-
UE_LOG(LogMcpAutomationBridgeSubsystem, Warning,
|
|
681
|
-
TEXT("HandleSculptLandscape: RequestId=%s Path='%s' Name='%s'"),
|
|
682
|
-
*RequestId, *LandscapePath, *LandscapeName);
|
|
683
|
-
|
|
684
|
-
double LocX = 0, LocY = 0, LocZ = 0;
|
|
685
|
-
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
686
|
-
// Accept both 'location' and 'position' parameter names for consistency
|
|
687
|
-
if (Payload->TryGetObjectField(TEXT("location"), LocObj) && LocObj) {
|
|
688
|
-
(*LocObj)->TryGetNumberField(TEXT("x"), LocX);
|
|
689
|
-
(*LocObj)->TryGetNumberField(TEXT("y"), LocY);
|
|
690
|
-
(*LocObj)->TryGetNumberField(TEXT("z"), LocZ);
|
|
691
|
-
} else if (Payload->TryGetObjectField(TEXT("position"), LocObj) && LocObj) {
|
|
692
|
-
(*LocObj)->TryGetNumberField(TEXT("x"), LocX);
|
|
693
|
-
(*LocObj)->TryGetNumberField(TEXT("y"), LocY);
|
|
694
|
-
(*LocObj)->TryGetNumberField(TEXT("z"), LocZ);
|
|
695
|
-
} else {
|
|
696
|
-
SendAutomationError(
|
|
697
|
-
RequestingSocket, RequestId,
|
|
698
|
-
TEXT("location or position required. Example: {\"location\": {\"x\": "
|
|
699
|
-
"0, \"y\": 0, \"z\": 100}}"),
|
|
700
|
-
TEXT("INVALID_ARGUMENT"));
|
|
701
|
-
return true;
|
|
702
|
-
}
|
|
703
|
-
FVector TargetLocation(LocX, LocY, LocZ);
|
|
704
|
-
|
|
705
|
-
FString ToolMode = TEXT("Raise");
|
|
706
|
-
Payload->TryGetStringField(TEXT("toolMode"), ToolMode);
|
|
707
|
-
|
|
708
|
-
double BrushRadius = 1000.0;
|
|
709
|
-
Payload->TryGetNumberField(TEXT("brushRadius"), BrushRadius);
|
|
710
|
-
|
|
711
|
-
double BrushFalloff = 0.5;
|
|
712
|
-
Payload->TryGetNumberField(TEXT("brushFalloff"), BrushFalloff);
|
|
713
|
-
|
|
714
|
-
double Strength = 0.1;
|
|
715
|
-
Payload->TryGetNumberField(TEXT("strength"), Strength);
|
|
716
|
-
|
|
717
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
718
|
-
|
|
719
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
720
|
-
RequestingSocket, LandscapePath,
|
|
721
|
-
LandscapeName, TargetLocation, ToolMode,
|
|
722
|
-
BrushRadius, BrushFalloff, Strength]() {
|
|
723
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
724
|
-
if (!Subsystem)
|
|
725
|
-
return;
|
|
726
|
-
|
|
727
|
-
ALandscape *Landscape = nullptr;
|
|
728
|
-
if (!LandscapePath.IsEmpty()) {
|
|
729
|
-
Landscape = Cast<ALandscape>(
|
|
730
|
-
StaticLoadObject(ALandscape::StaticClass(), nullptr, *LandscapePath));
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
if (!Landscape && GEditor) {
|
|
734
|
-
if (UEditorActorSubsystem *ActorSS =
|
|
735
|
-
GEditor->GetEditorSubsystem<UEditorActorSubsystem>()) {
|
|
736
|
-
TArray<AActor *> AllActors = ActorSS->GetAllLevelActors();
|
|
737
|
-
ALandscape *Fallback = nullptr;
|
|
738
|
-
int32 LandscapeCount = 0;
|
|
739
|
-
|
|
740
|
-
for (AActor *A : AllActors) {
|
|
741
|
-
if (ALandscape *L = Cast<ALandscape>(A)) {
|
|
742
|
-
LandscapeCount++;
|
|
743
|
-
Fallback = L;
|
|
744
|
-
|
|
745
|
-
if (!LandscapeName.IsEmpty() &&
|
|
746
|
-
L->GetActorLabel().Equals(LandscapeName,
|
|
747
|
-
ESearchCase::IgnoreCase)) {
|
|
748
|
-
Landscape = L;
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
if (!Landscape && LandscapeCount == 1) {
|
|
755
|
-
Landscape = Fallback;
|
|
756
|
-
UE_LOG(LogMcpAutomationBridgeSubsystem, Warning,
|
|
757
|
-
TEXT("HandleSculptLandscape: Exact match for '%s' not found, "
|
|
758
|
-
"using single available Landscape: '%s'"),
|
|
759
|
-
*LandscapeName, *Landscape->GetActorLabel());
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
if (!Landscape) {
|
|
764
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
765
|
-
TEXT("Failed to find landscape"),
|
|
766
|
-
TEXT("LOAD_FAILED"));
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
ULandscapeInfo *LandscapeInfo = Landscape->GetLandscapeInfo();
|
|
771
|
-
if (!LandscapeInfo) {
|
|
772
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
773
|
-
TEXT("Landscape has no info"),
|
|
774
|
-
TEXT("INVALID_LANDSCAPE"));
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
// Convert World Location to Landscape Local Space
|
|
779
|
-
FVector LocalPos =
|
|
780
|
-
Landscape->GetActorTransform().InverseTransformPosition(TargetLocation);
|
|
781
|
-
int32 CenterX = FMath::RoundToInt(LocalPos.X);
|
|
782
|
-
int32 CenterY = FMath::RoundToInt(LocalPos.Y);
|
|
783
|
-
|
|
784
|
-
// Convert Brush Radius to Vertex Units (assuming uniform scale for
|
|
785
|
-
// simplicity, or use X)
|
|
786
|
-
float ScaleX = Landscape->GetActorScale3D().X;
|
|
787
|
-
int32 RadiusVerts = FMath::Max(1, FMath::RoundToInt(BrushRadius / ScaleX));
|
|
788
|
-
int32 FalloffVerts = FMath::RoundToInt(RadiusVerts * BrushFalloff);
|
|
789
|
-
|
|
790
|
-
int32 MinX = CenterX - RadiusVerts;
|
|
791
|
-
int32 MaxX = CenterX + RadiusVerts;
|
|
792
|
-
int32 MinY = CenterY - RadiusVerts;
|
|
793
|
-
int32 MaxY = CenterY + RadiusVerts;
|
|
794
|
-
|
|
795
|
-
// Clamp to landscape extents
|
|
796
|
-
int32 LMinX, LMinY, LMaxX, LMaxY;
|
|
797
|
-
if (LandscapeInfo->GetLandscapeExtent(LMinX, LMinY, LMaxX, LMaxY)) {
|
|
798
|
-
MinX = FMath::Max(MinX, LMinX);
|
|
799
|
-
MinY = FMath::Max(MinY, LMinY);
|
|
800
|
-
MaxX = FMath::Min(MaxX, LMaxX);
|
|
801
|
-
MaxY = FMath::Min(MaxY, LMaxY);
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
if (MinX > MaxX || MinY > MaxY) {
|
|
805
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
806
|
-
TEXT("Brush outside landscape bounds"),
|
|
807
|
-
nullptr, TEXT("OUT_OF_BOUNDS"));
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
int32 SizeX = MaxX - MinX + 1;
|
|
812
|
-
int32 SizeY = MaxY - MinY + 1;
|
|
813
|
-
TArray<uint16> HeightData;
|
|
814
|
-
HeightData.SetNumZeroed(SizeX * SizeY);
|
|
815
|
-
|
|
816
|
-
FLandscapeEditDataInterface LandscapeEdit(LandscapeInfo);
|
|
817
|
-
LandscapeEdit.GetHeightData(MinX, MinY, MaxX, MaxY, HeightData.GetData(),
|
|
818
|
-
0);
|
|
819
|
-
|
|
820
|
-
bool bModified = false;
|
|
821
|
-
for (int32 Y = MinY; Y <= MaxY; ++Y) {
|
|
822
|
-
for (int32 X = MinX; X <= MaxX; ++X) {
|
|
823
|
-
float Dist = FMath::Sqrt(FMath::Square((float)(X - CenterX)) +
|
|
824
|
-
FMath::Square((float)(Y - CenterY)));
|
|
825
|
-
if (Dist > RadiusVerts)
|
|
826
|
-
continue;
|
|
827
|
-
|
|
828
|
-
float Alpha = 1.0f;
|
|
829
|
-
if (Dist > (RadiusVerts - FalloffVerts)) {
|
|
830
|
-
Alpha = 1.0f -
|
|
831
|
-
((Dist - (RadiusVerts - FalloffVerts)) / (float)FalloffVerts);
|
|
832
|
-
}
|
|
833
|
-
Alpha = FMath::Clamp(Alpha, 0.0f, 1.0f);
|
|
834
|
-
|
|
835
|
-
int32 Index = (Y - MinY) * SizeX + (X - MinX);
|
|
836
|
-
if (Index < 0 || Index >= HeightData.Num())
|
|
837
|
-
continue;
|
|
838
|
-
|
|
839
|
-
uint16 CurrentHeight = HeightData[Index];
|
|
840
|
-
|
|
841
|
-
float ScaleZ = Landscape->GetActorScale3D().Z;
|
|
842
|
-
float HeightScale =
|
|
843
|
-
128.0f / ScaleZ; // Conversion factor from World Z to uint16
|
|
844
|
-
|
|
845
|
-
float Delta = 0.0f;
|
|
846
|
-
if (ToolMode.Equals(TEXT("Raise"), ESearchCase::IgnoreCase)) {
|
|
847
|
-
Delta = Strength * Alpha * 100.0f *
|
|
848
|
-
HeightScale; // Arbitrary strength multiplier
|
|
849
|
-
} else if (ToolMode.Equals(TEXT("Lower"), ESearchCase::IgnoreCase)) {
|
|
850
|
-
Delta = -Strength * Alpha * 100.0f * HeightScale;
|
|
851
|
-
} else if (ToolMode.Equals(TEXT("Flatten"), ESearchCase::IgnoreCase)) {
|
|
852
|
-
float CurrentVal = (float)CurrentHeight;
|
|
853
|
-
float Target = (TargetLocation.Z - Landscape->GetActorLocation().Z) /
|
|
854
|
-
ScaleZ * 128.0f +
|
|
855
|
-
32768.0f;
|
|
856
|
-
Delta = (Target - CurrentVal) * Strength * Alpha;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
int32 NewHeight =
|
|
860
|
-
FMath::Clamp((int32)(CurrentHeight + Delta), 0, 65535);
|
|
861
|
-
if (NewHeight != CurrentHeight) {
|
|
862
|
-
HeightData[Index] = (uint16)NewHeight;
|
|
863
|
-
bModified = true;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
if (bModified) {
|
|
869
|
-
LandscapeEdit.SetHeightData(MinX, MinY, MaxX, MaxY, HeightData.GetData(),
|
|
870
|
-
0, true);
|
|
871
|
-
LandscapeEdit.Flush();
|
|
872
|
-
Landscape->PostEditChange();
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
876
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
877
|
-
Resp->SetStringField(TEXT("toolMode"), ToolMode);
|
|
878
|
-
Resp->SetNumberField(TEXT("modifiedVertices"),
|
|
879
|
-
bModified ? HeightData.Num() : 0);
|
|
880
|
-
|
|
881
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
882
|
-
TEXT("Landscape sculpted"), Resp,
|
|
883
|
-
FString());
|
|
884
|
-
});
|
|
885
|
-
|
|
886
|
-
return true;
|
|
887
|
-
#else
|
|
888
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
889
|
-
TEXT("sculpt_landscape requires editor build."),
|
|
890
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
891
|
-
return true;
|
|
892
|
-
#endif
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
bool UMcpAutomationBridgeSubsystem::HandleSetLandscapeMaterial(
|
|
896
|
-
const FString &RequestId, const FString &Action,
|
|
897
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
898
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
899
|
-
const FString Lower = Action.ToLower();
|
|
900
|
-
if (!Lower.Equals(TEXT("set_landscape_material"), ESearchCase::IgnoreCase)) {
|
|
901
|
-
return false;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
#if WITH_EDITOR
|
|
905
|
-
if (!Payload.IsValid()) {
|
|
906
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
907
|
-
TEXT("set_landscape_material payload missing"),
|
|
908
|
-
TEXT("INVALID_PAYLOAD"));
|
|
909
|
-
return true;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
FString LandscapePath;
|
|
913
|
-
Payload->TryGetStringField(TEXT("landscapePath"), LandscapePath);
|
|
914
|
-
FString LandscapeName;
|
|
915
|
-
Payload->TryGetStringField(TEXT("landscapeName"), LandscapeName);
|
|
916
|
-
FString MaterialPath;
|
|
917
|
-
if (!Payload->TryGetStringField(TEXT("materialPath"), MaterialPath) ||
|
|
918
|
-
MaterialPath.IsEmpty()) {
|
|
919
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
920
|
-
TEXT("materialPath required"),
|
|
921
|
-
TEXT("INVALID_ARGUMENT"));
|
|
922
|
-
return true;
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
926
|
-
|
|
927
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
928
|
-
RequestingSocket, LandscapePath,
|
|
929
|
-
LandscapeName, MaterialPath]() {
|
|
930
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
931
|
-
if (!Subsystem)
|
|
932
|
-
return;
|
|
933
|
-
|
|
934
|
-
ALandscape *Landscape = nullptr;
|
|
935
|
-
if (!LandscapePath.IsEmpty()) {
|
|
936
|
-
Landscape = Cast<ALandscape>(
|
|
937
|
-
StaticLoadObject(ALandscape::StaticClass(), nullptr, *LandscapePath));
|
|
938
|
-
}
|
|
939
|
-
if (!Landscape && !LandscapeName.IsEmpty()) {
|
|
940
|
-
if (UEditorActorSubsystem *ActorSS =
|
|
941
|
-
GEditor->GetEditorSubsystem<UEditorActorSubsystem>()) {
|
|
942
|
-
TArray<AActor *> AllActors = ActorSS->GetAllLevelActors();
|
|
943
|
-
for (AActor *A : AllActors) {
|
|
944
|
-
if (A && A->IsA<ALandscape>() &&
|
|
945
|
-
A->GetActorLabel().Equals(LandscapeName,
|
|
946
|
-
ESearchCase::IgnoreCase)) {
|
|
947
|
-
Landscape = Cast<ALandscape>(A);
|
|
948
|
-
break;
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
// Fallback: If no path/name provided (or name not found but let's be
|
|
955
|
-
// generous if no path was given), find first available landscape
|
|
956
|
-
if (!Landscape && LandscapePath.IsEmpty() && LandscapeName.IsEmpty()) {
|
|
957
|
-
if (UEditorActorSubsystem *ActorSS =
|
|
958
|
-
GEditor->GetEditorSubsystem<UEditorActorSubsystem>()) {
|
|
959
|
-
TArray<AActor *> AllActors = ActorSS->GetAllLevelActors();
|
|
960
|
-
for (AActor *A : AllActors) {
|
|
961
|
-
if (ALandscape *L = Cast<ALandscape>(A)) {
|
|
962
|
-
Landscape = L;
|
|
963
|
-
break;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
if (!Landscape) {
|
|
969
|
-
Subsystem->SendAutomationError(
|
|
970
|
-
RequestingSocket, RequestId,
|
|
971
|
-
TEXT("Failed to find landscape and no name provided"),
|
|
972
|
-
TEXT("LOAD_FAILED"));
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
// Use Silent load to avoid engine warnings if path is invalid or type
|
|
977
|
-
// mismatch
|
|
978
|
-
UMaterialInterface *Mat = Cast<UMaterialInterface>(
|
|
979
|
-
StaticLoadObject(UMaterialInterface::StaticClass(), nullptr,
|
|
980
|
-
*MaterialPath, nullptr, LOAD_NoWarn));
|
|
981
|
-
|
|
982
|
-
if (!Mat) {
|
|
983
|
-
// Check existence separately only if load failed, to distinguish error
|
|
984
|
-
// type (optional)
|
|
985
|
-
if (!UEditorAssetLibrary::DoesAssetExist(MaterialPath)) {
|
|
986
|
-
Subsystem->SendAutomationError(
|
|
987
|
-
RequestingSocket, RequestId,
|
|
988
|
-
FString::Printf(TEXT("Material asset not found: %s"),
|
|
989
|
-
*MaterialPath),
|
|
990
|
-
TEXT("ASSET_NOT_FOUND"));
|
|
991
|
-
} else {
|
|
992
|
-
Subsystem->SendAutomationError(
|
|
993
|
-
RequestingSocket, RequestId,
|
|
994
|
-
TEXT("Failed to load material (invalid type?)"),
|
|
995
|
-
TEXT("LOAD_FAILED"));
|
|
996
|
-
}
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
Landscape->LandscapeMaterial = Mat;
|
|
1001
|
-
Landscape->PostEditChange();
|
|
1002
|
-
|
|
1003
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
1004
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
1005
|
-
Resp->SetStringField(TEXT("landscapePath"), Landscape->GetPathName());
|
|
1006
|
-
Resp->SetStringField(TEXT("materialPath"), MaterialPath);
|
|
1007
|
-
|
|
1008
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
1009
|
-
TEXT("Landscape material set"), Resp,
|
|
1010
|
-
FString());
|
|
1011
|
-
});
|
|
1012
|
-
|
|
1013
|
-
return true;
|
|
1014
|
-
#else
|
|
1015
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1016
|
-
TEXT("set_landscape_material requires editor build."),
|
|
1017
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
1018
|
-
return true;
|
|
1019
|
-
#endif
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
bool UMcpAutomationBridgeSubsystem::HandleCreateLandscapeGrassType(
|
|
1023
|
-
const FString &RequestId, const FString &Action,
|
|
1024
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
1025
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
1026
|
-
const FString Lower = Action.ToLower();
|
|
1027
|
-
if (!Lower.Equals(TEXT("create_landscape_grass_type"),
|
|
1028
|
-
ESearchCase::IgnoreCase)) {
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
#if WITH_EDITOR
|
|
1033
|
-
if (!Payload.IsValid()) {
|
|
1034
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
1035
|
-
TEXT("create_landscape_grass_type payload missing"),
|
|
1036
|
-
TEXT("INVALID_PAYLOAD"));
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
FString Name;
|
|
1041
|
-
if (!Payload->TryGetStringField(TEXT("name"), Name) || Name.IsEmpty()) {
|
|
1042
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("name required"),
|
|
1043
|
-
TEXT("INVALID_ARGUMENT"));
|
|
1044
|
-
return true;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
FString MeshPath;
|
|
1048
|
-
if (!Payload->TryGetStringField(TEXT("meshPath"), MeshPath) ||
|
|
1049
|
-
MeshPath.IsEmpty()) {
|
|
1050
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("meshPath required"),
|
|
1051
|
-
TEXT("INVALID_ARGUMENT"));
|
|
1052
|
-
return true;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
double Density = 1.0;
|
|
1056
|
-
Payload->TryGetNumberField(TEXT("density"), Density);
|
|
1057
|
-
|
|
1058
|
-
double MinScale = 0.8;
|
|
1059
|
-
Payload->TryGetNumberField(TEXT("minScale"), MinScale);
|
|
1060
|
-
|
|
1061
|
-
double MaxScale = 1.2;
|
|
1062
|
-
Payload->TryGetNumberField(TEXT("maxScale"), MaxScale);
|
|
1063
|
-
|
|
1064
|
-
TWeakObjectPtr<UMcpAutomationBridgeSubsystem> WeakSubsystem(this);
|
|
1065
|
-
|
|
1066
|
-
AsyncTask(ENamedThreads::GameThread, [WeakSubsystem, RequestId,
|
|
1067
|
-
RequestingSocket, Name, MeshPath,
|
|
1068
|
-
Density, MinScale, MaxScale]() {
|
|
1069
|
-
UMcpAutomationBridgeSubsystem *Subsystem = WeakSubsystem.Get();
|
|
1070
|
-
if (!Subsystem)
|
|
1071
|
-
return;
|
|
1072
|
-
|
|
1073
|
-
// Use Silent load to avoid engine warnings
|
|
1074
|
-
UStaticMesh *StaticMesh = Cast<UStaticMesh>(StaticLoadObject(
|
|
1075
|
-
UStaticMesh::StaticClass(), nullptr, *MeshPath, nullptr, LOAD_NoWarn));
|
|
1076
|
-
if (!StaticMesh) {
|
|
1077
|
-
Subsystem->SendAutomationError(
|
|
1078
|
-
RequestingSocket, RequestId,
|
|
1079
|
-
FString::Printf(TEXT("Static mesh not found: %s"), *MeshPath),
|
|
1080
|
-
TEXT("ASSET_NOT_FOUND"));
|
|
1081
|
-
return;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
FString PackagePath = TEXT("/Game/Landscape");
|
|
1085
|
-
FString AssetName = Name;
|
|
1086
|
-
FString FullPackagePath =
|
|
1087
|
-
FString::Printf(TEXT("%s/%s"), *PackagePath, *AssetName);
|
|
1088
|
-
|
|
1089
|
-
// Check if already exists
|
|
1090
|
-
if (UObject *ExistingAsset = StaticLoadObject(
|
|
1091
|
-
ULandscapeGrassType::StaticClass(), nullptr, *FullPackagePath)) {
|
|
1092
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
1093
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
1094
|
-
Resp->SetStringField(TEXT("asset_path"), ExistingAsset->GetPathName());
|
|
1095
|
-
Resp->SetStringField(TEXT("message"), TEXT("Asset already exists"));
|
|
1096
|
-
Subsystem->SendAutomationResponse(
|
|
1097
|
-
RequestingSocket, RequestId, true,
|
|
1098
|
-
TEXT("Landscape grass type already exists"), Resp, FString());
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
UPackage *Package = CreatePackage(*FullPackagePath);
|
|
1103
|
-
ULandscapeGrassType *GrassType = NewObject<ULandscapeGrassType>(
|
|
1104
|
-
Package, FName(*AssetName), RF_Public | RF_Standalone);
|
|
1105
|
-
if (!GrassType) {
|
|
1106
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
1107
|
-
TEXT("Failed to create grass type asset"),
|
|
1108
|
-
TEXT("CREATION_FAILED"));
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
FGrassVariety Variety;
|
|
1113
|
-
Variety.GrassMesh = StaticMesh;
|
|
1114
|
-
Variety.GrassDensity.Default = static_cast<float>(Density);
|
|
1115
|
-
|
|
1116
|
-
Variety.ScaleX = FFloatInterval(static_cast<float>(MinScale),
|
|
1117
|
-
static_cast<float>(MaxScale));
|
|
1118
|
-
Variety.ScaleY = FFloatInterval(static_cast<float>(MinScale),
|
|
1119
|
-
static_cast<float>(MaxScale));
|
|
1120
|
-
Variety.ScaleZ = FFloatInterval(static_cast<float>(MinScale),
|
|
1121
|
-
static_cast<float>(MaxScale));
|
|
1122
|
-
|
|
1123
|
-
Variety.RandomRotation = true;
|
|
1124
|
-
Variety.AlignToSurface = true;
|
|
1125
|
-
|
|
1126
|
-
GrassType->GrassVarieties.Add(Variety);
|
|
1127
|
-
|
|
1128
|
-
Package->MarkPackageDirty();
|
|
1129
|
-
FAssetRegistryModule::AssetCreated(GrassType);
|
|
1130
|
-
|
|
1131
|
-
FString PackageFileName = FPackageName::LongPackageNameToFilename(
|
|
1132
|
-
FullPackagePath, FPackageName::GetAssetPackageExtension());
|
|
1133
|
-
FSavePackageArgs SaveArgs;
|
|
1134
|
-
SaveArgs.TopLevelFlags = RF_Public | RF_Standalone;
|
|
1135
|
-
SaveArgs.Error = GError;
|
|
1136
|
-
SaveArgs.SaveFlags = SAVE_NoError;
|
|
1137
|
-
bool bSaved =
|
|
1138
|
-
UPackage::SavePackage(Package, GrassType, *PackageFileName, SaveArgs);
|
|
1139
|
-
|
|
1140
|
-
if (!bSaved) {
|
|
1141
|
-
Subsystem->SendAutomationError(RequestingSocket, RequestId,
|
|
1142
|
-
TEXT("Failed to save grass type asset"),
|
|
1143
|
-
TEXT("SAVE_FAILED"));
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
1148
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
1149
|
-
Resp->SetStringField(TEXT("asset_path"), GrassType->GetPathName());
|
|
1150
|
-
|
|
1151
|
-
Subsystem->SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
1152
|
-
TEXT("Landscape grass type created"),
|
|
1153
|
-
Resp, FString());
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
return true;
|
|
1157
|
-
#else
|
|
1158
|
-
SendAutomationResponse(
|
|
1159
|
-
RequestingSocket, RequestId, false,
|
|
1160
|
-
TEXT("create_landscape_grass_type requires editor build."), nullptr,
|
|
1161
|
-
TEXT("NOT_IMPLEMENTED"));
|
|
1162
|
-
return true;
|
|
1163
|
-
#endif
|
|
1164
|
-
}
|