// public function to add an request for joint creation // this joint will just be added to a waiting list that is NOT processed during the main // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests. public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position, Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) { AuroraODEPhysicsJoint joint = new AuroraODEPhysicsJoint(); joint.ObjectNameInScene = objectNameInScene; joint.Type = jointType; joint.Position = position; joint.Rotation = rotation; joint.RawParams = parms; joint.BodyNames = new List<string>(bodyNames); joint.TrackedBodyName = trackedBodyName; joint.LocalRotation = localRotation; joint.jointID = IntPtr.Zero; joint.ErrorMessageCount = 0; lock (externalJointRequestsLock) { if (!requestedJointsToBeCreated.Contains(joint)) // forbid same creation request from entering twice { requestedJointsToBeCreated.Add(joint); } } return joint; }
// internal utility function: must be called within a lock (OdeLock) private void InternalAddPendingJoint(AuroraODEPhysicsJoint joint) { pendingJoints.Add(joint); SOPName_to_pendingJoint.Add(joint.ObjectNameInScene, joint); }