5959#include < mujoco/mjmodel.h>
6060#include < mujoco/mjplugin.h>
6161#include < mujoco/mjtnum.h>
62- #include " engine/engine_crossplatform.h"
62+ #include " engine/engine_crossplatform.h" // IWYU pragma: keep
6363#include " engine/engine_plugin.h"
6464#include " engine/engine_util_errmem.h"
6565#include " user/user_cache.h"
@@ -73,7 +73,6 @@ extern "C" {
7373}
7474
7575namespace {
76- using mujoco::user::VectorToString;
7776 using mujoco::user::FilePath;
7877 using std::max;
7978 using std::min;
@@ -211,8 +210,8 @@ mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) {
211210 mjuu_setvec (aamm_, 1e10 , 1e10 , 1e10 );
212211 mjuu_setvec (aamm_+3 , -1e10 , -1e10 , -1e10 );
213212 szgraph_ = 0 ;
214- center_ = NULL ;
215- graph_ = NULL ;
213+ center_ = nullptr ;
214+ graph_ = nullptr ;
216215 needhull_ = false ;
217216 maxhullvert_ = -1 ;
218217 processed_ = false ;
@@ -254,14 +253,14 @@ mjCMesh& mjCMesh::operator=(const mjCMesh& other) {
254253 this ->center_ = (double *)mju_malloc (ncenter);
255254 memcpy (this ->center_ , other.center_ , ncenter);
256255 } else {
257- this ->center_ = NULL ;
256+ this ->center_ = nullptr ;
258257 }
259258 if (other.graph_ ) {
260259 size_t szgraph = szgraph_*sizeof (int );
261260 this ->graph_ = (int *)mju_malloc (szgraph);
262261 memcpy (this ->graph_ , other.graph_ , szgraph);
263262 } else {
264- this ->graph_ = NULL ;
263+ this ->graph_ = nullptr ;
265264 }
266265 }
267266 PointToLocal ();
@@ -332,8 +331,8 @@ void mjCMesh::CopyFromSpec() {
332331 if (center_) mju_free (center_);
333332 if (graph_) mju_free (graph_);
334333 szgraph_ = 0 ;
335- center_ = NULL ;
336- graph_ = NULL ;
334+ center_ = nullptr ;
335+ graph_ = nullptr ;
337336
338337 // use filename if name is missing
339338 if (name.empty ()) {
@@ -524,7 +523,7 @@ namespace {
524523struct VertexKey {
525524 float v[3 ];
526525
527- bool operator ==(const VertexKey & other) const {
526+ bool operator ==(const VertexKey& other) const {
528527 return (v[0 ] == other.v [0 ] && v[1 ] == other.v [1 ] && v[2 ] == other.v [2 ]);
529528 }
530529
@@ -1212,7 +1211,7 @@ void mjCMesh::LoadSTL(mjResource* resource) {
12121211
12131212 // get file data in buffer
12141213 char * buffer = 0 ;
1215- int buffer_sz = mju_readResource (resource, (const void **) &buffer);
1214+ int buffer_sz = mju_readResource (resource, (const void **)&buffer);
12161215
12171216 // still not found
12181217 if (buffer_sz < 0 ) {
@@ -1285,7 +1284,7 @@ void mjCMesh::LoadMSH(mjResource* resource, bool remove_repeated) {
12851284
12861285 // get file data in buffer
12871286 char * buffer = 0 ;
1288- int buffer_sz = mju_readResource (resource, (const void **) &buffer);
1287+ int buffer_sz = mju_readResource (resource, (const void **)&buffer);
12891288
12901289 // still not found
12911290 if (buffer_sz < 0 ) {
@@ -1880,15 +1879,15 @@ void mjCMesh::MakeGraph() {
18801879 qh_zero (qh, stderr);
18811880
18821881 // qhull basic init
1883- qh_init_A (qh, stdin, stdout, stderr, 0 , NULL );
1882+ qh_init_A (qh, stdin, stdout, stderr, 0 , nullptr );
18841883
18851884 // install longjmp error handler
18861885 exitcode = setjmp (qh->errexit );
18871886 qh->NOerrexit = false ;
18881887 if (!exitcode) {
18891888 // actual init
18901889 qh_initflags (qh, const_cast <char *>(qhopt.c_str ()));
1891- qh_init_B (qh, vert_.data (), nvert (), 3 , False );
1890+ qh_init_B (qh, vert_.data (), nvert (), 3 , qh_False );
18921891
18931892 // construct convex hull
18941893 qh_qhull (qh);
@@ -2661,10 +2660,11 @@ void mjCMesh::MakeNormal() {
26612660 normal_[3 *i+2 ]*normal_[3 *i+2 ]);
26622661
26632662 // divide by length
2664- if (len > mjMINVAL)
2663+ if (len > mjMINVAL) {
26652664 for (int j=0 ; j < 3 ; j++) {
26662665 normal_[3 *i+j] /= len;
2667- }else {
2666+ }
2667+ } else {
26682668 normal_[3 *i] = normal_[3 *i+1 ] = 0 ;
26692669 normal_[3 *i+2 ] = 1 ;
26702670 }
@@ -3270,7 +3270,7 @@ void mjCSkin::Compile(const mjVFS* vfs) {
32703270 // get index and check range
32713271 int jj = vertid_[i][j];
32723272 if (jj < 0 || jj >= nvert) {
3273- throw mjCError (this , " vertid %d out of range in skin" , NULL , jj);
3273+ throw mjCError (this , " vertid %d out of range in skin" , nullptr , jj);
32743274 }
32753275
32763276 // accumulate
@@ -3281,7 +3281,7 @@ void mjCSkin::Compile(const mjVFS* vfs) {
32813281 // check coverage
32823282 for (int i=0 ; i < nvert; i++) {
32833283 if (vw[i] <= mjMINVAL) {
3284- throw mjCError (this , " vertex %d must have positive total weight in skin" , NULL , i);
3284+ throw mjCError (this , " vertex %d must have positive total weight in skin" , nullptr , i);
32853285 }
32863286 }
32873287
@@ -3314,7 +3314,7 @@ void mjCSkin::Compile(const mjVFS* vfs) {
33143314// load skin in SKN BIN format
33153315void mjCSkin::LoadSKN (mjResource* resource) {
33163316 char * buffer = 0 ;
3317- int buffer_sz = mju_readResource (resource, (const void **) &buffer);
3317+ int buffer_sz = mju_readResource (resource, (const void **)&buffer);
33183318
33193319 if (buffer_sz < 0 ) {
33203320 throw mjCError (this , " could not read SKN file '%s'" , resource->name );
@@ -3589,8 +3589,8 @@ void inline ComputeBasis<Stencil2D>(double basis[9], const double* x,
35893589
35903590 for (int i = 0 ; i < 3 ; i++) {
35913591 for (int j = 0 ; j < 3 ; j++) {
3592- basis[3 *i+j] = ( basisL[i]*basisR[j] +
3593- basisR[i]*basisL[j] ) / (8 *volume*volume);
3592+ basis[3 *i+j] = (basisL[i]*basisR[j] +
3593+ basisR[i]*basisL[j]) / (8 *volume*volume);
35943594 }
35953595 }
35963596}
@@ -3625,8 +3625,8 @@ void inline ComputeBasis<Stencil3D>(double basis[9], const double* x,
36253625
36263626 for (int i = 0 ; i < 3 ; i++) {
36273627 for (int j = 0 ; j < 3 ; j++) {
3628- basis[3 *i+j] = ( normalL[i]*normalR[j] +
3629- normalR[i]*normalL[j] ) / (36 *2 *volume*volume);
3628+ basis[3 *i+j] = (normalL[i]*normalR[j] +
3629+ normalR[i]*normalL[j]) / (36 *2 *volume*volume);
36303630 }
36313631 }
36323632}
@@ -3898,7 +3898,7 @@ void inline ComputeLinearStiffness(std::vector<double>& K,
38983898 }
38993899
39003900 if (dof != n) { // SHOULD NOT OCCUR
3901- throw mjCError (NULL , " incorrect number of basis functions" );
3901+ throw mjCError (nullptr , " incorrect number of basis functions" );
39023902 }
39033903
39043904 // tensor contraction of the gradients of elastic strains
@@ -4263,8 +4263,7 @@ void mjCFlex::Compile(const mjVFS* vfs) {
42634263 for (int e = 0 ; e < kNumEdges [dim-1 ]; e++) {
42644264 auto pair = std::pair (
42654265 min (v[eledge[dim-1 ][e][0 ]], v[eledge[dim-1 ][e][1 ]]),
4266- max (v[eledge[dim-1 ][e][0 ]], v[eledge[dim-1 ][e][1 ]])
4267- );
4266+ max (v[eledge[dim-1 ][e][0 ]], v[eledge[dim-1 ][e][1 ]]));
42684267
42694268 // if edge is already present in the vector only store its index
42704269 auto [it, inserted] = edge_indices.insert ({pair, nedge});
0 commit comments