/// <summary> /// Performs the actual linking on engine instances /// </summary> /// <param name="src"></param> /// <param name="target"></param> public override void OnLink(ShapeLink src, ShapeLink target) { base.OnLink(src, target); // Ignore links which don't belong to us if (src.OwnerShape != this) { return; } // Get the anchor the target link points to AnchorShape anchorShape = GetAnchorFromLink(target); if (anchorShape == null || !HasEngineInstance()) { return; } // Get the entity instance the target points to EngineInstanceEntity entityInstance = GetEntityFromAnchor(anchorShape); // Add the actor to the constraint if (entityInstance != null) { // We have an anchor which belongs to an entity. Add the entity to the constraint // and pass the anchor position, relative to the parent entity. Vector3F anchorPositionLS = anchorShape.LocalSpacePosition; bool bResult = EngineConstraintInstance.AddEntityAnchor( (long)anchorShape.UniqueID, entityInstance, anchorPositionLS); Debug.Assert(bResult == true); } else { // Our anchor is statically attached to the world. // Add the static world anchor to the constraint. Pass the world space position of the anchor // for this purpose. Vector3F anchorPositionWS = anchorShape.Position; bool bResult = EngineConstraintInstance.AddWorldAnchor((long)anchorShape.UniqueID, anchorShape); Debug.Assert(bResult == true); } }