Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOUNDS returns wrong values when Waterfall mod is installed. #2905

Closed
Dunbaratu opened this issue Mar 25, 2021 · 2 comments
Closed

BOUNDS returns wrong values when Waterfall mod is installed. #2905

Dunbaratu opened this issue Mar 25, 2021 · 2 comments
Labels
bug Weird outcome is probably not what the mod programmer expected. duplicate Will close because another PR or issue is the same. (please link to it when using this label)

Comments

@Dunbaratu
Copy link
Member

Dunbaratu commented Mar 25, 2021

I was noticing my landing script thought my vessel was over 18 meters tall, when clearly it was only about 3 or 4 meters high.

Diagnosing this, it turns out that engines return wrong bounds when the Waterfall mod is installed. It seems to be that the exhaust plume is being counted as part of the engine's dimensions (even when the throttle is zero so the engine isn't firing).

To reproduce:

  1. Have these two mods installed: Waterfall, and Stock Waterfall Configs.
  2. Make a ship that uses a Terrier engine (may happen with other engines too, but this is the one I noticed it with).
  3. for p in ship:parts { print "bounds for " + p + " is " + p:bounds. }
  4. Note the :RELMIN for the Terrier engine part has a negative Z of about 18.1 meters.

To fix this we should probably have some better logic within bounds calculations to know which components are "not physical" and therefore should not count. Something that's purely visual with no colliders probably shouldn't count.

@Dunbaratu Dunbaratu added the bug Weird outcome is probably not what the mod programmer expected. label Mar 25, 2021
@Dunbaratu
Copy link
Member Author

Probable cause: PartValue.GetBoundsValue() iterates over all Meshes in the component with this:

MeshFilter[] meshes = Part.GetComponentsInChildren<MeshFilter>();

Some of those meshes will be visual-only (and will be unnecessarily detailed with more vertices than the object "physically" has in its collider).
It should probably be iterating over just the colliders, not all the meshes, using this:

Collider[] colliders = Part.GetComponentsInChildren<Collider>();

The Collider type has a .bounds member just like the mesh type does so presumably the algorithm from there down shouldn't need to change that much.

@Dunbaratu
Copy link
Member Author

Closing to redirect it over to issue #2942.

@Dunbaratu Dunbaratu added the duplicate Will close because another PR or issue is the same. (please link to it when using this label) label May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Weird outcome is probably not what the mod programmer expected. duplicate Will close because another PR or issue is the same. (please link to it when using this label)
Projects
None yet
Development

No branches or pull requests

1 participant