Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/curves.cc
| Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | static void curves_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) | ||||
| dst.curve_num = src.curve_num; | dst.curve_num = src.curve_num; | ||||
| const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; | const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; | ||||
| CustomData_copy(&src.point_data, &dst.point_data, CD_MASK_ALL, alloc_type, dst.point_num); | CustomData_copy(&src.point_data, &dst.point_data, CD_MASK_ALL, alloc_type, dst.point_num); | ||||
| CustomData_copy(&src.curve_data, &dst.curve_data, CD_MASK_ALL, alloc_type, dst.curve_num); | CustomData_copy(&src.curve_data, &dst.curve_data, CD_MASK_ALL, alloc_type, dst.curve_num); | ||||
| dst.curve_offsets = static_cast<int *>(MEM_dupallocN(src.curve_offsets)); | dst.curve_offsets = static_cast<int *>(MEM_dupallocN(src.curve_offsets)); | ||||
| if (curves_src->surface_uv_map != nullptr) { | |||||
| curves_dst->surface_uv_map = BLI_strdup(curves_src->surface_uv_map); | |||||
| } | |||||
| dst.runtime = MEM_new<bke::CurvesGeometryRuntime>(__func__); | dst.runtime = MEM_new<bke::CurvesGeometryRuntime>(__func__); | ||||
| dst.runtime->type_counts = src.runtime->type_counts; | dst.runtime->type_counts = src.runtime->type_counts; | ||||
| dst.update_customdata_pointers(); | dst.update_customdata_pointers(); | ||||
| curves_dst->batch_cache = nullptr; | curves_dst->batch_cache = nullptr; | ||||
| } | } | ||||
| static void curves_free_data(ID *id) | static void curves_free_data(ID *id) | ||||
| { | { | ||||
| Curves *curves = (Curves *)id; | Curves *curves = (Curves *)id; | ||||
| BKE_animdata_free(&curves->id, false); | BKE_animdata_free(&curves->id, false); | ||||
| blender::bke::CurvesGeometry::wrap(curves->geometry).~CurvesGeometry(); | blender::bke::CurvesGeometry::wrap(curves->geometry).~CurvesGeometry(); | ||||
| BKE_curves_batch_cache_free(curves); | BKE_curves_batch_cache_free(curves); | ||||
| MEM_SAFE_FREE(curves->mat); | MEM_SAFE_FREE(curves->mat); | ||||
| MEM_SAFE_FREE(curves->surface_uv_map); | |||||
| } | } | ||||
| static void curves_foreach_id(ID *id, LibraryForeachIDData *data) | static void curves_foreach_id(ID *id, LibraryForeachIDData *data) | ||||
| { | { | ||||
| Curves *curves = (Curves *)id; | Curves *curves = (Curves *)id; | ||||
| for (int i = 0; i < curves->totcol; i++) { | for (int i = 0; i < curves->totcol; i++) { | ||||
| BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->mat[i], IDWALK_CB_USER); | BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->mat[i], IDWALK_CB_USER); | ||||
| } | } | ||||
| Show All 24 Lines | CustomData_blend_write(writer, | ||||
| &curves->geometry.curve_data, | &curves->geometry.curve_data, | ||||
| curve_layers, | curve_layers, | ||||
| curves->geometry.curve_num, | curves->geometry.curve_num, | ||||
| CD_MASK_ALL, | CD_MASK_ALL, | ||||
| &curves->id); | &curves->id); | ||||
| BLO_write_int32_array(writer, curves->geometry.curve_num + 1, curves->geometry.curve_offsets); | BLO_write_int32_array(writer, curves->geometry.curve_num + 1, curves->geometry.curve_offsets); | ||||
| BLO_write_string(writer, curves->surface_uv_map); | |||||
| BLO_write_pointer_array(writer, curves->totcol, curves->mat); | BLO_write_pointer_array(writer, curves->totcol, curves->mat); | ||||
| if (curves->adt) { | if (curves->adt) { | ||||
| BKE_animdata_blend_write(writer, curves->adt); | BKE_animdata_blend_write(writer, curves->adt); | ||||
| } | } | ||||
| } | } | ||||
| static void curves_blend_read_data(BlendDataReader *reader, ID *id) | static void curves_blend_read_data(BlendDataReader *reader, ID *id) | ||||
| { | { | ||||
| Curves *curves = (Curves *)id; | Curves *curves = (Curves *)id; | ||||
| BLO_read_data_address(reader, &curves->adt); | BLO_read_data_address(reader, &curves->adt); | ||||
| BKE_animdata_blend_read_data(reader, curves->adt); | BKE_animdata_blend_read_data(reader, curves->adt); | ||||
| /* Geometry */ | /* Geometry */ | ||||
| CustomData_blend_read(reader, &curves->geometry.point_data, curves->geometry.point_num); | CustomData_blend_read(reader, &curves->geometry.point_data, curves->geometry.point_num); | ||||
| CustomData_blend_read(reader, &curves->geometry.curve_data, curves->geometry.curve_num); | CustomData_blend_read(reader, &curves->geometry.curve_data, curves->geometry.curve_num); | ||||
| update_custom_data_pointers(*curves); | update_custom_data_pointers(*curves); | ||||
| BLO_read_int32_array(reader, curves->geometry.curve_num + 1, &curves->geometry.curve_offsets); | BLO_read_int32_array(reader, curves->geometry.curve_num + 1, &curves->geometry.curve_offsets); | ||||
| if (curves->surface_uv_map != nullptr) { | |||||
JacquesLucke: This check shouldn't be necessary. | |||||
| BLO_read_data_address(reader, &curves->surface_uv_map); | |||||
| } | |||||
| curves->geometry.runtime = MEM_new<blender::bke::CurvesGeometryRuntime>(__func__); | curves->geometry.runtime = MEM_new<blender::bke::CurvesGeometryRuntime>(__func__); | ||||
| /* Recalculate curve type count cache that isn't saved in files. */ | /* Recalculate curve type count cache that isn't saved in files. */ | ||||
| blender::bke::CurvesGeometry::wrap(curves->geometry).update_curve_types(); | blender::bke::CurvesGeometry::wrap(curves->geometry).update_curve_types(); | ||||
| /* Materials */ | /* Materials */ | ||||
| BLO_read_pointer_array(reader, (void **)&curves->mat); | BLO_read_pointer_array(reader, (void **)&curves->mat); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 205 Lines • Show Last 20 Lines | |||||
This check shouldn't be necessary.