Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call mjv_makeScene after self._model_ptr inited #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions mujoco_py/mjrendercontext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down