31 template <
typename T,
typename F>
43 solve(data, result, size,
44 spring_constant, damping_constant,
45 limit, multiplier, []() {
return false; });
51 template <
typename T,
typename F>
56 const F& interrupt,
const UT_DMatrix4 *ref_xform =
nullptr);
59 template <
typename T,
typename F>
66 solve(data_x, data_y, data_z, result_x, result_y, result_z, size,
67 spring_constant, damping_constant, limit, multiplier,
68 [](){
return false; }, ref_xform);
76 return ((vel + (current - last) * spring) * (1.0 - decay));
91 newvel = spring(curr, k, d, last, vel);
92 newpos = last + (newvel * 0.5);
94 newvel = spring(curr, k, d, newpos, vel);
101 limit2 = limit * limit;
106 len2 = 2.0 * limit - limit2 / len;
110 velocity = vel + (diff *
f);
123 local_pos *= (*ref_xform);
124 goal *= (*ref_xform);
127 return (local_pos - goal) * multiplier + goal;
131 template <
typename T,
typename F>
146 goal.
assign(data_x[
j], data_y[j], data_z[j]);
147 result_vec = simulate(goal, spring_constant, damping_constant, limit, multiplier,
148 (ref_xform ==
nullptr) ?
nullptr : &(ref_xform[j]),
151 result_x[
j] = result_vec.
x();
152 result_y[
j] = result_vec.
y();
153 result_z[
j] = result_vec.
z();
161 template <
typename T,
typename F>
173 result[i] = simulate(data[i], spring_constant, damping_constant, limit,
constexpr SYS_FORCE_INLINE T length2() const noexcept
vfloat4 sqrt(const vfloat4 &a)
constexpr SYS_FORCE_INLINE T & z() noexcept
static void solve(const UT_Vector3T< T > *data, UT_Vector3T< T > *result, int size, fpreal spring_constant, fpreal damping_constant, fpreal limit, UT_Vector3T< T > multiplier, const F &interrupt)
**But if you need a result
static void solve(const fpreal *data_x, const fpreal *data_y, const fpreal *data_z, fpreal *result_x, fpreal *result_y, fpreal *result_z, int size, fpreal spring_constant, fpreal damping_constant, fpreal limit, UT_Vector3T< T > multiplier, const UT_DMatrix4 *ref_xform=nullptr)
static void solve(const UT_Vector3T< T > *data, UT_Vector3T< T > *result, int size, fpreal spring_constant, fpreal damping_constant, fpreal limit, UT_Vector3T< T > multiplier)
__hostdev__ uint64_t last(uint32_t i) const
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f)
Set the values of the vector components.
SIM_API const UT_StringHolder position
constexpr SYS_FORCE_INLINE T & y() noexcept
constexpr SYS_FORCE_INLINE T & x() noexcept