Skip to content

Commit 9c67558

Browse files
committed
Improve flags functions
* Also improved if indents
1 parent 01068c3 commit 9c67558

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

include/math/flags.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ static constexpr enumType operator^(enumType a, enumType b) noexcept \
3434
{ \
3535
return (enumType)((uint64)a ^ (uint64)b); \
3636
} \
37-
static constexpr enumType operator!(enumType a) noexcept \
37+
static constexpr enumType operator!(enumType v) noexcept \
3838
{ \
39-
return (enumType)!((uint64)a); \
39+
return (enumType)!((uint64)v); \
4040
} \
41-
static constexpr enumType operator~(enumType a) noexcept \
41+
static constexpr enumType operator~(enumType v) noexcept \
4242
{ \
43-
return (enumType)~((uint64)a); \
43+
return (enumType)~((uint64)v); \
4444
} \
4545
static constexpr enumType& operator|=(enumType& a, enumType b) noexcept \
4646
{ \
@@ -54,13 +54,21 @@ static constexpr enumType& operator^=(enumType& a, enumType b) noexcept \
5454
{ \
5555
return a = a ^ b; \
5656
} \
57-
static constexpr bool hasAnyFlag(enumType a, enumType flags) noexcept \
57+
static constexpr bool hasAnyFlag(enumType v, enumType flags) noexcept \
5858
{ \
59-
return (uint64)(a & flags); \
59+
return (uint64)(v & flags) ? true : false; \
6060
} \
61-
static constexpr bool hasOneFlag(enumType a, enumType flag) noexcept \
61+
static constexpr bool hasOneFlag(enumType v, enumType flag) noexcept \
6262
{ \
63-
return (uint64)(a & flag) == (uint64)a; \
63+
return (v & flag) == v; \
64+
} \
65+
static constexpr void setFlags(enumType& v, enumType flags) noexcept \
66+
{ \
67+
v |= flags; \
68+
} \
69+
static constexpr void unsetFlags(enumType& v, enumType flags) noexcept \
70+
{ \
71+
v &= ~flags; \
6472
}
6573

6674
} // namespace math

include/math/simd/vector/float.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,7 @@ static f32x4 abs(f32x4 v) noexcept
884884
#if defined(MATH_SIMD_SUPPORT_SSE)
885885
if constexpr (std::numeric_limits<float>::is_iec559)
886886
return _mm_and_ps(v.data, _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)));
887-
else
888-
return _mm_max_ps(_mm_sub_ps(_mm_setzero_ps(), v.data), v.data);
887+
else return _mm_max_ps(_mm_sub_ps(_mm_setzero_ps(), v.data), v.data);
889888
#elif defined(MATH_SIMD_SUPPORT_NEON)
890889
return vabsq_f32(v.data);
891890
#else

source/bvh.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ void Bvh::recreate(const uint8* vertices, const uint8* indices, const Aabb& root
330330
{
331331
if (centroidData[primitives[i]][axis] < split)
332332
i++;
333-
else
334-
std::swap(primitives[i], primitives[j--]);
333+
else std::swap(primitives[i], primitives[j--]);
335334
}
336335

337336
auto count1 = i - firstPrimitive;
@@ -463,8 +462,7 @@ void Bvh::recreate(const Aabb* aabbs, const Aabb& rootAabb, uint32 aabbCount, co
463462
{
464463
if (centroidData[primitiveData[i]][axis] < split)
465464
i++;
466-
else
467-
std::swap(primitiveData[i], primitiveData[j--]);
465+
else std::swap(primitiveData[i], primitiveData[j--]);
468466
}
469467

470468
auto count1 = i - firstPrimitive;

0 commit comments

Comments
 (0)