24 b.add_input<
decl::Bool>(
N_(
"Selection")).default_value(
true).hide_value().supports_field();
25 b.add_input<
decl::Float>(
N_(
"Scale"),
"Scale").default_value(1.0f).min(0.0f).supports_field();
29 .
description(
N_(
"Origin of the scaling for each element. If multiple elements are "
30 "connected, their center is averaged"));
32 .default_value({1.0f, 0.0f, 0.0f})
41 uiItemR(layout,
ptr,
"domain", 0,
"", ICON_NONE);
42 uiItemR(layout,
ptr,
"scale_mode", 0,
"", ICON_NONE);
140 scale_transform.
values[0][0] = scale;
159 for (const int island_index : range) {
160 const ElementIsland &island = islands[island_index];
163 float3 center = {0.0f, 0.0f, 0.0f};
165 VectorSet<int> vertex_indices;
166 for (const int poly_index : island.element_indices) {
167 get_vertex_indices(mesh, poly_index, vertex_indices);
168 center += params.centers[poly_index];
169 scale += params.scales[poly_index];
173 const float f = 1.0f / island.element_indices.size();
177 for (const int vert_index : vertex_indices) {
178 MVert &vert = mesh.mvert[vert_index];
179 const float3 old_position = vert.co;
180 const float3 new_position = transform_with_uniform_scale(old_position, center, scale);
181 copy_v3_v3(vert.co, new_position);
195 for (const int island_index : range) {
196 const ElementIsland &island = islands[island_index];
199 float3 center = {0.0f, 0.0f, 0.0f};
200 float3 axis = {0.0f, 0.0f, 0.0f};
202 VectorSet<int> vertex_indices;
203 for (const int poly_index : island.element_indices) {
204 get_vertex_indices(mesh, poly_index, vertex_indices);
205 center += params.centers[poly_index];
206 scale += params.scales[poly_index];
207 axis += params.axis_vectors[poly_index];
211 const float f = 1.0f / island.element_indices.size();
216 if (math::is_zero(axis)) {
217 axis = float3(1.0f, 0.0f, 0.0f);
220 const float4x4 transform = create_single_axis_transform(center, axis, scale);
221 for (const int vert_index : vertex_indices) {
222 MVert &vert = mesh.mvert[vert_index];
223 const float3 old_position = vert.co;
224 const float3 new_position = transform * old_position;
225 copy_v3_v3(vert.co, new_position);
237 for (
const int poly_index : face_selection) {
241 const int v1 = poly_loops[loop_index].v;
242 const int v2 = poly_loops[loop_index + 1].v;
245 disjoint_set.
join(poly_loops.first().v, poly_loops.last().v);
254 for (
const int poly_index : face_selection) {
257 const int island_id = disjoint_set.
find_root(poly_loops[0].
v);
259 if (island_index == islands.
size()) {
273 for (
const MLoop &loop : poly_loops) {
274 r_vertex_indices.
add(loop.v);
285 evaluator.
add(fields.
axis, &
out.axis_vectors);
335 for (
const int edge_index : edge_selection) {
337 disjoint_set.
join(edge.v1, edge.v2);
346 for (
const int edge_index : edge_selection) {
348 const int island_id = disjoint_set.
find_root(edge.v1);
350 if (island_index == islands.
size()) {
363 r_vertex_indices.
add(edge.v1);
364 r_vertex_indices.
add(edge.v2);
419 switch (scale_mode) {
426 {selection_field, scale_field, center_field, axis_field});
433 switch (scale_mode) {
440 {selection_field, scale_field, center_field, axis_field});
452 params.set_output(
"Geometry", std::move(geometry));
void * CustomData_duplicate_referenced_layer(struct CustomData *data, int type, int totelem)
@ GEO_COMPONENT_TYPE_MESH
void BKE_mesh_tag_coords_changed(struct Mesh *mesh)
void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, bool is_available)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_SCALE_ELEMENTS
void nodeRegisterType(struct bNodeType *ntype)
#define BLI_assert_unreachable()
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
GeometryNodeScaleElementsMode
@ GEO_NODE_SCALE_ELEMENTS_SINGLE_AXIS
@ GEO_NODE_SCALE_ELEMENTS_UNIFORM
NSNotificationCenter * center
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
int64_t find_root(int64_t x)
void join(int64_t x, int64_t y)
constexpr IndexRange index_range() const
int64_t index_of_or_add(const Key &key)
void append(const T &value)
void reserve(const int64_t min_capacity)
void append_as(ForwardValue &&...value)
IndexMask get_evaluated_selection_as_mask()
void set_selection(Field< bool > selection)
int add(GField field, GVArray *varray_ptr)
StringRefNull description() const
SyclQueue void void size_t num_bytes void
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
vec_base< T, 3 > cross(const vec_base< T, 3 > &a, const vec_base< T, 3 > &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
static Vector< ElementIsland > prepare_face_islands(const Mesh &mesh, const IndexMask face_selection)
static void scale_edges_on_axis(MeshComponent &mesh_component, const AxisScaleFields &fields)
static Vector< ElementIsland > prepare_edge_islands(const Mesh &mesh, const IndexMask edge_selection)
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
static void scale_faces_on_axis(MeshComponent &mesh_component, const AxisScaleFields &fields)
static float3 transform_with_uniform_scale(const float3 &position, const float3 ¢er, const float scale)
static void get_edge_vertices(const Mesh &mesh, int edge_index, VectorSet< int > &r_vertex_indices)
static void scale_vertex_islands_on_axis(Mesh &mesh, const Span< ElementIsland > islands, const AxisScaleParams ¶ms, const GetVertexIndicesFn get_vertex_indices)
static AxisScaleParams evaluate_axis_scale_fields(FieldEvaluator &evaluator, const AxisScaleFields &fields)
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void scale_faces_uniformly(MeshComponent &mesh_component, const UniformScaleFields &fields)
static UniformScaleParams evaluate_uniform_scale_fields(FieldEvaluator &evaluator, const UniformScaleFields &fields)
static float4x4 create_single_axis_transform(const float3 ¢er, const float3 &axis, const float scale)
static void scale_vertex_islands_uniformly(Mesh &mesh, const Span< ElementIsland > islands, const UniformScaleParams ¶ms, const GetVertexIndicesFn get_vertex_indices)
static void node_geo_exec(GeoNodeExecParams params)
static void node_update(bNodeTree *ntree, bNode *node)
static void scale_edges_uniformly(MeshComponent &mesh_component, const UniformScaleFields &fields)
static void get_face_vertices(const Mesh &mesh, int face_index, VectorSet< int > &r_vertex_indices)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
vec_base< float, 3 > float3
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
void register_node_type_geo_scale_elements()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
void modify_geometry_sets(ForeachSubGeometryCallback callback)
struct bNodeSocket * next
NodeGeometryExecFunction geometry_node_execute
void(* updatefunc)(struct bNodeTree *ntree, struct bNode *node)
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare
void(* initfunc)(struct bNodeTree *ntree, struct bNode *node)
static float4x4 identity()
float4x4 transposed() const
VArray< float3 > axis_vectors
Vector< int > element_indices