bevyengine / bevyengine/bevy

Don't Serialize Meta-data componts in dynamic scene

Open
#6,523 0 comments 0 reactions 0 assignees View on GitHub
A-Reflection A-Scenes C-Performance C-Usability D-Complex
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?
at the moment bevy dynamic scene are already bloated with having to Serialize the type name and value separately and as strings. so to cut down on some bloat and make the files more readable and editable it should not serialize purely computed structs such as GlobalTransform and ComputedVisibility the developers should not be manually setting the value for insertion anyway.

## What solution would you like?

1. remove reflect component from all meta-data type structs. e.g. GlobalTransform, ComputedVisibility
2. move the insertion of the required meta-data struct onto the reflect components implementation. e.g. reflect inserting Transform should also insert GlobalTransform.
3. expand reflect component macro to accept optional Depecnecy component tuple that will be inserted with default values when the reflect insert is used

```rust
#[derive(Default, Component, Reflect, Serialize, Deserialize)]
#[reflect(Component(GlobalTransform), Serialize, Deserialize)]
struct Transform{...};
```

## What alternative(s) have you considered?

this would depend on if there is ever a situation you would want a transform but not a global transform.
- expand derive Component macro to accept optional Depecnecy component tuple that will be inserted with default values whenever inserting the component like a bundle but always default
```rust
#[derive(Default, Component(GlobalTransform), Reflect, Serialize, Deserialize)]
#[reflect(Component, Serialize, Deserialize)]
struct Transform{...};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.