diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_MapValueOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_MapValueOperation.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cc b/source/blender/compositor/operations/COM_MapValueOperation.cc index 03fa80d220d..94fecc3f49e 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.cc +++ b/source/blender/compositor/operations/COM_MapValueOperation.cc @@ -25,6 +25,7 @@ MapValueOperation::MapValueOperation() this->addInputSocket(DataType::Value); this->addOutputSocket(DataType::Value); this->m_inputOperation = nullptr; + flags.can_be_constant = true; } void MapValueOperation::initExecution() @@ -60,4 +61,27 @@ void MapValueOperation::deinitExecution() this->m_inputOperation = nullptr; } +void MapValueOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) +{ + for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { + const float input = *it.in(0); + TexMapping *texmap = this->m_settings; + float value = (input + texmap->loc[0]) * texmap->size[0]; + if (texmap->flag & TEXMAP_CLIP_MIN) { + if (value < texmap->min[0]) { + value = texmap->min[0]; + } + } + if (texmap->flag & TEXMAP_CLIP_MAX) { + if (value > texmap->max[0]) { + value = texmap->max[0]; + } + } + + it.out[0] = value; + } +} + } // namespace blender::compositor |