7 [
Attribute(
"8",
desc:
"How agressively does the camera rotates towards the entity under cursor.")]
8 private float m_fSnapStrength;
10 [
Attribute(
"0.25", uiwidget: UIWidgets.Slider,
desc:
"When hovering over geometry, what's its maximum screen ration for the snap to happen.\nIt would be impractical to snap to too large objects, especially when they're encompassing the camera (e.g., building interiors).",
params:
"0 1 0.01")]
11 private float m_fMaxGeometryRatio;
13 private bool m_bSnapped;
15 private vector m_vPosPrev;
16 private vector m_vRotPrev;
25 if (!param.isManualInputEnabled)
30 Print(
string.Format(
"%1 requires SCR_HoverEditableEntityFilter on the editor manager!", Type()), LogLevel.ERROR);
38 bool isDelegate =
false;
42 ResetSnap(param.transform, entity);
47 if (m_TransformingManager && m_TransformingManager.IsEditing(entity))
57 vector bboxMin, bboxMax;
58 IEntity owner = entity.GetOwner();
59 owner.GetWorldBounds(bboxMin, bboxMax);
60 if (vector.Distance(bboxMin, bboxMax) > 0)
62 WorkspaceWidget workspace =
GetGame().GetWorkspace();
63 BaseWorld world = owner.GetWorld();
64 bboxMin = workspace.ProjWorldToScreen(bboxMin, world);
65 bboxMax = workspace.ProjWorldToScreen(bboxMax, world);
67 WidgetManager.GetReferenceScreenSize(refW, refH);
68 if (vector.Distance(bboxMin, bboxMax) / refH > m_fMaxGeometryRatio)
71 ResetSnap(param.transform, entity);
78 if (!m_bSnapped && (entity != m_EntityPrev || param.transform[3] != m_vPosPrev || param.transform[2] != m_vRotPrev))
80 ResetSnap(param.transform, entity);
88 if (!entity.GetPos(target))
93 target = vector.Direction(param.transform[3], target).Normalized();
94 param.transform[2] = vector.Lerp(param.transform[2], target, Math.Min(m_fSnapStrength * param.timeSlice, 1));
97 m_EntityPrev = entity;
98 m_vPosPrev = param.transform[3];
99 m_vRotPrev = param.transform[2];
101 param.isDirty =
true;
107 m_EntityPrev = entity;
108 m_vPosPrev = transformationNew[3];
109 m_vRotPrev = transformationNew[2];
115 override bool EOnCameraInit()