18-06-2018, 12:09 PM
(This post was last modified: 18-06-2018, 12:46 PM by M. Hanssen.)
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:
The code we use to attach and detach pinpoint constraints is:
The .dmp file link is: https://we.tl/nJRKIzrFSm, I really hope you can help us fix this issue!
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!