|
@@ -266,18 +266,22 @@ Vec3 Vec3::sFusedMultiplyAdd(Vec3Arg inMul1, Vec3Arg inMul2, Vec3Arg inAdd)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-Vec3 Vec3::sSelect(Vec3Arg inV1, Vec3Arg inV2, UVec4Arg inControl)
|
|
|
+Vec3 Vec3::sSelect(Vec3Arg inNotSet, Vec3Arg inSet, UVec4Arg inControl)
|
|
|
{
|
|
|
-#if defined(JPH_USE_SSE4_1)
|
|
|
- Type v = _mm_blendv_ps(inV1.mValue, inV2.mValue, _mm_castsi128_ps(inControl.mValue));
|
|
|
+#if defined(JPH_USE_SSE4_1) && !defined(JPH_PLATFORM_WASM) // _mm_blendv_ps has problems on FireFox
|
|
|
+ Type v = _mm_blendv_ps(inNotSet.mValue, inSet.mValue, _mm_castsi128_ps(inControl.mValue));
|
|
|
+ return sFixW(v);
|
|
|
+#elif defined(JPH_USE_SSE)
|
|
|
+ __m128 is_set = _mm_castsi128_ps(_mm_srai_epi32(inControl.mValue, 31));
|
|
|
+ Type v = _mm_or_ps(_mm_and_ps(is_set, inSet.mValue), _mm_andnot_ps(is_set, inNotSet.mValue));
|
|
|
return sFixW(v);
|
|
|
#elif defined(JPH_USE_NEON)
|
|
|
- Type v = vbslq_f32(vreinterpretq_u32_s32(vshrq_n_s32(vreinterpretq_s32_u32(inControl.mValue), 31)), inV2.mValue, inV1.mValue);
|
|
|
+ Type v = vbslq_f32(vreinterpretq_u32_s32(vshrq_n_s32(vreinterpretq_s32_u32(inControl.mValue), 31)), inSet.mValue, inNotSet.mValue);
|
|
|
return sFixW(v);
|
|
|
#else
|
|
|
Vec3 result;
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
- result.mF32[i] = inControl.mU32[i] ? inV2.mF32[i] : inV1.mF32[i];
|
|
|
+ result.mF32[i] = (inControl.mU32[i] & 0x80000000u) ? inSet.mF32[i] : inNotSet.mF32[i];
|
|
|
#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
|
|
|
result.mF32[3] = result.mF32[2];
|
|
|
#endif // JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
|
|
@@ -715,7 +719,7 @@ Vec3 Vec3::Normalized() const
|
|
|
|
|
|
Vec3 Vec3::NormalizedOr(Vec3Arg inZeroValue) const
|
|
|
{
|
|
|
-#if defined(JPH_USE_SSE4_1)
|
|
|
+#if defined(JPH_USE_SSE4_1) && !defined(JPH_PLATFORM_WASM) // _mm_blendv_ps has problems on FireFox
|
|
|
Type len_sq = _mm_dp_ps(mValue, mValue, 0x7f);
|
|
|
Type is_zero = _mm_cmpeq_ps(len_sq, _mm_setzero_ps());
|
|
|
#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
|