Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Problems deleting obi colliders with pin constraints
#1
Exclamación 
Hello, I'm trying to do something seemingly trivial - to cleanly delete an object with an ObiCollider and not have my pin constraints blow up - but apparently it's complicated.

I'm creating these pins via scripting, following examples from the documentation. The pinning works fine until I destroy a collider in my scene. When that happens, my console starts getting spammed with the following:

Code:
System.IndexOutOfRangeException: Index 15 is out of range of '15' Length.

This Exception was thrown from a job compiled with Burst, which has limited exception support.

[redacted rest due to forum anti-spam]


After a lot of excruciatingly painful debugging, I finally have an idea of why this is happening, but no idea how to proceed.

From what I have gathered, the issue is due to the fact that when I destroy (or disable) a collider, this changes the number of items in `ObiColliderWorld.instance.colliderHandles`, but the collider handle indexes in the pin constraints don't ever get updated. This also happens if I disable the object. Presumably because in either case, `ObiColliderBase.RemoveCollider` is invoked, which modifies the collider handle list.

This either spams burst errors or causes the rope to jump to completely unrelated obi colliders. Even just disabling and re-enabling an obi collider will steal ropes from other objects - e.g. if I have 10 colliders in my scene, with a pin on collider A at index 9, disabling collider B at index 5 rearranges the list so that A is now at index 8 and index 9 is invalid, which will spam errors until I re-enable B, which causes B to get assigned index 9 again, and now the pin is pointing to B instead of A.

I have no idea how to proceed. I've tried deleting the collider at different steps of the process (using the actor callbacks) in case it was timing-related, but the issue persists. Explicitly calling `rope.SetConstraintsDirty(Oni.ConstraintType.Pin);` after destroying my object doesn't seem to fix anything either.

I don't know what I'm doing wrong - it seems like the issue is a fundamental one, that removing any collider in the scene has the potential to break completely unrelated pin constraints. The only solution I can think of is to modify my pins any time any obi collider is destroyed, but I don't see how that's feasible, since there's no way to make pins immediately aware of the change.

I'm using obi 6.5.4 with burst backend (burst 1.8.14), and the problem persists with oni backend as well (ropes just jump to wrong colliders instead of throwing exceptions). I'm basically at my wit's end here - any help is appreciated.
Reply


Messages In This Thread
Problems deleting obi colliders with pin constraints - by btduser - 12-05-2024, 07:29 AM