| 57 | |
| 58 | template<typename Patch> |
| 59 | __forceinline void evalLocalGrid(const Patch* patch, const BBox2f& srange, const int lx0, const int lx1, const int ly0, const int ly1) |
| 60 | { |
| 61 | const float scale_x = rcp(srange.upper.x-srange.lower.x); |
| 62 | const float scale_y = rcp(srange.upper.y-srange.lower.y); |
| 63 | count += (lx1-lx0)*(ly1-ly0); |
| 64 | |
| 65 | #if 0 |
| 66 | for (unsigned iy=ly0; iy<ly1; iy++) { |
| 67 | for (unsigned ix=lx0; ix<lx1; ix++) { |
| 68 | const float lu = select(ix == swidth -1, float(1.0f), (float(ix)-srange.lower.x)*scale_x); |
| 69 | const float lv = select(iy == sheight-1, float(1.0f), (float(iy)-srange.lower.y)*scale_y); |
| 70 | const Vec3fa p = patch->patch.eval(lu,lv); |
| 71 | const float u = float(ix)*rcp_swidth; |
| 72 | const float v = float(iy)*rcp_sheight; |
| 73 | const int ofs = (iy-y0)*dwidth+(ix-x0); |
| 74 | Px[ofs] = p.x; |
| 75 | Py[ofs] = p.y; |
| 76 | Pz[ofs] = p.z; |
| 77 | U[ofs] = u; |
| 78 | V[ofs] = v; |
| 79 | } |
| 80 | } |
| 81 | #else |
| 82 | foreach2(lx0,lx1,ly0,ly1,[&](const vboolx& valid, const vintx& ix, const vintx& iy) { |
| 83 | const vfloatx lu = select(ix == swidth -1, vfloatx(1.0f), (vfloatx(ix)-srange.lower.x)*scale_x); |
| 84 | const vfloatx lv = select(iy == sheight-1, vfloatx(1.0f), (vfloatx(iy)-srange.lower.y)*scale_y); |
| 85 | const Vec3vfx p = patch->patch.eval(lu,lv); |
| 86 | Vec3vfx n = zero; |
| 87 | if (unlikely(Nx != nullptr)) n = normalize_safe(patch->patch.normal(lu,lv)); |
| 88 | const vfloatx u = vfloatx(ix)*rcp_swidth; |
| 89 | const vfloatx v = vfloatx(iy)*rcp_sheight; |
| 90 | const vintx ofs = (iy-y0)*dwidth+(ix-x0); |
| 91 | if (likely(all(valid)) && all(iy==iy[0])) { |
| 92 | const unsigned ofs2 = ofs[0]; |
| 93 | vfloatx::storeu(Px+ofs2,p.x); |
| 94 | vfloatx::storeu(Py+ofs2,p.y); |
| 95 | vfloatx::storeu(Pz+ofs2,p.z); |
| 96 | vfloatx::storeu(U+ofs2,u); |
| 97 | vfloatx::storeu(V+ofs2,v); |
| 98 | if (unlikely(Nx != nullptr)) { |
| 99 | vfloatx::storeu(Nx+ofs2,n.x); |
| 100 | vfloatx::storeu(Ny+ofs2,n.y); |
| 101 | vfloatx::storeu(Nz+ofs2,n.z); |
| 102 | } |
| 103 | } else { |
| 104 | foreach_unique_index(valid,iy,[&](const vboolx& valid, const int iy0, const int j) { |
| 105 | const unsigned ofs2 = ofs[j]-j; |
| 106 | vfloatx::storeu(valid,Px+ofs2,p.x); |
| 107 | vfloatx::storeu(valid,Py+ofs2,p.y); |
| 108 | vfloatx::storeu(valid,Pz+ofs2,p.z); |
| 109 | vfloatx::storeu(valid,U+ofs2,u); |
| 110 | vfloatx::storeu(valid,V+ofs2,v); |
| 111 | if (unlikely(Nx != nullptr)) { |
| 112 | vfloatx::storeu(valid,Nx+ofs2,n.x); |
| 113 | vfloatx::storeu(valid,Ny+ofs2,n.y); |
| 114 | vfloatx::storeu(valid,Nz+ofs2,n.z); |
| 115 | } |
| 116 | }); |
nothing calls this directly
no test coverage detected