More refinement in the handling of wreckage.
The velocities of the various pieces of wreckage are modified via three approaches:
- Add more drag to the pieces, by a factor of 3.
- Apply a variable rate of vertical velocity based on mass of part; less mass has a slower acceleration applied. (Yes, ideally density would be a far better determinant, but I've not figured out a means of calculating it.
)
- Reduce the horizontal component of additional 'ejection' velocity by a factor of 2; now the pieces fan out over a much narrower initial angle.
The result is a fall pattern that is smaller and more nearly circular, instead of a VERY wide, VERY narrow arc. This also hugely reduces the former behaviour whereby parts followed increasingly curved paths.
In the 3-panel image above, the left frame shows my Zero at the far left, and we're looking at the exploded plane's pieces from the side. Note the range in position of the pieces in terms of distance traveled from the exploded plane, as well as in height.
The middle frame is at the same instant in time, but the view is now from behind. Note the fairly small lateral spread in the paths the parts are taking; formerly this spread was at least 2X wider.
In the third frame the view is from my Zero looking back just after the pieces have fallen to the surface. The pattern of fall shown by the splashes reveals a roughly circular dispersion of reasonably small areal coverage. The stock pattern would have been a pretty narrow arc lying nearer to my plane and extending L-R by at least 2X the width of this pattern.
In short, the pieces do not travel as far, they do not spread out as widely, and they have a larger range of ejection and falling speed.
In the Java snippets below I show my changes done to achieve this result. I'm sure further tuning could be done by a Real Programmer
TM, of which I am not.
Note the power law function modifying the vertical acceleration variable, World.g. Variable A is the 'retarding' factor to slow each part, based on mass; I've tripled its effect. Array [dv] holds the 8 values that are randomly selected from and applied to the horizontal component of each individual part's velocity upon release from the plane; I've halved the values.
From Wreckage.class
public boolean tick()
{
float f = Time.tickLenFs();
float f2 = (float)v.length();
float f1 = 10F / (f2 + 0.1F);
if(f1 > 1.0F)
f1 = 1.0F;
f1 *= Wreckage.dv[lr] * f; //NOTE: [lr] has values randomly taken from array dv[]
pos.getAbs(Wreckage.p, Wreckage.o);
Wreckage.o.increment(W.z * f, W.y * f, -W.x * f);
Wreckage.oh.set(f1, 0.0F, 0.0F);
Wreckage.oh.transform(v);
Wreckage.o.setYaw(Wreckage.o.getYaw() - f1);
float f4 = A * f;
v.x = deceleron(v.x, f4);
v.y = deceleron(v.y, f4);
v.z = deceleron(v.z, f4);
// v.z -= World.g() * f;
v.z -= (World.g() + (float) Math.pow(A, 0.25F) * 9F) * f; //reduces vert accel with decreasing mass; g effectively becomes -9.35 to -4.25 (800kg to 0.4kg)
Wreckage.p.scaleAdd(f, v, Wreckage.p);
double d = World.land().HQ(Wreckage.p.x, Wreckage.p.y);
private void construct(float f)
{
.
.
.
wn = 60F + 80F / (wn + 0.2F);
W.scale(wn);
lr = World.Rnd().nextInt(0, 8);
// A = 0.02F / M;
A = 0.06F / M;
interpPut(new Interpolater(), null, Time.current(), null);
MsgDestroy.Post(Time.current() + 0x1d4c0L, this); //1d4c0 = 120,000, or 120 sec
}
// private static float dv[] = {
// -80F, -60F, -40F, -20F, 20F, 40F, 60F, 80F, 0.0F
// };
private static float dv[] = {
-40F, -30F, -20F, -10F, 10F, 20F, 30F, 40F, 0.0F
};