Refactor: Extract CurvesGeometry read/write function #105737

Merged
Falk David merged 3 commits from filedescriptor/blender:refactor-curves-extract-read-write-functions into main 2023-03-13 18:43:03 +01:00
3 changed files with 12 additions and 12 deletions
Showing only changes of commit 8a8305065a - Show all commits

View File

@ -389,8 +389,8 @@ class CurvesGeometry : public ::CurvesGeometry {
* File Read/Write.
*/
void blend_read(BlendDataReader *reader);
void blend_write(BlendWriter *writer, ID *id);
void blend_read(BlendDataReader &reader);
filedescriptor marked this conversation as resolved Outdated

Use references here instead of pointers

Use references here instead of pointers
void blend_write(BlendWriter &writer, ID *id);
filedescriptor marked this conversation as resolved Outdated

If the id argument is expected to be non-null, it should be a reference too

If the `id` argument is expected to be non-null, it should be a reference too
};
static_assert(sizeof(blender::bke::CurvesGeometry) == sizeof(::CurvesGeometry));

View File

@ -135,7 +135,7 @@ static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_addre
BKE_id_blend_write(writer, &curves->id);
/* Direct data */
curves->geometry.wrap().blend_write(writer, &curves->id);
curves->geometry.wrap().blend_write(*writer, &curves->id);
BLO_write_string(writer, curves->surface_uv_map);
@ -152,7 +152,7 @@ static void curves_blend_read_data(BlendDataReader *reader, ID *id)
BKE_animdata_blend_read_data(reader, curves->adt);
/* Geometry */
curves->geometry.wrap().blend_read(reader);
curves->geometry.wrap().blend_read(*reader);
BLO_read_data_address(reader, &curves->surface_uv_map);

View File

@ -1579,15 +1579,15 @@ GVArray CurvesGeometry::adapt_domain(const GVArray &varray,
/** \name File reading/writing.
* \{ */
void CurvesGeometry::blend_read(BlendDataReader *reader)
void CurvesGeometry::blend_read(BlendDataReader &reader)
{
CustomData_blend_read(reader, &this->point_data, this->point_num);
CustomData_blend_read(reader, &this->curve_data, this->curve_num);
CustomData_blend_read(&reader, &this->point_data, this->point_num);
CustomData_blend_read(&reader, &this->curve_data, this->curve_num);
BLO_read_int32_array(reader, this->curve_num + 1, &this->curve_offsets);
BLO_read_int32_array(&reader, this->curve_num + 1, &this->curve_offsets);
}
void CurvesGeometry::blend_write(BlendWriter *writer, ID *id)
void CurvesGeometry::blend_write(BlendWriter &writer, ID *id)
{
Vector<CustomDataLayer, 16> point_layers;
Vector<CustomDataLayer, 16> curve_layers;
@ -1595,11 +1595,11 @@ void CurvesGeometry::blend_write(BlendWriter *writer, ID *id)
CustomData_blend_write_prepare(this->curve_data, curve_layers);
CustomData_blend_write(
writer, &this->point_data, point_layers, this->point_num, CD_MASK_ALL, id);
&writer, &this->point_data, point_layers, this->point_num, CD_MASK_ALL, id);
CustomData_blend_write(
writer, &this->curve_data, curve_layers, this->curve_num, CD_MASK_ALL, id);
&writer, &this->curve_data, curve_layers, this->curve_num, CD_MASK_ALL, id);
BLO_write_int32_array(writer, this->curve_num + 1, this->curve_offsets);
BLO_write_int32_array(&writer, this->curve_num + 1, this->curve_offsets);
}
/** \} */