Skip to content

Commit

Permalink
Merge branch 'main' into dev/in-camera-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
glabute committed Sep 12, 2023
2 parents 73913fe + 197c41c commit 4cebb20
Show file tree
Hide file tree
Showing 61 changed files with 4,530 additions and 903 deletions.
16 changes: 16 additions & 0 deletions com.unity.cinemachine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
- Bugfix: Occasional precision issue when camera rotation is exactly 180 degress, causing rotational flickering.
- Bugfix: Deceleration at the end of axis range was too aggressive.
- Bugfix: Orbital recentering should not be forced when transitioning to a camera.
- Bugfix: InheritPosition takes the actual camera position, so it works consistently if transitioning mid-blend.
- Bugfix: CinemachineDeoccluder was causing a pop when OnTargetObjectWarped was called.
- Bugfix: Spurious camera cut events were being issued, especially in HDRP.
- Bugfix: Mull reference exceptions when inspector is hidden behind another tab.
- Bugfix: GroupFraming inspector was displaying incorrect warning when LookAt target is a group.
- Bugfix: GroupFraming displays more accurate group size indicator in the game view.
- Bugfix: nullrefs in log when target group was deleted but was still being referenced by vcams.
- Regression fix: CinemachineCollider generated NaN positions if no target was set.
- Added Recentering Target to OrbitalFollow. Recentering is now possible with Lazy Follow.
- Improved OrbitalFollow's ForceCameraPosition algorithm.
- Deoccluder accommodates camera radius in all modes.
- StateDrivenCamera: child camera enabled status and priority are now taken into account when choosing the current active camera.
- Renamed CinemachineSplineDolly.CameraUp to CameraRotation, which more accurately reflects what it does.
- Renamed InputAxis.DoRecentering() to InputAxis.UpdateRecentering()
- Added API in Deoccluder and ThirdPersonFollow to access which collision objects are impacting the camera position.
- Added ICinemachineTargetGroup.IsValid property to detect deleted groups.
- Removed CinemachineToolSettings overlay.
- New sample: ThirdPersonWithAimMode showing how to implement a FreeLook camera with Aim mode.


## [3.0.0-pre.7] - 2023-05-04
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Group Framing

This CinemachineCamera extension adds the ability to frame multiple targets when they are members of a CinemachineTargetGroup. It can be used to dynamically adjust the zoom or to move the camera closer to or farther from the targets, to keep them in the frame.
This CinemachineCamera extension adds the ability to frame one or more targets when they are members of a CinemachineTargetGroup. It can be used to dynamically adjust the zoom or to move the camera closer to or farther from the targets, to keep them in the frame at the desired size.

For this to work, the CinemachineCamera's Tracking Target must be a CinemachineTargetGroup, with at least one member, and having a nonzero size.

