Modify signature of plugin reset callback.

The `reset` function is called inside `mj_resetData`, before any physics forwarding call has been made. It is therefore an error to read anything from mjData at this stage.

The only valid operation on mjData during `reset` is for a plugin to write into its own state variable slots and data struct. We modify the function signature to only provide access to these.

PiperOrigin-RevId: 495032492
Change-Id: Ic6d2967d2571a9083cbca1ba239ca70a8a51f474
This commit is contained in:
Saran Tunyasuvunakool
2022-12-13 08:40:59 -08:00
committed by Copybara-Service
parent 2e6af64b31
commit 5c021d042b
4 changed files with 13 additions and 9 deletions
+2 -1
View File
@@ -1149,7 +1149,8 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
d->plugin[i] = m->plugin[i];
const mjpPlugin* plugin = mjp_getPluginAtSlot(m->plugin[i]);
if (plugin->reset) {
plugin->reset(m, d, i);
plugin->reset(m, &d->plugin_state[m->plugin_stateadr[i]],
(void*)(d->plugin_data[i]), i);
}
}
}