30 #include <type_traits>
34 namespace GU_SurfaceDeform
37 template <
typename T,
typename Container>
45 inline T get(
size_t i)
const noexcept
50 inline void set(
size_t i,
const T &
value) noexcept
55 inline size_t size() const noexcept
61 template <
typename T,
typename Container,
typename Policy>
77 inline void set(
size_t i,
const T &
value) noexcept {
81 inline size_t size() const noexcept {
93 template<
typename PA,
typename RESOLVER,
typename PTARRAY>
101 const RESOLVER &resolve)
105 std::is_same_v<PtType, GA_Offset> || std::is_same_v<PtType, int>,
106 "surface capture points come out as GA_Offset or point index");
126 for (
exint i = r.begin(),
end = r.end(); i <
end; ++i)
131 resolve(i, pos, mininfo);
133 GA_Offset primoff = mininfo.prim.offset();
137 primoffsets[i] = primoff;
138 primuvs[i] =
UT_Vector3(mininfo.u1, mininfo.v1, 0.0f);
155 primptcounts.
begin(), primptcounts.
end(),
156 primptstarts.
begin() + 1);
159 GA_Size offsetcount = primptstarts[primptstarts.
size()-1];
170 for (
exint i = r.begin(),
end = r.end(); i <
end; ++i)
181 &surfacegdp, primoff, offsets, weights, primuv,
true);
183 for (
int j=0;
j<offsets.
size(); ++
j)
185 if constexpr (std::is_same_v<PtType, GA_Offset>)
186 ptcapture[primptstarts[i] +
j] = offsets[
j];
188 ptcapture[primptstarts[i] +
j] =
190 ptweights[primptstarts[i] +
j] = weights[
j];
197 template<
typename PA,
typename PTARRAY>
208 primptstarts, ptcapture, ptweights, positions, surfacegdp,
231 const DEFRESTPOS &constrestpos,
232 const DEFANIMPOS &constanimpos,
248 for (
exint i = r.begin(),
end = r.end(); i <
end; ++i)
250 GA_Size ptstart = primptstarts[i];
251 GA_Size ptend = primptstarts[i + 1];
252 if (ptstart != ptend)
263 for (
int j = ptstart;
j < ptend; ++
j)
268 float w = ptweights[
j];
269 restpos += w * constrestpos[index];
270 animpos += w * constanimpos[index];
272 restnml += w * restnmlattrib.
get(ptoff);
273 animnml += w * animnmlattrib.
get(ptoff);
275 resttan += w * resttanattrib.
get(ptoff);
276 animtan += w * animtanattrib.
get(ptoff);
297 if constexpr(std::is_same_v<value_type, UT_Matrix4>)
299 newposdata.set(i, restspace * deformspace);
304 pos *= restspace * deformspace;
306 newposdata.set(i, pos);
312 if constexpr(std::is_same_v<value_type, UT_Matrix4>)
318 newposdata.set(i, points[i].
data());
334 template<
typename PA>
365 void init(
const GU_Detail &restSurfaceGdp);
372 template<
typename PA>
380 if (!myRayIntersect || !myRestSurface)
383 const exint numpts = positions.size();
394 for (
exint i = r.begin(),
end = r.end(); i <
end; ++i)
397 myRayIntersect->minimumPoint(positions[i], mininfo);
402 (
int)myRestSurface->primitiveIndex(primoff);
403 coarseU[i] = mininfo.u1;
404 coarseV[i] = mininfo.v1;
419 bool isValid()
const {
return myRestSurface !=
nullptr; }
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
void UTparallelFor(const Range &range, const Body &body, const int subscribe_ratio=2, const int min_grain_size=1, const bool force_use_task_scope=true)
GLdouble GLdouble GLint GLint const GLdouble * points
GLsizei const GLfloat * value
void setSizeNoInit(exint newsize)
UT_Vector3T< float > UT_Vector3
int minimumPoint(const UT_Vector3 &p, GU_MinInfo &mininfo, const GEO_Primitive *prim=0) const
exint GA_Size
Defines the bit width for index and offset types in GA.
UT_Matrix4T< float > UT_Matrix4
#define GA_INVALID_OFFSET
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
GLuint GLsizei const GLuint const GLintptr * offsets
#define utZoneScopedN(name)
GEO_API void GEOgetInterpolationWeights(const GEO_Detail *detail, GA_Offset primoff, UT_Array< GA_Offset > &offsets, UT_Array< float > &weights, const UT_Vector3 &uvw, bool is_point_offsets=false)
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
void lookat(const UT_Vector3T< S > &from, const UT_Vector3T< S > &to, T roll=0)
SYS_FORCE_INLINE GA_Offset offset() const
UT_UniquePtr< GA_Attribute > GA_AttributeUPtr
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
void translate(T dx, T dy, T dz=0)
GLubyte GLubyte GLubyte GLubyte w
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
SYS_FORCE_INLINE GA_Size getPrimitiveVertexCount(GA_Offset primoff) const
iterator end()
End iterator.