Python ufbx API completion plan - #3
Conversation
|
Cursor Agent can help with this pull request. Just |
- Extended C wrapper to expose Light, Camera, Bone, and Texture structures - Implemented full Python bindings in Cython for all four element types - Added properties to Scene class: lights, cameras, bones, textures - Added properties to Node class: light, camera, bone - Updated type hints in .pyi file with complete API signatures - Added comprehensive tests to verify new functionality - All tests pass (43 passed, 3 skipped) Light properties: - name, color, intensity, local_direction - type, decay, area_shape, inner_angle, outer_angle - cast_light, cast_shadows Camera properties: - name, projection_mode, resolution, resolution_is_pixels - field_of_view_deg, field_of_view_tan - orthographic_extent, orthographic_size - aspect_ratio, near_plane, far_plane Bone properties: - name, radius, relative_length, is_root Texture properties: - name, filename, absolute_filename, relative_filename, type Co-authored-by: sakura9515 <sakura9515@gmail.com>
41f1c78 to
b1128be
Compare
- Implemented AnimStack, AnimLayer, AnimCurve classes for animation system - Implemented SkinDeformer, SkinCluster for skinning/rigging - Implemented BlendDeformer, BlendChannel, BlendShape for blend shapes/morphs - Implemented Constraint class for node constraints - Extended C wrapper with 70+ new accessor functions - Added Scene properties: anim_stacks, anim_curves, skin_deformers, blend_deformers, blend_shapes, constraints - Updated type hints with complete API signatures - Added comprehensive test suite for all new classes - All tests pass (55 passed, 3 skipped) AnimStack properties: - name, time_begin, time_end, layers AnimLayer properties: - name, weight, weight_is_animated, blended, additive - compose_rotation, compose_scale AnimCurve properties: - name, num_keyframes, min_value, max_value, min_time, max_time SkinDeformer properties: - name, clusters SkinCluster properties: - name, num_weights BlendDeformer properties: - name, channels BlendChannel properties: - name, weight BlendShape properties: - name, num_offsets Constraint properties: - name, type, weight, active This completes the Python ufbx API coverage with all major element types now fully implemented. Co-authored-by: sakura9515 <sakura9515@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2fe0705b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def type(self): | ||
| """Light type (LightType enum)""" | ||
| if self._scene._closed: | ||
| raise RuntimeError("Scene is closed") | ||
| return LightType(ufbx_wrapper_light_get_type(self._light)) |
There was a problem hiding this comment.
Handle volume light enum value
The C enum ufbx_light_type in ufbx-c/ufbx.h includes UFBX_LIGHT_VOLUME (value 4), but LightType only defines 0–3. When a scene contains a volumetric light, Light.type will call LightType(4) and raise ValueError, so accessing the property will crash instead of returning a usable value. Consider adding the missing enum value or a safe fallback for unknown values.
Useful? React with 👍 / 👎.
| def decay(self): | ||
| """Light decay mode (LightDecay enum)""" | ||
| if self._scene._closed: | ||
| raise RuntimeError("Scene is closed") | ||
| return LightDecay(ufbx_wrapper_light_get_decay(self._light)) |
There was a problem hiding this comment.
Handle cubic light decay enum value
The C enum ufbx_light_decay in ufbx-c/ufbx.h includes UFBX_LIGHT_DECAY_CUBIC (value 3), but LightDecay only defines 0–2. If an FBX uses cubic decay, Light.decay will raise ValueError when it constructs LightDecay(3), breaking access for those assets. Add the missing enum value or guard against unknown decay values.
Useful? React with 👍 / 👎.
| def type(self): | ||
| """Texture type (TextureType enum)""" | ||
| if self._scene._closed: | ||
| raise RuntimeError("Scene is closed") | ||
| return TextureType(ufbx_wrapper_texture_get_type(self._texture)) |
There was a problem hiding this comment.
Map texture types to ufbx_texture_type values
Texture.type wraps ufbx_texture_type from ufbx-c/ufbx.h, which is defined as FILE/LAYERED/PROCEDURAL/SHADER (values 0–3). The Python TextureType enum only defines DIFFUSE/NORMAL (0–1), so values 2 or 3 will raise ValueError, and even 0/1 are mislabeled. This makes Texture.type unreliable for real scenes. Align the enum with ufbx_texture_type or introduce a separate enum for shader map usage.
Useful? React with 👍 / 👎.
| def type(self): | ||
| """Constraint type (ConstraintType enum)""" | ||
| if self._scene._closed: | ||
| raise RuntimeError("Scene is closed") | ||
| return ConstraintType(ufbx_wrapper_constraint_get_type(self._constraint)) |
There was a problem hiding this comment.
Align constraint enum values with ufbx_constraint_type
ufbx_constraint_type in ufbx-c/ufbx.h starts with UNKNOWN=0, AIM=1, PARENT=2, and includes POSITION/ROTATION/SCALE/SINGLE_CHAIN_IK. The Python ConstraintType only defines AIM=0 and PARENT=1, so Constraint.type mislabels AIM constraints as PARENT and will throw ValueError for most other constraint types. This breaks constraint inspection for many FBX files. The enum should mirror the C values or guard unknowns.
Useful? React with 👍 / 👎.
Implement full Python API for Light, Camera, Bone, and Texture to enhance 3D asset data access.