blob: 2eb50a5a3a5d9ec149acdd44be1571d16cb7838e [file] [log] [blame]
Brad Bishope42b3e32020-01-15 22:08:42 -05001From 461861cd2e34294830b121db834c05ff39424f6f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 27 Dec 2019 18:42:51 -0800
4Subject: [PATCH] Fix Wimplicit-int-float-conversion warnings with clang 10+
5
6This is a new warning in clang which will be available in clang 10
7onwards
8
9Fixes
10error: implicit conversion from 'const int' to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion]
11
12Upstream-Status: Submitted [https://github.com/g-truc/glm/pull/986]
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 glm/gtx/scalar_multiplication.hpp | 2 +-
16 test/gtx/gtx_fast_trigonometry.cpp | 32 +++++++++++++++---------------
17 2 files changed, 17 insertions(+), 17 deletions(-)
18
19diff --git a/glm/gtx/scalar_multiplication.hpp b/glm/gtx/scalar_multiplication.hpp
20index f391f8de..496ba193 100644
21--- a/glm/gtx/scalar_multiplication.hpp
22+++ b/glm/gtx/scalar_multiplication.hpp
23@@ -54,7 +54,7 @@ namespace glm
24 template<typename T> \
25 return_type_scalar_multiplication<T, Vec> \
26 operator/(Vec lh, T const& s){ \
27- return lh *= 1.0f / s; \
28+ return lh *= 1.0f / static_cast<float>(s); \
29 }
30
31 GLM_IMPLEMENT_SCAL_MULT(vec2)
32diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp
33index f3bf17bf..f3c4e957 100644
34--- a/test/gtx/gtx_fast_trigonometry.cpp
35+++ b/test/gtx/gtx_fast_trigonometry.cpp
36@@ -239,12 +239,12 @@ namespace taylorCos
37 std::vector<glm::vec4> Results;
38 Results.resize(Samples);
39
40- float Steps = (End - Begin) / Samples;
41+ float Steps = (End - Begin) / float(Samples);
42
43 std::clock_t const TimeStampBegin = std::clock();
44
45 for(std::size_t i = 0; i < Samples; ++i)
46- Results[i] = fastCosNew(AngleShift + glm::vec4(Begin + Steps * i));
47+ Results[i] = fastCosNew(AngleShift + glm::vec4(Begin + Steps * float(i)));
48
49 std::clock_t const TimeStampEnd = std::clock();
50
51@@ -280,12 +280,12 @@ namespace taylorCos
52 std::vector<glm::vec4> Results;
53 Results.resize(Samples);
54
55- float Steps = (End - Begin) / Samples;
56+ float Steps = (End - Begin) / float(Samples);
57
58 std::clock_t const TimeStampBegin = std::clock();
59
60 for(std::size_t i = 0; i < Samples; ++i)
61- Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * i));
62+ Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * float(i)));
63
64 std::clock_t const TimeStampEnd = std::clock();
65
66@@ -327,12 +327,12 @@ namespace taylorCos
67 std::vector<glm::vec4> Results;
68 Results.resize(Samples);
69
70- float Steps = (End - Begin) / Samples;
71+ float Steps = (End - Begin) / float(Samples);
72
73 std::clock_t const TimeStampBegin = std::clock();
74
75 for(std::size_t i = 0; i < Samples; ++i)
76- Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * i));
77+ Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * float(i)));
78
79 std::clock_t const TimeStampEnd = std::clock();
80
81@@ -349,12 +349,12 @@ namespace taylorCos
82 std::vector<glm::vec4> Results;
83 Results.resize(Samples);
84
85- float Steps = (End - Begin) / Samples;
86+ float Steps = (End - Begin) / float(Samples);
87
88 std::clock_t const TimeStampBegin = std::clock();
89
90 for(std::size_t i = 0; i < Samples; ++i)
91- Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * i));
92+ Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * float(i)));
93
94 std::clock_t const TimeStampEnd = std::clock();
95
96@@ -371,12 +371,12 @@ namespace taylorCos
97 std::vector<glm::vec4> Results;
98 Results.resize(Samples);
99
100- float Steps = (End - Begin) / Samples;
101+ float Steps = (End - Begin) / float(Samples);
102
103 std::clock_t const TimeStampBegin = std::clock();
104
105 for(std::size_t i = 0; i < Samples; ++i)
106- Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * i));
107+ Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * float(i)));
108
109 std::clock_t const TimeStampEnd = std::clock();
110
111@@ -466,12 +466,12 @@ namespace taylor2
112 std::vector<float> Results;
113 Results.resize(Samples);
114
115- float Steps = (End - Begin) / Samples;
116+ float Steps = (End - Begin) / float(Samples);
117
118 std::clock_t const TimeStampBegin = std::clock();
119
120 for(std::size_t i = 0; i < Samples; ++i)
121- Results[i] = taylorCosA(AngleShift.x + Begin + Steps * i);
122+ Results[i] = taylorCosA(AngleShift.x + Begin + Steps * float(i));
123
124 std::clock_t const TimeStampEnd = std::clock();
125
126@@ -488,12 +488,12 @@ namespace taylor2
127 std::vector<float> Results;
128 Results.resize(Samples);
129
130- float Steps = (End - Begin) / Samples;
131+ float Steps = (End - Begin) / float(Samples);
132
133 std::clock_t const TimeStampBegin = std::clock();
134
135 for(std::size_t i = 0; i < Samples; ++i)
136- Results[i] = taylorCosB(AngleShift.x + Begin + Steps * i);
137+ Results[i] = taylorCosB(AngleShift.x + Begin + Steps * float(i));
138
139 std::clock_t const TimeStampEnd = std::clock();
140
141@@ -510,12 +510,12 @@ namespace taylor2
142 std::vector<float> Results;
143 Results.resize(Samples);
144
145- float Steps = (End - Begin) / Samples;
146+ float Steps = (End - Begin) / float(Samples);
147
148 std::clock_t const TimeStampBegin = std::clock();
149
150 for(std::size_t i = 0; i < Samples; ++i)
151- Results[i] = taylorCosC(AngleShift.x + Begin + Steps * i);
152+ Results[i] = taylorCosC(AngleShift.x + Begin + Steps * float(i));
153
154 std::clock_t const TimeStampEnd = std::clock();
155
156--
1572.24.1
158