Page MenuHome

functions branch. Added multiply and divide to vector math node
AbandonedPublic

Authored by Eitan (EitanSomething) on Aug 6 2019, 10:33 PM.

Details

Summary

Added a Multiply and Divide node to the vector node

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested changes to this revision.Aug 7 2019, 9:24 AM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/blenlib/BLI_math.hpp
206

This does not actually work. You have to check b.is_zero(). For annoying reasons the 0 in this comparison calls the float3(const float *ptr) constructor...

source/blender/functions/functions/vectors.cpp
186

the (float3) cast should not be necessary here.
Also, what we need is a safe-divide: it returns zero for the coordinates b is zero in.
Same for the llvm stuff.

You can also make an utility in the CodeBuilder to build a safe-divide.

This revision now requires changes to proceed.Aug 7 2019, 9:24 AM
Eitan (EitanSomething) marked an inline comment as done.Aug 7 2019, 2:23 PM
Eitan (EitanSomething) updated this revision to Diff 16904.
source/blender/blenlib/BLI_math.hpp
206

Well, in this function it should still be an assert. The current version should produce a compiler error.

Eitan (EitanSomething) marked an inline comment as done.Aug 7 2019, 2:28 PM
Eitan (EitanSomething) updated this revision to Diff 16906.
Eitan (EitanSomething) updated this revision to Diff 16908.
  • BLI_assert(b.is_zero);

Added safe divide

source/blender/blenlib/BLI_math.hpp
143

that is correct at least.

It should be a static function and should take float3s as inputs. Also I think the loop does not make this code better compared to a version without a loop.

source/blender/functions/functions/vectors.cpp
196

I suggest you just remove the llvm division generation for now. Otherwise you'd have to make the safe-divide work for this too, which is a bit more tricky.

  • Made safe_divide static and input float3
  • Removed MultiplyVectorsGen
Jacques Lucke (JacquesLucke) requested changes to this revision.Aug 10 2019, 8:34 AM

Only two minor things missing, then this should be good to go :)

source/blender/blenlib/BLI_math.hpp
227

Do you actually make debug builds yourself? Can't test right now, but this should not work without () after is_zero.

source/blender/functions/functions/vectors.cpp
186

Please use clang-format. It would automatically format the code according to our code style. There is a space missing here.

This revision now requires changes to proceed.Aug 10 2019, 8:34 AM
source/blender/blenlib/BLI_math.hpp
227

It compiled for me, but I will add them

source/blender/functions/functions/vectors.cpp
186

I had clang format on so it should have worked

  • fixed formatting issues.
  • fixed errors
Eitan (EitanSomething) marked 2 inline comments as done.Aug 11 2019, 7:07 PM
Eitan (EitanSomething) marked an inline comment as done.Aug 12 2019, 3:24 PM
Eitan (EitanSomething) marked an inline comment as done.