83#define BLENDER_ZMAX 10000.0f
85template<
bool ShouldClamp>
92 if (
math::abs(from_max - from_min) < 1e-6f) {
98 result = (value - from_min) / (from_max - from_min);
108 if constexpr (ShouldClamp) {
109 if (to_max > to_min) {
124 static auto no_clamp_function = mf::build::SI5_SO<float, float, float, float, float, float>(
125 "Map Range No Clamp",
126 [](
const float value,
127 const float from_min,
128 const float from_max,
130 const float to_max) ->
float {
133 mf::build::exec_presets::SomeSpanOrSingle<0>());
134 static auto clamp_function = mf::build::SI5_SO<float, float, float, float, float, float>(
136 [](
const float value,
137 const float from_min,
138 const float from_max,
140 const float to_max) ->
float {
143 mf::build::exec_presets::SomeSpanOrSingle<0>());
164 ntype.
ui_description =
"Map an input value range into a destination range";
167 ntype.
declare = file_ns::cmp_node_map_range_declare;
168 ntype.
draw_buttons = file_ns::node_composit_buts_map_range;
169 ntype.
gpu_fn = file_ns::node_gpu_material;
#define NODE_CLASS_OP_VECTOR
#define CMP_NODE_MAP_RANGE
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void set_matching_fn(const mf::MultiFunction *fn)
int compositor_domain_priority() const
void node_register_type(bNodeType &ntype)
T clamp(const T &a, const T &min, const T &max)
static void cmp_node_map_range_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static float map_range(const float value, const float from_min, const float from_max, const float to_min, const float to_max)
static bool get_should_clamp(const bNode &node)
static void node_composit_buts_map_range(uiLayout *layout, bContext *, PointerRNA *ptr)
static void register_node_type_cmp_map_range()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
uiLayout & column(bool align)