Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcloud.cc
| Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Lines | for (; md; md = md->next) { | ||||
| } | } | ||||
| if (mti->modifyGeometrySet) { | if (mti->modifyGeometrySet) { | ||||
| mti->modifyGeometrySet(md, &mectx, &geometry_set); | mti->modifyGeometrySet(md, &mectx, &geometry_set); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static PointCloud *take_pointcloud_ownership_from_geometry_set(GeometrySet &geometry_set) | |||||
| { | |||||
| if (!geometry_set.has<PointCloudComponent>()) { | |||||
| return nullptr; | |||||
| } | |||||
| PointCloudComponent &pointcloud_component = | |||||
| geometry_set.get_component_for_write<PointCloudComponent>(); | |||||
| PointCloud *pointcloud = pointcloud_component.release(); | |||||
| if (pointcloud != nullptr) { | |||||
| /* Add back, but as read-only non-owning component. */ | |||||
| pointcloud_component.replace(pointcloud, GeometryOwnershipType::ReadOnly); | |||||
| } | |||||
| else { | |||||
| /* The component was empty, we can also remove it. */ | |||||
| geometry_set.remove<PointCloudComponent>(); | |||||
| } | |||||
| return pointcloud; | |||||
| } | |||||
| void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) | void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) | ||||
| { | { | ||||
| /* Free any evaluated data and restore original data. */ | /* Free any evaluated data and restore original data. */ | ||||
| BKE_object_free_derived_caches(object); | BKE_object_free_derived_caches(object); | ||||
| /* Evaluate modifiers. */ | /* Evaluate modifiers. */ | ||||
| PointCloud *pointcloud = static_cast<PointCloud *>(object->data); | PointCloud *pointcloud = static_cast<PointCloud *>(object->data); | ||||
| GeometrySet geometry_set = GeometrySet::create_with_pointcloud(pointcloud, | GeometrySet geometry_set = GeometrySet::create_with_pointcloud(pointcloud, | ||||
| GeometryOwnershipType::ReadOnly); | GeometryOwnershipType::ReadOnly); | ||||
| pointcloud_evaluate_modifiers(depsgraph, scene, object, geometry_set); | pointcloud_evaluate_modifiers(depsgraph, scene, object, geometry_set); | ||||
| PointCloud *pointcloud_eval = take_pointcloud_ownership_from_geometry_set(geometry_set); | |||||
| /* Tf the geometry set, did not contain a point cloud, we still create an empty one. */ | |||||
| if (pointcloud_eval == nullptr) { | |||||
| pointcloud_eval = BKE_pointcloud_new_nomain(0); | |||||
| } | |||||
| /* Assign evaluated object. */ | /* Assign evaluated object. */ | ||||
| PointCloud *dummy_pointcloud = BKE_pointcloud_new_nomain(0); | const bool eval_is_owned = pointcloud_eval != pointcloud; | ||||
| BKE_object_eval_assign_data(object, &dummy_pointcloud->id, true); | BKE_object_eval_assign_data(object, &pointcloud_eval->id, eval_is_owned); | ||||
| object->runtime.geometry_set_eval = new GeometrySet(geometry_set); | object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set)); | ||||
| } | } | ||||
| /* Draw Cache */ | /* Draw Cache */ | ||||
| void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud, int mode) = nullptr; | void (*BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud, int mode) = nullptr; | ||||
| void (*BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud) = nullptr; | void (*BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud) = nullptr; | ||||
| void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode) | void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode) | ||||
| { | { | ||||
| Show All 11 Lines | |||||