Skip to content

Add find_node and find_material methods, remove deprecated count properties - #8

Merged
popomore merged 3 commits into
mainfrom
claude/implement-scene-nodes-meshes-czAev
Jan 26, 2026
Merged

Add find_node and find_material methods, remove deprecated count properties#8
popomore merged 3 commits into
mainfrom
claude/implement-scene-nodes-meshes-czAev

Conversation

@popomore

Copy link
Copy Markdown
Owner

Summary

This PR adds find_node() and find_material() methods to the Scene class for convenient lookup of nodes and materials by name, while removing the deprecated node_count and mesh_count properties in favor of using len(scene.nodes) and len(scene.meshes).

Key Changes

  • Added find methods: Implemented Scene.find_node(name) and Scene.find_material(name) methods that wrap the underlying ufbx C library functions (ufbx_find_node and ufbx_find_material)
  • Removed deprecated properties: Deleted node_count and mesh_count properties from the Scene class type hints
  • Updated all usages: Replaced all calls to scene.node_count with len(scene.nodes) and scene.mesh_count with len(scene.meshes) throughout the codebase
  • Added example usage: Demonstrated the new find methods in the basic usage example with practical lookups for common node names and materials

Implementation Details

  • The find methods properly handle UTF-8 encoding for name parameters
  • Both methods return None if the requested node/material is not found
  • Methods include proper error handling for closed scenes
  • The C bindings for ufbx_find_node and ufbx_find_material are declared in the Cython extern block
  • All test files and examples have been updated to use the new API conventions

- Add node_count property to get number of nodes in scene
- Add mesh_count property to get number of meshes in scene
- Add find_node(name) method to find node by name
- Add find_material(name) method to find material by name
- Add ufbx_find_node and ufbx_find_material extern declarations
- Remove Scene.node_count and Scene.mesh_count (not in API.md)
- Update basic_usage.py to demonstrate find_node/find_material
- Update tests to use len(scene.nodes) and len(scene.meshes)
- Keep only API documented in API.md
Node new properties:
- attrib_type: ElementType enum for attribute type
- inherit_mode: InheritMode enum for transform inheritance
- visible: bool visibility flag
- euler_rotation: Vec3 euler angles in degrees

Mesh new properties:
- faces: list of (index_begin, num_indices) tuples
- face_material: numpy array of face material indices
- skin_deformers: list of SkinDeformer attached to mesh
- blend_deformers: list of BlendDeformer attached to mesh
- edge_crease: numpy array of edge crease values
- vertex_crease: numpy array of vertex crease values

Also updates:
- ufbx_wrapper.h/c with new wrapper functions
- __init__.pyi type hints
- API.md documentation status
@popomore
popomore merged commit fb5c7fa into main Jan 26, 2026
5 checks passed
@popomore
popomore deleted the claude/implement-scene-nodes-meshes-czAev branch January 26, 2026 15:32
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