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 ColorGeometry clamp_value(const ColorGeometry val, | |||||
| const ColorGeometry min, | |||||
| const ColorGeometry max) | |||||
| { | { | ||||
| Color4f tmp; | ColorGeometry 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>(read_span, span, max, min); | clamp_attribute<int>(read_span, span, max, min); | ||||
| } | } | ||||
| else { | else { | ||||
| clamp_attribute<int>(read_span, span, min, max); | clamp_attribute<int>(read_span, span, min, max); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case CD_PROP_COLOR: { | case CD_PROP_COLOR: { | ||||
| Span<Color4f> read_span = attribute_input->get_span<Color4f>(); | Span<ColorGeometry> read_span = attribute_input->get_span<ColorGeometry>(); | ||||
| MutableSpan<Color4f> span = attribute_result->get_span_for_write_only<Color4f>(); | MutableSpan<ColorGeometry> span = attribute_result->get_span_for_write_only<ColorGeometry>(); | ||||
| Color4f min = params.get_input<Color4f>("Min_003"); | ColorGeometry min = params.get_input<ColorGeometry>("Min_003"); | ||||
| Color4f max = params.get_input<Color4f>("Max_003"); | ColorGeometry max = params.get_input<ColorGeometry>("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); | ||||
| } | } | ||||
| } | } | ||||
| clamp_attribute<Color4f>(read_span, span, min, max); | clamp_attribute<ColorGeometry>(read_span, span, min, max); | ||||
| break; | break; | ||||
| } | } | ||||
| default: { | default: { | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Show All 35 Lines | |||||