|
|
@ -48,7 +48,7 @@ void UJoint::SolvePosition(const double H) const{ |
|
|
|
const double W1 = L1->GetPositionalInverseMass(R1, N); |
|
|
|
const double W1 = L1->GetPositionalInverseMass(R1, N); |
|
|
|
const double W2 = L2->GetPositionalInverseMass(R2, N); |
|
|
|
const double W2 = L2->GetPositionalInverseMass(R2, N); |
|
|
|
|
|
|
|
|
|
|
|
constexpr double A = 1. / 10000000; // Compliance (inverse of stiffness)
|
|
|
|
constexpr double A = 0; //1. / 10000000; // Compliance (inverse of stiffness)
|
|
|
|
|
|
|
|
|
|
|
|
const Vector3d P = -C / (W1 + W2 + A / (H * H)) * N; |
|
|
|
const Vector3d P = -C / (W1 + W2 + A / (H * H)) * N; |
|
|
|
|
|
|
|
|
|
|
@ -61,7 +61,7 @@ void UJoint::SolvePosition(const double H) const{ |
|
|
|
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; |
|
|
|
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; |
|
|
|
L1->Orientation = (L1->Orientation + Add1).normalized(); |
|
|
|
L1->Orientation = (L1->Orientation + Add1).normalized(); |
|
|
|
L2->Orientation = (L2->Orientation - Add2).normalized(); |
|
|
|
L2->Orientation = (L2->Orientation - Add2).normalized(); |
|
|
|
UE_LOG(LogTemp, Log, TEXT("%f | %f | %f"), C, P.norm(), R2.cross(P).norm()); |
|
|
|
// UE_LOG(LogTemp, Log, TEXT("%f"), P.norm());
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Rotational Constraints
|
|
|
|
// Rotational Constraints
|
|
|
@ -79,16 +79,16 @@ void UJoint::SolvePosition(const double H) const{ |
|
|
|
const double W1 = L1->GetRotationalInverseMass(N); |
|
|
|
const double W1 = L1->GetRotationalInverseMass(N); |
|
|
|
const double W2 = L2->GetRotationalInverseMass(N); |
|
|
|
const double W2 = L2->GetRotationalInverseMass(N); |
|
|
|
|
|
|
|
|
|
|
|
constexpr double A = 0; //1. / 10000000;
|
|
|
|
constexpr double A = 0; //1. / 100000000;
|
|
|
|
const Vector3d P = Theta / (W1 + W2 + A / (H * H)) * N; |
|
|
|
const Vector3d P = Theta / (W1 + W2 + A / (H * H)) * N; |
|
|
|
|
|
|
|
|
|
|
|
Vector3d T1 = I1.inverse() * P; |
|
|
|
Vector3d T1 = I1.inverse() * P; |
|
|
|
Vector3d T2 = I2.inverse() * P; |
|
|
|
Vector3d T2 = I2.inverse() * P; |
|
|
|
const Quaterniond Add1 = Quaterniond(0, T1.x(), T1.y(), T1.z()) * L1->Orientation * 0.5; |
|
|
|
const Quaterniond Add1 = Quaterniond(0, T1.x(), T1.y(), T1.z()) * L1->Orientation * 0.5; |
|
|
|
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; |
|
|
|
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; |
|
|
|
//L1->Orientation = (L1->Orientation + Add1).normalized();
|
|
|
|
L1->Orientation = (L1->Orientation + Add1).normalized(); |
|
|
|
//L2->Orientation = (L2->Orientation - Add2).normalized();
|
|
|
|
L2->Orientation = (L2->Orientation - Add2).normalized(); |
|
|
|
//UE_LOG(LogTemp, Log, TEXT("%f | %f | %f | %f"), N.norm(), W1, W2, Q.norm());
|
|
|
|
// UE_LOG(LogTemp, Log, TEXT("%f"), Add2.norm());
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|