Remove the convexhull compiler option.

PiperOrigin-RevId: 690307675
Change-Id: I62d8213579ad07296ca96de004d39ae012174aa4
This commit is contained in:
Yuval Tassa
2024-10-27 04:30:12 -07:00
committed by Copybara-Service
parent 61cb552f8a
commit 7dc8aef807
14 changed files with 58 additions and 87 deletions
+1 -13
View File
@@ -772,23 +772,11 @@ has any effect. The settings here are global and apply to the entire model.
models compiled with this flag, it is important to remember that collision geoms are often placed in a
:ref:`group<body-geom-group>` which is invisible by default.
.. _compiler-convexhull:
:at:`convexhull`: :at-val:`[false, true], "true"`
If this attribute is "true", the compiler will automatically generate a convex hull for every mesh that is used in at
least one non-visual geom (in the sense of the discardvisual attribute above). This is done to speed up collision
detection; recall :ref:`Collision` section in the Computation chapter. Even if the mesh is already convex, the hull
contains edge information that is not present in the mesh file, so it needs to be constructed. The only reason to
disable this feature is to speed up re-loading of a model with large meshes during model editing (since the convex
hull computation is the slowest operation performed by the compiler). However once model design is finished, this
feature should be enabled, because the availability of convex hulls substantially speeds up collision detection with
large meshes.
.. _compiler-usethread:
:at:`usethread`: :at-val:`[false, true], "true"`
If this attribute is "true", the model compiler will run in multi-threaded mode. Currently multi-threading is used
for computing the length ranges of actuators and for loading meshes.
for computing the length ranges of actuators and for parallel loading of meshes.
.. _compiler-fusestatic:
+2 -2
View File
@@ -52,9 +52,9 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`fitaabb<compiler-fitaabb>` | :ref:`eulerseq<compiler-eulerseq>` | :ref:`meshdir<compiler-meshdir>` | :ref:`texturedir<compiler-texturedir>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`discardvisual<compiler-discardvisual>` | :ref:`convexhull<compiler-convexhull>` | :ref:`usethread<compiler-usethread>` | :ref:`fusestatic<compiler-fusestatic>` | |
| | | | :ref:`discardvisual<compiler-discardvisual>` | :ref:`usethread<compiler-usethread>` | :ref:`fusestatic<compiler-fusestatic>` | :ref:`inertiafromgeom<compiler-inertiafromgeom>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`inertiafromgeom<compiler-inertiafromgeom>` | :ref:`inertiagrouprange<compiler-inertiagrouprange>` | :ref:`assetdir<compiler-assetdir>` | :ref:`alignfree<compiler-alignfree>` | |
| | | | :ref:`inertiagrouprange<compiler-inertiagrouprange>` | :ref:`assetdir<compiler-assetdir>` | :ref:`alignfree<compiler-alignfree>` | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |_| compiler |br| |_| |L| | | .. table:: |
+1
View File
@@ -9,6 +9,7 @@ General
^^^^^^^
- The global compiler flag ``exactmeshinertia`` has been removed and replaced with the mesh-specific
:ref:`inertia<asset-mesh-inertia>` attribute.
- The not-useful ``convexhull`` compiler option (to disable computation of mesh convex hulls) has been removed.
- Removed the deprecated ``mju_rotVecMat`` and ``mju_rotVecMatT`` functions.
- Sorting now uses a faster, native sort function (fixes :github:issue:`1638`).
- The PBR texture layers introduced in 3.2.1 were refactored from seperate sub-elements to a single
-1
View File
@@ -1693,7 +1693,6 @@ typedef struct mjsCompiler_ { // compiler options
mjtByte degree; // angles in radians or degrees
char eulerseq[3]; // sequence for euler rotations
mjtByte discardvisual; // discard visual geoms in parser
mjtByte convexhull; // compute mesh convex hulls
mjtByte usethread; // use multiple threads to speed up compiler
mjtByte fusestatic; // fuse static bodies with parent
int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom)
-1
View File
@@ -131,7 +131,6 @@ typedef struct mjsCompiler_ { // compiler options
mjtByte degree; // angles in radians or degrees
char eulerseq[3]; // sequence for euler rotations
mjtByte discardvisual; // discard visual geoms in parser
mjtByte convexhull; // compute mesh convex hulls
mjtByte usethread; // use multiple threads to speed up compiler
mjtByte fusestatic; // fuse static bodies with parent
int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom)
-5
View File
@@ -8853,11 +8853,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='mjtByte'),
doc='discard visual geoms in parser',
),
StructFieldDecl(
name='convexhull',
type=ValueType(name='mjtByte'),
doc='compute mesh convex hulls',
),
StructFieldDecl(
name='usethread',
type=ValueType(name='mjtByte'),
-1
View File
@@ -39,7 +39,6 @@ void mjs_defaultSpec(mjSpec* spec) {
spec->compiler.eulerseq[0] = 'x';
spec->compiler.eulerseq[1] = 'y';
spec->compiler.eulerseq[2] = 'z';
spec->compiler.convexhull = 1;
spec->compiler.usethread = 1;
spec->compiler.inertiafromgeom = mjINERTIAFROMGEOM_AUTO;
spec->compiler.inertiagrouprange[1] = mjNGROUP-1;
+1 -1
View File
@@ -563,7 +563,7 @@ void mjCMesh::Compile(const mjVFS* vfs) {
}
// make graph describing convex hull
if ((model->compiler.convexhull && needhull_) || face_.empty()) {
if (needhull_ || face_.empty()) {
MakeGraph();
}
-1
View File
@@ -42,7 +42,6 @@ extern const int gain_sz;
extern const int bias_sz;
extern const int stage_sz;
extern const int datatype_sz;
extern const mjMap coordinate_map[];
extern const mjMap angle_map[];
extern const mjMap enable_map[];
extern const mjMap bool_map[];
+2 -5
View File
@@ -97,9 +97,9 @@ static void UpdateString(string& psuffix, int count, int i) {
const char* MJCF[nMJCF][mjXATTRNUM] = {
{"mujoco", "!", "1", "model"},
{"<"},
{"compiler", "*", "20", "autolimits", "boundmass", "boundinertia", "settotalmass",
{"compiler", "*", "19", "autolimits", "boundmass", "boundinertia", "settotalmass",
"balanceinertia", "strippath", "coordinate", "angle", "fitaabb", "eulerseq",
"meshdir", "texturedir", "discardvisual", "convexhull", "usethread",
"meshdir", "texturedir", "discardvisual", "usethread",
"fusestatic", "inertiafromgeom", "inertiagrouprange", "assetdir", "alignfree"},
{"<"},
{"lengthrange", "?", "10", "mode", "useexisting", "uselimit",
@@ -1008,9 +1008,6 @@ void mjXReader::Compiler(XMLElement* section, mjSpec* spec) {
if (MapValue(section, "discardvisual", &n, bool_map, 2)) {
spec->compiler.discardvisual = (n==1);
}
if (MapValue(section, "convexhull", &n, bool_map, 2)) {
spec->compiler.convexhull = (n==1);
}
if (MapValue(section, "usethread", &n, bool_map, 2)) {
spec->compiler.usethread = (n==1);
}
-3
View File
@@ -920,9 +920,6 @@ void mjXWriter::Compiler(XMLElement* root) {
XMLElement* section = InsertEnd(root, "compiler");
// settings
if (!model->compiler.convexhull) {
WriteAttrTxt(section, "convexhull", FindValue(bool_map, 2, model->compiler.convexhull));
}
WriteAttrTxt(section, "angle", "radian");
if (!model->get_meshdir().empty()) {
WriteAttrTxt(section, "meshdir", model->get_meshdir());
+1 -1
View File
@@ -1,6 +1,6 @@
<mujoco model="midphase">
<include file="humanoid.xml"/>
<compiler autolimits="true" boundmass="1e-05" boundinertia="1e-11" coordinate="local" angle="radian" eulerseq="xyz"/>
<compiler autolimits="true" boundmass="1e-05" boundinertia="1e-11" angle="radian" eulerseq="xyz"/>
<option timestep="0.001" cone="elliptic" noslip_iterations="5" noslip_tolerance="0"/>
<size njmax="1000" nconmax="500"/>
<visual>
+50 -52
View File
@@ -75,7 +75,6 @@ using ::testing::ElementsAre;
using ::testing::HasSubstr;
using ::testing::IsNull;
using ::testing::NotNull;
using ::testing::StartsWith;
// ------------- test invalid filenames ----------------------------------------
@@ -337,8 +336,7 @@ TEST_F(MjCMeshTest, DeduplicateSTLVertices) {
TEST_F(MjCMeshTest, LoadMSH) {
const std::string xml_path = GetTestDataFilePath(kMeshPath);
char error[1024];
size_t error_sz = 1024;
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error, error_sz);
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
ASSERT_EQ(model->nmeshvert, 36);
mj_deleteModel(model);
@@ -418,8 +416,9 @@ TEST_F(MjCMeshTest, TinyMeshLoads) {
</worldbody>
</mujoco>
)";
mjModel* model = LoadModelFromString(xml);
ASSERT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -458,8 +457,9 @@ TEST_F(MjCMeshTest, FaceNormalAutogenerated) {
</worldbody>
</mujoco>
)";
mjModel* model = LoadModelFromString(xml);
ASSERT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -480,9 +480,9 @@ TEST_F(MjCMeshTest, SmallInertiaLoads) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, NotNull()) << error.data();
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -510,18 +510,18 @@ TEST_F(MjCMeshTest, TinyInertiaFails) {
TEST_F(MjCMeshTest, FlippedFaceAllowedLegacyInertia) {
const std::string xml_path = GetTestDataFilePath(kMalformedFaceOBJPath);
std::array<char, 1024> error;
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(model, testing::NotNull()) << error.data();
char error[1024];
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
EXPECT_THAT(model->nmeshface, 4);
mj_deleteModel(model);
}
TEST_F(MjCMeshTest, MissingFaceAllowedConvexInertia) {
const std::string xml_path = GetTestDataFilePath(kCompareInertiaPath);
std::array<char, 1024> error;
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(model, testing::NotNull()) << error.data();
char error[1024];
mjModel* model = mj_loadXML(xml_path.c_str(), 0, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
EXPECT_THAT(model->nmeshface, 10);
EXPECT_THAT(model->body_inertia[3], model->body_inertia[9]);
EXPECT_THAT(model->body_inertia[4], model->body_inertia[10]);
@@ -583,9 +583,9 @@ TEST_F(MjCMeshTest, FlippedFaceAllowedWorld) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
CheckTetrahedronWasRescaled(model);
mj_deleteModel(model);
}
@@ -605,9 +605,9 @@ TEST_F(MjCMeshTest, FlippedFaceAllowedNoMass) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull()) << error.data();
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
CheckTetrahedronWasRescaled(model);
mj_deleteModel(model);
}
@@ -628,9 +628,9 @@ TEST_F(MjCMeshTest, FlippedFaceAllowedInertial) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
CheckTetrahedronWasRescaled(model);
mj_deleteModel(model);
}
@@ -650,9 +650,9 @@ TEST_F(MjCMeshTest, FlippedFaceAllowedNegligibleArea) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
CheckTetrahedronWasRescaled(model);
mj_deleteModel(model);
}
@@ -706,9 +706,9 @@ TEST_F(MjCMeshTest, AreaTooSmallAllowedWorld) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -736,10 +736,9 @@ TEST_F(MjCMeshTest, VolumeTooSmall) {
TEST_F(MjCMeshTest, VolumeSmallAllowedShell) {
static constexpr char xml[] = R"(
<mujoco>
<compiler convexhull="false"/>
<asset>
<mesh name="example_mesh"
vertex="0 0 0 1 0 0 0 1 0 1 1 0"
vertex="0 0 0 1 0 0 0 1 0 1 1 1e-6"
face="0 1 2 2 1 3" />
</asset>
<worldbody>
@@ -749,9 +748,9 @@ TEST_F(MjCMeshTest, VolumeSmallAllowedShell) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
EXPECT_LE(mju_abs(model->geom_size[0]), 1);
EXPECT_LE(mju_abs(model->geom_size[1]), 1);
EXPECT_LE(mju_abs(model->geom_size[2]), 1);
@@ -815,9 +814,9 @@ TEST_F(MjCMeshTest, VolumeTooSmallAllowedWorld) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -895,8 +894,9 @@ TEST_F(MjCMeshTest, MeshPosQuat) {
</worldbody>
</mujoco>
)";
mjModel* model = LoadModelFromString(xml);
ASSERT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
// Loading the mesh results in an offset of the geom's pos and quat due to the
// fact that the geom's center is not the volumetric center of the mesh. To
// recover the geom's originally specified pose, the offset used is stored in
@@ -953,8 +953,9 @@ TEST_F(MjCMeshTest, MeshScale) {
</worldbody>
</mujoco>
)";
mjModel* model = LoadModelFromString(xml);
ASSERT_THAT(model, NotNull());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
EXPECT_THAT(AsVector(model->mesh_scale + 0, 3), ElementsAre(1, 1, 1));
EXPECT_THAT(AsVector(model->mesh_scale + 3, 3), ElementsAre(0.9, 1, -1));
@@ -972,9 +973,9 @@ TEST_F(MjCMeshTest, CreateFaceTexCoord) {
</asset>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(model, NotNull()) << error.data();
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, NotNull()) << error;
mj_deleteModel(model);
}
@@ -1057,13 +1058,10 @@ TEST_F(MjCMeshTest, InvalidIndexInFace) {
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(model, IsNull());
EXPECT_THAT(
error.data(),
HasSubstr(
"in face 0, vertex index 6 does not exist"));
EXPECT_THAT(error, HasSubstr("in face 0, vertex index 6 does not exist"));
mj_deleteModel(model);
}
-1
View File
@@ -5727,7 +5727,6 @@ public unsafe struct mjsCompiler_ {
public byte degree;
public fixed sbyte eulerseq[3];
public byte discardvisual;
public byte convexhull;
public byte usethread;
public byte fusestatic;
public int inertiafromgeom;