Commit: 9facc5067af9975f923d17993de15ddebbb5458a Author: Hans Goudey Date: Fri Jan 27 14:07:48 2023 -0600 Branches: master https://developer.blender.org/rB9facc5067af9975f923d17993de15ddebbb5458a
Cleanup: Simplify mesh and point cloud conversion Since mesh positions are stored as a generic attribute, the attribute doesn't need special handling here. =================================================================== M source/blender/blenkernel/BKE_mesh.h M source/blender/blenkernel/intern/mesh_convert.cc =================================================================== diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 557b70b8a11..c9928b9c4d6 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -212,7 +212,7 @@ void BKE_mesh_to_curve(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); -void BKE_pointcloud_from_mesh(struct Mesh *me, struct PointCloud *pointcloud); +void BKE_pointcloud_from_mesh(const struct Mesh *me, struct PointCloud *pointcloud); void BKE_mesh_to_pointcloud(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index ffc3365b908..d9a84e98326 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -627,29 +627,11 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene * /*scene*/, Obj } } -void BKE_pointcloud_from_mesh(Mesh *me, PointCloud *pointcloud) +void BKE_pointcloud_from_mesh(const Mesh *me, PointCloud *pointcloud) { - using namespace blender; - - BLI_assert(me != nullptr); - /* The pointcloud should only contain the position attribute, otherwise more attributes would - * need to be initialized below. */ - BLI_assert(pointcloud->attributes().all_ids().size() == 1); - CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint, me->totvert); + CustomData_free(&pointcloud->pdata, pointcloud->totpoint); pointcloud->totpoint = me->totvert; - - /* Copy over all attributes. */ CustomData_merge(&me->vdata, &pointcloud->pdata, CD_MASK_PROP_ALL, CD_DUPLICATE, me->totvert); - - bke::AttributeAccessor mesh_attributes = me->attributes(); - bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write(); - - const VArray<float3> vert_positions = mesh_attributes.lookup_or_default<float3>( - "position", ATTR_DOMAIN_POINT, float3(0)); - bke::SpanAttributeWriter<float3> point_positions = - point_attributes.lookup_or_add_for_write_only_span<float3>("position", ATTR_DOMAIN_POINT); - vert_positions.materialize(point_positions.span); - point_positions.finish(); } void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene * /*scene*/, Object *ob) @@ -675,10 +657,7 @@ void BKE_mesh_to_pointcloud(Main *bmain, Depsgraph *depsgraph, Scene * /*scene*/ void BKE_mesh_from_pointcloud(const PointCloud *pointcloud, Mesh *me) { - BLI_assert(pointcloud != nullptr); - me->totvert = pointcloud->totpoint; - CustomData_merge( &pointcloud->pdata, &me->vdata, CD_MASK_PROP_ALL, CD_DUPLICATE, pointcloud->totpoint); } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs