Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Pointer): pointer implementation #86

Closed
wants to merge 1 commit into from
Closed

Conversation

bddckr
Copy link
Contributor

@bddckr bddckr commented May 15, 2018

The pointer concept is the ability to designate an area of the scene
with a destination. A pointer consists of multiple independent
functionality which is implemented through a component that casts
and returns points that define the pointer beam, one that
generically renders points via game objects and a third component
handles the selection functionality of a pointer.

A pointer knows when it is activated, deactivated, when it starts
hovering (enters) a new object, when it finishes hovering (exits) an
object and knows what coordinates of the object it is hovering over.
These are all cast as events with a special pointer payload
containing information about the pointer target.

The Straight Line Cast implementation casts a straight line from an
origin point (e.g. controller) and stops when it collides with an
object (or reaches the set maximum length). The same applies to the
added Parabolic Line Cast, but it casts a parabolic line instead.

Additionally the introduction of more components that raycast means
the existing PhysicsCast class is moved to the new namespace
Cast.

@bddckr bddckr added the w_inprogress waffle.io label label May 15, 2018
@bddckr
Copy link
Contributor Author

bddckr commented May 15, 2018

  • Fix remaining TODOs found in the code.
  • Docs, docs, docs.
  • Maybe figure out a way to not have to specify the PointsCast on multiple components (Pointer, PointsRenderer and another one...) This is actually intended.
  • Remove BasePointer and others coming from the old pointer branch.
  • Ensure commit message lists the addition of the ParabolicLineCast for A pointer that emits a parabolic curve with a cursor that reacts to other scene objects #8.
  • Split into multiple commits perhaps.
  • Target the master branch after everything above is done.

Down the line:

  • Tests from the previous PR.
  • New tests for the new components and the parabolic line cast.

See #90.

/// prevent the cast being projected high into the sky and curving back down.
/// </summary>
[Tooltip("The maximum angle in degrees of the origin before the cast curve height is restricted. A lower angle setting will prevent the cast being projected high into the sky and curving back down.")]
[Range(1, 100)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Tooltip()] should be the last attribute before the parameter

/// <summary>
/// The maximum angle in degrees of the origin before the cast curve height is restricted. A lower angle setting will
/// prevent the cast being projected high into the sky and curving back down.
/// </summary>
[Range(1, 100)]
[Tooltip("The maximum angle in degrees of the origin before the cast curve height is restricted. A lower angle setting will prevent the cast being projected high into the sky and curving back down.")]
public float heightLimitAngle = 100f;

AdjustForEarlyCollisions(jointPosition, downPosition);
}

protected virtual Vector3 ProjectForwardBeam()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protected methods also need XML docs

/// <summary>
/// The result of the most recent cast. <see langword="null"/> when the cast didn't hit anything.
/// </summary>
public RaycastHit? TargetHit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field should be targetHit

Also why have RaycastHit nullable type? can't you just check RaycastHit.transform == null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable because I don't want the intrinsic knowledge of how Unity uses RaycastHit to be part of this - they could change that, too (but probably won't). This way a user just has to test for existence, rather than know about how RaycastHit handles its properties to signal "nothing was hit".

/// <summary>
/// The points along the the most recent cast.
/// </summary>
public IReadOnlyList<Vector3> Points;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

points

/// An optional <see cref="ExclusionRule"/> to determine targets based on the set rules.
/// </summary>
[Tooltip("An optional ExclusionRule to determine targets based on the set rules.")]
public ExclusionRule exclusionRule;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is called targetValidity elsewhere

{
using UnityEngine;

public class PointerSelection : MonoBehaviour
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs

@@ -3,6 +3,7 @@
using UnityEngine;
using UnityEngine.Events;
using System;
using VRTK.Core.Cast;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need Cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As specified in the commit message (and the PR description):

Additionally the introduction of more components that raycast means
the existing PhysicsCast class is moved to the new namespace
Cast.

These other classes are referencing PhysicsCast that now lives in that other namespace.

@@ -1,7 +1,7 @@
namespace VRTK.Core.Pointer
{
using UnityEngine;
using VRTK.Core.Utility;
using VRTK.Core.Cast;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need Cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment: These other classes are referencing PhysicsCast that now lives in that other namespace.

{
using UnityEngine;

public static class BezierCurveGenerator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs blitz

/// the downward cast.
/// </summary>
[Tooltip("The maximum length of the projected cast. The x value is the length of the forward cast, the y value is the length of the downward cast.")]
public Vector2 maximumLength = new Vector2(10f, float.PositiveInfinity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to inherit the existing problem with the bezier pointer cast (i will attempt to explain with MSPaint obvs)

Normal cast:
image

Limited cast:
(Down doesnt reach floor so not valid target)
image

Simply angling the forward cast beam down means you can now reach the floor
image

There is an open bug for this issue:
ExtendRealityLtd/VRTK#1288

No viable solution as of yet (maybe it relies on rotation of beam? or always does a forward beam in world forward for working out viability of downward length?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into #89.

@bddckr bddckr changed the base branch from feat/solid-straight-pointer to master May 20, 2018 09:52
@bddckr bddckr changed the title feat(Pointer): split functionality feat(Pointer): pointer implementation May 20, 2018
@bddckr bddckr changed the title feat(Pointer): pointer implementation feat(Pointer): pointer implementation - resolves #7, resolves #8 May 20, 2018
@bddckr bddckr force-pushed the feat/pointers branch 2 times, most recently from 565bc31 to 1142693 Compare May 20, 2018 10:06
@bddckr bddckr dismissed thestonefox’s stale review May 20, 2018 10:19

I did the requested changes and added a comment explaining Cast namespace change.

@bddckr bddckr requested a review from thestonefox May 20, 2018 10:19
@bddckr bddckr force-pushed the feat/pointers branch 9 times, most recently from 116d342 to 1cf96c8 Compare May 21, 2018 12:44
The pointer concept is the ability to designate an area of the scene
with a destination. A pointer consists of multiple independent
functionality which is implemented through a component that casts
and returns points that define the pointer beam, one that
generically renders points via game objects and a third component
handles the selection functionality of a pointer.

A pointer knows when it is activated, deactivated, when it starts
hovering (enters) a new object, when it finishes hovering (exits) an
object and knows what coordinates of the object it is hovering over.
These are all cast as events with a special pointer payload
containing information about the pointer target.

The Straight Line Cast implementation casts a straight line from an
origin point (e.g. controller) and stops when it collides with an
object (or reaches the set maximum length). The same applies to the
added Parabolic Line Cast, but it casts a parabolic line instead.

Additionally the introduction of more components that raycast means
the existing `PhysicsCast` class is moved to the new namespace
`Cast`.
@thestonefox thestonefox changed the title feat(Pointer): pointer implementation - resolves #7, resolves #8 feat(Pointer): pointer implementation May 23, 2018
@thestonefox
Copy link
Member

superseded by #95

@thestonefox thestonefox deleted the feat/pointers branch May 23, 2018 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
w_inprogress waffle.io label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants