35 Kokkos::View<const float*, CpMem> invMass,
36 Kokkos::View<
const float* [3],
CpMem> posPred,
37 Kokkos::View<
const float* [4],
CpMem> quatPred,
38 Kokkos::View<
const float* [4],
CpMem> quatStatic,
39 Kokkos::View<
const float* [3],
CpMem> invInertia,
40 Kokkos::View<
float* [3],
CpMem> deltaPos,
41 Kokkos::View<
float* [4],
CpMem> deltaQuat,
42 Kokkos::View<int*, CpMem> constraintCounts,
43 Kokkos::View<float, CpMem> maxOverlap) {
47 "peclet::dem::solve_position", Kokkos::RangePolicy<CpExec>(space, 0, numContacts),
48 KOKKOS_LAMBDA(
int idx) {
51 const float invMassA = invMass(idA);
52 const float invMassB = (idB >= 0) ? invMass(idB) : 0.0f;
54 const F3 pA =
ldF3(posPred, idA);
55 const F4 qA =
ldF4(quatPred, idA);
59 pB =
ldF3(posPred, idB);
60 qB =
ldF4(quatPred, idB);
77 const F3 pAsurf =
add3(pA, rA);
80 const F3 pAc =
add3(pA, rA);
81 const F3 pBc =
add3(pB, rB);
87 const F3 invIA =
ldF3(invInertia, idA);
88 const F3 invIB = (idB >= 0) ?
ldF3(invInertia, idB) :
F3{0, 0, 0};
89 const float wTotal = computeW(rA, n, invMassA, invIA) + computeW(rB, n, invMassB, invIB);
93 const float dLambda = -C / wTotal;
96 Kokkos::atomic_add(&deltaPos(idA, 0), n.x * dLambda * invMassA);
97 Kokkos::atomic_add(&deltaPos(idA, 1), n.y * dLambda * invMassA);
98 Kokkos::atomic_add(&deltaPos(idA, 2), n.z * dLambda * invMassA);
101 const F3 dTheta{rn.
x * invIA.
x * dLambda, rn.
y * invIA.
y * dLambda,
102 rn.
z * invIA.
z * dLambda};
104 Kokkos::atomic_add(&deltaQuat(idA, 0), dq.
x);
105 Kokkos::atomic_add(&deltaQuat(idA, 1), dq.
y);
106 Kokkos::atomic_add(&deltaQuat(idA, 2), dq.
z);
107 Kokkos::atomic_add(&deltaQuat(idA, 3), dq.
w);
110 Kokkos::atomic_add(&deltaPos(idB, 0), -n.x * dLambda * invMassB);
111 Kokkos::atomic_add(&deltaPos(idB, 1), -n.y * dLambda * invMassB);
112 Kokkos::atomic_add(&deltaPos(idB, 2), -n.z * dLambda * invMassB);
114 const F3 dTheta{-rn.
x * invIB.
x * dLambda, -rn.
y * invIB.
y * dLambda,
115 -rn.
z * invIB.
z * dLambda};
117 Kokkos::atomic_add(&deltaQuat(idB, 0), dq.
x);
118 Kokkos::atomic_add(&deltaQuat(idB, 1), dq.
y);
119 Kokkos::atomic_add(&deltaQuat(idB, 2), dq.
z);
120 Kokkos::atomic_add(&deltaQuat(idB, 3), dq.
w);
121 Kokkos::atomic_add(&constraintCounts(idB), 1);
123 Kokkos::atomic_add(&constraintCounts(idA), 1);
126 Kokkos::atomic_max(&maxOverlap(), -C);
void solvePositionKokkos(Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, Kokkos::View< const float *, CpMem > invMass, Kokkos::View< const float *[3], CpMem > posPred, Kokkos::View< const float *[4], CpMem > quatPred, Kokkos::View< const float *[4], CpMem > quatStatic, Kokkos::View< const float *[3], CpMem > invInertia, Kokkos::View< float *[3], CpMem > deltaPos, Kokkos::View< float *[4], CpMem > deltaQuat, Kokkos::View< int *, CpMem > constraintCounts, Kokkos::View< float, CpMem > maxOverlap)
Accumulate XPBD position corrections for numContacts contacts.