Download

Summing forces at locations?

Hello. I’m using a physics simulation to control the environmental effects on an object. I am running the simulation in another thread so when it finishes it returns the force and torque on an object and then sets of a new task. This unlocks it from the the tick and also makes efficient use of multi-threading. I am however, getting weird results.

When I first tested my system I had it call AddForceAtLocation for each force generated. It gave me good results but I thought it was inefficient and I wanted the async task to return a single force and torque.

What I did was just sum all the forces and torques where for each force i:


TotalForce += Force_i;
// Both in world location
FVector R = ForceLocation - CenterOfMass;
FVector Torque_i = R^F;

TotalTorque += Torque_i;

Then once I had all the force I could simply:


Mesh->AddForce(TotalForce);
Mesh->AddTorque(TotalTorque);

The torques are giving me crazy results. They cause my object to spin around and move in unexpected ways and stabilize standing on their nose sometimes.

I have applied the forces independently to confirm that they are giving the expected results. The forces alone work well and will control the position of the object as expected but the torques are just crazy. I have confirmed that the force position is correct in regards to the center of mass.

I feel like I must be doing something silly or simple that is wrong. I’m exhausted from debugging so my mind is warped in weird ways. What is wrong with my code.

Here is a video showing buoyancy and drag with no torques and then the buoyancy with no torques but the drag torques are included. The center of mass of the mesh is in the middle on the bottom. I don’t know why the drag torques are pushing the boat up out of the water like that. I have put in break points and checked the variable values and everything is what I expect it to be.

https://youtu.be/kIbrnDkpX0Q

Is this something simple and my brain has just melted?