code cleanup and improve brush direction
This commit is contained in:
12
src/util.h
12
src/util.h
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user