@@ -61,7 +61,7 @@ struct lp_norm<T,1,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointLikeVectorial
61
61
};
62
62
63
63
template<typename T> NBL_PARTIAL_REQ_TOP (concepts::FloatingPointLikeVectorial<T>)
64
- struct lp_norm<T,2 ,false NBL_PARTIAL_REQ_BOT (conceptsconcepts ::FloatingPointLikeVectorial<T>) >
64
+ struct lp_norm<T,2 ,false NBL_PARTIAL_REQ_BOT (concepts ::FloatingPointLikeVectorial<T>) >
65
65
{
66
66
using scalar_type = typename vector_traits<T>::scalar_type;
67
67
@@ -91,7 +91,7 @@ scalar_type_t<T> lpNorm(NBL_CONST_REF_ARG(T) v)
91
91
return impl::lp_norm<T,LP>::__call (v);
92
92
}
93
93
94
- template <typename T NBL_FUNC_REQUIRES (concepts::Vectorial<T> && vector_traits<T>::Dimension == 3 )
94
+ template <typename T NBL_FUNC_REQUIRES (concepts::Vectorial<T>)
95
95
T reflect (T I, T N, typename vector_traits<T>::scalar_type NdotI)
96
96
{
97
97
return N * 2.0f * NdotI - I;
@@ -284,21 +284,21 @@ T reflectRefract(bool _refract, T I, T N, typename vector_traits<T>::scalar_type
284
284
}
285
285
286
286
// valid only for `theta` in [-PI,PI]
287
- template <typename T NBL_FUNC_REQUIRES (is_scalar_v <T>)
287
+ template <typename T NBL_FUNC_REQUIRES (concepts::FloatingPointLikeScalar <T>)
288
288
void sincos (T theta, NBL_REF_ARG (T) s, NBL_REF_ARG (T) c)
289
289
{
290
290
c = cos<T>(theta);
291
- s = sqrt<T>(NBL_FP64_LITERAL (1.0 )-c*c);
292
- s = ieee754::flipSign (s, theta < NBL_FP64_LITERAL (0.0 ));
291
+ s = sqrt<T>(T ( NBL_FP64_LITERAL (1.0 ) )-c*c);
292
+ s = ieee754::flipSign (s, theta < T ( NBL_FP64_LITERAL (0.0 ) ));
293
293
}
294
294
295
295
template <typename T NBL_FUNC_REQUIRES (is_scalar_v<T>)
296
296
matrix <T, 2 , 3 > frisvad (vector <T, 3 > n)
297
297
{
298
- const T a = NBL_FP64_LITERAL (1.0 ) / (NBL_FP64_LITERAL (1.0 ) + n.z);
298
+ const T a = T ( NBL_FP64_LITERAL (1.0 )) / (T ( NBL_FP64_LITERAL (1.0 ) ) + n.z);
299
299
const T b = -n.x * n.y * a;
300
- return (n.z < -NBL_FP64_LITERAL (0.9999999 )) ? matrix <T, 2 , 3 >(vector <T, 3 >(0.0 ,-1.0 ,0.0 ), vector <T, 3 >(-1.0 ,0.0 ,0.0 )) :
301
- matrix <T, 2 , 3 >(vector <T, 3 >(NBL_FP64_LITERAL (1.0 )-n.x*n.x*a, b, -n.x), vector <T, 3 >(b, NBL_FP64_LITERAL (1.0 )-n.y*n.y*a, -n.y));
300
+ return (n.z < -T ( NBL_FP64_LITERAL (0.9999999 ) )) ? matrix <T, 2 , 3 >(vector <T, 3 >(0.0 ,-1.0 ,0.0 ), vector <T, 3 >(-1.0 ,0.0 ,0.0 )) :
301
+ matrix <T, 2 , 3 >(vector <T, 3 >(T ( NBL_FP64_LITERAL (1.0 )) -n.x*n.x*a, b, -n.x), vector <T, 3 >(b, T ( NBL_FP64_LITERAL (1.0 ) )-n.y*n.y*a, -n.y));
302
302
}
303
303
304
304
bool partitionRandVariable (float leftProb, NBL_REF_ARG (float ) xi, NBL_REF_ARG (float ) rcpChoiceProb)
@@ -311,9 +311,9 @@ bool partitionRandVariable(float leftProb, NBL_REF_ARG(float) xi, NBL_REF_ARG(fl
311
311
const bool pickRight = xi >= leftProb * NEXT_ULP_AFTER_UNITY;
312
312
313
313
// This is all 100% correct taking into account the above NEXT_ULP_AFTER_UNITY
314
- xi -= pickRight ? leftProb : 0.0 ;
314
+ xi -= pickRight ? leftProb : 0.0f ;
315
315
316
- rcpChoiceProb = NBL_FP64_LITERAL ( 1.0 ) / (pickRight ? (NBL_FP64_LITERAL ( 1.0 ) - leftProb) : leftProb);
316
+ rcpChoiceProb = 1.0f / (pickRight ? (1.0f - leftProb) : leftProb);
317
317
xi *= rcpChoiceProb;
318
318
319
319
return pickRight;
@@ -332,9 +332,9 @@ struct conditionalAbsOrMax_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointL
332
332
static T __call (bool cond, NBL_CONST_REF_ARG (T) x, NBL_CONST_REF_ARG (T) limit)
333
333
{
334
334
using UintOfTSize = unsigned_integer_of_size_t<sizeof (T)>;
335
- const T condAbs = bit_cast<T>(bit_cast<UintOfTSize>(x) & (cond ? 0x7fFFffFFu : 0xffFFffFFu ));
335
+ const T condAbs = bit_cast<T>(bit_cast<UintOfTSize>(x) & (cond ? (numeric_limits<UintOfTSize>:: max >> 1 ) : numeric_limits<UintOfTSize>:: max ));
336
336
337
- return max (condAbs, limit);
337
+ return max <T> (condAbs, limit);
338
338
}
339
339
};
340
340
@@ -348,28 +348,13 @@ struct conditionalAbsOrMax_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointL
348
348
using Uint32VectorWithDimensionOfT = vector <uint32_t, dimensionOfT>;
349
349
using scalar_type = typename vector_traits<T>::scalar_type;
350
350
351
- Uint32VectorWithDimensionOfT xAsUintVec;
352
- {
353
- array_get<T, scalar_type> getter;
354
- array_set<Uint32VectorWithDimensionOfT, UintOfTSize> setter;
355
-
356
- for (int i = 0 ; i < dimensionOfT; ++i)
357
- setter (xAsUintVec, i, bit_cast<UintOfTSize>(getter (x, i)));
358
- }
351
+ Uint32VectorWithDimensionOfT xAsUintVec = bit_cast<Uint32VectorWithDimensionOfT, T>(x);
359
352
360
- const Uint32VectorWithDimensionOfT mask = cond ? _static_cast<Uint32VectorWithDimensionOfT>(0x7fFFffFFu ) : _static_cast<Uint32VectorWithDimensionOfT>(0xffFFffFFu );
353
+ const Uint32VectorWithDimensionOfT mask = cond ? _static_cast<Uint32VectorWithDimensionOfT>(numeric_limits<UintOfTSize>:: max >> 1 ) : _static_cast<Uint32VectorWithDimensionOfT>(numeric_limits<UintOfTSize>:: max );
361
354
const Uint32VectorWithDimensionOfT condAbsAsUint = xAsUintVec & mask;
355
+ T condAbs = bit_cast<T, Uint32VectorWithDimensionOfT>(condAbsAsUint);
362
356
363
- T condAbs;
364
- {
365
- array_get<Uint32VectorWithDimensionOfT, UintOfTSize> getter;
366
- array_set<T, scalar_type> setter;
367
-
368
- for (int i = 0 ; i < dimensionOfT; ++i)
369
- setter (condAbs, i, bit_cast<scalar_type>(getter (condAbsAsUint, i)));
370
- }
371
-
372
- return max (condAbs, limit);
357
+ return max <T>(condAbs, limit);
373
358
}
374
359
};
375
360
0 commit comments