- Route Warium and Futurism force queues through smoothed per-substep delivery - Evaluate wing, stabilizer, control surface and air brake forces every physics substep - Add optional improved flight model with angle-of-attack lift and stalls - Add auto trim toggled by a client key and a server packet - Add config options, translations, and mixin plugin version gating - Bump mod version to 0.2.0 and bundle Futurism 0.0.4 as a compile-only dependency
40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package dev.lumareth.improvedAerodynamics.flight;
|
|
|
|
/**
|
|
* Sum of the forces and torques of a set of surfaces, in ship axes. Torques of forces are taken about the center of
|
|
* mass; pure torques (Warium's ship relative rotations) are kept apart since VS scales them differently.
|
|
*/
|
|
final class Wrench {
|
|
final double[] force = new double[3];
|
|
final double[] forceTorque = new double[3];
|
|
final double[] torque = new double[3];
|
|
|
|
void clear() {
|
|
for (int i = 0; i < 3; i++) {
|
|
force[i] = 0.0;
|
|
forceTorque[i] = 0.0;
|
|
torque[i] = 0.0;
|
|
}
|
|
}
|
|
|
|
/** Force on the surface's block, with r the block center relative to the center of mass. */
|
|
void addForce(double[] r, double x, double y, double z) {
|
|
force[0] += x;
|
|
force[1] += y;
|
|
force[2] += z;
|
|
forceTorque[0] += r[1] * z - r[2] * y;
|
|
forceTorque[1] += r[2] * x - r[0] * z;
|
|
forceTorque[2] += r[0] * y - r[1] * x;
|
|
}
|
|
|
|
void addTorque(double x, double y, double z) {
|
|
torque[0] += x;
|
|
torque[1] += y;
|
|
torque[2] += z;
|
|
}
|
|
|
|
double totalTorque(int axis) {
|
|
return forceTorque[axis] + torque[axis];
|
|
}
|
|
}
|