Expand All @@ -18,12 +18,12 @@ For this to work, the CinemachineCamera's Tracking Target must be a CinemachineT
| | _Dolly Then Zoom_ | Move the camera as much as permitted by the ranges, then adjust the FOV if necessary to make the shot. |
| __Lateral Adjustment__ || How to adjust the camera horizontally and vertically to get the desired framing. You can change position to reframe, or rotate the camera to reframe. |
| | _Change Position_ | Camera is moved horizontally and vertically until the desired framing is achieved. |
| | _Dolly Only_ | Camera is rotated to achieve the desired framing. |
| | _Change Rotation_ | Camera is rotated to achieve the desired framing. |
| __Framing Size__ || The screen-space bounding box that the targets should occupy. Use 1 to fill the whole screen, 0.5 to fill half the screen, and so on. |
| __Damping__ || How gradually to make the framing adjustment. A larger number gives a slower response, smaller numbers a snappier one. |
| __Dolly Range__ || The allowable range that the camera may be moved in order to achieve the desired framing. A negative distance is towards the target, and a positive distance is away from the target. |
| __FOV Range__ || If adjusting FOV, do not set the FOV outside of this range. |
| __Ortho Size Range__ || If adjusting Orthographic Size, do not set it outside of this range. |
| __FOV Range__ || If adjusting FOV, it will be clamped to this range. |
| __Ortho Size Range__ || If adjusting Orthographic Size, it will be clamped to this range. |



Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ If you attach an input controller to the CinemachineCamera, then the player can
| __Radius__ || In Sphere mode, this defines the radius of the surface sphere |
| __Top__, __Center__, __Bottom__ || In ThreeRing mode, these define the height and radius of the 3 orbit rings that are used to create the orbit surface. These values are relative to the target's origin. |
| __Spline Curvature__ || In ThreeRing mode, this defines the tautness of the line that connects the 3 orbits. This line determines the final shape of the surface. |
| __Recentering Target__ || Defines the reference frame for horizontal recentering. The axis center will be dynamically updated to be behind the selected object. |
||_Axis Center_|Static reference frame. Axis center value is not dynamically updated.|
||_Parent Object_|Axis center is dynamically adjusted to be behind the parent object's forward.|
||_Tracking Target_|Axis center is dynamically adjusted to be behind the Tracking Target's forward.|
||_LookAt Target_|Axis center is dynamically adjusted to be behind the LookAt Target's forward.|
| __Horizontal Axis__ || Horizontal positioning (rotation about the Y axis) of the camera on the surface. Value is in degrees, and Range defines the allowable value limits. If Wrap is checked, the value wraps around when it crosses the edge of its range. You can define a Center position here, which can be used if recentering logic is enabled in the axis driver. |
| __Vertical Axis__ || Vertical positioning (rotation about the X axis) of the camera on the surface. Value is in degrees in Sphere mode, but is in arbitrary units in ThreeRing mode. Range defines the allowable value limits. If Wrap is checked, the value wraps around when it crosses the edge of its range. You can define a Center position here, which can be used if recentering logic is enabled in the axis driver. |
| __Radial Axis__ || Controls the camera distance from the target by scaling the orbits. Value is a scalar multiplier of the orbit heights and radii. Range defines the allowable value limits. If Wrap is checked, the value wraps around when it crosses the edge of its range. You can define a Center position here, which can be used if recentering logic is enabled in the axis driver. |
Expand Down
12 changes: 0 additions & 12 deletions com.unity.cinemachine/Documentation~/handles.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,3 @@ This starts from where the camera is placed. You can drag the points to increase

For more information on the Tracked object offset property see, [Rotation Composer properties](CinemachineRotationComposer.md).

## Cinemachine tool settings

The Cinemachine tool settings are automatically displayed when a FreeLook camera is selected. These settings allow you to adjust the position of the three separate camera rigs: **Top**, **Middle**, and **Bottom**.

![overlays-menu](images/overlays-menu.png)

For more information, see [Cinemachine FreeLook Camera](FreeLookCameras.md).

To deactivate the Cinemachine tool settings for a FreeLook camera:

* Right-click on the **Scene** tab in the Scene view.
* Select **Overlays** and then **Cinemachine tools** from the pop-up menu.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Unity.Cinemachine.Editor
class CinemachineDeoccluderEditor : UnityEditor.Editor
{
CinemachineDeoccluder Target => target as CinemachineDeoccluder;
static List<List<Vector3>> s_pathsCache;

public override VisualElement CreateInspectorGUI()
{
Expand Down Expand Up @@ -48,9 +49,11 @@ static void DrawColliderGizmos(CinemachineDeoccluder collider, GizmoType type)
Gizmos.DrawLine(pos, pos + forwardFeelerVector * distance);

// Show the avoidance path, for debugging
for (int i = 0; i < collider.DebugPaths.Count; ++i)
s_pathsCache ??= new ();
collider.DebugCollisionPaths(s_pathsCache, null);
for (int i = 0; i < s_pathsCache.Count; ++i)
{
var path = collider.DebugPaths[i];
var path = s_pathsCache[i];
Gizmos.color = CinemachineDeoccluderPrefs.CameraPathColor.Value;
Vector3 p0 = vcam.State.ReferenceLookAt;
for (int j = 0; j < path.Count; ++j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@ void OnDisable()

public override VisualElement CreateInspectorGUI()
{
var serializedTarget = new SerializedObject(Target);
var ux = new VisualElement();
this.AddMissingCmCameraHelpBox(ux, CmPipelineComponentInspectorUtility.RequiredTargets.Group);
var groupSizeIsZeroHelp = ux.AddChild(new HelpBox("Group size is zero, cannot frame.", HelpBoxMessageType.Warning));

ux.Add(new PropertyField(serializedTarget.FindProperty(() => Target.FramingMode)));
ux.Add(new PropertyField(serializedTarget.FindProperty(() => Target.FramingSize)));
ux.Add(new PropertyField(serializedTarget.FindProperty(() => Target.Damping)));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.FramingMode)));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.FramingSize)));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.Damping)));

