Constraints on the CKM angle γ in B0→D¯0K*0 and B0→D0K*0 from a Dalitz analysis of D0 and D¯0 decays to KSπ+π-