Fix Rocketship wall damage flash misinterpreted as model scaling

This commit is contained in:
UnixNight committed 2026-11-03 16:53:56 -05:00
1 parent b5ef5b8b64
commit 62e908e26d
13 files changed
+255 -21

No files matched your search

+51
View File
@@ -16,6 +16,7 @@ var tests=new(string,Action)[]{
("Rocket wall374 does not inherit horizontal reflection",Wall),
("actual passenger can activate RETURN while ship owns control",Return),
("exact four resource families and additive fire visibility",Visuals),
("wall impact pulses material color without deforming any owned geometry",ImpactVisuals),
};
foreach(var(name,check)in tests){check();Console.WriteLine("PASS "+name);}
Console.WriteLine($"Rocketship integration: {tests.Length} groups passed; bounded static VR02, not original whole-game verification.");
@@ -130,6 +131,56 @@ static void Visuals()
f.Interactions.Inventory.SelectGadget(-1);visuals.Update(visuals.Mesh,f.Ship,.2,f.Player.Appearance);
Check(visuals.Mesh.Draws.TakeLast(4).All(d=>!d.Visible),"cleanup hides every owned layer");
}
static void ImpactVisuals()
{
using var f=new Fixture();
var points=new Vector3[]{new(0,-1000,-1000),new(0,1000,-1000),new(0,1000,1000)};
var wall=new Mesh(points.Select(p=>new MeshVertex(p,Vector2.Zero,Vector3.One)).ToArray(),[0,1,2])
{HasCollisionMaterialIds=true,CollisionPolygons=[new(0,0,-Vector3.UnitX,"wall","wall",0)]};
var ship=new Rocketship(f.Ship.Actor,wall,"VR02");
var visuals=new RocketshipVisuals(f.World,Path.GetFullPath("artifacts/extracted"));
var clips=new[]{"strato","jimdrive","godrocket","firestrato"}
.Select(name=>new MorphAnimation($"artifacts/extracted/rocketship/{name}/animation.json")).ToArray();
var offsets=new int[4];offsets[0]=f.World.Vertices.Length;
for(int i=1;i<4;i++)offsets[i]=offsets[i-1]+clips[i-1].Base.Vertices.Length;
var tinted=false;
for(int frame=0;frame<130;frame++)
{
if(frame is 0 or 65)
{
ship.Mount(new(-51,300,0),new(0,270,0),f.Player.CameraEye);
ship.StepInput(new(true,false,false,false,false),FixedStepClock.Step);
ship.StepFrame(default,FixedStepClock.Step);
ship.StepBody(FixedStepClock.Step);
Check(ship.ImpactActive&&ship.Contacts==(frame==0?1:2),"actual wall374 starts each impact");
}
ship.StepFrame(default,FixedStepClock.Step);
double time=frame/60d;
visuals.Update(visuals.Mesh,ship,time,f.Player.Appearance);
var color=ship.ImpactColor;
Check(color.X==1&&color.W==1&&color.Y==color.Z&&color.Y>=0&&color.Y<=1,"red flash RGBA bounds");
tinted|=color.Y<.1f;
for(int layer=0;layer<4;layer++)
{
var expected=new MeshVertex[clips[layer].Base.Vertices.Length];
var root=layer==2?ship.CompanionRoot:ship.Root;
clips[layer].Sample(time,expected,RocketOrientation.Model(ship.Rotation,root,Vector3.One));
for(int i=0;i<expected.Length;i++)
{
var actual=visuals.Mesh.Vertices[offsets[layer]+i];
Near(actual.Position,expected[i].Position,$"impact preserves layer{layer} vertex{i}");
var tint=layer==0?new Vector3(color.X,color.Y,color.Z):Vector3.One;
Near(actual.Color,expected[i].Color*tint,$"material tint only on ship layer{layer} vertex{i}");
}
}
//A second render without a simulation step must not accumulate tint.
var sample=visuals.Mesh.Vertices[offsets[0]];
visuals.Update(visuals.Mesh,ship,time,f.Player.Appearance);
Near(visuals.Mesh.Vertices[offsets[0]].Color,sample.Color,"render does not multiply prior-frame tint");
}
Check(tinted&&!ship.ImpactActive&&ship.ImpactColor==Vector4.One,"repeated impacts expire to untinted unit geometry");
ship.Reset();Check(ship.ImpactColor==Vector4.One,"reset clears impact color");
}
static void Check(bool ok,string message){if(!ok)throw new Exception(message);}
static void Near(Vector3 actual,Vector3 expected,string message)=>Check(float.IsFinite(actual.X+actual.Y+actual.Z)&&Vector3.Distance(actual,expected)<.002f,$"{message}: {actual} != {expected}");