code cleanup and improve brush direction

This commit is contained in:
2019-02-11 18:39:26 +01:00
parent 97c3ac0d19
commit 171ab31b47
5 changed files with 97 additions and 144 deletions

View File

@@ -95,7 +95,7 @@ template<typename T, int N> struct cbuffer
m_index = 0;
m_count = 0;
}
T& head()
const T& head() const
{
return m_index == 0 ? m_vec[m_count - 1] : m_vec[m_index - 1];
}
@@ -118,6 +118,16 @@ template<typename T, int N> struct cbuffer
tot += m_vec[i];
return tot / (float)m_count;
}
template<typename T2 = T> T2 average_threshold(T threshold) const
{
T2 tot{};
if (m_count == 0)
return tot;
int n = 0;
for (int i = 0; i < m_count; i++)
tot += glm::abs(m_vec[i] - head()) < threshold ? 0 : m_vec[i], n++;
return tot / (float)n;
}
};
template<typename T, int Max = 0>