Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
| Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| float3 tmp; | float3 tmp; | ||||
| tmp.x = std::min(std::max(val.x, min.x), max.x); | tmp.x = std::min(std::max(val.x, min.x), max.x); | ||||
| tmp.y = std::min(std::max(val.y, min.y), max.y); | tmp.y = std::min(std::max(val.y, min.y), max.y); | ||||
| tmp.z = std::min(std::max(val.z, min.z), max.z); | tmp.z = std::min(std::max(val.z, min.z), max.z); | ||||
| return tmp; | return tmp; | ||||
| } | } | ||||
| template<> inline Color4f clamp_value(const Color4f val, const Color4f min, const Color4f max) | template<> | ||||
| inline ColorGeometry4f clamp_value(const ColorGeometry4f val, | |||||
| const ColorGeometry4f min, | |||||
| const ColorGeometry4f max) | |||||
| { | { | ||||
| Color4f tmp; | ColorGeometry4f tmp; | ||||
| tmp.r = std::min(std::max(val.r, min.r), max.r); | tmp.r = std::min(std::max(val.r, min.r), max.r); | ||||
| tmp.g = std::min(std::max(val.g, min.g), max.g); | tmp.g = std::min(std::max(val.g, min.g), max.g); | ||||
| tmp.b = std::min(std::max(val.b, min.b), max.b); | tmp.b = std::min(std::max(val.b, min.b), max.b); | ||||
| tmp.a = std::min(std::max(val.a, min.a), max.a); | tmp.a = std::min(std::max(val.a, min.a), max.a); | ||||
| return tmp; | return tmp; | ||||
| } | } | ||||
| template<typename T> | template<typename T> | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | case CD_PROP_INT32: { | ||||
| clamp_attribute<int>(attribute_input->typed<int>(), results, max, min); | clamp_attribute<int>(attribute_input->typed<int>(), results, max, min); | ||||
| } | } | ||||
| else { | else { | ||||
| clamp_attribute<int>(attribute_input->typed<int>(), results, min, max); | clamp_attribute<int>(attribute_input->typed<int>(), results, min, max); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_COLOR: { | case CD_PROP_COLOR: { | ||||
| Color4f min = params.get_input<Color4f>("Min_003"); | ColorGeometry4f min = params.get_input<ColorGeometry4f>("Min_003"); | ||||
| Color4f max = params.get_input<Color4f>("Max_003"); | ColorGeometry4f max = params.get_input<ColorGeometry4f>("Max_003"); | ||||
| if (operation == NODE_CLAMP_RANGE) { | if (operation == NODE_CLAMP_RANGE) { | ||||
| if (min.r > max.r) { | if (min.r > max.r) { | ||||
| std::swap(min.r, max.r); | std::swap(min.r, max.r); | ||||
| } | } | ||||
| if (min.g > max.g) { | if (min.g > max.g) { | ||||
| std::swap(min.g, max.g); | std::swap(min.g, max.g); | ||||
| } | } | ||||
| if (min.b > max.b) { | if (min.b > max.b) { | ||||
| std::swap(min.b, max.b); | std::swap(min.b, max.b); | ||||
| } | } | ||||
| if (min.a > max.a) { | if (min.a > max.a) { | ||||
| std::swap(min.a, max.a); | std::swap(min.a, max.a); | ||||
| } | } | ||||
| } | } | ||||
| MutableSpan<Color4f> results = attribute_result.as_span<Color4f>(); | MutableSpan<ColorGeometry4f> results = attribute_result.as_span<ColorGeometry4f>(); | ||||
| clamp_attribute<Color4f>(attribute_input->typed<Color4f>(), results, min, max); | clamp_attribute<ColorGeometry4f>( | ||||
| attribute_input->typed<ColorGeometry4f>(), results, min, max); | |||||
| break; | break; | ||||
| } | } | ||||
| default: { | default: { | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Show All 35 Lines | |||||