28 {
SOCK_FLOAT,
N_(
"From Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
29 {
SOCK_FLOAT,
N_(
"From Max"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
30 {
SOCK_FLOAT,
N_(
"To Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
31 {
SOCK_FLOAT,
N_(
"To Max"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
32 {
SOCK_FLOAT,
N_(
"Steps"), 4.0f, 4.0f, 4.0f, 0.0f, -FLT_MAX, FLT_MAX},
33 {
SOCK_VECTOR,
N_(
"From Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
34 {
SOCK_VECTOR,
N_(
"From Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX},
35 {
SOCK_VECTOR,
N_(
"To Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
36 {
SOCK_VECTOR,
N_(
"To Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX},
37 {
SOCK_VECTOR,
N_(
"Steps"), 4.0f, 4.0f, 4.0f, 0.0f, -FLT_MAX, FLT_MAX},
49 uiItemR(layout,
ptr,
"data_type", 0,
"", ICON_NONE);
50 uiItemR(layout,
ptr,
"interpolation_type", 0,
"", ICON_NONE);
106 const float min_from,
107 const float max_from,
125 const float factor =
safe_divide(value - min_from, max_from - min_from);
126 return min_to + factor * (max_to - min_to);
130 const float min_from,
131 const float max_from,
154 const float factor =
safe_divide(value - min_from, max_from - min_from);
156 return min_to + factor_mapped * (max_to - min_to);
162 return (3.0f - 2.0f *
x) * (
x *
x);
166 const float min_from,
167 const float max_from,
171 const float factor =
safe_divide(value - min_from, max_from - min_from);
172 const float factor_clamped =
std::clamp(factor, 0.0f, 1.0f);
174 return min_to + factor_mapped * (max_to - min_to);
180 return x *
x *
x * (
x * (
x * 6.0f - 15.0f) + 10.0f);
184 const float min_from,
185 const float max_from,
189 const float factor =
safe_divide(value - min_from, max_from - min_from);
190 const float factor_clamped =
std::clamp(factor, 0.0f, 1.0f);
192 return min_to + factor_mapped * (max_to - min_to);
202 const float min_from =
params.get_input<
float>(
"From Min");
203 const float max_from =
params.get_input<
float>(
"From Max");
204 const float min_to =
params.get_input<
float>(
"To Min");
205 const float max_to =
params.get_input<
float>(
"To Max");
210 switch (interpolation_type) {
212 for (
int i : span.index_range()) {
213 result_span[i] =
map_linear(span[i], min_from, max_from, min_to, max_to);
218 const float steps =
params.get_input<
float>(
"Steps");
219 for (
int i : span.index_range()) {
220 result_span[i] =
map_stepped(span[i], min_from, max_from, min_to, max_to,
steps);
225 for (
int i : span.index_range()) {
226 result_span[i] =
map_smoothstep(span[i], min_from, max_from, min_to, max_to);
231 for (
int i : span.index_range()) {
232 result_span[i] =
map_smootherstep(span[i], min_from, max_from, min_to, max_to);
239 params.get_input<
bool>(
"Clamp")) {
241 const float clamp_min = min_to < max_to ? min_to : max_to;
242 const float clamp_max = min_to < max_to ? max_to : min_to;
245 result_span[i] =
std::clamp(result_span[i], clamp_min, clamp_max);
265 switch (interpolation_type) {
267 for (
int i : span.index_range()) {
268 result_span[i].x =
map_linear(span[i].
x, min_from.x, max_from.
x, min_to.x, max_to.x);
269 result_span[i].y =
map_linear(span[i].
y, min_from.y, max_from.
y, min_to.y, max_to.y);
270 result_span[i].z =
map_linear(span[i].
z, min_from.z, max_from.
z, min_to.z, max_to.z);
276 for (
int i : span.index_range()) {
278 span[i].
x, min_from.x, max_from.
x, min_to.x, max_to.x,
steps.x);
280 span[i].
y, min_from.y, max_from.
y, min_to.y, max_to.y,
steps.y);
282 span[i].
z, min_from.z, max_from.
z, min_to.z, max_to.z,
steps.z);
287 for (
int i : span.index_range()) {
288 result_span[i].x =
map_smoothstep(span[i].
x, min_from.x, max_from.
x, min_to.x, max_to.x);
289 result_span[i].y =
map_smoothstep(span[i].
y, min_from.y, max_from.
y, min_to.y, max_to.y);
290 result_span[i].z =
map_smoothstep(span[i].
z, min_from.z, max_from.
z, min_to.z, max_to.z);
295 for (
int i : span.index_range()) {
296 result_span[i].x =
map_smootherstep(span[i].
x, min_from.x, max_from.
x, min_to.x, max_to.x);
297 result_span[i].y =
map_smootherstep(span[i].
y, min_from.y, max_from.
y, min_to.y, max_to.y);
298 result_span[i].z =
map_smootherstep(span[i].
z, min_from.z, max_from.
z, min_to.z, max_to.z);
305 params.get_input<
bool>(
"Clamp")) {
309 clamp_min.
x = min_to.x < max_to.x ? min_to.x : max_to.x;
310 clamp_max.
x = min_to.x < max_to.x ? max_to.x : min_to.x;
311 clamp_min.
y = min_to.y < max_to.y ? min_to.y : max_to.y;
312 clamp_max.
y = min_to.y < max_to.y ? max_to.y : min_to.y;
313 clamp_min.
z = min_to.z < max_to.z ? min_to.z : max_to.z;
314 clamp_max.
z = min_to.z < max_to.z ? max_to.z : min_to.z;
327 if (result_attribute) {
328 return result_attribute->domain();
331 if (source_attribute) {
332 return source_attribute->domain();
339 const std::string input_name =
params.get_input<std::string>(
"Attribute");
340 const std::string result_name =
params.get_input<std::string>(
"Result");
342 if (input_name.empty() || result_name.empty()) {
353 input_name, domain, data_type);
355 if (!attribute_input) {
357 TIP_(
"No attribute with name \"") + input_name +
"\"");
362 result_name, domain, data_type);
363 if (!attribute_result) {
365 TIP_(
"Could not find or create attribute with name \"") +
397 params.set_output(
"Geometry", geometry_set);
void nodeSetSocketAvailability(struct bNodeSocket *sock, bool is_available)
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
#define GEO_NODE_ATTRIBUTE_MAP_RANGE
#define NODE_CLASS_ATTRIBUTE
void nodeRegisterType(struct bNodeType *ntype)
#define BLI_assert_unreachable()
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float safe_divide(float a, float b)
MINLINE void clamp_v3_v3v3(float vec[3], const float min[3], const float max[3])
static uint8 component(Color32 c, uint i)
@ NODE_MAP_RANGE_SMOOTHERSTEP
@ NODE_MAP_RANGE_SMOOTHSTEP
_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 GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_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 y
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void apply_span_and_save()
constexpr IndexRange index_range() const
void *(* MEM_callocN)(size_t len, const char *str)
TypedWriteAttribute< float3 > Float3WriteAttribute
TypedReadAttribute< float > FloatReadAttribute
TypedReadAttribute< float3 > Float3ReadAttribute
TypedWriteAttribute< float > FloatWriteAttribute
std::unique_ptr< ReadAttribute > ReadAttributePtr
static void map_range_float(FloatReadAttribute attribute_input, FloatWriteAttribute attribute_result, const GeoNodeExecParams ¶ms)
static void map_range_float3(Float3ReadAttribute attribute_input, Float3WriteAttribute attribute_result, const GeoNodeExecParams ¶ms)
static float map_linear(const float value, const float min_from, const float max_from, const float min_to, const float max_to)
static void map_range_attribute(GeometryComponent &component, const GeoNodeExecParams ¶ms)
static float smootherstep_polynomial(float x)
static float smoothstep_polynomial(float x)
static float map_smoothstep(const float value, const float min_from, const float max_from, const float min_to, const float max_to)
static float map_stepped(const float value, const float min_from, const float max_from, const float min_to, const float max_to, const float steps)
static AttributeDomain get_result_domain(const GeometryComponent &component, StringRef source_name, StringRef result_name)
static float map_smootherstep(const float value, const float min_from, const float max_from, const float min_to, const float max_to)
static void geo_node_attribute_map_range_exec(GeoNodeExecParams params)
static void geo_node_attribute_map_range_update(bNodeTree *UNUSED(ntree), bNode *node)
static void fn_attribute_map_range_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static bNodeSocketTemplate geo_node_attribute_map_range_in[]
void register_node_type_geo_attribute_map_range()
static void geo_node_attribute_map_range_init(bNodeTree *UNUSED(ntree), bNode *node)
static bNodeSocketTemplate geo_node_attribute_map_range_out[]
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
bool has(const GeometryComponentType component_type) const
uint8_t interpolation_type
Compact definition of a node socket.
struct bNodeSocket * next
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
ccl_device_inline int clamp(int a, int mn, int mx)