Skip to content

Bounds should calculate using Colliders instead of MeshFilters. #2942

@Dunbaratu

Description

@Dunbaratu

kOS Bounds is based on iterating over these MeshFilters:

Part.GetComponentsInChildren<MeshFilter>();

But it turns out MeshFilters are all the Rendering shapes, not all the collider shapes. Generally the same algorithm could be used but have it iterate over the part's colliders rather than its MeshFilters, i.e. these:

Part.GetComponentsInChildren<Colllider>();

Using the MeshFilters causes these three issues:

  1. It causes issue BOUNDS returns wrong values when Waterfall mod is installed. #2905 with the Waterfall mod (which I will close and redirect here).
  2. Because the rendered mesh is typically more high-res than the collider, there's a discrepancy between the answers. The collider is the one that physically matters so it's the one kOS should return.
  3. Because the rendered mesh is typically more high-res than the collider, using the collider will give it fewer vertices to iterate over, making the algorithm less expensive.

Ignore triggers

IMPORTANT: When using Colliders, bypass any that have Collider.isTrigger == true. Those don't count as a real physical object (the physics engine does not make it hit things, it passes right though things). A trigger is a special case sort of collider that merely fires off a callback hook when it touches things, so the programmer can react to that callback in whatever arbitrary way. An example of where this is used in KSP is the invisible collider spheres around robot scanner arms in the Breaking Ground DLC. Those colliders are "trigger" colliders and ignoring them will prevent them from falsifying the bounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugWeird outcome is probably not what the mod programmer expected.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions