Object/collection asset workflow would need the bounding box for snapping.
The bounding box is stored inside an ID property. Currently ID properties aren't
stored in the asset index.
This task adds storing/reading ID properties as part of the asset index.
## Approach ##
Custom Properties is a general data structure and the conversion between `blender::io::serialize::Value` should be accessible to other areas of blender as well.
There are two places where this could be added (BLI_serialize.h or BKE_idprops.h) I prefer it to be a part of BKE_idprops; reasoning is that `BLI_serialize` will be kept abstract and to the point.
NOTE: IDP_ID will not be supported. When passed these custom properties will be ignored. A warning will be logged.
- Introduce `blenkernel/intern/idprop_serialize.cc` containing the data transformation methods.
- Add test cases in `blenkernel/intern/idprop_serialize_test.cc` for data transformation between custom properties and `blender::io::serialize::Value`.
-- We should add test cases for each specific custom property type.
-- We could add a test case that randomly generates custom properties , transform them to serialize and back. Compare with input data.
- Add CPP-only section to `blenkernel/BKE_idprops.h`.
- Call the conversion methods from `asset_indexer.cc`.
## Data Mapping ##
For data mapping we store the internal structure of IDProperty to the indexer (including meta-data) to be able to deserialize it back.
```
[
{
"name": ..,
"value": ..,
"type": ..,
/* `subtype` and `length` are only available for IDP_ARRAYs. */
"subtype": ..,
},
]
```
| **DNA** | **Serialize type** | **Note** |
| IDProperty.name | StringValue| |
| IDProperty.type | StringValue| "IDP_STRING", "IDP_INT", "IDP_FLOAT", "IDP_ARRAY", "IDP_GROUP", "IDP_DOUBLE"|
| IDProperty.subtype | StringValue| "IDP_INT", "IDP_FLOAT", "IDP_GROUP", "IDP_DOUBLE" |
| IDProperty.value | StringValue | When type is IDP_STRING |
| IDProperty.value | IntValue | When type is IDP_INT |
| IDProperty.value | DoubleValue | When type is IDP_FLOAT/IDP_DOUBLE |
| IDProperty.value | ArrayValue | When type is IDP_GROUP. Recursively uses the same structure as described in this section. |
| IDProperty.value | ArrayValue | When type is IDP_ARRAY. Each element holds a single element as described in this section. |
NOTE: IDP_ID and IDP_IDARRAY arent' supported. The entry will not be added.
Example
```
[
{
"name": "MyIntValue,
"type": "IDP_INT",
"value": 6,
},
{
"name": "myComplexArray",
"type": "IDP_ARRAY",
"subtype": "IDP_GROUP",
"value": [
[
{
"name": ..
....
}
]
]
}
]
```
## Considered alternatives ##
- Add conversion functions inside `asset_indexer`; makes generic code part of a specific solution.
- Add conversion functions inside `BLI_serialize`; would add data transformation responsibilities inside a unit that is currently only responsible for formatting.
- Use direct mapping between IDP properties and Values; leads to missing information and edge cases (empty primitive arrays) that could not be deserialized.