Skip to content

Conversation

csprance
Copy link
Collaborator

@csprance csprance commented Jul 21, 2025

HDA Library Management & Asset Picker System

image

Overview

Adds comprehensive HDA library management with directory-based organization, fuzzy search asset picker, and robust error handling. Solves the "finding HDAs in a sea of built-ins" problem and provides a smooth workflow for HDA selection and management.

Core Features

🏗️ HDA Library Management API (C++)

  • New HAPI Methods: get_hda_libraries(), load_hda_library(), get_library_info(), get_user_hda_libraries()
  • Built-in Filtering: Automatically excludes Houdini system libraries, shows only user assets
  • Session Integration: Library tracking with proper cleanup and memory management

🎨 Library Management UI

  • Tree-Based Organization: Libraries grouped by directory structure with smart folder naming
  • Bulk Operations: Add/remove entire directories of HDAs in one click
  • JSON Persistence: Cache selected libraries to res://hego_library.json for fast access
  • Visual Polish: Collapsible trees, asset counts, contextual icons

🔍 Fuzzy Search Asset Picker

  • Houdini-Style Search: Type "scal" to match "Sop/scatter", just like in Houdini
  • Inspector Integration: "Select HDA" button on HEGoNode3D opens asset picker
  • Dual Access: Available in both inspector and HDA tab
  • Direct File Reading: Bypasses UI dependencies for reliable data access

🛡️ License Failure Resilience

  • Graceful Degradation: No more Godot crashes when Houdini license is unavailable
  • Smart Error Handling: HOUDINI_CHECK_ERROR_RETURN prevents session corruption
  • Clear Messaging: Helpful error logs instead of cryptic crashes
  • Asset Node Guards: All operations check node validity before proceeding

🔄 Asset Switching Improvements

  • Clean State Reset: Selecting new HDA clears old parameters, inputs, and outputs
  • Force Re-instantiation: reset_node_id() binding ensures fresh asset creation
  • Consistent Behavior: Works identically in inspector and HDA tab

Technical Implementation

Modified Files:

  • src/hego_api.{h,cpp} - Core library management API
  • src/hego_nodes/hego_asset_node.cpp - Error handling and method bindings
  • src/util/node/create_nodes.cpp - License-safe node creation
  • demo/addons/hego/HEGoNode3D.gd - Asset picker integration and cleanup
  • demo/addons/hego/ui/ - Complete library management UI system

Key Patterns:

  • Error-First Design: All HAPI calls use HOUDINI_CHECK_ERROR_RETURN for graceful failures
  • State Management: Explicit cleanup prevents stale HDA data persistence
  • Direct Data Access: Asset picker reads JSON files directly, avoiding UI coupling

Developer Impact

Before: Manual HDA path entry, crashes on license issues, mixed cached parameters
After: Visual HDA browser, fuzzy search, license-resilient operation, clean asset switching

Migration: Fully backward compatible - existing workflows unchanged, new features opt-in


This system transforms HDA workflow from tedious manual management to a polished, search-driven experience that handles real-world edge cases gracefully.

csprance added 16 commits July 20, 2025 10:37
  - Replace repetitive if/elif chains in add_parm_ui() with cleaner m…
Refactor build workflow to use 'main' branch and simplify job steps
…ow to fix image paths when it makes the submodule
## Added Features

### Core API (C++)
- `get_hda_libraries()` - Query all loaded HDA libraries with metadata
- `load_hda_library(file_path)` - Load HDA libraries from file paths
- `get_library_info(library_id)` - Get library details by ID
- `get_user_hda_libraries()` - Filter user-loaded libraries (excludes built-ins)
- `scan_user_hda_directories()` - Return common user HDA directory paths
- Added `explicitly_loaded_libraries` tracking array

### UI Components
- **Library tab** (`ui/hego_control_library.tscn`, `ui/library_control.gd`)
  - Tree view for available/cached libraries organized by directory
  - Add/remove libraries with bulk directory operations
  - JSON persistence to `res://hego_library.json`
- **Asset picker dialog** (`ui/asset_picker_dialog.tscn`, `ui/asset_picker_dialog.gd`)
  - Tree view of cached library assets
  - Direct JSON file reading
- **HEGoNode3D inspector integration**
  - Added "Select HDA" button using `@export_tool_button`
  - Opens asset picker dialog, populates `asset_name` property

### Session Management
- Enhanced plugin cleanup with proper Houdini session termination
- Memory cleanup for library tracking on exit

## Modified Files

**Core API:** `src/hego_api.h`, `src/hego_api.cpp`
**Godot Integration:** `demo/addons/hego/HEGoNode3D.gd`, `demo/addons/hego/hego.gd`, `demo/addons/hego/hego_control.tscn`
**UI System:** `demo/addons/hego/ui/library_control.gd`, `demo/addons/hego/ui/hego_control_library.tscn`, `demo/addons/hego/ui/asset_picker_dialog.gd`, `demo/addons/hego/ui/asset_picker_dialog.tscn`, `demo/addons/hego/ui/hego_control.gd`
Copy link
Owner

@peterprickarz peterprickarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good! On the c++ side I'd use the get_string(session, string_handle) function in hego_util though, will save a couple lines and be more readable. Feel free to add in the result checks there to be safe.

@csprance
Copy link
Collaborator Author

Will do!
p.s. I added you on discord

@csprance csprance merged commit 0f43524 into peterprickarz:main Jul 21, 2025
github-actions bot added a commit that referenced this pull request Jul 21, 2025
Based on commit 0f43524 by Chris Sprance:
Hda library (#29)
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.

2 participants