Skip to content

Commit bc721e3

Browse files
authored
Merge pull request #232 from Kapim/devel
Release
2 parents 131042f + 8d78cd0 commit bc721e3

File tree

7 files changed

+51
-234
lines changed

7 files changed

+51
-234
lines changed

arcor2_AREditor/Assets/BASE/Scripts/GameManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public class GameManager : Singleton<GameManager> {
201201
/// <summary>
202202
/// Api version
203203
/// </summary>
204-
public const string ApiVersion = "0.18.0";
204+
public const string ApiVersion = "0.19.0";
205205
/// <summary>
206206
/// List of projects metadata
207207
/// </summary>
512 Bytes
Binary file not shown.

arcor2_AREditor/Assets/BASE/Scripts/WebsocketManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ public async void ConnectToServer(string domain, int port) {
157157

158158
GameManager.Instance.ConnectionStatus = GameManager.ConnectionStatusEnum.Connecting;
159159
try {
160-
APIDomainWS = GetWSURI(domain, port);
160+
APIDomainWS = GetWSURI(domain.Trim(), port);
161161
websocket = new WebSocket(APIDomainWS);
162-
serverDomain = domain;
162+
serverDomain = domain.Trim();
163163

164164
websocket.OnOpen += OnConnected;
165165
websocket.OnError += OnError;

arcor2_AREditor/Assets/TABLET/Prefabs/ConnectionPrefab.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ MonoBehaviour:
159159
position: 0
160160
weight: 0.1
161161
- color: {r: 1, g: 1, b: 1, a: 1}
162-
direction: 2
162+
direction: 0
163163
position: 0
164164
weight: 0.1
165165
resolution: 20

arcor2_AREditor/Assets/TABLET/Scripts/GUI/ActionPickerMenu.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,37 @@ private void ClearMenu() {
115115
}
116116

117117
private RequestResult CheckActionParameters(Base.ActionMetadata actionMetadata) {
118+
//TODO - otestovat
118119
RequestResult result = new RequestResult(true);
119120
bool poseError = false, jointsError = false, dynamicValueError = false;
120121
bool anyOrientation = ProjectManager.Instance.AnyOrientationInTheProject();
121122
bool anyJoints = ProjectManager.Instance.AnyJointsInTheProject();
122123
foreach (ParameterMetadata param in actionMetadata.ParametersMetadata.Values) {
123-
if (!poseError && param.Type == ParameterMetadata.POSE && !anyOrientation) {
124-
result.Success = false;
125-
result.Message += "(there is no available orientation in the project and this action requires it)\n";
126-
poseError = true;
124+
125+
if (!poseError && param.Type == ParameterMetadata.POSE) {
126+
int poseParemetersCount = 0;
127+
if (anyOrientation) {
128+
foreach (ParameterMetadata parameter in actionMetadata.ParametersMetadata.Values) {
129+
if (parameter.Type == ParameterMetadata.POSE) {
130+
if (++poseParemetersCount > 1) {
131+
break;
132+
}
133+
134+
}
135+
}
136+
}
137+
138+
if (poseParemetersCount == 1 && !currentActionPoint.AnyOrientation()) {
139+
result.Success = false;
140+
result.Message += "(there is no available orientation in the selected AP and this action requires it)\n";
141+
poseError = true;
142+
} else if (!anyOrientation) {
143+
result.Success = false;
144+
result.Message += "(there is no available orientation in the project and this action requires it)\n";
145+
poseError = true;
146+
}
147+
148+
127149
}
128150
if (!jointsError && param.Type == ParameterMetadata.JOINTS && !anyJoints) {
129151
result.Success = false;

arcor2_AREditor/Assets/TABLET/Scripts/GUI/MainSettingsMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private void OnDestroy() {
305305
}
306306

307307
public void SetProjectServiceURI(string uri) {
308-
PlayerPrefsHelper.SaveString("ProjectServiceURI", uri);
308+
PlayerPrefsHelper.SaveString("ProjectServiceURI", uri.Trim());
309309
ResetProjectServiceURIButton.SetInteractivity(true);
310310
}
311311

arcor2_AREditor/Assets/TABLET/Scripts/GUI/Sight.cs

Lines changed: 20 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ private void Awake() {
2525
GameManager.Instance.OnEditorStateChanged += OnEditorStateChanged;
2626
}
2727

28+
private void Start() {
29+
InvokeRepeating("UpdateSight", 0.1f, 0.1f);
30+
}
31+
2832
private void OnEditorStateChanged(object sender, EditorStateEventArgs args) {
2933
switch (args.Data) {
3034
case GameManager.EditorStateEnum.Normal:
@@ -36,22 +40,10 @@ private void OnEditorStateChanged(object sender, EditorStateEventArgs args) {
3640
break;
3741
}
3842
}
39-
private void Update() {
43+
44+
private void UpdateSight() {
4045
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0f));
41-
if (SelectedGizmoAxis?.GetInvocationList().Length > 0) {
42-
RaycastHit[] hits = Physics.RaycastAll(ray.origin, ray.direction);
43-
foreach (RaycastHit hit in hits) {
44-
if (hit.collider.gameObject.CompareTag("gizmo_x")) {
45-
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.X));
46-
} else if (hit.collider.gameObject.CompareTag("gizmo_y")) {
47-
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.Y));
48-
} else if(hit.collider.gameObject.CompareTag("gizmo_z")) {
49-
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.Z));
50-
}
51-
}
52-
}
5346
if (SelectorMenu.Instance.CanvasGroup.alpha > 0 && SelectorMenu.Instance.gameObject.activeSelf) {
54-
5547

5648
RaycastHit hitinfo = new RaycastHit();
5749
bool anyHit = false, directHit = false;
@@ -122,8 +114,8 @@ private void Update() {
122114
}
123115
if (h) {
124116
items.Sort((x, y) => x.Item1.CompareTo(y.Item1));
125-
/* if (items.Count > 10)
126-
items.RemoveRange(10, items.Count - 10);*/
117+
/* if (items.Count > 10)
118+
items.RemoveRange(10, items.Count - 10);*/
127119
SelectorMenu.Instance.UpdateAimMenu(items);
128120
} else {
129121
SelectorMenu.Instance.UpdateAimMenu(new List<Tuple<float, InteractiveObject>>());
@@ -133,221 +125,24 @@ private void Update() {
133125
}
134126

135127
}
128+
}
136129

137-
//if (SelectorMenu.Instance.Active) {
138-
/* if (SelectorMenu.Instance.CanvasGroup.alpha > 0 && SelectorMenu.Instance.gameObject.activeSelf) {
139-
140-
//if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), out hit, Mathf.Infinity)) {
141-
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0f));
142-
143-
RaycastHit hitinfo = new RaycastHit();
144-
bool anyHit = false, directHit = false;
145-
if (Physics.Raycast(ray, out RaycastHit hit)) {
146-
hitinfo = hit;
147-
anyHit = true;
148-
directHit = true;
149-
//Debug.DrawRay(ray.origin, ray.direction);
150-
} else {
151-
RaycastHit[] hits = Physics.BoxCastAll(ray.origin, new Vector3(0.03f, 0.03f, 0.0001f), ray.direction, Camera.main.transform.rotation);
152-
if (hits.Length > 0) {
153-
154-
float minDist = float.MaxValue;
155-
foreach (RaycastHit h in hits) {
156-
Vector3 dir = ray.direction;
157-
158-
Vector3 point = ray.origin + dir * Vector3.Distance(ray.origin, h.point);
159-
float dist = Vector3.Distance(point, h.collider.ClosestPointOnBounds(point));
160-
Debug.DrawLine(point, h.point);
161-
Debug.DrawRay(ray.origin, ray.direction);
162-
if (dist < minDist) {
163-
hitinfo = h;
164-
anyHit = true;
165-
minDist = dist;
166-
}
167-
}
168-
}
169-
}
170-
if (anyHit) {
171-
Vector3 lhs = hitinfo.point - ray.origin;
172-
173-
float dotP = Vector3.Dot(lhs, ray.direction.normalized);
174-
Vector3 point = ray.origin + ray.direction.normalized * dotP;
175-
List<Tuple<float, InteractiveObject>> items = new List<Tuple<float, InteractiveObject>>();
176-
bool h = false;
177-
foreach (SelectorItem item in SelectorMenu.Instance.SelectorItems.Values) {
178-
if (!item.InteractiveObject.Enabled)
179-
continue;
180-
try {
181-
if (item.InteractiveObject == null) {
182-
continue;
183-
184-
}
185-
float dist = item.InteractiveObject.GetDistance(hitinfo.point);
186-
187-
foreach (Collider c in item.InteractiveObject.Colliders) {
188-
189-
if (c == hitinfo.collider) {
190-
dist = 0;
191-
h = true;
192-
}
193-
194-
}
195-
196-
197-
if (item.InteractiveObject is ActionObjectNoPose || dist > 0.2) { // add objects max 20cm away from point of impact
198-
199-
Debug.DrawLine(ray.origin, hitinfo.point);
200-
continue;
201-
}
202-
203-
items.Add(new Tuple<float, InteractiveObject>(dist, item.InteractiveObject));
204-
} catch (MissingReferenceException ex) {
205-
Debug.LogError(ex);
206-
Debug.LogError($"{item.InteractiveObject.GetName()}: {hitinfo.collider.name}");
207-
}
208-
}
209-
if (h) {
210-
items.Sort((x, y) => x.Item1.CompareTo(y.Item1));
211-
SelectorMenu.Instance.UpdateAimMenu(items);
212-
} else {
213-
SelectorMenu.Instance.UpdateAimMenu(new List<Tuple<float, InteractiveObject>>());
214-
}
215-
} else {
216-
SelectorMenu.Instance.UpdateAimMenu(new List<Tuple<float, InteractiveObject>>());
217-
}
218-
219-
}
220-
*/
221-
222-
/*if (SelectorMenu.Instance.CanvasGroup.alpha == 0 || !SelectorMenu.Instance.gameObject.activeSelf)
223-
return;
224-
//if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), out hit, Mathf.Infinity)) {
130+
private void FixedUpdate() {
225131
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0f));
226-
227-
RaycastHit hitinfo = new RaycastHit();
228-
bool anyHit = false;
229-
if (Physics.Raycast(ray, out RaycastHit hit)) {
230-
hitinfo = hit;
231-
anyHit = true;
232-
} else {
233-
RaycastHit[] hits = Physics.BoxCastAll(ray.origin, new Vector3(0.03f, 0.03f, 0.0001f), ray.direction, Camera.main.transform.rotation);
234-
if (hits.Length > 0) {
235-
float minDist = float.MaxValue;
236-
foreach (RaycastHit h in hits) {
237-
Vector3 dir = ray.direction;
238-
239-
Vector3 point = ray.origin + dir * Vector3.Distance(ray.origin, h.point);
240-
float dist = Vector3.Distance(point, h.collider.ClosestPointOnBounds(point));
241-
Debug.DrawLine(point, h.point);
242-
Debug.DrawRay(ray.origin, ray.direction);
243-
if (dist < minDist) {
244-
hitinfo = h;
245-
anyHit = true;
246-
minDist = dist;
247-
}
248-
}
249-
}
250-
}
251-
if (anyHit) {
252-
Vector3 lhs = hitinfo.point - ray.origin;
253-
254-
float dotP = Vector3.Dot(lhs, ray.direction.normalized);
255-
Vector3 point = ray.origin + ray.direction.normalized * dotP;
256-
SelectorMenu.Instance.UpdateAimMenu(hitinfo.point);
257-
} else {
258-
SelectorMenu.Instance.UpdateAimMenu(null);
259-
}*/
260-
261-
/*
262-
RaycastHit[] hits = Physics.BoxCastAll(ray.origin, new Vector3(0.03f, 0.03f, 0.0001f), ray.direction, Camera.main.transform.rotation);
263-
if (hits.Length > 0) {
264-
float minDist = float.MaxValue;
265-
foreach (RaycastHit h in hits) {
266-
Vector3 dir = ray.direction;
267-
dir.Normalize();
268-
Vector3 point = ray.origin + dir * Vector3.Distance(ray.origin, h.point);
269-
float dist = Vector3.Distance(point, h.collider.ClosestPointOnBounds(point));
270-
Debug.DrawLine(point, h.point);
271-
Debug.DrawRay(ray.origin, ray.direction);
272-
if (dist < minDist) {
273-
hitinfo = h;
274-
minDist = dist;
132+
if (SelectedGizmoAxis?.GetInvocationList().Length > 0) {
133+
RaycastHit[] hits = Physics.RaycastAll(ray.origin, ray.direction);
134+
foreach (RaycastHit hit in hits) {
135+
if (hit.collider.gameObject.CompareTag("gizmo_x")) {
136+
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.X));
137+
} else if (hit.collider.gameObject.CompareTag("gizmo_y")) {
138+
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.Y));
139+
} else if(hit.collider.gameObject.CompareTag("gizmo_z")) {
140+
SelectedGizmoAxis.Invoke(this, new GizmoAxisEventArgs(Gizmo.Axis.Z));
275141
}
276142
}
277-
Vector3 lhs = hitinfo.point - ray.origin;
278-
279-
float dotP = Vector3.Dot(lhs, ray.direction.normalized);
280-
Vector3 point2 = ray.origin + ray.direction.normalized * dotP;
281-
SelectorMenu.Instance.UpdateAimMenu(point2);
282-
} else {
283-
SelectorMenu.Instance.UpdateAimMenu(null);
284143
}
285-
*/
286-
/*ExtDebug.DrawBoxCastBox(ray.origin, new Vector3(0.05f, 0.05f, 0.00001f), Camera.main.transform.rotation, ray.direction, 20f, Color.green);
287-
List<Tuple<float, InteractiveObject>> orderedTransforms = new List<Tuple<float, InteractiveObject>>();
288-
if (hits.Length > 0) {
289-
RaycastHit hit = hits.First();
290-
GameManager.Instance.GetAllInteractiveObjects();
291-
}*/
292-
/*foreach (RaycastHit hit in hits) {
293-
294-
float dist = Vector3.Cross(ray.direction, hit.point - ray.origin).magnitude;
295-
InteractiveObject interactiveObject = hit.collider.transform.gameObject.GetComponent<InteractiveObject>();
296-
if (interactiveObject is null) {
297-
OnClickCollider collider = hit.collider.transform.gameObject.GetComponent<OnClickCollider>();
298-
if (collider is null) {
299-
continue;
300-
}
301-
interactiveObject = collider.Target.gameObject.GetComponent<InteractiveObject>();
302-
if (interactiveObject is null) {
303-
continue;
304-
}
305-
}
306-
if (!InteractiveObjectInList(orderedTransforms, interactiveObject)) {
307-
orderedTransforms.Add(new Tuple<float, InteractiveObject>(dist, interactiveObject));
308-
}
309-
310-
//hit.collider.transform.gameObject.SendMessage("OnHoverStart");
311-
/*try {
312-
if (CurrentObject == null) {
313-
hit.collider.transform.gameObject.SendMessage("OnHoverStart");
314-
HoverStartTime = System.DateTime.UtcNow;
315-
CurrentObject = hit.collider.transform.gameObject;
316-
} else {
317-
if (!GameObject.ReferenceEquals(hit.collider.transform.gameObject, CurrentObject)) {
318-
CurrentObject.SendMessage("OnHoverEnd");
319-
if (endingHover) {
320-
StopAllCoroutines();
321-
endingHover = false;
322-
}
323-
hit.collider.transform.gameObject.SendMessage("OnHoverStart");
324-
HoverStartTime = System.DateTime.UtcNow;
325-
CurrentObject = hit.collider.transform.gameObject;
326-
} else {
327-
328-
if (endingHover) {
329-
StopAllCoroutines();
330-
endingHover = false;
331-
HoverStartTime = System.DateTime.UtcNow;
332-
}
333-
}
334-
}
335-
} catch (Exception e) {
336-
Debug.LogError(e);
337-
}*/
338-
/*}
339-
340-
orderedTransforms.Sort((x, y) => x.Item1.CompareTo(y.Item1));
144+
341145

342-
SelectorMenu.Instance.UpdateAimMenu(orderedTransforms);
343-
//SelectorMenu.Instance.UpdateAimMenu(orderedTransforms.Select(_ => _.Item2).Distinct().ToList());
344-
345-
/*else {
346-
if (CurrentObject != null) {
347-
if (!endingHover)
348-
StartCoroutine(HoverEnd());
349-
}
350-
}*/
351146
}
352147

353148
private bool InteractiveObjectInList(List<Tuple<float, InteractiveObject>> list, InteractiveObject interactiveObject) {

0 commit comments

Comments
 (0)