Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Reflect for Mesh #9779

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Conversation

SludgePhD
Copy link
Contributor

Objective

  • I want to associate TypeData with Mesh, to make it editable/inspectable in my reflection-based editor. Mesh has to implement Reflect for that. The precise reflection behavior does not matter.

Solution

  • #[derive(Reflect)], ignore fields whose types aren't reflectable.
  • Call App::register_asset_reflect in the MeshPlugin.

Changelog

  • Mesh now implements Reflect.

Copy link
Contributor

@nicopap nicopap left a comment

Choose a reason for hiding this comment

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

This looks good to me. Just need to add some registrations

crates/bevy_render/src/mesh/mod.rs Show resolved Hide resolved
primitive_topology: PrimitiveTopology,
/// `std::collections::BTreeMap` with all defined vertex attributes (Positions, Normals, ...)
/// for this mesh. Attribute ids to attribute values.
/// Uses a BTreeMap because, unlike HashMap, it has a defined iteration order,
/// which allows easy stable VertexBuffers (i.e. same buffer order)
#[reflect(ignore)]
attributes: BTreeMap<MeshVertexAttributeId, MeshAttributeData>,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you feel like it I don't see anything preventing anyone from implementing Reflect on PrimitiveTopology and MeshAttributeData.

@nicopap nicopap added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen A-Reflection Runtime information about types A-Assets Load files from disk to use for things like images, models, and sounds labels Sep 12, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 12, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 12, 2023
Merged via the queue into bevyengine:main with commit b900b97 Sep 12, 2023
22 checks passed
@SludgePhD SludgePhD deleted the reflect-mesh branch September 13, 2023 10:00
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- I want to associate `TypeData` with `Mesh`, to make it
editable/inspectable in my reflection-based editor. `Mesh` has to
implement `Reflect` for that. The precise reflection behavior does not
matter.

## Solution

- `#[derive(Reflect)]`, ignore fields whose types aren't reflectable.
- Call `App::register_asset_reflect` in the `MeshPlugin`.

---

## Changelog

- `Mesh` now implements `Reflect`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Reflection Runtime information about types A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants