Page MenuHome

Functions branch: Add more Float Math ops
AcceptedPublic

Authored by artem ivanov (ixd) on Aug 7 2019, 7:41 PM.

Details

Summary

Added:

  • Subtract
  • Divide
  • Power
  • Log
  • Square Root
  • Absolute
  • Modulo
  • Cosine
  • Tangent
  • Arcsine
  • Arccosine
  • Arctangent
  • Arctan2
  • Fract
  • Ceil
  • Floor
  • Round
  • Snap

Notes:
None in EnumProperty is a separator.
May corrupt .blend files that used Float Math node with Multiply, Min, Max, Sin (Enum values are changed)

Diff Detail

Repository
rB Blender

Event Timeline

artem ivanov (ixd) retitled this revision from Functions branch: Add more Float Math nodes to Functions branch: Add more Float Math ops.

We need to create tasks so we don’t end up working on the same thing

Yeah right πŸ˜…

I’m working on the vector math node

Jacques Lucke (JacquesLucke) requested changes to this revision.Aug 7 2019, 8:00 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/functions/functions/scalar_math.cpp
142

what is intpt? Please use a more descriptive name.

166

I think in this case you can also just return zero. Don't try to be clever.

187

how are negative numbers handled?

383

I think we should assert isfinite instead of having a condition. Same above.

This revision now requires changes to proceed.Aug 7 2019, 8:00 PM
source/blender/functions/functions/scalar_math.cpp
187

sasqrtf takes care of it.

source/blender/blenlib/intern/math_base_inline.c:159

MINLINE float sasqrtf(float fac)
{
  if (UNLIKELY(fac <= 0.0f)) {
    return 0.0f;
  }
  else {
    return sqrtf(fac);
  }
}
source/blender/functions/functions/scalar_math.cpp
383

isfinite is pretty cheap function (something like fabsf(value) <= FLT_MAX). Inf can happen when user is tweaking nodes (e.g. pow -> multiply -> pow chain can produce such values fairly easy for 32-bit floats). So IMHO no need to crash in such a case.

  • more descriptive var name (scalar_math.cpp:142)
  • logarithm logic fix
artem ivanov (ixd) marked 4 inline comments as done.Aug 12 2019, 3:39 PM
This revision is now accepted and ready to land.Aug 12 2019, 4:28 PM