Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove vector comparison operators #986

Merged
merged 1 commit into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion filament/include/filament/Box.h
Expand Up @@ -143,7 +143,7 @@ struct Aabb {
* @return true if min >= max, i.e: the volume of the box is null or negative
*/
bool isEmpty() const noexcept {
return min >= max;
return any(greaterThanEqual(min, max));
}
};

Expand Down
15 changes: 7 additions & 8 deletions filament/test/filament_test.cpp
Expand Up @@ -424,10 +424,9 @@ TEST(FilamentTest, ColorConversion) {
EXPECT_PRED2(vec3eq, (sRGBColor{1.0f, 0.0f, 0.0f}),
Color::toSRGB<ACCURATE>({1.0f, 0.0f, 0.0f}));

// 0.5 is > 0.5
EXPECT_LT((sRGBColor{0.5f, 0.0f, 0.0f}), Color::toSRGB<FAST>({0.5f, 0.0f, 0.0f}));
// 0.5 is > 0.5
EXPECT_LT((sRGBColor{0.5f, 0.0f, 0.0f}), Color::toSRGB<ACCURATE>({0.5f, 0.0f, 0.0f}));
EXPECT_LT((sRGBColor{0.5f, 0.0f, 0.0f}.x), Color::toSRGB<FAST>({0.5f, 0.0f, 0.0f}).x);

EXPECT_LT((sRGBColor{0.5f, 0.0f, 0.0f}.x), Color::toSRGB<ACCURATE>({0.5f, 0.0f, 0.0f}).x);

EXPECT_PRED1(isGray, Color::toSRGB<FAST>(LinearColor{0.5f}));
EXPECT_PRED1(isGray, Color::toSRGB<ACCURATE>(LinearColor{0.5f}));
Expand All @@ -443,10 +442,10 @@ TEST(FilamentTest, ColorConversion) {
// 1.0 stays 1.0
EXPECT_PRED2(vec3eq, (LinearColor{1.0f, 0.0f, 0.0f}), Color::toLinear<ACCURATE>({1.0f, 0.0f, 0.0f}));

// 0.5 is < 0.5
EXPECT_GT((LinearColor{0.5f, 0.0f, 0.0f}), Color::toLinear<FAST>({0.5f, 0.0f, 0.0f}));
// 0.5 is < 0.5
EXPECT_GT((LinearColor{0.5f, 0.0f, 0.0f}), Color::toLinear<ACCURATE>({0.5f, 0.0f, 0.0f}));

EXPECT_GT((LinearColor{0.5f, 0.0f, 0.0f}.x), Color::toLinear<FAST>({0.5f, 0.0f, 0.0f}).x);

EXPECT_GT((LinearColor{0.5f, 0.0f, 0.0f}.x), Color::toLinear<ACCURATE>({0.5f, 0.0f, 0.0f}).x);

EXPECT_PRED1(isGray, Color::toLinear<FAST>(sRGBColor{0.5f}));
EXPECT_PRED1(isGray, Color::toLinear<ACCURATE>(sRGBColor{0.5f}));
Expand Down
38 changes: 0 additions & 38 deletions libs/math/include/math/TVecHelpers.h
Expand Up @@ -268,44 +268,6 @@ class TVecComparisonOperators {
return !operator ==(lv, rv);
}

template<typename RT>
friend inline
bool MATH_PURE operator >(const VECTOR<T>& lv, const VECTOR<RT>& rv) {
// w/ inlining we end-up with many branches that will pollute the BPU cache
MATH_NOUNROLL
for (size_t i = 0; i < lv.size(); i++) {
if (lv[i] != rv[i]) {
return lv[i] > rv[i];
}
}
return false;
}

template<typename RT>
friend inline
constexpr bool MATH_PURE operator <=(const VECTOR<T>& lv, const VECTOR<RT>& rv) {
return !(lv > rv);
}

template<typename RT>
friend inline
bool MATH_PURE operator <(const VECTOR<T>& lv, const VECTOR<RT>& rv) {
// w/ inlining we end-up with many branches that will pollute the BPU cache
MATH_NOUNROLL
for (size_t i = 0; i < lv.size(); i++) {
if (lv[i] != rv[i]) {
return lv[i] < rv[i];
}
}
return false;
}

template<typename RT>
friend inline
constexpr bool MATH_PURE operator >=(const VECTOR<T>& lv, const VECTOR<RT>& rv) {
return !(lv < rv);
}

template<typename RT>
friend inline
VECTOR<bool> MATH_PURE equal(const VECTOR<T>& lv, const VECTOR<RT>& rv) {
Expand Down
3 changes: 3 additions & 0 deletions libs/utils/test/test_StructureOfArrays.cpp
Expand Up @@ -30,6 +30,9 @@ struct TestFloat4 : public float4 {
z = -3;
w = -4;
}
friend bool operator < (TestFloat4 const& lhs, TestFloat4 const& rhs) noexcept {
return any(lessThan(lhs, rhs));
}
};

using SoA = utils::StructureOfArrays<float, double, TestFloat4>;
Expand Down