6# include <openvdb/openvdb.h>
35 for (float3 &position : positions.slice(range)) {
36 position += translation;
43 threading::parallel_for(positions.index_range(), 1024, [&](
const IndexRange range) {
44 for (float3 &position : positions.slice(range)) {
45 position = math::transform_point(matrix, position);
53 mesh.tag_positions_changed();
62 std::optional<Bounds<float3>>
bounds;
63 if (pointcloud.
runtime->bounds_cache.is_cached()) {
69 "position", bke::AttrDomain::Point);
74 bounds->min += translation;
75 bounds->max += translation;
84 "position", bke::AttrDomain::Point);
92 for (
const int layer_index : grease_pencil.layers().index_range()) {
93 Layer &layer = grease_pencil.layer(layer_index);
94 float4x4 local_transform = layer.local_transform();
95 local_transform.
location() += translation;
96 layer.set_local_transform(local_transform);
103 for (
const int layer_index : grease_pencil.layers().index_range()) {
104 Layer &layer = grease_pencil.layer(layer_index);
105 float4x4 local_transform = layer.local_transform();
106 local_transform = transform * local_transform;
107 layer.set_local_transform(local_transform);
115 for (float4x4 &instance_transform : transforms.slice(range)) {
116 add_v3_v3(instance_transform.ptr()[3], translation);
125 for (float4x4 &instance_transform : transforms.slice(range)) {
126 instance_transform = transform * instance_transform;
133 bool found_too_small_scale =
false;
135 openvdb::Mat4s vdb_matrix;
136 memcpy(vdb_matrix.asPointer(), &transform,
sizeof(
float[4][4]));
137 openvdb::Mat4d vdb_matrix_d{vdb_matrix};
143 float4x4 grid_matrix = bke::volume_grid::get_transform_matrix(*volume_grid);
144 grid_matrix = transform * grid_matrix;
147 found_too_small_scale =
true;
149 bke::volume_grid::clear_tree(*volume_grid);
163 bke::volume_grid::set_transform_matrix(*volume_grid, grid_matrix);
169 return found_too_small_scale;
187 for (const int64_t i : range) {
188 deform_mats[i] = deform_mat * deform_mats[i];
193 edit_hints.deform_mats.emplace(edit_hints.curves_id_orig.geometry.point_num, deform_mat);
214 m.location() += translation;
220 if (
Curves *curves = geometry.get_curves_for_write()) {
221 curves->geometry.wrap().translate(translation);
223 if (
Mesh *mesh = geometry.get_mesh_for_write()) {
226 if (
PointCloud *pointcloud = geometry.get_pointcloud_for_write()) {
229 if (
GreasePencil *grease_pencil = geometry.get_grease_pencil_for_write()) {
232 if (
Volume *volume = geometry.get_volume_for_write()) {
235 if (
bke::Instances *instances = geometry.get_instances_for_write()) {
250 if (
Curves *curves = geometry.get_curves_for_write()) {
251 curves->geometry.wrap().transform(transform);
253 if (
Mesh *mesh = geometry.get_mesh_for_write()) {
256 if (
PointCloud *pointcloud = geometry.get_pointcloud_for_write()) {
259 if (
GreasePencil *grease_pencil = geometry.get_grease_pencil_for_write()) {
262 if (
Volume *volume = geometry.get_volume_for_write()) {
265 if (
bke::Instances *instances = geometry.get_instances_for_write()) {
Low-level operations for curves.
Low-level operations for grease pencil.
void BKE_mesh_translate(Mesh *mesh, const float offset[3], bool do_keys)
General operations for point clouds.
int BKE_volume_num_grids(const Volume *volume)
blender::bke::VolumeGridData * BKE_volume_grid_get_for_write(Volume *volume, int grid_index)
bool BKE_volume_grid_determinant_valid(double determinant)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
static void translate_positions(MutableSpan< float3 > positions, const float3 &translation)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
btScalar determinant() const
Return the determinant of the matrix.
constexpr IndexRange index_range() const
std::optional< MutableSpan< float3 > > positions_for_write()
std::optional< Array< float3x3 > > deform_mats
static void transform_positions(const Span< blender::float3 > src, const blender::float4x4 &transform, blender::MutableSpan< blender::float3 > dst)
static void translate_positions(MutableSpan< float3 > positions, const float3 &translation)
static void translate_greasepencil(GreasePencil &grease_pencil, const float3 translation)
static void transform_instances(bke::Instances &instances, const float4x4 &transform)
static bool transform_volume(Volume &volume, const float4x4 &transform)
void translate_geometry(bke::GeometrySet &geometry, const float3 translation)
static void translate_gizmos_edit_hints(bke::GizmoEditHints &edit_hints, const float3 &translation)
static void translate_instances(bke::Instances &instances, const float3 translation)
static void transform_curve_edit_hints(bke::CurvesEditHints &edit_hints, const float4x4 &transform)
static void transform_gizmo_edit_hints(bke::GizmoEditHints &edit_hints, const float4x4 &transform)
void transform_mesh(Mesh &mesh, float3 translation, math::Quaternion rotation, float3 scale)
static void translate_curve_edit_hints(bke::CurvesEditHints &edit_hints, const float3 &translation)
static void translate_volume(Volume &volume, const float3 translation)
std::optional< TransformGeometryErrors > transform_geometry(bke::GeometrySet &geometry, const float4x4 &transform)
static void transform_pointcloud(PointCloud &pointcloud, const float4x4 &transform)
static void translate_pointcloud(PointCloud &pointcloud, const float3 translation)
static void transform_greasepencil(GreasePencil &grease_pencil, const float4x4 &transform)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
MatT from_location(const typename MatT::loc_type &location)
T determinant(const MatBase< T, Size, Size > &mat)
MatT from_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
PointCloudRuntimeHandle * runtime
const c_style_mat & ptr() const
Map< NodeGizmoID, float4x4 > gizmo_transforms