Additional static functions and constants used to extend existing Mesh support inside of Unity.
More...
|
static int | NearestVertexIndex (this UnityEngine.Mesh mesh, UnityEngine.Vector3 targetPosition) |
| Return the index of the closest vertex to the targetPosition on the Mesh. More...
|
|
Additional static functions and constants used to extend existing Mesh support inside of Unity.
Definition at line 35 of file Mesh.cs.
static int Hydrogen.Mesh.NearestVertexIndex |
( |
this UnityEngine.Mesh |
mesh, |
|
|
UnityEngine.Vector3 |
targetPosition |
|
) |
| |
|
static |
Return the index of the closest vertex to the targetPosition on the Mesh.
- Returns
- The vertex index on the mesh.
- Parameters
-
mesh | The mesh to compare against. |
targetPosition | The position to check against. |
Definition at line 54 of file Mesh.cs.
57 UnityEngine.Vector3[] vertices = mesh.vertices;
60 float nearestDistance = UnityEngine.Mathf.Infinity;
63 int best = vertices.Length - 1;
65 for (var i = 0; i < (best + 1); i++) {
66 UnityEngine.Vector3 vertex = vertices [i];
67 UnityEngine.Vector3 difference = targetPosition - vertex;
69 float differenceDist = difference.sqrMagnitude;
71 if (differenceDist < nearestDistance) {
72 nearestDistance = differenceDist;
const int Hydrogen.Mesh.VerticesArrayLimit = 65535 |
The maximum vertices allowed in a Mesh when counting index 0 of an array as one.
This is useful for looping so you dont have to do -1 all the time.
Definition at line 46 of file Mesh.cs.
const int Hydrogen.Mesh.VerticesLimit = 65536 |
The maximum vertices allowed in a Mesh.
This is a limitation of the short integer.
Definition at line 41 of file Mesh.cs.