From 180c8ca5395bcba6f04aaecc9b0affab5f47f745 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Tue, 11 Oct 2022 11:28:14 -0700 Subject: [PATCH] [gf] make vec*.h use GfSqrt instead of sqrt with gcc, at least, this avoids using a double for vec3f::GetLength, which avoids a compiler warning when using -Wconversion --- pxr/base/gf/vec.template.h | 3 +-- pxr/base/gf/vec2d.h | 3 +-- pxr/base/gf/vec2f.h | 3 +-- pxr/base/gf/vec2h.h | 3 +-- pxr/base/gf/vec3d.h | 3 +-- pxr/base/gf/vec3f.h | 3 +-- pxr/base/gf/vec3h.h | 3 +-- pxr/base/gf/vec4d.h | 3 +-- pxr/base/gf/vec4f.h | 3 +-- pxr/base/gf/vec4h.h | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/pxr/base/gf/vec.template.h b/pxr/base/gf/vec.template.h index ca6779adf8..596bd68489 100644 --- a/pxr/base/gf/vec.template.h +++ b/pxr/base/gf/vec.template.h @@ -252,8 +252,7 @@ class {{ VEC }} {% if IS_FLOATING_POINT(SCL) %} /// Length {{ SCL }} GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec2d.h b/pxr/base/gf/vec2d.h index 0f9811afdc..191a1fce2f 100644 --- a/pxr/base/gf/vec2d.h +++ b/pxr/base/gf/vec2d.h @@ -248,8 +248,7 @@ class GfVec2d /// Length double GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec2f.h b/pxr/base/gf/vec2f.h index c02b031324..d22277be66 100644 --- a/pxr/base/gf/vec2f.h +++ b/pxr/base/gf/vec2f.h @@ -248,8 +248,7 @@ class GfVec2f /// Length float GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec2h.h b/pxr/base/gf/vec2h.h index c0b0e23a24..ff813f9164 100644 --- a/pxr/base/gf/vec2h.h +++ b/pxr/base/gf/vec2h.h @@ -249,8 +249,7 @@ class GfVec2h /// Length GfHalf GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec3d.h b/pxr/base/gf/vec3d.h index 960201de75..e71266c210 100644 --- a/pxr/base/gf/vec3d.h +++ b/pxr/base/gf/vec3d.h @@ -260,8 +260,7 @@ class GfVec3d /// Length double GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec3f.h b/pxr/base/gf/vec3f.h index c5c2800bbc..0a6ae625ec 100644 --- a/pxr/base/gf/vec3f.h +++ b/pxr/base/gf/vec3f.h @@ -260,8 +260,7 @@ class GfVec3f /// Length float GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec3h.h b/pxr/base/gf/vec3h.h index 847ab6d499..279ff81029 100644 --- a/pxr/base/gf/vec3h.h +++ b/pxr/base/gf/vec3h.h @@ -261,8 +261,7 @@ class GfVec3h /// Length GfHalf GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec4d.h b/pxr/base/gf/vec4d.h index 4ef9344251..1699ffc5fd 100644 --- a/pxr/base/gf/vec4d.h +++ b/pxr/base/gf/vec4d.h @@ -272,8 +272,7 @@ class GfVec4d /// Length double GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec4f.h b/pxr/base/gf/vec4f.h index f21f30b3c3..4b2838c649 100644 --- a/pxr/base/gf/vec4f.h +++ b/pxr/base/gf/vec4f.h @@ -272,8 +272,7 @@ class GfVec4f /// Length float GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the diff --git a/pxr/base/gf/vec4h.h b/pxr/base/gf/vec4h.h index d1f5ec015d..67b110dbbf 100644 --- a/pxr/base/gf/vec4h.h +++ b/pxr/base/gf/vec4h.h @@ -273,8 +273,7 @@ class GfVec4h /// Length GfHalf GetLength() const { - // TODO should use GfSqrt. - return sqrt(GetLengthSq()); + return GfSqrt(GetLengthSq()); } /// Normalizes the vector in place to unit length, returning the