How to find vertices under collision?

We have object A (static ground) which is a plane with 65000 vertices and object B (rigid body) which is a cube with 8 vertices.
If object B collides with object A, is there a way in python to get the vertices from object A where this collision occurs?

collision sensor can not grab the position (as far as i know).
however you can cast a ray as soon as the collision occurs, then with the ray you can get the ray.hitPosition this will not be accurate collision wise.

so simply said, OBJ B collides with OBJ a, collision senor fires, then cast a ray from OBJ B downwards so it detects OBJ A then use ray.hitPosition to get the position underneath OBJ B.

I think* it can be work around with collisionCallback, so then you use that to calculate which vertices is closest to the impact, I believe* BluePrintRandom has something like this with a kdtree in the resource forum

collision callback gets you the closest contact point,

you can than use kdtree to get closest point, or if the terrain is a regular grid, you can access the vertex by rounding to a grid position, and registering each vertex in a dictionary with the grid position as the key

def roundPartial (value, resolution):
    return round (value / resolution) * resolution

pos = (roundPartial(object.worldPosition.x, .25),roundPartial(object.worldPosition.y, .25))
#code to get point from dictionary

#used to create dictionary you build from vertex
if 'Grid' not in own:
    grid = {}
    mesh = terrain.meshes[0]
    for v_index in range(mesh.getVertexArrayLength(0)):
        vert = mesh.getVertex(0, v_index)
        pos = mesh[0].worldTransform*vert.XYZ
        pos =  (roundPartial(pos.x,. 25),roundPartial(pos.y .25))
        grid.update( { pos:(vertex) }
   own['Grid'] = grid