topotopo 0.4.0 → 0.5.1
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/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +327 -147
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +198 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +57 -5
- package/dist/render/preview.d.ts +17 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +74 -5
- package/dist/render/raster.js +527 -143
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +13 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorExportPlugin
|
|
3
|
+
## Keeps TopoTopo's files out of exports, and lists in the export log every package whose outputs are failed, stale or
|
|
4
|
+
## never cooked (a plugin cannot fail an export; CI runs topotopo godot status --strict or tools/check.gd).
|
|
5
|
+
## The addon's .gd files never reach _export_file (Godot's GDScript exporter takes them first): topotopo godot setup
|
|
6
|
+
## adds addons/topotopo/* to every preset's exclude_filter.
|
|
7
|
+
|
|
8
|
+
## A package's TopoTopo folders, never shipped (a safety net for a missing .gdignore), and its concept art.
|
|
9
|
+
const PACKAGE_DIRS := ["graphs", "assets", "inputs", "exports", "versions", "packages", "attachments"]
|
|
10
|
+
## Files at a package's top level that are notes and manifests, never shipped.
|
|
11
|
+
const PACKAGE_TOP := ["json", "md", "txt"]
|
|
12
|
+
|
|
13
|
+
## plugin.gd: the package checks.
|
|
14
|
+
var host: Object
|
|
15
|
+
var _package_of := {}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
func _get_name() -> String:
|
|
19
|
+
return "TopoTopo"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
func _export_begin(_features: PackedStringArray, _is_debug: bool, _path: String, _flags: int) -> void:
|
|
23
|
+
_package_of.clear()
|
|
24
|
+
if host == null:
|
|
25
|
+
return
|
|
26
|
+
for p in host.export_problems():
|
|
27
|
+
get_export_platform().add_message(EditorExportPlatform.EXPORT_MESSAGE_ERROR, "TopoTopo", p)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
func _export_end() -> void:
|
|
31
|
+
_package_of.clear()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
func _export_file(path: String, _type: String, _features: PackedStringArray) -> void:
|
|
35
|
+
if skipped(path):
|
|
36
|
+
skip()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Whether an exported file is one of TopoTopo's: a .topo (its status resource), the addon, the workspace manifest and
|
|
40
|
+
## its shared copies, and inside a package folder (a folder holding a .topo) its top-level .json/.md/.txt files and
|
|
41
|
+
## everything under its TopoTopo folders.
|
|
42
|
+
func skipped(path: String) -> bool:
|
|
43
|
+
if path.get_extension() == "topo":
|
|
44
|
+
return true
|
|
45
|
+
if path.begins_with("res://addons/topotopo/"):
|
|
46
|
+
return true
|
|
47
|
+
if path == "res://topotopo-workspace.json" or path.begins_with("res://topotopo-packages/") or path.contains("/topotopo-packages/"):
|
|
48
|
+
return true
|
|
49
|
+
var pkg := _package_dir_of(path.get_base_dir())
|
|
50
|
+
if pkg == "":
|
|
51
|
+
return false
|
|
52
|
+
var rel := path.trim_prefix(pkg + "/")
|
|
53
|
+
if not rel.contains("/"):
|
|
54
|
+
return PACKAGE_TOP.has(rel.get_extension().to_lower())
|
|
55
|
+
return PACKAGE_DIRS.has(rel.get_slice("/", 0))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## The nearest folder at or above `dir` that holds a .topo, or "".
|
|
59
|
+
func _package_dir_of(dir: String) -> String:
|
|
60
|
+
var d := dir
|
|
61
|
+
while d != "" and d != "res:" and d != "res://":
|
|
62
|
+
if not _package_of.has(d):
|
|
63
|
+
var found := false
|
|
64
|
+
for f in DirAccess.get_files_at(d):
|
|
65
|
+
if f.length() > 5 and f.ends_with(".topo"):
|
|
66
|
+
found = true
|
|
67
|
+
break
|
|
68
|
+
_package_of[d] = found
|
|
69
|
+
if _package_of[d]:
|
|
70
|
+
return d
|
|
71
|
+
d = d.get_base_dir()
|
|
72
|
+
return ""
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends GLTFDocumentExtension
|
|
3
|
+
## Reads EXT_mesh_gpu_instancing, which TopoTopo writes for packed instances: each instance's TRANSLATION, ROTATION and
|
|
4
|
+
## SCALE (and _COLOR when the instances carry a colour) go into node metadata as MultiMesh rows, which
|
|
5
|
+
## instances_post_import.gd turns into a MultiMeshInstance3D after Godot made the meshes. GLBs without the extension
|
|
6
|
+
## are left alone.
|
|
7
|
+
|
|
8
|
+
const EXT := "EXT_mesh_gpu_instancing"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
func _get_supported_extensions() -> PackedStringArray:
|
|
12
|
+
return PackedStringArray([EXT])
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
func _import_preflight(_state: GLTFState, extensions: PackedStringArray) -> Error:
|
|
16
|
+
return OK if extensions.has(EXT) else ERR_SKIP
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
static func _components(acc: GLTFAccessor) -> int:
|
|
20
|
+
match acc.accessor_type:
|
|
21
|
+
GLTFAccessor.TYPE_SCALAR:
|
|
22
|
+
return 1
|
|
23
|
+
GLTFAccessor.TYPE_VEC2:
|
|
24
|
+
return 2
|
|
25
|
+
GLTFAccessor.TYPE_VEC3:
|
|
26
|
+
return 3
|
|
27
|
+
GLTFAccessor.TYPE_VEC4:
|
|
28
|
+
return 4
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## The floats of an accessor (count × components), or an error string.
|
|
33
|
+
static func _read(state: GLTFState, index: int, what: String, allowed: Array) -> Variant:
|
|
34
|
+
var accessors := state.get_accessors()
|
|
35
|
+
if index < 0 or index >= accessors.size():
|
|
36
|
+
return "%s names accessor %d, which the file does not have" % [what, index]
|
|
37
|
+
var acc: GLTFAccessor = accessors[index]
|
|
38
|
+
var n := _components(acc)
|
|
39
|
+
if not allowed.has(n):
|
|
40
|
+
return "%s has %d components per instance; %s are read" % [what, n, " or ".join(allowed.map(func(x): return str(x)))]
|
|
41
|
+
if acc.component_type != GLTFAccessor.COMPONENT_TYPE_SINGLE_FLOAT:
|
|
42
|
+
return "%s is not float32 (component type %d); TopoTopo writes float32" % [what, acc.component_type]
|
|
43
|
+
if acc.sparse_count > 0:
|
|
44
|
+
return "%s is a sparse accessor, which is not read" % what
|
|
45
|
+
var views := state.get_buffer_views()
|
|
46
|
+
if acc.buffer_view < 0 or acc.buffer_view >= views.size():
|
|
47
|
+
return "%s has no buffer view" % what
|
|
48
|
+
var bv: GLTFBufferView = views[acc.buffer_view]
|
|
49
|
+
var data := bv.load_buffer_view_data(state)
|
|
50
|
+
var start := acc.byte_offset
|
|
51
|
+
var stride := bv.byte_stride
|
|
52
|
+
if stride <= 0 or stride == n * 4:
|
|
53
|
+
if start + acc.count * n * 4 > data.size():
|
|
54
|
+
return "%s reads past the end of its buffer view" % what
|
|
55
|
+
return data.slice(start, start + acc.count * n * 4).to_float32_array()
|
|
56
|
+
var out := PackedFloat32Array()
|
|
57
|
+
out.resize(acc.count * n)
|
|
58
|
+
for i in acc.count:
|
|
59
|
+
var at := start + i * stride
|
|
60
|
+
if at + n * 4 > data.size():
|
|
61
|
+
return "%s reads past the end of its buffer view" % what
|
|
62
|
+
var row := data.slice(at, at + n * 4).to_float32_array()
|
|
63
|
+
for c in n:
|
|
64
|
+
out[i * n + c] = row[c]
|
|
65
|
+
return out
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
func _import_node(state: GLTFState, _gltf_node: GLTFNode, json: Dictionary, node: Node) -> Error:
|
|
69
|
+
if not json.has("extensions") or typeof(json["extensions"]) != TYPE_DICTIONARY or not json["extensions"].has(EXT):
|
|
70
|
+
return OK
|
|
71
|
+
var file := state.filename if state.filename != "" else state.base_path
|
|
72
|
+
var attrs = json["extensions"][EXT].get("attributes", {})
|
|
73
|
+
if typeof(attrs) != TYPE_DICTIONARY:
|
|
74
|
+
push_error("TopoTopo: %s: node %s: %s has no attributes" % [file, node.name, EXT])
|
|
75
|
+
return ERR_INVALID_DATA
|
|
76
|
+
var t = _read(state, int(attrs.get("TRANSLATION", -1)), "TRANSLATION", [3]) if attrs.has("TRANSLATION") else null
|
|
77
|
+
var r = _read(state, int(attrs.get("ROTATION", -1)), "ROTATION", [4]) if attrs.has("ROTATION") else null
|
|
78
|
+
var s = _read(state, int(attrs.get("SCALE", -1)), "SCALE", [3]) if attrs.has("SCALE") else null
|
|
79
|
+
var col = _read(state, int(attrs.get("_COLOR", -1)), "_COLOR", [3, 4]) if attrs.has("_COLOR") else null
|
|
80
|
+
for v in [t, r, s, col]:
|
|
81
|
+
if typeof(v) == TYPE_STRING:
|
|
82
|
+
push_error("TopoTopo: %s: node %s: %s" % [file, node.name, v])
|
|
83
|
+
return ERR_INVALID_DATA
|
|
84
|
+
var count := -1
|
|
85
|
+
for pair in [[t, 3], [r, 4], [s, 3]]:
|
|
86
|
+
if pair[0] != null:
|
|
87
|
+
var c: int = pair[0].size() / pair[1]
|
|
88
|
+
if count >= 0 and c != count:
|
|
89
|
+
push_error("TopoTopo: %s: node %s: the instance attributes have different counts" % [file, node.name])
|
|
90
|
+
return ERR_INVALID_DATA
|
|
91
|
+
count = c
|
|
92
|
+
if count < 0:
|
|
93
|
+
push_error("TopoTopo: %s: node %s: %s names no TRANSLATION, ROTATION or SCALE" % [file, node.name, EXT])
|
|
94
|
+
return ERR_INVALID_DATA
|
|
95
|
+
for k in attrs.keys():
|
|
96
|
+
if String(k).begins_with("_") and k != "_COLOR":
|
|
97
|
+
push_warning("TopoTopo: %s: node %s: the instance attribute %s is dropped (a MultiMesh carries transforms and colours only)" % [file, node.name, k])
|
|
98
|
+
# one MultiMesh row per instance: T·R·S, the basis by columns (scaled_local), 12 floats in MultiMesh 3D order
|
|
99
|
+
var rows := PackedFloat32Array()
|
|
100
|
+
rows.resize(count * 12)
|
|
101
|
+
for i in count:
|
|
102
|
+
var q := Quaternion(r[i * 4], r[i * 4 + 1], r[i * 4 + 2], r[i * 4 + 3]) if r != null else Quaternion.IDENTITY
|
|
103
|
+
var b := Basis(q)
|
|
104
|
+
if s != null:
|
|
105
|
+
b = b.scaled_local(Vector3(s[i * 3], s[i * 3 + 1], s[i * 3 + 2]))
|
|
106
|
+
var o := Vector3(t[i * 3], t[i * 3 + 1], t[i * 3 + 2]) if t != null else Vector3.ZERO
|
|
107
|
+
var k := i * 12
|
|
108
|
+
rows[k] = b.x.x
|
|
109
|
+
rows[k + 1] = b.y.x
|
|
110
|
+
rows[k + 2] = b.z.x
|
|
111
|
+
rows[k + 3] = o.x
|
|
112
|
+
rows[k + 4] = b.x.y
|
|
113
|
+
rows[k + 5] = b.y.y
|
|
114
|
+
rows[k + 6] = b.z.y
|
|
115
|
+
rows[k + 7] = o.y
|
|
116
|
+
rows[k + 8] = b.x.z
|
|
117
|
+
rows[k + 9] = b.y.z
|
|
118
|
+
rows[k + 10] = b.z.z
|
|
119
|
+
rows[k + 11] = o.z
|
|
120
|
+
node.set_meta("topotopo_instances", rows)
|
|
121
|
+
if col != null:
|
|
122
|
+
var size: int = col.size() / count if count > 0 else 4
|
|
123
|
+
var colors := PackedFloat32Array()
|
|
124
|
+
colors.resize(count * 4)
|
|
125
|
+
for i in count:
|
|
126
|
+
colors[i * 4] = col[i * size]
|
|
127
|
+
colors[i * 4 + 1] = col[i * size + 1]
|
|
128
|
+
colors[i * 4 + 2] = col[i * size + 2]
|
|
129
|
+
colors[i * 4 + 3] = col[i * size + 3] if size == 4 else 1.0
|
|
130
|
+
node.set_meta("topotopo_instance_colors", colors)
|
|
131
|
+
return OK
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="none" stroke="#e0e0e0" stroke-width="1.5" stroke-linejoin="round" d="M2 12.5 6 4l3 5.5 1.8-3 3.2 6z"/><circle cx="6" cy="4" r="1.2" fill="#8eef97"/></svg>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorInspectorPlugin
|
|
3
|
+
## A status header on an imported TopoTopo package (package.gd) in the Inspector, with the panel's actions.
|
|
4
|
+
|
|
5
|
+
const Package := preload("package.gd")
|
|
6
|
+
|
|
7
|
+
## plugin.gd
|
|
8
|
+
var host: Object
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
func _can_handle(object: Object) -> bool:
|
|
12
|
+
return object is Resource and object.get_script() == Package
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
func _parse_begin(object: Object) -> void:
|
|
16
|
+
var res: Resource = object
|
|
17
|
+
var box := VBoxContainer.new()
|
|
18
|
+
var head := Label.new()
|
|
19
|
+
var status := String(res.get("status"))
|
|
20
|
+
head.text = "TopoTopo package %s: %s" % [res.get("package_id"), status.replace("_", " ") if status != "" else "not imported"]
|
|
21
|
+
box.add_child(head)
|
|
22
|
+
var msg := String(res.get("message"))
|
|
23
|
+
if msg != "":
|
|
24
|
+
var l := Label.new()
|
|
25
|
+
l.text = msg
|
|
26
|
+
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
27
|
+
box.add_child(l)
|
|
28
|
+
var topo := res.resource_path
|
|
29
|
+
if topo.ends_with(".topo") and host:
|
|
30
|
+
var row := HBoxContainer.new()
|
|
31
|
+
for a in [["Open in TopoTopo", func(): host.open_in_topotopo(topo)], ["Recook", func(): host.cook_now([topo], true)],
|
|
32
|
+
["Show Report", func(): host.show_report(topo)]]:
|
|
33
|
+
var b := Button.new()
|
|
34
|
+
b.text = a[0]
|
|
35
|
+
b.pressed.connect(a[1])
|
|
36
|
+
row.add_child(b)
|
|
37
|
+
box.add_child(row)
|
|
38
|
+
add_custom_control(box)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorScenePostImportPlugin
|
|
3
|
+
## Runs after Godot made the meshes of an imported scene (LODs, shadow meshes, extracted materials included): every
|
|
4
|
+
## MeshInstance3D that gltf_instancing.gd marked with instance rows becomes a MultiMeshInstance3D of the same mesh, in
|
|
5
|
+
## the same place in the tree. Nodes without the mark, and so every other GLB of the game, are left alone.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
func _post_process(scene: Node) -> void:
|
|
9
|
+
var marked: Array = []
|
|
10
|
+
_collect(scene, marked)
|
|
11
|
+
for n in marked:
|
|
12
|
+
_replace(n, scene)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
func _collect(n: Node, out: Array) -> void:
|
|
16
|
+
for c in n.get_children():
|
|
17
|
+
_collect(c, out)
|
|
18
|
+
if n is MeshInstance3D and n.has_meta("topotopo_instances"):
|
|
19
|
+
out.append(n)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
func _replace(n: MeshInstance3D, root: Node) -> void:
|
|
23
|
+
var rows: PackedFloat32Array = n.get_meta("topotopo_instances")
|
|
24
|
+
var colors: PackedFloat32Array = n.get_meta("topotopo_instance_colors", PackedFloat32Array())
|
|
25
|
+
var count := rows.size() / 12
|
|
26
|
+
var mm := MultiMesh.new()
|
|
27
|
+
mm.transform_format = MultiMesh.TRANSFORM_3D
|
|
28
|
+
mm.use_colors = colors.size() > 0
|
|
29
|
+
mm.mesh = n.mesh
|
|
30
|
+
mm.instance_count = count
|
|
31
|
+
if colors.size():
|
|
32
|
+
var buf := PackedFloat32Array()
|
|
33
|
+
buf.resize(count * 16)
|
|
34
|
+
for i in count:
|
|
35
|
+
for c in 12:
|
|
36
|
+
buf[i * 16 + c] = rows[i * 12 + c]
|
|
37
|
+
for c in 4:
|
|
38
|
+
buf[i * 16 + 12 + c] = colors[i * 4 + c]
|
|
39
|
+
mm.buffer = buf
|
|
40
|
+
elif count > 0:
|
|
41
|
+
mm.buffer = rows
|
|
42
|
+
var mmi := MultiMeshInstance3D.new()
|
|
43
|
+
mmi.name = n.name
|
|
44
|
+
mmi.transform = n.transform
|
|
45
|
+
mmi.visible = n.visible
|
|
46
|
+
mmi.layers = n.layers
|
|
47
|
+
mmi.cast_shadow = n.cast_shadow
|
|
48
|
+
mmi.visibility_range_begin = n.visibility_range_begin
|
|
49
|
+
mmi.visibility_range_begin_margin = n.visibility_range_begin_margin
|
|
50
|
+
mmi.visibility_range_end = n.visibility_range_end
|
|
51
|
+
mmi.visibility_range_end_margin = n.visibility_range_end_margin
|
|
52
|
+
mmi.visibility_range_fade_mode = n.visibility_range_fade_mode
|
|
53
|
+
mmi.gi_mode = n.gi_mode
|
|
54
|
+
mmi.multimesh = mm
|
|
55
|
+
mmi.material_overlay = n.material_overlay
|
|
56
|
+
_copy_materials(n, mmi, colors.size() > 0)
|
|
57
|
+
var parent := n.get_parent()
|
|
58
|
+
var at := n.get_index()
|
|
59
|
+
parent.remove_child(n)
|
|
60
|
+
parent.add_child(mmi)
|
|
61
|
+
parent.move_child(mmi, at)
|
|
62
|
+
mmi.owner = root
|
|
63
|
+
for c in n.get_children():
|
|
64
|
+
n.remove_child(c)
|
|
65
|
+
mmi.add_child(c)
|
|
66
|
+
_own(c, root)
|
|
67
|
+
n.free()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Keep the effective materials, including Godot's import overrides. Instance colours use material copies; surface
|
|
71
|
+
## overrides need a private mesh because MultiMeshInstance3D has no per-instance surface override API.
|
|
72
|
+
func _copy_materials(n: MeshInstance3D, mmi: MultiMeshInstance3D, coloured: bool) -> void:
|
|
73
|
+
if n.material_override:
|
|
74
|
+
mmi.material_override = _coloured(n.material_override) if coloured else n.material_override
|
|
75
|
+
return
|
|
76
|
+
var mesh := n.mesh
|
|
77
|
+
if mesh == null:
|
|
78
|
+
return
|
|
79
|
+
if mesh.get_surface_count() <= 1:
|
|
80
|
+
var base: Material = n.get_active_material(0) if mesh.get_surface_count() == 1 else null
|
|
81
|
+
mmi.material_override = _coloured(base) if coloured else base
|
|
82
|
+
return
|
|
83
|
+
if mesh is ArrayMesh:
|
|
84
|
+
var overrides := coloured
|
|
85
|
+
for i in mesh.get_surface_count():
|
|
86
|
+
overrides = overrides or n.get_surface_override_material(i) != null
|
|
87
|
+
if not overrides:
|
|
88
|
+
return
|
|
89
|
+
var copy: ArrayMesh = mesh.duplicate()
|
|
90
|
+
for i in mesh.get_surface_count():
|
|
91
|
+
var base := n.get_active_material(i)
|
|
92
|
+
copy.surface_set_material(i, _coloured(base) if coloured else base)
|
|
93
|
+
mmi.multimesh.mesh = copy
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
func _coloured(base: Material) -> Material:
|
|
97
|
+
if base is BaseMaterial3D:
|
|
98
|
+
var m: BaseMaterial3D = base.duplicate()
|
|
99
|
+
m.vertex_color_use_as_albedo = true
|
|
100
|
+
return m
|
|
101
|
+
if base != null:
|
|
102
|
+
return base
|
|
103
|
+
var s := StandardMaterial3D.new()
|
|
104
|
+
s.vertex_color_use_as_albedo = true
|
|
105
|
+
return s
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
func _own(n: Node, root: Node) -> void:
|
|
109
|
+
n.owner = root
|
|
110
|
+
for c in n.get_children():
|
|
111
|
+
_own(c, root)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends Resource
|
|
3
|
+
## The imported resource of a TopoTopo package (<id>.topo): its status and its outputs. Levels and code never use it;
|
|
4
|
+
## they use the output GLBs, so a failed .topo import never breaks a level.
|
|
5
|
+
|
|
6
|
+
## The package id (the .topo file's name).
|
|
7
|
+
@export var package_id := ""
|
|
8
|
+
## The name it publishes under, or "".
|
|
9
|
+
@export var package_name := ""
|
|
10
|
+
@export var title := ""
|
|
11
|
+
## ok, failed (an output did not cook, or the package does not open), stale_no_topotopo (sources changed and TopoTopo
|
|
12
|
+
## is not set up here: the committed outputs are used).
|
|
13
|
+
@export var status := ""
|
|
14
|
+
@export_multiline var message := ""
|
|
15
|
+
## The TopoTopo version that cooked the outputs.
|
|
16
|
+
@export var topotopo_version := ""
|
|
17
|
+
## One entry per output: {id, label, kind, graph, files (res://), state (ok, failed), errors [{node, message, hint}]}.
|
|
18
|
+
@export var outputs: Array = []
|
|
19
|
+
## Outputs not imported: id -> why.
|
|
20
|
+
@export var skipped: Dictionary = {}
|
|
21
|
+
## Files outputs had and have no more, kept on disk: res:// -> output id.
|
|
22
|
+
@export var orphans: Dictionary = {}
|
|
23
|
+
@export var notes: PackedStringArray = PackedStringArray()
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorImportPlugin
|
|
3
|
+
## Imports a TopoTopo package (<id>.topo) as a status resource (package.gd). A stale package is cooked first; the
|
|
4
|
+
## outputs it writes are plain GLBs and PNGs Godot imports itself, with their own .import settings. The import never
|
|
5
|
+
## replaces an output that did not cook (the last good one stays), and never imports outputs itself while Godot is
|
|
6
|
+
## importing (plugin.gd imports what the cook wrote once the batch has ended).
|
|
7
|
+
|
|
8
|
+
const Record := preload("record.gd")
|
|
9
|
+
const Package := preload("package.gd")
|
|
10
|
+
|
|
11
|
+
## plugin.gd
|
|
12
|
+
var host: Object
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
func _get_importer_name() -> String:
|
|
16
|
+
return "topotopo.package"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
func _get_visible_name() -> String:
|
|
20
|
+
return "TopoTopo Package"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
func _get_recognized_extensions() -> PackedStringArray:
|
|
24
|
+
return PackedStringArray(["topo"])
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
func _get_save_extension() -> String:
|
|
28
|
+
return "res"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
func _get_resource_type() -> String:
|
|
32
|
+
return "Resource"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
func _get_preset_count() -> int:
|
|
36
|
+
return 1
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
func _get_preset_name(_preset_index: int) -> String:
|
|
40
|
+
return "Default"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
func _get_priority() -> float:
|
|
44
|
+
return 1.0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Before every other import of a batch (textures are 0, scenes 100), so a cook run from here writes the new bytes
|
|
48
|
+
## before Godot imports those files.
|
|
49
|
+
func _get_import_order() -> int:
|
|
50
|
+
return -100
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
func _get_format_version() -> int:
|
|
54
|
+
return 1
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
func _can_import_threaded() -> bool:
|
|
58
|
+
return false
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
func _get_import_options(_path: String, _preset_index: int) -> Array[Dictionary]:
|
|
62
|
+
return [
|
|
63
|
+
{"name": "outputs/folder", "default_value": "outputs", "property_hint": PROPERTY_HINT_NONE, "hint_string": "",
|
|
64
|
+
"description": "Where the outputs go: a folder relative to the package folder, or a res:// path."},
|
|
65
|
+
{"name": "outputs/per_output_folders", "default_value": true,
|
|
66
|
+
"description": "On: <folder>/<id>/<id>.glb. Off: <folder>/<id>.glb."},
|
|
67
|
+
{"name": "outputs/skip", "default_value": "", "description": "Output ids not to cook, comma-separated."},
|
|
68
|
+
{"name": "instances/mode", "default_value": 0, "property_hint": PROPERTY_HINT_ENUM, "hint_string": "MultiMesh,Expand",
|
|
69
|
+
"description": "MultiMesh: packed instances become MultiMeshInstance3D nodes. Expand: real copies."},
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
func _get_option_visibility(_path: String, _option_name: StringName, _options: Dictionary) -> bool:
|
|
74
|
+
return true
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
func _import(source_file: String, save_path: String, options: Dictionary, _platform_variants: Array[String], gen_files: Array[String]) -> Error:
|
|
78
|
+
var res := Package.new()
|
|
79
|
+
res.package_id = source_file.get_file().get_basename()
|
|
80
|
+
var abs_topo := ProjectSettings.globalize_path(source_file)
|
|
81
|
+
_manifest(res, abs_topo)
|
|
82
|
+
var code := _cook_if_stale(source_file, abs_topo, options, res)
|
|
83
|
+
var st = host.packages.get(source_file) if host else null
|
|
84
|
+
if st != null and st.record != null:
|
|
85
|
+
var rec: Dictionary = st.record
|
|
86
|
+
res.topotopo_version = String(rec.get("topotopo", ""))
|
|
87
|
+
res.notes = PackedStringArray(rec.get("notes", []))
|
|
88
|
+
res.orphans = rec.get("orphans", {})
|
|
89
|
+
var skipped := {}
|
|
90
|
+
for id in rec.get("skipped", {}):
|
|
91
|
+
skipped[id] = String(rec.skipped[id].get("why", ""))
|
|
92
|
+
res.skipped = skipped
|
|
93
|
+
var outs := []
|
|
94
|
+
for id in Record._sorted_keys(rec.get("outputs", {})):
|
|
95
|
+
var o: Dictionary = rec.outputs[id]
|
|
96
|
+
outs.append({"id": id, "label": o.get("label", id), "kind": o.get("kind", ""), "graph": o.get("graph", ""),
|
|
97
|
+
"files": Record._sorted_keys(o.get("files", {})), "state": o.get("state", ""), "errors": o.get("errors", [])})
|
|
98
|
+
res.outputs = outs
|
|
99
|
+
# every output file is a file of this import: one deleted by hand imports the .topo again, which restores it
|
|
100
|
+
for f in Record.output_files(rec):
|
|
101
|
+
gen_files.append(f)
|
|
102
|
+
var err := ResourceSaver.save(res, save_path + "." + _get_save_extension())
|
|
103
|
+
if err != OK:
|
|
104
|
+
push_error("TopoTopo: %s: the import could not be saved (error %d)" % [source_file, err])
|
|
105
|
+
return err
|
|
106
|
+
if host:
|
|
107
|
+
host.imported(source_file)
|
|
108
|
+
host.packages_changed.emit()
|
|
109
|
+
return code
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
func _manifest(res: Package, abs_topo: String) -> void:
|
|
113
|
+
# a manifest that does not parse is said by the cook, with where and why
|
|
114
|
+
var json := JSON.new()
|
|
115
|
+
if json.parse(FileAccess.get_file_as_string(abs_topo).trim_prefix("")) != OK:
|
|
116
|
+
return
|
|
117
|
+
var raw = json.data
|
|
118
|
+
if typeof(raw) == TYPE_DICTIONARY:
|
|
119
|
+
res.title = String(raw.get("title", ""))
|
|
120
|
+
res.package_name = String(raw.get("name", "")) if raw.get("name") != null else ""
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
func _fail(res: Package, status: String, message: String, code: Error) -> Error:
|
|
124
|
+
res.status = status
|
|
125
|
+
res.message = message
|
|
126
|
+
push_error(message)
|
|
127
|
+
return code
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
func _cook_if_stale(topo: String, abs_topo: String, options: Dictionary, res: Package) -> Error:
|
|
131
|
+
if host == null:
|
|
132
|
+
return _fail(res, "failed", "TopoTopo: %s: the TopoTopo plugin is not enabled" % topo, ERR_UNAVAILABLE)
|
|
133
|
+
if Record.is_published_copy(abs_topo):
|
|
134
|
+
return _fail(res, "failed", "TopoTopo: %s is a published copy; hide its folder with .gdignore (topotopo godot setup %s)" % [topo, host.project], ERR_INVALID_DATA)
|
|
135
|
+
if abs_topo.get_base_dir() == host.project:
|
|
136
|
+
return _fail(res, "failed", "TopoTopo: %s: a package at the project's root is not supported (its assets/ would hide the game's art): move it into a folder" % topo, ERR_INVALID_DATA)
|
|
137
|
+
var opts: Dictionary = host.options_for(topo, options)
|
|
138
|
+
if opts.has("error"):
|
|
139
|
+
return _fail(res, "failed", "TopoTopo: %s: %s" % [topo, opts.error], ERR_INVALID_DATA)
|
|
140
|
+
var fr: Dictionary = host.check(topo, opts)
|
|
141
|
+
if host.is_stale(fr):
|
|
142
|
+
if not host.runner.found():
|
|
143
|
+
host.say_missing_once()
|
|
144
|
+
return _fail(res, "stale_no_topotopo", host.not_set_up_text(topo, fr), ERR_UNAVAILABLE)
|
|
145
|
+
# the last cook of these very files did not finish them: say why rather than cook them again (Recook retries)
|
|
146
|
+
if fr.why != "options" and host.failed_unchanged(topo):
|
|
147
|
+
return _fail(res, "failed", "TopoTopo: %s did not cook: %s" % [topo, host.packages[topo].error], FAILED)
|
|
148
|
+
# a running cook that has this package (the batch's, or the watcher's): wait for it; else cook it now
|
|
149
|
+
var run: Dictionary = host.runner.run_with(abs_topo)
|
|
150
|
+
if not run.is_empty():
|
|
151
|
+
host.wait_for(run, abs_topo)
|
|
152
|
+
fr = host.check(topo, opts)
|
|
153
|
+
# (a running cook had other import options than this import: cook with these)
|
|
154
|
+
if run.is_empty() or (host.is_stale(fr) and fr.why == "options"):
|
|
155
|
+
host.cook([topo], false, true, false, {topo: opts})
|
|
156
|
+
fr = host.check(topo, opts)
|
|
157
|
+
if host.is_stale(fr):
|
|
158
|
+
var st = host.packages.get(topo, {})
|
|
159
|
+
var why: String = st.get("error", "") if st.get("error", "") != "" else fr.text
|
|
160
|
+
var code := ERR_TIMEOUT if why.contains("timed out") or why.contains("past its timeout") else FAILED
|
|
161
|
+
return _fail(res, "failed", "TopoTopo: %s did not cook: %s" % [topo, why], code)
|
|
162
|
+
host.say_skipped_once(topo, host.packages.get(topo, {}).get("record"))
|
|
163
|
+
if fr.state == "failed":
|
|
164
|
+
res.status = "failed"
|
|
165
|
+
var lines := PackedStringArray()
|
|
166
|
+
var rec = host.packages.get(topo, {}).get("record")
|
|
167
|
+
var outputs = rec.get("outputs", {}) if typeof(rec) == TYPE_DICTIONARY else {}
|
|
168
|
+
var pkg := topo.get_file().get_basename()
|
|
169
|
+
for id in Record._sorted_keys(outputs):
|
|
170
|
+
for e in outputs[id].get("errors", []):
|
|
171
|
+
var line := "TopoTopo: %s > %s: %s%s%s" % [pkg, id, ("[%s] " % e.node) if String(e.get("node", "")) != "" else "", e.get("message", ""),
|
|
172
|
+
(" (hint: %s)" % e.hint) if String(e.get("hint", "")) != "" else ""]
|
|
173
|
+
lines.append(line)
|
|
174
|
+
push_error(line)
|
|
175
|
+
var failed := 0
|
|
176
|
+
for id in outputs:
|
|
177
|
+
if outputs[id].get("state") == "failed":
|
|
178
|
+
failed += 1
|
|
179
|
+
res.message = "\n".join(lines) if lines.size() else fr.text
|
|
180
|
+
host.toast("TopoTopo: %s: %d of %d outputs did not cook; the last good result is kept" % [pkg, failed, outputs.size()], EditorToaster.SEVERITY_ERROR)
|
|
181
|
+
return ERR_TIMEOUT if res.message.contains("timed out") else FAILED
|
|
182
|
+
res.status = "ok"
|
|
183
|
+
if not host.runner.found():
|
|
184
|
+
res.message = "cooked elsewhere, current (TopoTopo is not set up here)"
|
|
185
|
+
return OK
|
|
186
|
+
res.message = fr.text if fr.note != "update_topotopo" else "%s (cooked by TopoTopo %s, newer than the one here: update TopoTopo)" % [fr.text, host.packages[topo].record.get("topotopo", "")]
|
|
187
|
+
return OK
|