2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
|
|
|
|
#include "COM_MathBaseOperation.h"
|
2020-05-08 18:16:39 +02:00
|
|
|
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_rotation.h"
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2020-08-07 15:58:58 +02:00
|
|
|
MathBaseOperation::MathBaseOperation()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-08-23 15:28:08 +02:00
|
|
|
/* TODO(manzanilla): after removing tiled implementation, template this class to only add needed
|
|
|
|
|
* number of inputs. */
|
2021-10-13 23:01:15 +02:00
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_output_socket(DataType::Value);
|
|
|
|
|
use_clamp_ = false;
|
2021-10-13 23:01:53 +02:00
|
|
|
flags_.can_be_constant = true;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:32:49 +02:00
|
|
|
void MathBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
2012-05-31 20:26:42 +00:00
|
|
|
{
|
2014-04-15 16:06:12 +02:00
|
|
|
NodeOperationInput *socket;
|
2021-11-29 19:23:43 +01:00
|
|
|
rcti temp_area = COM_AREA_NONE;
|
2021-10-13 23:01:15 +02:00
|
|
|
socket = this->get_input_socket(0);
|
2021-09-28 19:32:49 +02:00
|
|
|
const bool determined = socket->determine_canvas(COM_AREA_NONE, temp_area);
|
|
|
|
|
if (determined) {
|
|
|
|
|
this->set_canvas_input_index(0);
|
2012-06-15 18:42:03 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2021-09-28 19:32:49 +02:00
|
|
|
this->set_canvas_input_index(1);
|
2012-05-31 20:26:42 +00:00
|
|
|
}
|
2021-09-28 19:32:49 +02:00
|
|
|
NodeOperation::determine_canvas(preferred_area, r_area);
|
2012-05-31 20:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:28:08 +02:00
|
|
|
void MathBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs)
|
|
|
|
|
{
|
|
|
|
|
BuffersIterator<float> it = output->iterate_with(inputs, area);
|
|
|
|
|
update_memory_buffer_partial(it);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathDivideOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float divisor = *it.in(1);
|
|
|
|
|
*it.out = clamp_when_enabled((divisor == 0) ? 0 : *it.in(0) / divisor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = sin(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathCosineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = cos(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTangentOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = tan(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathHyperbolicSineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = sinh(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathHyperbolicCosineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = cosh(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathHyperbolicTangentOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = tanh(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathArcSineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
float value1 = *it.in(0);
|
|
|
|
|
*it.out = clamp_when_enabled((value1 <= 1 && value1 >= -1) ? asin(value1) : 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathArcCosineOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
float value1 = *it.in(0);
|
|
|
|
|
*it.out = clamp_when_enabled((value1 <= 1 && value1 >= -1) ? acos(value1) : 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathArcTangentOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = atan(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathPowerOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value1 = *it.in(0);
|
|
|
|
|
const float value2 = *it.in(1);
|
|
|
|
|
if (value1 >= 0) {
|
|
|
|
|
*it.out = pow(value1, value2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const float y_mod_1 = fmod(value2, 1);
|
|
|
|
|
/* If input value is not nearly an integer, fall back to zero, nicer than straight rounding.
|
|
|
|
|
*/
|
|
|
|
|
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
|
|
|
|
|
*it.out = pow(value1, floorf(value2 + 0.5f));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*it.out = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathLogarithmOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value1 = *it.in(0);
|
|
|
|
|
const float value2 = *it.in(1);
|
|
|
|
|
if (value1 > 0 && value2 > 0) {
|
|
|
|
|
*it.out = log(value1) / log(value2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*it.out = 0.0;
|
|
|
|
|
}
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathMinimumOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
2024-01-22 15:58:18 +01:00
|
|
|
*it.out = std::min(*it.in(0), *it.in(1));
|
2021-08-23 15:28:08 +02:00
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathMaximumOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
2024-01-22 15:58:18 +01:00
|
|
|
*it.out = std::max(*it.in(0), *it.in(1));
|
2021-08-23 15:28:08 +02:00
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathRoundOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = round(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathModuloOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value2 = *it.in(1);
|
|
|
|
|
*it.out = (value2 == 0) ? 0 : fmod(*it.in(0), value2);
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 12:13:00 +02:00
|
|
|
void MathFlooredModuloOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value2 = *it.in(1);
|
|
|
|
|
*it.out = (value2 == 0) ? 0 : *it.in(0) - floorf(*it.in(0) / value2) * value2;
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:28:08 +02:00
|
|
|
void MathAbsoluteOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = fabs(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathRadiansOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = DEG2RADF(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathDegreesOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = RAD2DEGF(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathArcTan2Operation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = atan2(*it.in(0), *it.in(1));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathFloorOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = floor(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathCeilOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = ceil(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathFractOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value = *it.in(0);
|
|
|
|
|
*it.out = clamp_when_enabled(value - floor(value));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSqrtOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value = *it.in(0);
|
|
|
|
|
*it.out = clamp_when_enabled(value > 0 ? sqrt(value) : 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathInverseSqrtOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value = *it.in(0);
|
|
|
|
|
*it.out = clamp_when_enabled(value > 0 ? 1.0f / sqrt(value) : 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSignOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = compatible_signf(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathExponentOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = expf(*it.in(0));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathTruncOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value = *it.in(0);
|
|
|
|
|
*it.out = (value >= 0.0f) ? floor(value) : ceil(value);
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSnapOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float value1 = *it.in(0);
|
|
|
|
|
const float value2 = *it.in(1);
|
|
|
|
|
if (value1 == 0 || value2 == 0) { /* Avoid dividing by zero. */
|
|
|
|
|
*it.out = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*it.out = floorf(value1 / value2) * value2;
|
|
|
|
|
}
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathWrapOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = wrapf(*it.in(0), *it.in(1), *it.in(2));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathPingpongOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = pingpongf(*it.in(0), *it.in(1));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathCompareOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
2024-01-22 15:58:18 +01:00
|
|
|
*it.out = (fabsf(*it.in(0) - *it.in(1)) <= std::max(*it.in(2), 1e-5f)) ? 1.0f : 0.0f;
|
2021-08-23 15:28:08 +02:00
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathMultiplyAddOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = it.in(0)[0] * it.in(1)[0] + it.in(2)[0];
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSmoothMinOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = smoothminf(*it.in(0), *it.in(1), *it.in(2));
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MathSmoothMaxOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
|
|
|
|
{
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
*it.out = -smoothminf(-it.in(0)[0], -it.in(1)[0], it.in(2)[0]);
|
|
|
|
|
clamp_when_enabled(it.out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
} // namespace blender::compositor
|