Skip to content

PR #390 is breaking calculations dependent on part size in the SPH. #410

Description

@BrettRyland

What did you do before the bug occurred?

PR #390 (which was added in v1.41.0) is breaking BDArmory HP and armour calculations in the SPH by returning 0-sized parts when they're selected from the menu.
In general, it breaks any part size calculations in the editor performed from OnStart.

This is easily demonstrated using a test class

public class PartSizeTest : PartModule
{
	public override void OnStart(StartState state)
	{
		var bounds = part.GetRendererBounds();
		Debug.Log($"DEBUG {part.partInfo.name} has {bounds.Length} bounds: {string.Join(", ", bounds)}, part size: {CalculatePartSize(bounds)}");
	}

	public Vector3 CalculatePartSize(Bounds[] bounds)
	{
		Bounds result = new Bounds(part.transform.position, Vector3.zero);
		for (int i = 0; i < bounds.Length; i++)
		{
			result.Encapsulate(bounds[i]);
		}
		return result.size;
	}
}

and patch (so that the class is added to all parts for the test)

@PART[*]
{
	%MODULE[PartSizeTest]
	{}
}

then starting with a MK1Fuselage tank and selecting a second one from the menu
Image

With v1.40.1:

[LOG 13:35:23.511] DEBUG MK1Fuselage has 1 bounds: Center: (0.0, 10.0, 0.0), Extents: (0.6, 0.6, 1.0), part size: (1.3, 1.3, 1.9)
[LOG 13:35:24.723] DEBUG MK1Fuselage has 1 bounds: Center: (16.5, 1.2, 15.6), Extents: (0.6, 0.6, 1.0), part size: (1.3, 1.3, 1.9)

With v1.41.1 (or v1.41.0):

[LOG 13:33:34.369] DEBUG MK1Fuselage has 1 bounds: Center: (0.0, 10.0, 0.0), Extents: (0.6, 0.6, 1.0), part size: (1.3, 1.3, 1.9)
[LOG 13:33:36.939] DEBUG MK1Fuselage has 0 bounds: , part size: (0.0, 0.0, 0.0)

What happened?

The bool ignoreTransparentFX = !p.frozen; condition used in the PR is insufficient and should not be used, or at least, it should be optional and default to the previous behaviour.

Note: any such modification that changes a behaviour (other than purely performance behaviours) should default to the status quo to avoid permanently breaking mods that are no longer maintained.

Upload your ksp.log file

KSP.log

A screenshot of the problem

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingunconfirmedCan't reproduce, more information needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions