Skip to content

Do not set geom_dataid for primitives fitted to a mesh. - #3471

Open
robertomeroni wants to merge 1 commit into
google-deepmind:mainfrom
robertomeroni:contrib/fitted-primitive-no-mesh-dataid
Open

Do not set geom_dataid for primitives fitted to a mesh.#3471
robertomeroni wants to merge 1 commit into
google-deepmind:mainfrom
robertomeroni:contrib/fitted-primitive-no-mesh-dataid

Conversation

@robertomeroni

Copy link
Copy Markdown

A geom whose type is a primitive but which carries a mesh= attribute is fitted to that mesh, and XMLreference states that the compiled mjModel holds "no reference to the mesh used for fitting". mjCGeom::Compile clears meshname_ to that end, but IndexAssets runs afterwards and re-resolves geom->mesh from spec_meshname_, which is untouched, so CopyTree stored the mesh id anyway.

The stale id defeats the geom_dataid == -1 early-out in mjc_PlaneConvex, which then walks the fitting mesh and can emit up to 3 contacts into a buffer that mj_maxContact sized at 1 for a plane-ellipsoid pair: SIGSEGV, or the driver's own contact-count check firing. Saving and reloading the same model produced a correct geom_dataid of -1, so the two paths disagreed.

Gate the assignment on the geom type, matching the guard used elsewhere in the compiler (user_model.cc:5317). Fitted primitives now also render as primitives: texture repeat is no longer divided by geom size, and mjVIS_MESHBVH no longer draws the fitting mesh's bounding volumes on them.

A geom whose type is a primitive but which carries a mesh= attribute is fitted
to that mesh, and XMLreference states that the compiled mjModel holds "no
reference to the mesh used for fitting". mjCGeom::Compile clears meshname_ to
that end, but IndexAssets runs afterwards and re-resolves geom->mesh from
spec_meshname_, which is untouched, so CopyTree stored the mesh id anyway.

The stale id defeats the geom_dataid == -1 early-out in mjc_PlaneConvex, which
then walks the fitting mesh and can emit up to 3 contacts into a buffer that
mj_maxContact sized at 1 for a plane-ellipsoid pair: SIGSEGV, or the driver's
own contact-count check firing. Saving and reloading the same model produced a
correct geom_dataid of -1, so the two paths disagreed.

Gate the assignment on the geom type, matching the guard used elsewhere in the
compiler (user_model.cc:5317). Fitted primitives now also render as primitives:
texture repeat is no longer divided by geom size, and mjVIS_MESHBVH no longer
draws the fitting mesh's bounding volumes on them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant