Skip to content

feat: improve materials - #5

Merged
popomore merged 2 commits into
mainfrom
feat/materials
Jan 24, 2026
Merged

feat: improve materials#5
popomore merged 2 commits into
mainfrom
feat/materials

Conversation

@popomore

Copy link
Copy Markdown
Owner

No description provided.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6216b63638

ℹ️ 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".

Comment thread ufbx/_ufbx.pyx
Comment on lines +25 to +29
ufbx_texture* texture
bint has_value
bint texture_enabled
bint feature_disabled
unsigned int value_components

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Match ufbx_material_map field types to ufbx.h

In ufbx.h, ufbx_material_map stores the flags as bool and value_components as uint8_t, but the Cython struct maps them to bint/unsigned int. Because those are 4‑byte ints in Cython, the layout no longer matches the C struct, so has_value, texture_enabled, feature_disabled, and value_components will be read from the wrong offsets (often into the next map). Any access to MaterialMap properties can then return garbage or crash. Use C types that match bool/uint8_t to preserve layout.

Useful? React with 👍 / 👎.

Comment thread ufbx/_ufbx.pyx
Comment on lines +118 to +122
ctypedef struct ufbx_material:
ufbx_element element
ufbx_material_fbx_maps fbx
ufbx_material_pbr_maps pbr
int shader_type

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Define full ufbx_material/ufbx_element layout

The Cython ufbx_element/ufbx_material structs only include name, fbx, pbr, and shader_type, but in ufbx.h both structs include additional fields (props/IDs in element, and features, shader, shader_prop_prefix, textures in material). That means the offsets for fbx, pbr, shader_type, and shading_model_name are wrong in Cython, so accessing material maps or shader info will read unrelated memory. This was introduced by switching to direct struct access; the layout must match the full C definition to avoid corrupted data or segfaults.

Useful? React with 👍 / 👎.

Comment thread ufbx/_ufbx.pyx
Comment on lines +138 to +142
ufbx_element element
ufbx_string filename
ufbx_string relative_filename
ufbx_string absolute_filename
int type

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Align ufbx_texture field order with ufbx.h

The C struct ufbx_texture places type immediately after the element union and before the filename fields, and the element union itself includes props/IDs. Here the Cython struct omits those element fields and reorders the members (filename, relative_filename, absolute_filename, then type). As a result, Texture.filename/relative_filename/absolute_filename and Texture.type will decode the wrong offsets, returning garbage or crashing on access. Either mirror the full ufbx.h layout or keep using wrapper accessors.

Useful? React with 👍 / 👎.

@popomore
popomore merged commit e953d53 into main Jan 24, 2026
5 checks passed
@popomore
popomore deleted the feat/materials branch January 24, 2026 10:48
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