Tanoda
Capsule.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System.Collections;
10using System.Collections.Generic;
11using UnityEngine;
12
13namespace Leap.Unity.Geometry {
14
15 [System.Serializable]
16 public struct Capsule {
17
18 public Vector3 posA;
19 public Vector3 posB;
20 public float radius;
21 public Transform transform;
22
23 // TODO: overrideMatrix not yet needed for Capsules.
24 //public Matrix4x4? overrideMatrix;
25
26 #region Constructors
27
28 public Capsule(Vector3 posA, Vector3 posB, float radius)
29 : this(posA, posB, radius, null) { }
30
31 public Capsule(Sphere sphere, Vector3 otherCenter)
32 : this(sphere.center, otherCenter, sphere.radius, sphere.transform) { }
33
34 public Capsule(Vector3 posA, Vector3 posB, float radius, Transform transform) {
35 this.posA = posA;
36 this.posB = posB;
37 this.radius = radius;
38 this.transform = transform;
39
40 //overrideMatrix = null;
41 }
42
43 #endregion
44
45
46
47 }
48
49 public static class CapsuleExtensions {
50
54 public static Capsule Sweep(this Sphere sphere, Vector3 newCenter) {
55 var capsule = new Capsule(sphere.center, newCenter, sphere.radius, sphere.transform);
56
57 // TODO: Add this once Sphere supports overrideMatrix
58 //capsule.overrideMatrix = sphere.overrideMatrix;
59
60 return capsule;
61 }
62
63 }
64
65}
Capsule(Vector3 posA, Vector3 posB, float radius, Transform transform)
Definition: Capsule.cs:34
Capsule(Sphere sphere, Vector3 otherCenter)
Definition: Capsule.cs:31
Capsule(Vector3 posA, Vector3 posB, float radius)
Definition: Capsule.cs:28