yoshinoToylogic / bulletsharp

Automatically exported from code.google.com/p/bulletsharp
MIT License
0 stars 0 forks source link

Using CollisionFilterGroups with many multithreaded instances generates memoryAccessViolation on step simulation #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In CreateRigidbody use these group and mask:

            CollisionFilterGroups group;
            if (layer == -1)
                group = isDynamic ? CollisionFilterGroups.DefaultFilter : CollisionFilterGroups.StaticFilter;
            else group = (CollisionFilterGroups)WorldsMasks[layer];

            CollisionFilterGroups mask = layer == -1 ? DefaultAllMaskNoStatic : (CollisionFilterGroups)WorldsMasks[layer];
            if (isDynamic) mask |= CollisionFilterGroups.StaticFilter;

        }

2. Create multiple worlds in seperate threads like this:

            ThreadPool.QueueUserWorkItem(s => StartPhysics());
            ThreadPool.QueueUserWorkItem(s => StartPhysics());
            ThreadPool.QueueUserWorkItem(s => StartPhysics());
            Thread.Sleep(20000);

        void StartPhysics()
        {
            var w = new PhysicsWorldContainer();
            var lst = new List<RigidBody>();
            for (int i = 0; i < 15; i++)
                lst.Add(w.CreateRigidbody(Vector3.Zero, Quaternion.Identity, new CapsuleShape(0.17f, 0.82f), 1f));
            while (true)
            {
                w.OnUpdate();
                Thread.Sleep(55);
            }
            lst.Clear();
        }

3. You'll see MemoryAccessViolation when StepSimulation is called.

What version of the product are you using? On what operating system?
BulletSharp 2.82, 32 bit used on a Windows 7 x64 .NET 4 CLR hosted by Exitgames 
Photon Server.

Original issue reported on code.google.com by wvlad....@gmail.com on 28 Feb 2014 at 9:34

GoogleCodeExporter commented 8 years ago
Forget to add

        public static readonly ReadOnlyCollection<int> WorldsMasks = new ReadOnlyCollection<int>(new[] { 1, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 });

        static readonly CollisionFilterGroups DefaultAllMaskNoStatic = CollisionFilterGroups.SensorTrigger | CollisionFilterGroups.KinematicFilter | CollisionFilterGroups.DefaultFilter | CollisionFilterGroups.DebrisFilter | CollisionFilterGroups.CharacterFilter;

Original comment by wvlad....@gmail.com on 28 Feb 2014 at 9:35

GoogleCodeExporter commented 8 years ago
Sorry, it seems like this exception is not related to the filtering. I'll 
investigate it again.

Original comment by wvlad....@gmail.com on 28 Feb 2014 at 11:12

GoogleCodeExporter commented 8 years ago
Close it, my mistake.

Original comment by wvlad....@gmail.com on 28 Feb 2014 at 11:18

GoogleCodeExporter commented 8 years ago
No worries :)

Original comment by andres.traks on 28 Feb 2014 at 4:28