Modernize struct and enum style in MuJoCo headers.

PiperOrigin-RevId: 936485706
Change-Id: I31864acc4bd44573127d3d04c6b1a23f9d9c4cbc
This commit is contained in:
Kyle Bayes
2026-06-23 00:47:13 -07:00
committed by Copybara-Service
parent afccd36dd4
commit 0fd7bea973
12 changed files with 463 additions and 548 deletions
+12 -18
View File
@@ -24,14 +24,13 @@
//---------------------------------- Resource Provider ---------------------------------------------
struct mjResource_ {
typedef struct mjResource_ {
char* name; // name of resource (filename, etc)
void* data; // opaque data pointer
mjVFS* vfs; // pointer to the VFS
char timestamp[512]; // timestamp of the resource
const struct mjpResourceProvider* provider; // pointer to the provider
};
typedef struct mjResource_ mjResource;
} mjResource;
// callback for opening a resource, returns zero on failure.
// Note: If opening fails, the close callback will not be called. Therefore, the
@@ -60,7 +59,7 @@ typedef int (*mjfUnmountResource)(mjResource* resource);
typedef int (*mjfResourceModified)(const mjResource* resource, const char* timestamp);
// struct describing a single resource provider
struct mjpResourceProvider {
typedef struct mjpResourceProvider {
const char* prefix; // prefix for match against a resource name
mjfOpenResource open; // opening callback
mjfReadResource read; // reading callback
@@ -69,8 +68,7 @@ struct mjpResourceProvider {
mjfUnmountResource unmount; // unmounting callback (optional)
mjfResourceModified modified; // resource modified callback (optional)
void* data; // opaque data pointer (resource invariant)
};
typedef struct mjpResourceProvider mjpResourceProvider;
} mjpResourceProvider;
//---------------------------------- Decoder -------------------------------------------------------
@@ -81,7 +79,7 @@ typedef mjSpec* (*mjfDecode)(mjResource* resource, const mjVFS* vfs);
typedef int (*mjfCanDecode)(const mjResource* resource);
// the struct defining the decoder plugin's interface
struct mjpDecoder {
typedef struct mjpDecoder {
const char* content_type;
const char* extension;
// user-facing functions
@@ -89,21 +87,19 @@ struct mjpDecoder {
mjfDecode decode; // main decoding function
// the caller takes ownership of the spec returned by decode and is responsible
// for cleaning it up
};
typedef struct mjpDecoder mjpDecoder;
} mjpDecoder;
//---------------------------------- Encoder -------------------------------------------------------
typedef int (*mjfEncode)(const mjSpec* s, const mjModel* m, const mjVFS* vfs,
mjResource* resource);
struct mjpEncoder {
typedef struct mjpEncoder {
const char* content_type;
const char* extension;
mjfEncode encode; // Function to encode an mjSpec and mjModel to a mjResource.
mjfCloseResource close_resource; // Function to close/free the resource.
};
typedef struct mjpEncoder mjpEncoder;
} mjpEncoder;
//---------------------------------- Plugins -------------------------------------------------------
@@ -114,7 +110,7 @@ typedef enum mjtPluginCapabilityBit_ {
mjPLUGIN_SDF = 1<<3, // signed distance fields
} mjtPluginCapabilityBit;
struct mjpPlugin_ {
typedef struct mjpPlugin_ {
const char* name; // globally unique name identifying the plugin
int nattribute; // number of configuration attributes
@@ -172,18 +168,16 @@ struct mjpPlugin_ {
// bounding box of implicit surface
void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes);
};
typedef struct mjpPlugin_ mjpPlugin;
} mjpPlugin;
struct mjSDF_ {
typedef struct mjSDF_ {
const mjpPlugin** plugin;
int* id;
mjtSDFType type;
mjtNum* relpos;
mjtNum* relmat;
mjtGeom* geomtype;
};
typedef struct mjSDF_ mjSDF;
} mjSDF;
//------------------------------------ Initialization ----------------------------------------------