// Set this sets and computes the displacement from the passed prim to the center-of-mass. // A user set value for center-of-mass overrides whatever might be passed in here. // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates). // Returns the relative offset from the root position to the center-of-mass. // Called at taint time. public virtual Vector3 SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement) { PhysicsScene.AssertInTaintTime("BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement"); Vector3 comDisp; if (UserSetCenterOfMassDisplacement.HasValue) { comDisp = (Vector3)UserSetCenterOfMassDisplacement; } else { comDisp = centerOfMassDisplacement; } // Eliminate any jitter caused be very slight differences in masses and positions if (comDisp.ApproxEquals(Vector3.Zero, 0.01f)) { comDisp = Vector3.Zero; } DetailLog("{0},BSSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}", LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp); if (!comDisp.ApproxEquals(PositionDisplacement, 0.01f)) { // Displacement setting is changing. // The relationship between the physical object and simulated object must be aligned. PositionDisplacement = comDisp; ForcePosition = RawPosition; } return(PositionDisplacement); }