From e75ad6bab4079847b412ee21ce59c4b9b492362c Mon Sep 17 00:00:00 2001 From: rqg Date: Thu, 16 Apr 2020 17:09:13 +0800 Subject: [PATCH] call mjv_makeScene after self._model_ptr inited which make skin tag cause seg fault --- mujoco_py/mjrendercontext.pyx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mujoco_py/mjrendercontext.pyx b/mujoco_py/mjrendercontext.pyx index 76b96a98..a529249f 100644 --- a/mujoco_py/mjrendercontext.pyx +++ b/mujoco_py/mjrendercontext.pyx @@ -33,12 +33,9 @@ cdef class MjRenderContext(object): cdef public object sim def __cinit__(self): - maxgeom = 1000 - mjv_makeScene(self._model_ptr, &self._scn, maxgeom) - mjv_defaultCamera(&self._cam) - mjv_defaultPerturb(&self._pert) - mjv_defaultOption(&self._vopt) - mjr_defaultContext(&self._con) + # __cinit__ run before __init__ self._model_ptr not init before call mjv_makeScene + # mv all init to line 54 + pass def __init__(self, MjSim sim, bint offscreen=True, int device_id=-1, opengl_backend=None, quiet=False): self.sim = sim @@ -53,6 +50,16 @@ cdef class MjRenderContext(object): self._model_ptr = sim.model.ptr self._data_ptr = sim.data.ptr + + mjv_defaultCamera(&self._cam) + mjv_defaultPerturb(&self._pert) + mjv_defaultOption(&self._vopt) + mjr_defaultContext(&self._con) + mjv_defaultScene(&self._scn) + + maxgeom = 1000 + mjv_makeScene(self._model_ptr, &self._scn, maxgeom) + self.scn = WrapMjvScene(&self._scn) self.cam = WrapMjvCamera(&self._cam) self.vopt = WrapMjvOption(&self._vopt)