Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access violation crash!
#1
We have a setup with 2 rope pulley systems where some targets are spawned dynamically, get pin constraints on the rope and get detached again when hit.
We get an access violation from libOni.dll on a regular base. Sadly the issue cannot be reproduced, but happens at random.

The crash exception states:

Quote:libOni.dll caused an Access Violation (0xc0000005) in module libOni.dll at 0033:3ea5f48b.

The code we use to attach and detach pinpoint constraints is:

Code:
public override T Spawn<T>(WorldObject worldObject)
   {
       T genericSpawnedObject = base.Spawn<T>(worldObject);
       HitablePulleyWorldObject spawnedObject = genericSpawnedObject as HitablePulleyWorldObject;
       if (spawnedObject != null)
       {
           ObiPinConstraintBatch batch = (ObiPinConstraintBatch) PinConstraints.GetFirstBatch();
           if (batch != null)
           {
               PinConstraints.RemoveFromSolver(null);
               int index = GetClosestParticleIndex();
               if (index >= 0)
               {
                   batch.AddConstraint(index, spawnedObject.GetComponentInChildren<ObiCollider>(), Vector3.zero, 1);
                   spawnedObject.RopeParticleIndex = index;
                   spawnedObject.PinConstraints = PinConstraints;
               }
               PinConstraints.AddToSolver(null);
               PinConstraints.PushDataToSolver();
           }
       }
       return genericSpawnedObject;
   }

   private int GetClosestParticleIndex()
   {
       int result = -1;

       float closestDistance = float.MaxValue;

       for (int i = 0; i < Rope.invMasses.Length; i++)
       {
           if (Rope.invMasses[i] > 0)
           {
               float distance = Vector3.Distance(Rope.GetParticlePosition(i), transform.position);
               if (distance < closestDistance)
               {
                   closestDistance = distance;
                   result = i;
               }
           }
       }
       return result;
   }


Code:
private void DetachFromRope()
   {
       ObiPinConstraintBatch batch = PinConstraints.GetFirstBatch();
       if (batch != null && RopeParticleIndex < batch.ConstraintCount)
       {
           PinConstraints.RemoveFromSolver(null);
           batch.RemoveConstraint(RopeParticleIndex);
           PinConstraints.AddToSolver(null);
           PinConstraints.PushDataToSolver();
       }
       Object.Destroy(GetComponent<ObiCollider>());
   }

The .dmp file link is: https://we.tl/nJRKIzrFSm, I really hope you can help us fix this issue!
Reply


Messages In This Thread
Access violation crash! - by M. Hanssen - 18-06-2018, 12:09 PM
RE: Access violation crash! - by josemendez - 18-06-2018, 03:09 PM
RE: Access violation crash! - by M. Hanssen - 19-06-2018, 10:50 AM
RE: Access violation crash! - by josemendez - 21-06-2018, 08:33 AM
RE: Access violation crash! - by M. Hanssen - 25-06-2018, 08:13 AM
RE: Access violation crash! - by M. Hanssen - 27-06-2018, 09:16 AM
RE: Access violation crash! - by josemendez - 27-06-2018, 05:04 PM
RE: Access violation crash! - by M. Hanssen - 09-07-2018, 01:13 PM
RE: Access violation crash! - by M. Hanssen - 27-07-2018, 11:16 AM