Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_transform.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #ifdef WITH_OPENVDB | #ifdef WITH_OPENVDB | ||||
| # include <openvdb/openvdb.h> | # include <openvdb/openvdb.h> | ||||
| #endif | #endif | ||||
| #include "BLI_float4x4.hh" | #include "BLI_float4x4.hh" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_pointcloud_types.h" | #include "DNA_pointcloud_types.h" | ||||
| #include "DNA_volume_types.h" | #include "DNA_volume_types.h" | ||||
| #include "BKE_curves.hh" | #include "BKE_curves.hh" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_pointcloud.h" | #include "BKE_pointcloud.h" | ||||
| #include "BKE_spline.hh" | |||||
| #include "BKE_volume.h" | #include "BKE_volume.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | static void translate_volume(Volume &volume, const float3 translation, const Depsgraph &depsgraph) | ||||
| transform_volume(volume, float4x4::from_location(translation), depsgraph); | transform_volume(volume, float4x4::from_location(translation), depsgraph); | ||||
| } | } | ||||
| static void translate_geometry_set(GeometrySet &geometry, | static void translate_geometry_set(GeometrySet &geometry, | ||||
| const float3 translation, | const float3 translation, | ||||
| const Depsgraph &depsgraph) | const Depsgraph &depsgraph) | ||||
| { | { | ||||
| if (Curves *curves = geometry.get_curves_for_write()) { | if (Curves *curves = geometry.get_curves_for_write()) { | ||||
| std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*curves); | bke::CurvesGeometry::wrap(curves->geometry).translate(translation); | ||||
| curve->translate(translation); | |||||
| geometry.replace_curves(curve_eval_to_curves(*curve)); | |||||
| } | } | ||||
| if (Mesh *mesh = geometry.get_mesh_for_write()) { | if (Mesh *mesh = geometry.get_mesh_for_write()) { | ||||
| translate_mesh(*mesh, translation); | translate_mesh(*mesh, translation); | ||||
| } | } | ||||
| if (PointCloud *pointcloud = geometry.get_pointcloud_for_write()) { | if (PointCloud *pointcloud = geometry.get_pointcloud_for_write()) { | ||||
| translate_pointcloud(*pointcloud, translation); | translate_pointcloud(*pointcloud, translation); | ||||
| } | } | ||||
| if (Volume *volume = geometry.get_volume_for_write()) { | if (Volume *volume = geometry.get_volume_for_write()) { | ||||
| translate_volume(*volume, translation, depsgraph); | translate_volume(*volume, translation, depsgraph); | ||||
| } | } | ||||
| if (geometry.has_instances()) { | if (geometry.has_instances()) { | ||||
| translate_instances(geometry.get_component_for_write<InstancesComponent>(), translation); | translate_instances(geometry.get_component_for_write<InstancesComponent>(), translation); | ||||
| } | } | ||||
| } | } | ||||
| void transform_geometry_set(GeometrySet &geometry, | void transform_geometry_set(GeometrySet &geometry, | ||||
| const float4x4 &transform, | const float4x4 &transform, | ||||
| const Depsgraph &depsgraph) | const Depsgraph &depsgraph) | ||||
| { | { | ||||
| if (Curves *curves = geometry.get_curves_for_write()) { | if (Curves *curves = geometry.get_curves_for_write()) { | ||||
| std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*curves); | bke::CurvesGeometry::wrap(curves->geometry).transform(transform); | ||||
| curve->transform(transform); | |||||
| geometry.replace_curves(curve_eval_to_curves(*curve)); | |||||
| } | } | ||||
| if (Mesh *mesh = geometry.get_mesh_for_write()) { | if (Mesh *mesh = geometry.get_mesh_for_write()) { | ||||
| transform_mesh(*mesh, transform); | transform_mesh(*mesh, transform); | ||||
| } | } | ||||
| if (PointCloud *pointcloud = geometry.get_pointcloud_for_write()) { | if (PointCloud *pointcloud = geometry.get_pointcloud_for_write()) { | ||||
| transform_pointcloud(*pointcloud, transform); | transform_pointcloud(*pointcloud, transform); | ||||
| } | } | ||||
| if (Volume *volume = geometry.get_volume_for_write()) { | if (Volume *volume = geometry.get_volume_for_write()) { | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||