private Vector3 GetSegmentConnectionOffsetForAppendOperation() { return(_segmentCollectionExtensionDirection * (FirstSegment.GetBoxSizeAlongNormalizedDirection(_segmentCollectionExtensionDirection) + _paddingSettings.PaddingAlongExtensionPlane)); }
private void ExtendOrShrinkBlockAlongExtensionPlane() { // Construct a new extension plane in order to take into account the block's Y offset Plane extensionPlane = _blockExtensionPlane.Plane; Vector3 pointOnBlockExtensionPlane = _blockExtensionPlane.PlaneQuad.Center; pointOnBlockExtensionPlane += extensionPlane.normal * _manualConstructionSettings.OffsetAlongGrowDirection; extensionPlane = new Plane(extensionPlane.normal, pointOnBlockExtensionPlane); Vector3 extensionPlaneIntersectionPoint; if (MouseCursor.Instance.IntersectsPlane(extensionPlane, out extensionPlaneIntersectionPoint)) { Vector3 toIntersectionPoint = extensionPlaneIntersectionPoint - _blockExtensionPlane.Plane.ProjectPoint(FirstSegment.FirstStackBasePosition); if (!FirstSegment.ExtensionDirection.IsPointingInSameGeneralDirection(toIntersectionPoint)) { ObjectPlacementBoxStackSegmentActions.ReverseExtensionDirectionForSegments(_blockSegments); _segmentExtensionDirection = FirstSegment.ExtensionDirection; } if (!toIntersectionPoint.IsPointingInSameGeneralDirection(_segmentCollectionExtensionDirection)) { RemoveLastNumberOfSegments(_blockSegments.Count - 1); _segmentCollectionExtensionDirection *= -1.0f; } // Calculate the number of stacks for all segments float adjacentSideLength = FirstSegment.ExtensionDirection.GetAbsDot(toIntersectionPoint); float numberOfStacks = adjacentSideLength / (FirstSegment.GetBoxSizeAlongNormalizedDirection(_segmentExtensionDirection) + _paddingSettings.PaddingAlongExtensionPlane); int integerNumberOfStacks = (int)numberOfStacks + 1; // Calculate the number of segments adjacentSideLength = toIntersectionPoint.GetAbsDot(_segmentCollectionExtensionDirection); float numberOfSegments = adjacentSideLength / (FirstSegment.GetBoxSizeAlongNormalizedDirection(_segmentCollectionExtensionDirection) + _paddingSettings.PaddingAlongExtensionPlane); int integerNumberOfSegments = (int)numberOfSegments + 1; int newNumberOfStacksInSegments = integerNumberOfStacks; int newNumberOfSegmentsInBlock = integerNumberOfSegments; if (AllShortcutCombos.Instance.Enable1To1RatioBlockAdjustment.IsActive()) { int min = Mathf.Min(newNumberOfSegmentsInBlock, newNumberOfStacksInSegments); newNumberOfStacksInSegments = min; newNumberOfSegmentsInBlock = min; } // Append or remove stacks from the segments based on the new number of stacks int deltaNumberOfStacks = newNumberOfStacksInSegments - FirstSegment.NumberOfStacks; AppendOrRemoveStacksToAllSegments(deltaNumberOfStacks); // Append or remove segments from the block based on the new number of segments int deltaNumberOfSegments = newNumberOfSegmentsInBlock - _blockSegments.Count; AppendOrRemoveSegmentsToBlock(deltaNumberOfSegments); // Apply any subdivision if necessary and adjust the corner exclusion hide flags. We need to do this every // time the block is updated because when the block shrinks or grows, its structure is affected and so is // the way in which subdivision and corner exclusion is applied. if (_subdivisionSettings.UseSubdivision) { _subdivisionApplyOperation.ApplySubdivisionToEntireBlock(_blockSegments, _subdivisionSettings); } AdjustCornerExclusionHideFlagsForEntireBlock(); SceneView.RepaintAll(); } }
private void ClearCornerExclusionHideFlagsInFirstAndLastSegments() { FirstSegment.ClearHideFlagInAllStacks(ObjectPlacementBoxHideFlags.BlockExcludeCorners); LastSegment.ClearHideFlagInAllStacks(ObjectPlacementBoxHideFlags.BlockExcludeCorners); }
public IEnumerator <T> GetEnumerator() => FirstSegment.Concat(SecondSegment).GetEnumerator();