private void OnCollisionStart(NodeCollisionStartEventArgs e) { //validate if (IsGripping) { return; } if (e.OtherNode == Node.Parent) { return; } if (OtherGripper != null && (e.OtherNode == OtherGripper.Node || e.OtherNode == OtherGripper.Node.Parent)) { return; } //register the node as touching if (!_touchingNodes.ContainsKey(e.OtherNode)) { _touchingNodes.Add(e.OtherNode, e); } //determine if other gripper is touching the item too if (OtherGripper != null) { if (e.OtherBody.Mass != 0) // don't grip immovable objects { if (OtherGripper.IsTouchingNode(e.OtherNode)) { Grip(e); OtherGripper.Grip(e); } } } }
private void OnCollisionEnd(NodeCollisionEndEventArgs e) { //unregister the node as touching if (_touchingNodes.ContainsKey(e.OtherNode)) { _touchingNodes.Remove(e.OtherNode); } //release grip if (IsGripping && !ProducesConstraint && (e.OtherNode == _gripping || _gripping.IsDeleted)) { ReleaseGrip(); OtherGripper?.ReleaseGrip(); } }