// AddPoint // if pt is less than Sqrt(combinationDistanceSq) from one of the // others the original is replaced with the mean of it // and pt, and false is returned. true means that pt was // added to pts private bool AddPoint(List <MyCP> pts, Vector3 pt, Vector3 normal, float depth, float combinationDistanceSq) { for (int i = pts.Count; i-- != 0;) { if (PointPointDistanceSq(pts[i].m_Position, pt) < combinationDistanceSq) { //pts[i] = 0.5f * (pts[i] + pt); return(false); } } MyCP cp = new MyCP(); cp.m_Normal = -normal; cp.m_Normal = MyMwcUtils.Normalize(cp.m_Normal); cp.m_Position = pt; cp.m_Depth = depth * 0.1f - 0.5f * MyPhysicsConfig.CollisionEpsilon; if (cp.m_Depth < -0.5f) { cp.m_Depth *= 0.5f; } pts.Add(cp); return(true); }
// AddPoint // if pt is less than Sqrt(combinationDistanceSq) from one of the // others the original is replaced with the mean of it // and pt, and false is returned. true means that pt was // added to pts private bool AddPoint(List<MyCP> pts, Vector3 pt, Vector3 normal, float depth , float combinationDistanceSq) { for (int i = pts.Count; i-- != 0; ) { if (PointPointDistanceSq(pts[i].m_Position, pt) < combinationDistanceSq) { //pts[i] = 0.5f * (pts[i] + pt); return false; } } MyCP cp = new MyCP(); cp.m_Normal = -normal; cp.m_Normal = MyMwcUtils.Normalize(cp.m_Normal); cp.m_Position = pt; cp.m_Depth = depth*0.1f - 0.5f*MyPhysicsConfig.CollisionEpsilon; if (cp.m_Depth < -0.5f) { cp.m_Depth *= 0.5f; } pts.Add(cp); return true; }