/// <summary> /// CollisionNotify gets called by the CollisionSystem each time a /// Collision is detected. /// </summary> /// <param name="collDetectInfo"></param> /// <param name="dirToBody0"></param> /// <param name="pointInfos"></param> /// <param name="numCollPts"></param> public override unsafe void CollisionNotify(ref CollDetectInfo collDetectInfo, ref Vector3 dirToBody0, SmallCollPointInfo *pointInfos, int numCollPts) { CollisionInfo info; // shortcuts to save typing it over and over CollisionSkin skin0 = collDetectInfo.Skin0; CollisionSkin skin1 = collDetectInfo.Skin1; // if more than one point, add another that is in the middle - collision if ((skin0 != null) && (skin0.Owner != null)) { // if either skin say don't generate contact points, then we don't bool generateContactPoints = skin0.OnCollisionEvent(skin0, skin1); if (skin1 != null) { generateContactPoints &= skin1.OnCollisionEvent(skin1, skin0); } if (generateContactPoints) { info = CollisionInfo.GetCollisionInfo(collDetectInfo, dirToBody0, pointInfos, numCollPts); colls.Add(info); skin0.Collisions.Add(info); if ((skin1 != null) && (skin1.Owner != null)) { skin1.Collisions.Add(info); } } } else if ((skin1 != null) && (skin1.Owner != null)) { // if either skin say don't generate contact points, then we don't bool generateContactPoints = skin1.OnCollisionEvent(skin1, skin0); if (skin0 != null) { generateContactPoints &= skin0.OnCollisionEvent(skin0, skin1); } if (generateContactPoints) { info = CollisionInfo.GetCollisionInfo(collDetectInfo, -dirToBody0, pointInfos, numCollPts); colls.Add(info); skin1.Collisions.Add(info); if ((skin0 != null) && (skin0.Owner != null)) { skin0.Collisions.Add(info); } } } else { System.Diagnostics.Debug.WriteLine("Collision detected with both skin bodies null."); } }