/// <summary> /// The height of the road at this position. Assumes position is over road. /// Only public for access by Road RenderObjects during construction. /// </summary> /// <param name="pos"></param> /// <returns></returns> public float BaseHeight(Vector2 pos) { float baseHeight = Terrain.GetTerrainHeightFlat(pos); if (Airborne) { Vector2 pos0 = edge.Node0.Position2d; Vector2 pos1 = edge.Node1.Position2d; Vector2 pos0to1 = pos1 - pos0; float t = Vector2.Dot(pos - pos0, pos0to1) / pos0to1.LengthSquared(); t = MathHelper.Clamp(t, 0.0f, 1.0f); //float rampHeight = RampHeight(pos); //if (t < 0.5f) //{ // float shortest = isect0.ShortestEdge * 0.5f; // t = Vector2.Distance(pos, pos0) / shortest; // t = 1.0f - MathHelper.Clamp(t, 0.0f, 1.0f); // rampHeight += t * (isect0.BaseHeight(pos) - rampHeight); //} //else //{ // float shortest = isect1.ShortestEdge * 0.5f; // t = Vector2.Distance(pos, pos1) / shortest; // t = 1.0f - MathHelper.Clamp(t, 0.0f, 1.0f); // rampHeight += t * (isect1.BaseHeight(pos) - rampHeight); //} float rampHeight = t < 0.5f ? isect0.BaseHeight(pos) : isect1.BaseHeight(pos); #if MF_AIRBORNE_THRU if (!edge.Node0.OnGround || !edge.Node1.OnGround) { baseHeight = rampHeight; } else #endif // MF_AIRBORNE_THRU { baseHeight = Math.Max(baseHeight, rampHeight); } } return(baseHeight); }