Body set index must be nonnegative and within the sets buffer length.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
parapoohda
Posts: 84
Joined: Fri May 31, 2019 6:30 am

Body set index must be nonnegative and within the sets buffer length.

Post by parapoohda » Sun Jan 12, 2020 11:23 am

I try to add trigger as Kinemetic. I think kinemetic is movable and not react to gravity so it seem a good idea.
But I can't seem get it by body handle.

here are my code that remove trigger

Code: Select all

public void RemoveKinemtic(int handle)
        {
                handleKinematicUnits.Remove(handle);
                Simulation.Bodies.Remove(handle);
        }
        
update after allow it to remove once it not error anymore
'

Code: Select all

public void RemoveKinemtic(int handle)
        {
            //System.Threading.Thread.Sleep(10000);
            if (handleKinematicUnits.ContainsKey(handle)) {
                handleKinematicUnits.Remove(handle);
                Simulation.Bodies.Remove(handle);

            }
        }
        

Norbo
Site Admin
Posts: 4835
Joined: Tue Jul 04, 2006 4:45 am

Re: Body set index must be nonnegative and within the sets buffer length.

Post by Norbo » Sun Jan 12, 2020 5:50 pm

There's nothing particularly special about kinematic bodies when it comes to addition/removal. Is this removal happening on a different thread than the physics simulation, potentially hitting a race condition?

parapoohda
Posts: 84
Joined: Fri May 31, 2019 6:30 am

Re: Body set index must be nonnegative and within the sets buffer length.

Post by parapoohda » Tue Jan 14, 2020 5:42 am

I remove it and forget to disable remove. So loop second time it try to remove the one that already remove.

Post Reply