scott's bugfix for partial contact in mex controller