Skip to content

Conversation

@ethandaviessmith
Copy link

Summary

Enables scene structure analysis for Godot projects. Loads and parses sub-scene files for complete hierarchical view
Allows for easier Scene analysis, signal connection validation, property completeness, and UI structuring, and project wide structure mapping.

Added to enable AI assistants to quickly understand existing project architectures by providing comprehensive scene structure context, ensuring code generation and modifications align with established patterns and reduce architectural inconsistencies.
It's also handy with summarizing, Node analysis, and debugging multiple scene files

Technical Implementation

Text-Based Parser: Uses direct .tscn file parsing instead of ResourceLoader.load() because headless mode lacks autoloads and script compilation errors occur before GDScript error handling can intervene. (This is the bulk of the added lines; +800)
Recursive Scene Loading: Automatically follows instance = ExtResource() references to build complete scene trees in a single call, eliminating multiple function invocations.

Core Functions Added

  • parse_tscn_file_recursive() - Main entry with recursive scene loading
  • parse_ext_resource_line() - Extracts external resources including sub-scenes
  • parse_node_line() - Parses node definitions and instance properties
  • parse_node_property() - Extracts property values and instance references
  • build_node_hierarchy_recursive() - Constructs hierarchies with sub-scene expansion
  • build_tree_recursive_with_scenes() - Builds complete trees with nested structures
  • extract_resource_id() - Extracts resource IDs from ExtResource references

Tests run:

  • Simple Scene Analysis - single root node, script detection, basic properties
  • Complex Multi-root Scene - virtual "Scene Root" container, full property/connection analysis, scene instance detection
  • Depth Limiting - proper depth cutoff with maxDepth=2, properties/connections exclusion
  • UI Component Scene - clean hierarchy analysis, layout and container node handling
  • Error Handling Missing File - graceful error handling with helpful messages
  • Different Node Types - mixed Control types (Panel, Label, Button), proper type identification
  • Invalid Project Path - project validation and clear error reporting
  • Performance Test - fast processing with minimal options on large scenes
  • Property Analysis - detailed property extraction (colors, positions, rotations), script detection accuracy

Enables scene structure analysis for any Godot project without script compilation dependencies, automatically expanding nested scenes.

Technical Implementation
Text-Based Parser: Uses direct .tscn file parsing instead of ResourceLoader.load() because headless mode lacks autoloads and script compilation errors occur before GDScript error handling can intervene.

Recursive Scene Loading: Automatically follows instance = ExtResource() references to build complete scene trees in a single call, eliminating multiple function invocations.

Core Functions Added
parse_tscn_file_recursive() - Main entry with recursive scene loading
parse_ext_resource_line() - Extracts external resources including sub-scenes
parse_node_line() - Parses node definitions and instance properties
parse_node_property() - Extracts property values and instance references
build_node_hierarchy_recursive() - Constructs hierarchies with sub-scene expansion
build_tree_recursive_with_scenes() - Builds complete trees with nested structures
extract_resource_id() - Extracts resource IDs from ExtResource references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant