OverviewFilesCommitsIssuesDocsReleasesPeers

proc-nodes / demo / importer_coverage_probe.gd

36 lines · gd ref:
## Can the importer's factory actually BUILD every type the bridge sends?
##
## Five places must agree for a node to survive the bridge, and the factory in
## graph_importer.cpp is the one nothing checks. The whole rotation/matrix
## family -- 18 types, all registered, all mapped on the Blender side -- could
## not be constructed by it, so any graph using one lost the node and every link
## either side of it, with one warning line in a headless log.
##
## Reads a JSON array of proc type names, writes a JSON object
## {"built": [...], "missing": [...]}.
extends SceneTree

func _init() -> void:
	var a := OS.get_cmdline_user_args()
	var types: Array = JSON.parse_string(FileAccess.get_file_as_string(a[0]))
	var nodes := []
	for i in range(types.size()):
		nodes.append({"id": i, "bl_type": "probe", "proc_type": types[i],
			"position": [0, 0], "properties": {}, "defaults": {}})
	var g: ProcNodeGraph = GraphImporter.import_from_json(
		JSON.stringify({"version": 1, "nodes": nodes, "connections": []}))
	var built := {}
	if g != null:
		for i in range(g.get_node_count()):
			var n: ProcNode = g.get_node(i)
			if n != null:
				built[str(n.get_node_type())] = true
	var missing := []
	for t in types:
		if not built.has(t):
			missing.append(t)
	FileAccess.open(a[1], FileAccess.WRITE).store_string(
		JSON.stringify({"built": built.keys(), "missing": missing}))
	print("types %d  built %d  missing %d" % [types.size(), built.size(), missing.size()])
	quit()