Ejemplo n.º 1
0
        /// <summary>
        /// Add a request for joint creation.
        /// </summary>
        /// <remarks>
        /// 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.
        /// </remarks>
        /// <param name="objectNameInScene"></param>
        /// <param name="jointType"></param>
        /// <param name="position"></param>
        /// <param name="rotation"></param>
        /// <param name="parms"></param>
        /// <param name="bodyNames"></param>
        /// <param name="trackedBodyName"></param>
        /// <param name="localRotation"></param>
        /// <returns></returns>
        public override PhysicsJoint RequestJointCreation(
            string objectNameInScene, PhysicsJointType jointType, Vector3 position,
            Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
        {
            OdePhysicsJoint joint = new OdePhysicsJoint();
            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;
        }
Ejemplo n.º 2
0
 // internal utility function: must be called within a lock (OdeLock)
 private void InternalAddPendingJoint(OdePhysicsJoint joint)
 {
     pendingJoints.Add(joint);
     SOPName_to_pendingJoint.Add(joint.ObjectNameInScene, joint);
 }