var perspectiveControls = ux.AddChild(new VisualElement());

var sizeAdjustmentProperty = serializedTarget.FindProperty(() => Target.SizeAdjustment);
var sizeAdjustmentProperty = serializedObject.FindProperty(() => Target.SizeAdjustment);
perspectiveControls.Add(new PropertyField(sizeAdjustmentProperty));
perspectiveControls.AddChild(new PropertyField(serializedTarget.FindProperty(() => Target.LateralAdjustment)));
var fovRange = perspectiveControls.AddChild(new PropertyField(serializedTarget.FindProperty(() => Target.FovRange)));
var dollyRange = perspectiveControls.AddChild(new PropertyField(serializedTarget.FindProperty(() => Target.DollyRange)));
perspectiveControls.AddChild(new PropertyField(serializedObject.FindProperty(() => Target.LateralAdjustment)));
var fovRange = perspectiveControls.AddChild(new PropertyField(serializedObject.FindProperty(() => Target.FovRange)));
var dollyRange = perspectiveControls.AddChild(new PropertyField(serializedObject.FindProperty(() => Target.DollyRange)));

var orthoControls = ux.AddChild(new VisualElement());
orthoControls.Add(new PropertyField(serializedTarget.FindProperty(() => Target.OrthoSizeRange)));
orthoControls.Add(new PropertyField(serializedObject.FindProperty(() => Target.OrthoSizeRange)));

ux.TrackPropertyValue(sizeAdjustmentProperty, (prop) =>
{
Expand All @@ -66,7 +65,11 @@ public override VisualElement CreateInspectorGUI()
{
var vcam = (targets[i] as CinemachineGroupFraming).ComponentOwner;
if (vcam != null)
{
group = vcam.FollowTargetAsGroup;
if (group != null && !group.IsValid)
group = null;
}
}
groupSizeIsZeroHelp.SetVisible(group != null && group.Sphere.radius < 0.01f);
Expand All @@ -87,31 +90,36 @@ protected virtual void OnGuiHandler(CinemachineBrain brain)
return;

var vcam = Target.ComponentOwner;
if (!brain.IsValidChannel(vcam))
if (!brain.IsValidChannel(vcam) || !brain.IsLiveChild(vcam))
return;

var group = vcam.LookAtTargetAsGroup;
if (group == null)
group ??= vcam.FollowTargetAsGroup;
if (group == null || !group.IsValid)
return;

CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenTargetMarker(
group, group.Sphere.position,
vcam.State.GetFinalOrientation(), brain.OutputCamera);
group.Sphere.position, brain.OutputCamera);
CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenGroupSizeMarker(
Target.GroupBounds, Target.GroupBoundsMatrix, brain.OutputCamera);
}

