public List <ColliderData> GetColliders() { Colliders = Colliders ?? new List <ColliderData>(); Colliders.Clear(); for (var i = 0; i < Creator.ColliderProviders.Count; i++) { var colliderProvider = Creator.ColliderProviders[i]; var colliders = colliderProvider.GetComponents <SphereCollider>(); for (var j = 0; j < colliders.Length; j++) { var collider = colliders[j]; var p = colliderProvider.transform.TransformPoint(collider.center); var r = collider.radius * colliderProvider.transform.lossyScale; var newCollider = new ColliderData { Position = p, Radius = r.x }; Colliders.Add(newCollider); } } return(Colliders); }
protected Vector3 FixCollision(Vector3 vertex, ColliderData collider) { var relPosition = vertex - collider.Position; var sumRadius = collider.Radius + Creator.Brush.CollisionDistance; if (relPosition.sqrMagnitude > sumRadius * sumRadius) { return(vertex); } var penetration = sumRadius - relPosition.magnitude; var normal = relPosition.normalized; var correction = normal * penetration; vertex += correction * 0.9f; return(vertex); }