13 #ifndef __GEO_Interpolate__
14 #define __GEO_Interpolate__
41 template<
typename INT>
57 template<
typename INT>
83 template<
typename T,
typename S>
88 weights[0] = (u1 *
v1);
89 weights[1] = (u1 *
v);
91 weights[3] = (u *
v1);
94 template<
typename T,
typename S>
124 template <
typename T>
132 case 0: x = 1; y = 2;
break;
133 case 1: x = 0; y = 2;
break;
134 case 2: x = 0; y = 1;
break;
138 template<
typename POLY>
140 GEOprimUVWPrecompute(
const POLY &poly,
int &xaxis,
int &yaxis,
float ¢rex,
float ¢rey)
145 GA_Size nvertices = poly.getFastVertexCount();
149 for (
GA_Size i = 0; i < nvertices; ++i)
152 p2 = poly.getPos3(i);
159 centrex = centre[xaxis]/
float(nvertices);
160 centrey = centre[yaxis]/
float(nvertices);
163 template<
typename POLY>
165 GEOprimUVWNonConvex(
const POLY &poly,
const UT_Vector3 &p,
int xaxis,
int yaxis,
float centrex,
float centrey,
const float w=0)
172 const GA_Size n = poly.getFastVertexCount();
186 p1[xaxis], p1[yaxis],
192 if (sample.
sample(x0, y0, output[0], output[1], 1e-6))
198 bool isedgecase = (output[0] < 0 || output[1] < 0 || output[0]+output[1] > 1);
204 if (output[0]+output[1] > 1)
205 output[1] = 1.0f - output[0];
209 if (output[1] != 1.0
f)
210 output[0] /= 1.0f - output[1];
211 output[0] = (output[0] +
float(li)) /
float(n);
229 p0 = poly.getPos3(li);
246 float u = scale *
cross(s, dv);
247 float v = scale *
cross(du, s);
258 UT_Vector2 clampedp = weights[0]*puv + weights[1]*pu + weights[2]*pv;
260 if (!found || d2 < mind2)
273 if (output[1] != 1.0
f)
274 output[0] /= 1.0f - output[1];
275 output[0] = (output[0] +
float(outputli)) /
float(n);
294 bool is_point_offsets=
false);
302 template <
typename T>
321 template <
typename T>
void GEOquadInterpolationWeights(T u, T v, S weights[4])
Definition of a geometry attribute.
GLenum GLuint GLenum GLsizei const GLchar * buf
void geoInterpolateAttributes(const GEO_Detail *source, const GA_AttributeRefMap &attribmap, const GA_Range &destrange, const GA_ROHandleT< INT > &primnumattrib, const GA_ROHandleV3 &primuvwattrib, const GEO_InterpolationOptions &options)
GEO_API void GEOevaluateInteriorPoint(const GEO_Detail *gdp, GA_Offset primoff, const GA_ROHandleT< T > &h, const UT_Vector3 &uvw, T *buf, int size)
GA_API const UT_StringHolder uv
bool SYSisFinite(fpreal64 f)
GLdouble GLdouble GLdouble z
constexpr SYS_FORCE_INLINE T & z() noexcept
exint GA_Size
Defines the bit width for index and offset types in GA.
A range of elements in an index-map.
GLuint GLsizei const GLuint const GLintptr * offsets
GA_API const UT_StringHolder scale
IMATH_NAMESPACE::V2f float
void setVertices(fpreal x0, fpreal y0, fpreal x1, fpreal y1, fpreal x2, fpreal y2)
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
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)
GLsizei GLsizei GLchar * source
A handle to simplify manipulation of multiple attributes.
GLfloat GLfloat GLfloat GLfloat h
void GEOgetXYProjection(const UT_Vector3T< T > &nml, int &x, int &y)
GLubyte GLubyte GLubyte GLubyte w
SYS_FORCE_INLINE void normal(const UT_Vector3T< T > &va, const UT_Vector3T< T > &vb)
constexpr SYS_FORCE_INLINE T & y() noexcept
int sample(fpreal x, fpreal y, float &u, float &v, fpreal tol=0.0)
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
void GEOtriInterpolationWeights(T u, T v, S weights[3])
T distance2d(const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2)
constexpr SYS_FORCE_INLINE T & x() noexcept