[DrawGizmo(GizmoType.Active | GizmoType.InSelectionHierarchy, typeof(CinemachineGroupFraming))]
static void DrawGroupComposerGizmos(CinemachineGroupFraming target, GizmoType selectionType)
{
// Show the group bounding box, as viewed from the camera position
if (target.enabled && target.ComponentOwner != null && target.ComponentOwner.FollowTargetAsGroup != null)
var vcam = target.ComponentOwner;
if (!target.enabled && vcam != null
&& (vcam.FollowTargetAsGroup != null && vcam.FollowTargetAsGroup.IsValid)
|| (vcam.LookAtTargetAsGroup != null && vcam.LookAtTargetAsGroup.IsValid))
{
var oldM = Gizmos.matrix;
var oldC = Gizmos.color;

Gizmos.matrix = target.GroupBoundsMatrix;
Bounds b = target.GroupBounds;
Gizmos.color = Color.yellow;
if (target.ComponentOwner.State.Lens.Orthographic)
if (vcam.State.Lens.Orthographic)
Gizmos.DrawWireCube(b.center, b.size);
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class CinemachineOrbitalFollowEditor : UnityEditor.Editor
void OnEnable()
{
CinemachineSceneToolUtility.RegisterTool(typeof(FollowOffsetTool));
CinemachineSceneToolUtility.RegisterTool(typeof(OrbitalFollowOrbitSelection));
//CinemachineSceneToolUtility.RegisterTool(typeof(OrbitalFollowOrbitSelection));
}

void OnDisable()
{
CinemachineSceneToolUtility.UnregisterTool(typeof(FollowOffsetTool));
CinemachineSceneToolUtility.UnregisterTool(typeof(OrbitalFollowOrbitSelection));
//CinemachineSceneToolUtility.UnregisterTool(typeof(OrbitalFollowOrbitSelection));
}

public override VisualElement CreateInspectorGUI()
Expand All @@ -35,6 +35,17 @@ public override VisualElement CreateInspectorGUI()
var m_Radius = ux.AddChild(new PropertyField(serializedObject.FindProperty(() => Target.Radius)));
var m_Orbits = ux.AddChild(new PropertyField(serializedObject.FindProperty(() => Target.Orbits)));

var row = ux.AddChild(InspectorUtility.PropertyRow(
serializedObject.FindProperty(() => Target.RecenteringTarget), out _));

var recenteringInactive = row.Contents.AddChild(new Label(" (inactive)")
{
tooltip = "Horizontal recentering is currently inactive, so the recentering target will be ignored.",
style = { alignSelf = Align.Center }
});
var recenteringProp = serializedObject.FindProperty(() => Target.HorizontalAxis).FindPropertyRelative(
"Recentering").FindPropertyRelative("Enabled");

ux.AddSpace();
this.AddInputControllerHelp(ux, "Orbital Follow has no input axis controller behaviour.");
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.HorizontalAxis)));
Expand All @@ -47,17 +58,20 @@ public override VisualElement CreateInspectorGUI()
m_Radius.SetVisible(mode == CinemachineOrbitalFollow.OrbitStyles.Sphere);
m_Orbits.SetVisible(mode == CinemachineOrbitalFollow.OrbitStyles.ThreeRing);
});

ux.TrackPropertyWithInitialCallback(recenteringProp, (p) => recenteringInactive.SetVisible(!p.boolValue));
return ux;
}

#if false // We disable the tool settings window, because it has only one thing in it, which isn't so useful and is a bit confusing tbh
static GUIContent[] s_OrbitNames =
{
new GUIContent("Top"),
new GUIContent("Center"),
new GUIContent("Bottom")
};
internal static GUIContent[] orbitNames => s_OrbitNames;

#endif
bool m_UpdateCache = true;
float m_VerticalAxisCache;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ protected virtual void OnGuiHandler(CinemachineBrain brain)

// Draw an on-screen gizmo for the target
if (Target.FollowTarget != null && isLive)
{
CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenTargetMarker(
null, Target.TrackedPoint,
vcam.State.GetFinalOrientation(), brain.OutputCamera);
}
Target.TrackedPoint, brain.OutputCamera);
}

void OnSceneGUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ protected virtual void OnGuiHandler(CinemachineBrain brain)

// Draw an on-screen gizmo for the target
if (Target.LookAtTarget != null && isLive)
{
CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenTargetMarker(
null, Target.TrackedPoint,
vcam.State.GetFinalOrientation(), brain.OutputCamera);
}
Target.TrackedPoint, brain.OutputCamera);
}

void OnSceneGUI()
Expand Down
3 changes: 2 additions & 1 deletion com.unity.cinemachine/Editor/Editors/CmCameraEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public override VisualElement CreateInspectorGUI()
if (Target == null)
return; // object deleted
var brain = CinemachineCore.FindPotentialTargetBrain(Target);
Target.InternalUpdateCameraState(brain == null ? Vector3.up : brain.DefaultWorldUp, -1);
var deltaTime = Application.isPlaying ? Time.deltaTime : -1;
Target.InternalUpdateCameraState(brain == null ? Vector3.up : brain.DefaultWorldUp, deltaTime);
bool haveDefault = Target.Target.TrackingTarget != Target.Follow;
defaultTargetLabel.SetVisible(haveDefault);
if (haveDefault)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ protected virtual void OnGuiHandler(CinemachineBrain brain)

// Draw an on-screen gizmo for the target
if (Target.LookAtTarget != null && isLive)
{
CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenTargetMarker(
Target.LookAtTargetAsGroup, Target.TrackedPoint,
vcam.State.GetFinalOrientation(), brain.OutputCamera);
}
Target.TrackedPoint, brain.OutputCamera);
}

void OnSceneGUI()
Expand Down
Loading

0 comments on commit 4cebb20

Please sign in to comment.