Page MenuHome

Add clamp for 2D, 3D and 4D vectors
ClosedPublic

Authored by Tiago Chaves (laurelkeys) on Mar 1 2020, 2:10 AM.

Details

Summary

Added specific clamping functions to vectors, so that calling CLAMP for each element can be avoided.

Created a GTest file for math_vector.

Diff Detail

Repository
rB Blender

Event Timeline

Campbell Barton (campbellbarton) requested changes to this revision.EditedMar 2 2020, 4:54 AM

Generally seems fine, one request inline.

Edit, I don't have a strong opinion on this one if others prefer longer name, personally it doesn't seem necessary.

source/blender/blenlib/intern/math_vector.c
1054–1073

I think it's reasonable to make the _flfl implicit.

as clamp_v2(vec, min, max) is quite clear.

clamp_v2_v2v2 could be kept since I think this more of an exception.

This revision now requires changes to proceed.Mar 2 2020, 4:54 AM

Removing the _flfl suffix when min and max values are floats.

source/blender/blenlib/intern/math_vector.c
1054–1073

Indeed, and since it's probably the most common case I think it'll be better to make it shorter.

This revision is now accepted and ready to land.Mar 4 2020, 1:10 AM