VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
virtual void AVR.Core.AVR_Ray.UpdateStraightRay ( )
inlineprotectedvirtual

Updates a ray with mode==STRAIGHT

Reimplemented in AVR.Core.AVR_SolidRay.

Definition at line 127 of file AVR_Ray.cs.

127  {
128  // Make sure we only have 2 positions
129  if (positions.Length != 2) positions = new Vector3[2];
130 
131  // Se which condition determines the endpoint, max_length or max_horizontal_distance. Semi-TODO: This seems like an unelegant solution. Find a better one.
132  Vector3 dest = RayForward * max_length;
133  if(new Vector2(dest.x, dest.z).magnitude > max_horizontal_distance){
134  dest *= max_horizontal_distance / Mathf.Max(new Vector2(dest.x, dest.z).magnitude, 0.0001f);
135  }
136 
137  // Initialize between here & max_length
138  this.positions[0] = transform.position;
139  this.positions[1] = transform.position + dest;
140 
141  // Set line
142  lr.useWorldSpace = true;
143  lr.positionCount = 2;
144  lr.SetPositions(positions);
145  }
Vector3 RayForward
Definition: AVR_Ray.cs:53
float max_horizontal_distance
Will restrict the length of the ray along the xz-Plane to a given value.
Definition: AVR_Ray.cs:45
float max_length
Maximum length of the ray
Definition: AVR_Ray.cs:43
Vector3[] positions
Definition: AVR_Ray.cs:52