public static void MigrateTConeFromCone(VFXSlot to, VFXSlot from, bool hasLink = false) { var to_center = to[0][0]; var to_baseRadius = to[1]; var to_topRadius = to[2]; var to_height = to[3]; var refSlot = from.refSlot; VFXSlot.CopySpace(to, refSlot, true); if (from.HasLink(false) || hasLink) { var parentCenter = refSlot[0]; var parentBaseRadius = refSlot[1]; var parentTopRadius = refSlot[2]; var parentHeight = refSlot[3]; to_center.Link(parentCenter, true); to_baseRadius.Link(parentBaseRadius, true); to_topRadius.Link(parentTopRadius, true); to_height.Link(parentHeight, true); } else { var center = from[0]; var baseRadius = from[1]; var topRadius = from[2]; var height = from[3]; var value = new TCone() { transform = new Transform() { position = (Vector3)center.value, scale = Vector3.one }, baseRadius = (float)baseRadius.value, topRadius = (float)topRadius.value, height = (float)height.value }; to.value = value; VFXSlot.CopyLinksAndValue(to_center, center, true); VFXSlot.CopyLinksAndValue(to_baseRadius, baseRadius, true); VFXSlot.CopyLinksAndValue(to_topRadius, topRadius, true); VFXSlot.CopyLinksAndValue(to_height, height, true); } }
public static void MigrateTConeFromCylinder(VFXSlot to, VFXSlot from) { var lastModel = from.owner as VFXModel; while (!(lastModel.GetParent() is VFXGraph)) { lastModel = lastModel.GetParent(); } var basePosition = lastModel.position; var graph = lastModel.GetParent() as VFXGraph; var to_center = to[0][0]; var to_baseRadius = to[1]; var to_topRadius = to[2]; var to_height = to[3]; var refSlot = from.refSlot; VFXSlot.CopySpace(to, refSlot, true); if (from.HasLink(false)) { var parentCenter = refSlot[0]; var parentRadius = refSlot[1]; var parentHeight = refSlot[2]; var correctedPosition = CorrectPositionFromCylinderToCone(graph, basePosition, parentHeight, parentCenter); correctedPosition.Link(to_center); to_baseRadius.Link(parentRadius, true); to_topRadius.Link(parentRadius, true); to_height.Link(parentHeight, true); } else { var center = from[0]; var radius = from[1]; var height = from[2]; var value = new TCone() { transform = new Transform() { position = (Vector3)center.value - new Vector3(0, (float)height.value * 0.5f, 0), scale = Vector3.one }, height = (float)height.value, baseRadius = (float)radius.value, topRadius = (float)radius.value, }; to.value = value; if (from.HasLink(true)) { var correctedPosition = CorrectPositionFromCylinderToCone(graph, basePosition, height, center); correctedPosition.Link(to_center); } VFXSlot.CopyLinksAndValue(to_baseRadius, radius, true); VFXSlot.CopyLinksAndValue(to_topRadius, radius, true); VFXSlot.CopyLinksAndValue(to_height, height, true); } }