1
This commit is contained in:
@@ -27,22 +27,31 @@ namespace BITKit.Physics
|
||||
|
||||
var vertices = _mesh.vertices;
|
||||
|
||||
if (vertices.Length > 2048) return false;
|
||||
if (vertices.Length > 256) return false;
|
||||
|
||||
var minPos = new Vector3(64, 64, 64);
|
||||
var minDistance = 64f;
|
||||
|
||||
for (var index = 0; index < _mesh.triangles.Length; index+=3)
|
||||
{
|
||||
var x = vertices[_mesh.triangles[index]];
|
||||
|
||||
if (Vector3.Distance(x, _position) > minDistance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var y = vertices[_mesh.triangles[index + 1]];
|
||||
var z = vertices[_mesh.triangles[index + 2]];
|
||||
|
||||
var pos = GeometryUtils.GetPosInTriangle(x, y, z, _position);
|
||||
|
||||
if (Vector3.Distance(pos, _position) < Vector3.Distance(minPos, _position))
|
||||
{
|
||||
minPos = pos;
|
||||
}
|
||||
var distance = Vector3.Distance(pos, _position);
|
||||
|
||||
if (!(distance < minDistance)) continue;
|
||||
|
||||
minPos = pos;
|
||||
minDistance = distance;
|
||||
}
|
||||
|
||||
position = minPos;
|
||||
|
Reference in New Issue
Block a user