BLI: Add "is_zero" method to float2 and float3 types

This is not necessary, but a nice convenience to avoid using `is_zero_v3`.

Differential Revision: https://developer.blender.org/D10713
This commit is contained in:
Hans Goudey 2021-03-14 22:36:35 -04:00
parent 070010e203
commit c23da7a5c9
2 changed files with 10 additions and 0 deletions

View File

@ -65,6 +65,11 @@ struct float2 {
return len_squared_v2(*this);
}
bool is_zero() const
{
return this->x == 0.0f && this->y == 0.0f;
}
float2 &operator+=(const float2 &other)
{
x += other.x;

View File

@ -174,6 +174,11 @@ struct float3 {
return len_squared_v3(*this);
}
bool is_zero() const
{
return this->x == 0.0f && this->y == 0.0f && this->z == 0.0f;
}
void reflect(const float3 &normal)
{
*this = this->reflected(normal);