Skip to content
Snippets Groups Projects
Commit b42b7b73 authored by Julius Nehring-Wirxel's avatar Julius Nehring-Wirxel
Browse files

normalize now respects the attribute type (i.e. it now works for double)

parent 461d716f
Branches
No related tags found
1 merge request!27normalize now respects the attribute type (i.e. it now works for double)
......@@ -9,6 +9,8 @@ namespace polymesh
template <class Pos3>
void normalize(vertex_attribute<Pos3>& pos)
{
using ScalarT = std::decay_t<decltype(pos.first()[0])>;
if (pos.mesh().vertices().size() == 0)
return;
......@@ -16,15 +18,15 @@ void normalize(vertex_attribute<Pos3>& pos)
auto mi = mm.min;
auto ma = mm.max;
auto cx = (mi[0] + ma[0]) * 0.5f;
auto cy = (mi[1] + ma[1]) * 0.5f;
auto cz = (mi[2] + ma[2]) * 0.5f;
auto cx = (mi[0] + ma[0]) * ScalarT(0.5);
auto cy = (mi[1] + ma[1]) * ScalarT(0.5);
auto cz = (mi[2] + ma[2]) * ScalarT(0.5);
auto sx = ma[0] - mi[0];
auto sy = ma[1] - mi[1];
auto sz = ma[2] - mi[2];
auto s = std::max(sx, std::max(sy, sz)) * 0.5f;
s = std::max(s, std::numeric_limits<float>::min());
auto s = std::max(sx, std::max(sy, sz)) * ScalarT(0.5);
s = std::max(s, std::numeric_limits<ScalarT>::min());
for (auto& p : pos)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment