Criterion for contacting is critically important for the Generalized Interpolation Material Point(GIMP) method. We present an improved criterion by adding a switching function. With the method dynamical response of high melting explosive(HMX) with cavities under shock is investigated. The physical model used in the present work is an elastic-to-plastic and thermal-dynamical model with Mie-Gruneissen equation of state. We mainly concern the influence of various parameters, including the impacting velocity $v$, cavity size $R$, etc, to the dynamical and thermodynamical behaviors of the material. For the colliding of two bodies with a cavity in each, a secondary impacting is observed. Correspondingly, the separation distance $D$ of the two bodies has a maximum value $D_{max}$ in between the initial and second impacts. When the initial impacting velocity $v$ is not large enough, the cavity collapses in a nearly symmetric fashion, the maximum separation distance $D_{max}$ increases with $v$. When the initial shock wave is strong enough to collapse the cavity asymmetrically along the shock direction, the variation of $D_{max}$ with $v$ does not show monotonic behavior. Our numerical results show clear indication that the existence of cavities in explosive helps the creation of ``hot spots.