diff --git a/Content/Blueprints/BP_TestBot.uasset b/Content/Blueprints/BP_TestBot.uasset index d19ec8e..cc4ac29 100644 Binary files a/Content/Blueprints/BP_TestBot.uasset and b/Content/Blueprints/BP_TestBot.uasset differ diff --git a/Content/Blueprints/BP_TestCube.uasset b/Content/Blueprints/BP_TestCube.uasset index 8afff8b..74dab91 100644 Binary files a/Content/Blueprints/BP_TestCube.uasset and b/Content/Blueprints/BP_TestCube.uasset differ diff --git a/Content/Levels/Main.umap b/Content/Levels/Main.umap index f5f4353..528b448 100644 Binary files a/Content/Levels/Main.umap and b/Content/Levels/Main.umap differ diff --git a/Content/Models/puma_link3.uasset b/Content/Models/puma_link3.uasset index b10bb7c..1164e60 100644 Binary files a/Content/Models/puma_link3.uasset and b/Content/Models/puma_link3.uasset differ diff --git a/Content/Models/test_arm.uasset b/Content/Models/test_arm.uasset index c306976..efcf86d 100644 Binary files a/Content/Models/test_arm.uasset and b/Content/Models/test_arm.uasset differ diff --git a/Content/Models/test_base.uasset b/Content/Models/test_base.uasset index 6ce86a9..f95bc47 100644 Binary files a/Content/Models/test_base.uasset and b/Content/Models/test_base.uasset differ diff --git a/Source/PBDRobotics/Joint.cpp b/Source/PBDRobotics/Joint.cpp index baf9d22..0a49084 100644 --- a/Source/PBDRobotics/Joint.cpp +++ b/Source/PBDRobotics/Joint.cpp @@ -48,7 +48,7 @@ void UJoint::SolvePosition(const double H) const{ const double W1 = L1->GetPositionalInverseMass(R1, 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; @@ -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; L1->Orientation = (L1->Orientation + Add1).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 @@ -79,16 +79,16 @@ void UJoint::SolvePosition(const double H) const{ const double W1 = L1->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; Vector3d T1 = I1.inverse() * P; Vector3d T2 = I2.inverse() * P; 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; - //L1->Orientation = (L1->Orientation + Add1).normalized(); - //L2->Orientation = (L2->Orientation - Add2).normalized(); - //UE_LOG(LogTemp, Log, TEXT("%f | %f | %f | %f"), N.norm(), W1, W2, Q.norm()); + L1->Orientation = (L1->Orientation + Add1).normalized(); + L2->Orientation = (L2->Orientation - Add2).normalized(); + // UE_LOG(LogTemp, Log, TEXT("%f"), Add2.norm()); } } diff --git a/Source/PBDRobotics/Joint.h b/Source/PBDRobotics/Joint.h index d43c1cf..189917a 100644 --- a/Source/PBDRobotics/Joint.h +++ b/Source/PBDRobotics/Joint.h @@ -38,12 +38,14 @@ public: // First - Second in World-Space Vector3d GetConnection() const; - - // + Vector3d FirstRotateAxis; Vector3d SecondRotateAxis; + // World Axis, around which the First Link wants to rotate Vector3d GetFirstWorldAxis() const; + + // World Axis, around which the Second Link wants to rotate Vector3d GetSecondWorldAxis() const; void SolvePosition(const double H) const; diff --git a/Source/PBDRobotics/Robot.cpp b/Source/PBDRobotics/Robot.cpp index 137db44..6980fb7 100644 --- a/Source/PBDRobotics/Robot.cpp +++ b/Source/PBDRobotics/Robot.cpp @@ -27,7 +27,7 @@ void ARobot::BeginPlay(){ void ARobot::Tick(const float DeltaTime){ Super::Tick(DeltaTime); - constexpr int SubSteps = 10; + constexpr int SubSteps = 30; const double h = DeltaTime / SubSteps; for (int i = 0; i < SubSteps; i++){ for (auto* Link : Parts)