Change user_api handle types.

PiperOrigin-RevId: 640978033
Change-Id: I53496671ac823b50e6f90ceee15bf3b314b06db8
This commit is contained in:
Alessio Quaglino
2024-06-06 12:05:17 -07:00
committed by Copybara-Service
parent 9a140bad14
commit f6084b4328
7 changed files with 427 additions and 424 deletions
+27 -39
View File
@@ -581,66 +581,61 @@ mjElement* mjs_nextChild(mjsBody* body, mjElement* child) {
// set string // set string
void mjs_setString(mjString dest, const char* text) { void mjs_setString(mjString* dest, const char* text) {
std::string* str = reinterpret_cast<std::string*>(dest); std::string* str = static_cast<std::string*>(dest);
*str = std::string(text); *str = std::string(text);
} }
// Set specific entry in destination string vector. // Set specific entry in destination string vector.
mjtByte mjs_setInStringVec(mjStringVec dest, int i, const char* text) { mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest); if (dest->size() <= i) {
if (v->size() <= i) {
mju_error("Requested index in mjs_setInStringVec is out of bounds"); mju_error("Requested index in mjs_setInStringVec is out of bounds");
return 0; return 0;
} }
v->at(i) = std::string(text); dest->at(i) = std::string(text);
return 1; return 1;
} }
// split text and copy into string array // split text and copy into string array
void mjs_setStringVec(mjStringVec dest, const char* text) { void mjs_setStringVec(mjStringVec* dest, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest); std::vector<std::string>* v = static_cast<std::vector<std::string>*>(dest);
*v = mjXUtil::String2Vector<std::string>(text); *v = mjXUtil::String2Vector<std::string>(text);
} }
// add text entry to destination string vector // add text entry to destination string vector
void mjs_appendString(mjStringVec dest, const char* text) { void mjs_appendString(mjStringVec* dest, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest); dest->push_back(std::string(text));
v->push_back(std::string(text));
} }
// copy int array to vector // copy int array to vector
void mjs_setInt(mjIntVec dest, const int* array, int size) { void mjs_setInt(mjIntVec* dest, const int* array, int size) {
std::vector<int>* v = reinterpret_cast<std::vector<int>*>(dest); dest->assign(size, 0.0);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
(*v)[i] = array[i]; (*dest)[i] = array[i];
} }
} }
// append int array to vector of arrays // append int array to vector of arrays
void mjs_appendIntVec(mjIntVecVec dest, const int* array, int size) { void mjs_appendIntVec(mjIntVecVec* dest, const int* array, int size) {
std::vector<std::vector<int>>* v = reinterpret_cast<std::vector<std::vector<int>>*>(dest); dest->push_back(std::vector<int>(array, array + size));
v->push_back(std::vector<int>(array, array + size));
} }
// copy float array to vector // copy float array to vector
void mjs_setFloat(mjFloatVec dest, const float* array, int size) { void mjs_setFloat(mjFloatVec* dest, const float* array, int size) {
std::vector<float>* v = reinterpret_cast<std::vector<float>*>(dest); dest->assign(size, 0.0);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
(*v)[i] = array[i]; (*dest)[i] = array[i];
} }
} }
@@ -648,42 +643,35 @@ void mjs_setFloat(mjFloatVec dest, const float* array, int size) {
// append float array to vector of arrays // append float array to vector of arrays
void mjs_appendFloatVec(mjFloatVecVec dest, const float* array, int size) { void mjs_appendFloatVec(mjFloatVecVec* dest, const float* array, int size) {
std::vector<std::vector<float>>* v = reinterpret_cast<std::vector<std::vector<float>>*>(dest); dest->push_back(std::vector<float>(array, array + size));
v->push_back(std::vector<float>(array, array + size));
} }
// copy double array to vector // copy double array to vector
void mjs_setDouble(mjDoubleVec dest, const double* array, int size) { void mjs_setDouble(mjDoubleVec* dest, const double* array, int size) {
std::vector<double>* v = reinterpret_cast<std::vector<double>*>(dest); dest->assign(size, 0.0);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
(*v)[i] = array[i]; (*dest)[i] = array[i];
} }
} }
// get string // get string
const char* mjs_getString(const mjString source) { const char* mjs_getString(const mjString* source) {
std::string* str = reinterpret_cast<std::string*>(source); return source->c_str();
if (!str) {
return nullptr;
}
return str->c_str();
} }
// get double array // get double array
const double* mjs_getDouble(const mjDoubleVec source, int* size) { const double* mjs_getDouble(const mjDoubleVec* source, int* size) {
std::vector<double>* v = reinterpret_cast<std::vector<double>*>(source);
if (size) { if (size) {
*size = v->size(); *size = source->size();
} }
return v->data(); return source->data();
} }
+175 -160
View File
@@ -25,21 +25,36 @@
// this is a C-API // this is a C-API
#ifdef __cplusplus #ifdef __cplusplus
#include <string>
#include <vector>
extern "C" { extern "C" {
#endif #endif
#define mjNAN NAN // used to mark undefined fields #define mjNAN NAN // used to mark undefined fields
//---------------------------------- handles to internal objects ----------------------------------- //---------------------------------- C/C++ handles to strings and arrays ---------------------------
typedef struct mjString_* mjString; #ifdef __cplusplus
typedef struct mjStringVec_* mjStringVec; // C++, defined to be compatible with corresponding std types
typedef struct mjIntVec_* mjIntVec; using mjString = std::string;
typedef struct mjIntVecVec_* mjIntVecVec; using mjStringVec = std::vector<std::string>;
typedef struct mjFloatVec_* mjFloatVec; using mjIntVec = std::vector<int>;
typedef struct mjFloatVecVec_* mjFloatVecVec; using mjIntVecVec = std::vector<std::vector<int>>;
typedef struct mjDoubleVec_* mjDoubleVec; using mjFloatVec = std::vector<float>;
using mjFloatVecVec = std::vector<std::vector<float>>;
using mjDoubleVec = std::vector<double>;
#else
// C, opaque pointers
typedef struct mjString_ mjString;
typedef struct mjStringVec_ mjStringVec;
typedef struct mjIntVec_ mjIntVec;
typedef struct mjIntVecVec_ mjIntVecVec;
typedef struct mjFloatVec_ mjFloatVec;
typedef struct mjFloatVecVec_ mjFloatVecVec;
typedef struct mjDoubleVec_ mjDoubleVec;
#endif
//---------------------------------- enum types (mjt) ---------------------------------------------- //---------------------------------- enum types (mjt) ----------------------------------------------
@@ -98,7 +113,7 @@ typedef struct mjElement_ { // element type, do not modify
typedef struct mjSpec_ { // model specification typedef struct mjSpec_ { // model specification
mjElement* element; // element type mjElement* element; // element type
mjString modelname; // model name mjString* modelname; // model name
// compiler settings // compiler settings
mjtByte autolimits; // infer "limited" attribute based on range mjtByte autolimits; // infer "limited" attribute based on range
@@ -110,8 +125,8 @@ typedef struct mjSpec_ { // model specification
mjtByte fitaabb; // meshfit to aabb instead of inertia box mjtByte fitaabb; // meshfit to aabb instead of inertia box
mjtByte degree; // angles in radians or degrees mjtByte degree; // angles in radians or degrees
char euler[3]; // sequence for euler rotations char euler[3]; // sequence for euler rotations
mjString meshdir; // mesh and hfield directory mjString* meshdir; // mesh and hfield directory
mjString texturedir; // texture directory mjString* texturedir; // texture directory
mjtByte discardvisual; // discard visual geoms in parser mjtByte discardvisual; // discard visual geoms in parser
mjtByte convexhull; // compute mesh convex hulls mjtByte convexhull; // compute mesh convex hulls
mjtByte usethread; // use multiple threads to speed up compiler mjtByte usethread; // use multiple threads to speed up compiler
@@ -144,8 +159,8 @@ typedef struct mjSpec_ { // model specification
size_t nstack; // (deprecated) number of mjtNums in mjData stack size_t nstack; // (deprecated) number of mjtNums in mjData stack
// global data // global data
mjString comment; // comment at top of XML mjString* comment; // comment at top of XML
mjString modelfiledir; // path to model file mjString* modelfiledir; // path to model file
// other // other
mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator mjtByte hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator
@@ -163,18 +178,18 @@ typedef struct mjsOrientation_ { // alternative orientation specifiers
typedef struct mjsPlugin_ { // plugin specification typedef struct mjsPlugin_ { // plugin specification
mjElement* instance; // element type mjElement* instance; // element type
mjString name; // name mjString* name; // name
mjString instance_name; // instance name mjString* instance_name; // instance name
int plugin_slot; // global registered slot number of the plugin int plugin_slot; // global registered slot number of the plugin
mjtByte active; // is the plugin active mjtByte active; // is the plugin active
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsPlugin; } mjsPlugin;
typedef struct mjsBody_ { // body specification typedef struct mjsBody_ { // body specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString childclass; // childclass name mjString* childclass; // childclass name
// body frame // body frame
double pos[3]; // frame position double pos[3]; // frame position
@@ -192,28 +207,28 @@ typedef struct mjsBody_ { // body specification
// other // other
mjtByte mocap; // is this a mocap body mjtByte mocap; // is this a mocap body
double gravcomp; // gravity compensation double gravcomp; // gravity compensation
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjtByte explicitinertial; // whether to save the body with explicit inertial clause mjtByte explicitinertial; // whether to save the body with explicit inertial clause
mjsPlugin plugin; // passive force plugin mjsPlugin plugin; // passive force plugin
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsBody; } mjsBody;
typedef struct mjsFrame_ { // frame specification typedef struct mjsFrame_ { // frame specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString childclass; // childclass name mjString* childclass; // childclass name
double pos[3]; // position double pos[3]; // position
double quat[4]; // orientation double quat[4]; // orientation
mjsOrientation alt; // alternative orientation mjsOrientation alt; // alternative orientation
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsFrame; } mjsFrame;
typedef struct mjsJoint_ { // joint specification typedef struct mjsJoint_ { // joint specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjtJoint type; // joint type mjtJoint type; // joint type
// kinematics // kinematics
@@ -245,15 +260,15 @@ typedef struct mjsJoint_ { // joint specification
// other // other
int group; // group int group; // group
mjtByte actgravcomp; // is gravcomp force applied via actuators mjtByte actgravcomp; // is gravcomp force applied via actuators
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsJoint; } mjsJoint;
typedef struct mjsGeom_ { // geom specification typedef struct mjsGeom_ { // geom specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // classname mjString* classname; // classname
mjtGeom type; // geom type mjtGeom type; // geom type
// frame, size // frame, size
@@ -285,24 +300,24 @@ typedef struct mjsGeom_ { // geom specification
mjtNum fluid_coefs[5]; // ellipsoid-fluid interaction coefs mjtNum fluid_coefs[5]; // ellipsoid-fluid interaction coefs
// visual // visual
mjString material; // name of material mjString* material; // name of material
float rgba[4]; // rgba when material is omitted float rgba[4]; // rgba when material is omitted
int group; // group int group; // group
// other // other
mjString hfieldname; // heightfield attached to geom mjString* hfieldname; // heightfield attached to geom
mjString meshname; // mesh attached to geom mjString* meshname; // mesh attached to geom
double fitscale; // scale mesh uniformly double fitscale; // scale mesh uniformly
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjsPlugin plugin; // sdf plugin mjsPlugin plugin; // sdf plugin
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsGeom; } mjsGeom;
typedef struct mjsSite_ { // site specification typedef struct mjsSite_ { // site specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// frame, size // frame, size
double pos[3]; // position double pos[3]; // position
@@ -313,27 +328,27 @@ typedef struct mjsSite_ { // site specification
// visual // visual
mjtGeom type; // geom type mjtGeom type; // geom type
mjString material; // name of material mjString* material; // name of material
int group; // group int group; // group
float rgba[4]; // rgba when material is omitted float rgba[4]; // rgba when material is omitted
// other // other
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsSite; } mjsSite;
typedef struct mjsCamera_ { // camera specification typedef struct mjsCamera_ { // camera specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// extrinsics // extrinsics
double pos[3]; // position double pos[3]; // position
double quat[4]; // orientation double quat[4]; // orientation
mjsOrientation alt; // alternative orientation mjsOrientation alt; // alternative orientation
mjtCamLight mode; // tracking mode mjtCamLight mode; // tracking mode
mjString targetbody; // target body for tracking/targeting mjString* targetbody; // target body for tracking/targeting
// intrinsics // intrinsics
double fovy; // y-field of view double fovy; // y-field of view
@@ -347,21 +362,21 @@ typedef struct mjsCamera_ { // camera specification
float principal_pixel[2]; // principal point (pixel) float principal_pixel[2]; // principal point (pixel)
// other // other
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsCamera; } mjsCamera;
typedef struct mjsLight_ { // light specification typedef struct mjsLight_ { // light specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// frame // frame
double pos[3]; // position double pos[3]; // position
double dir[3]; // direction double dir[3]; // direction
mjtCamLight mode; // tracking mode mjtCamLight mode; // tracking mode
mjString targetbody; // target body for targeting mjString* targetbody; // target body for targeting
// intrinsics // intrinsics
mjtByte active; // is light active mjtByte active; // is light active
@@ -376,14 +391,14 @@ typedef struct mjsLight_ { // light specification
float specular[3]; // specular color float specular[3]; // specular color
// other // other
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errorsx
} mjsLight; } mjsLight;
typedef struct mjsFlex_ { typedef struct mjsFlex_ {
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// contact properties // contact properties
int contype; // contact type int contype; // contact type
@@ -408,85 +423,85 @@ typedef struct mjsFlex_ {
double edgestiffness; // edge stiffness double edgestiffness; // edge stiffness
double edgedamping; // edge damping double edgedamping; // edge damping
float rgba[4]; // rgba when material is omitted float rgba[4]; // rgba when material is omitted
mjString material; // name of material used for rendering mjString* material; // name of material used for rendering
// mesh properties // mesh properties
mjStringVec vertbody; // vertex body names mjStringVec* vertbody; // vertex body names
mjDoubleVec vert; // vertex positions mjDoubleVec* vert; // vertex positions
mjIntVec elem; // element vertex ids mjIntVec* elem; // element vertex ids
mjFloatVec texcoord; // vertex texture coordinates mjFloatVec* texcoord; // vertex texture coordinates
// other // other
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsFlex; } mjsFlex;
typedef struct mjsMesh_ { // mesh specification typedef struct mjsMesh_ { // mesh specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjString content_type; // content type of file mjString* content_type; // content type of file
mjString file; // mesh file mjString* file; // mesh file
double refpos[3]; // reference position double refpos[3]; // reference position
double refquat[4]; // reference orientation double refquat[4]; // reference orientation
double scale[3]; // rescale mesh double scale[3]; // rescale mesh
mjtByte smoothnormal; // do not exclude large-angle faces from normals mjtByte smoothnormal; // do not exclude large-angle faces from normals
mjFloatVec uservert; // user vertex data mjFloatVec* uservert; // user vertex data
mjFloatVec usernormal; // user normal data mjFloatVec* usernormal; // user normal data
mjFloatVec usertexcoord; // user texcoord data mjFloatVec* usertexcoord; // user texcoord data
mjIntVec userface; // user vertex indices mjIntVec* userface; // user vertex indices
mjIntVec userfacenormal; // user normal indices mjIntVec* userfacenormal; // user normal indices
mjIntVec userfacetexcoord; // user texcoord indices mjIntVec* userfacetexcoord; // user texcoord indices
mjsPlugin plugin; // sdf plugin mjsPlugin plugin; // sdf plugin
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsMesh; } mjsMesh;
typedef struct mjsHField_ { // height field specification typedef struct mjsHField_ { // height field specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString content_type; // content type of file mjString* content_type; // content type of file
mjString file; // file: (nrow, ncol, [elevation data]) mjString* file; // file: (nrow, ncol, [elevation data])
double size[4]; // hfield size (ignore referencing geom size) double size[4]; // hfield size (ignore referencing geom size)
int nrow; // number of rows int nrow; // number of rows
int ncol; // number of columns int ncol; // number of columns
mjFloatVec userdata; // user-provided elevation data mjFloatVec* userdata; // user-provided elevation data
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsHField; } mjsHField;
typedef struct mjsSkin_ { // skin specification typedef struct mjsSkin_ { // skin specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjString file; // skin file mjString* file; // skin file
mjString material; // name of material used for rendering mjString* material; // name of material used for rendering
float rgba[4]; // rgba when material is omitted float rgba[4]; // rgba when material is omitted
float inflate; // inflate in normal direction float inflate; // inflate in normal direction
int group; // group for visualization int group; // group for visualization
// mesh // mesh
mjFloatVec vert; // vertex positions mjFloatVec* vert; // vertex positions
mjFloatVec texcoord; // texture coordinates mjFloatVec* texcoord; // texture coordinates
mjIntVec face; // faces mjIntVec* face; // faces
// skin // skin
mjStringVec bodyname; // body names mjStringVec* bodyname; // body names
mjFloatVec bindpos; // bind pos mjFloatVec* bindpos; // bind pos
mjFloatVec bindquat; // bind quat mjFloatVec* bindquat; // bind quat
mjIntVecVec vertid; // vertex ids mjIntVecVec* vertid; // vertex ids
mjFloatVecVec vertweight; // vertex weights mjFloatVecVec* vertweight; // vertex weights
// other // other
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsSkin; } mjsSkin;
typedef struct mjsTexture_ { // texture specification typedef struct mjsTexture_ { // texture specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjtTexture type; // texture type mjtTexture type; // texture type
// method 1: builtin // method 1: builtin
@@ -500,28 +515,28 @@ typedef struct mjsTexture_ { // texture specification
int width; // width in pixels int width; // width in pixels
// method 2: single file // method 2: single file
mjString content_type; // content type of file mjString* content_type; // content type of file
mjString file; // png file to load; use for all sides of cube mjString* file; // png file to load; use for all sides of cube
int gridsize[2]; // size of grid for composite file; (1,1)-repeat int gridsize[2]; // size of grid for composite file; (1,1)-repeat
char gridlayout[13]; // row-major: L,R,F,B,U,D for faces; . for unused char gridlayout[13]; // row-major: L,R,F,B,U,D for faces; . for unused
// method 3: separate files // method 3: separate files
mjStringVec cubefiles; // different file for each side of the cube mjStringVec* cubefiles; // different file for each side of the cube
// flip options // flip options
mjtByte hflip; // horizontal flip mjtByte hflip; // horizontal flip
mjtByte vflip; // vertical flip mjtByte vflip; // vertical flip
// other // other
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsTexture; } mjsTexture;
typedef struct mjsMaterial_ { // material specification typedef struct mjsMaterial_ { // material specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjString texture; // name of texture (empty: none) mjString* texture; // name of texture (empty: none)
mjtByte texuniform; // make texture cube uniform mjtByte texuniform; // make texture cube uniform
float texrepeat[2]; // texture repetition for 2D mapping float texrepeat[2]; // texture repetition for 2D mapping
float emission; // emission float emission; // emission
@@ -531,16 +546,16 @@ typedef struct mjsMaterial_ { // material specification
float metallic; // metallic float metallic; // metallic
float roughness; // roughness float roughness; // roughness
float rgba[4]; // rgba float rgba[4]; // rgba
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsMaterial; } mjsMaterial;
typedef struct mjsPair_ { typedef struct mjsPair_ {
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjString geomname1; // name of geom 1 mjString* geomname1; // name of geom 1
mjString geomname2; // name of geom 2 mjString* geomname2; // name of geom 2
// optional parameters: computed from geoms if not set by user // optional parameters: computed from geoms if not set by user
int condim; // contact dimensionality int condim; // contact dimensionality
@@ -550,38 +565,38 @@ typedef struct mjsPair_ {
double margin; // margin for contact detection double margin; // margin for contact detection
double gap; // include in solver if dist<margin-gap double gap; // include in solver if dist<margin-gap
double friction[5]; // full contact friction double friction[5]; // full contact friction
mjString info; // message appended to errors mjString* info; // message appended to errors
} mjsPair; } mjsPair;
typedef struct mjsExclude_ { typedef struct mjsExclude_ {
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString bodyname1; // name of geom 1 mjString* bodyname1; // name of geom 1
mjString bodyname2; // name of geom 2 mjString* bodyname2; // name of geom 2
mjString info; // message appended to errors mjString* info; // message appended to errors
} mjsExclude; } mjsExclude;
typedef struct mjsEquality_ { // equality specification typedef struct mjsEquality_ { // equality specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
mjtEq type; // constraint type mjtEq type; // constraint type
double data[mjNEQDATA]; // type-dependent data double data[mjNEQDATA]; // type-dependent data
mjtByte active; // is equality initially active mjtByte active; // is equality initially active
mjString name1; // name of object 1 mjString* name1; // name of object 1
mjString name2; // name of object 2 mjString* name2; // name of object 2
mjtNum solref[mjNREF]; // solver reference mjtNum solref[mjNREF]; // solver reference
mjtNum solimp[mjNIMP]; // solver impedance mjtNum solimp[mjNIMP]; // solver impedance
mjString info; // message appended to errors mjString* info; // message appended to errors
} mjsEquality; } mjsEquality;
typedef struct mjsTendon_ { // tendon specification typedef struct mjsTendon_ { // tendon specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// stiffness, damping, friction // stiffness, damping, friction
double stiffness; // stiffness coefficient double stiffness; // stiffness coefficient
@@ -599,27 +614,27 @@ typedef struct mjsTendon_ { // tendon specification
mjtNum solimp_limit[mjNIMP]; // solver impedance: tendon limits mjtNum solimp_limit[mjNIMP]; // solver impedance: tendon limits
// visual // visual
mjString material; // name of material for rendering mjString* material; // name of material for rendering
double width; // width for rendering double width; // width for rendering
float rgba[4]; // rgba when material is omitted float rgba[4]; // rgba when material is omitted
int group; // group int group; // group
// other // other
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjString info; // message appended to errors mjString* info; // message appended to errors
} mjsTendon; } mjsTendon;
typedef struct mjsWrap_ { // wrapping object specification typedef struct mjsWrap_ { // wrapping object specification
mjElement* element; // element type mjElement* element; // element type
mjString info; // message appended to errors mjString* info; // message appended to errors
} mjsWrap; } mjsWrap;
typedef struct mjsActuator_ { // actuator specification typedef struct mjsActuator_ { // actuator specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// gain, bias // gain, bias
mjtGain gaintype; // gain type mjtGain gaintype; // gain type
@@ -637,9 +652,9 @@ typedef struct mjsActuator_ { // actuator specification
// transmission // transmission
mjtTrn trntype; // transmission type mjtTrn trntype; // transmission type
double gear[6]; // length and transmitted force scaling double gear[6]; // length and transmitted force scaling
mjString target; // name of transmission target mjString* target; // name of transmission target
mjString refsite; // reference site, for site transmission mjString* refsite; // reference site, for site transmission
mjString slidersite; // site defining cylinder, for slider-crank mjString* slidersite; // site defining cylinder, for slider-crank
double cranklength; // crank length, for slider-crank double cranklength; // crank length, for slider-crank
double lengthrange[2]; // transmission length range double lengthrange[2]; // transmission length range
double inheritrange; // automatic range setting for position and intvelocity double inheritrange; // automatic range setting for position and intvelocity
@@ -654,23 +669,23 @@ typedef struct mjsActuator_ { // actuator specification
// other // other
int group; // group int group; // group
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjsPlugin plugin; // actuator plugin mjsPlugin plugin; // actuator plugin
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsActuator; } mjsActuator;
typedef struct mjsSensor_ { // sensor specification typedef struct mjsSensor_ { // sensor specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString classname; // class name mjString* classname; // class name
// sensor defintion // sensor defintion
mjtSensor type; // type of sensor mjtSensor type; // type of sensor
mjtObj objtype; // type of sensorized object mjtObj objtype; // type of sensorized object
mjString objname; // name of sensorized object mjString* objname; // name of sensorized object
mjtObj reftype; // type of referenced object mjtObj reftype; // type of referenced object
mjString refname; // name of referenced object mjString* refname; // name of referenced object
// user-defined sensors // user-defined sensors
mjtDataType datatype; // data type for sensor measurement mjtDataType datatype; // data type for sensor measurement
@@ -682,56 +697,56 @@ typedef struct mjsSensor_ { // sensor specification
double noise; // noise stdev double noise; // noise stdev
// other // other
mjDoubleVec userdata; // user data mjDoubleVec* userdata; // user data
mjsPlugin plugin; // sensor plugin mjsPlugin plugin; // sensor plugin
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsSensor; } mjsSensor;
typedef struct mjsNumeric_ { // custom numeric field specification typedef struct mjsNumeric_ { // custom numeric field specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjDoubleVec data; // initialization data mjDoubleVec* data; // initialization data
int size; // array size, can be bigger than data size int size; // array size, can be bigger than data size
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsNumeric; } mjsNumeric;
typedef struct mjsText_ { // custom text specification typedef struct mjsText_ { // custom text specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjString data; // text string mjString* data; // text string
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsText; } mjsText;
typedef struct mjsTuple_ { // tuple specification typedef struct mjsTuple_ { // tuple specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
mjIntVec objtype; // object types mjIntVec* objtype; // object types
mjStringVec objname; // object names mjStringVec* objname; // object names
mjDoubleVec objprm; // object parameters mjDoubleVec* objprm; // object parameters
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsTuple; } mjsTuple;
typedef struct mjsKey_ { // keyframe specification typedef struct mjsKey_ { // keyframe specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // name mjString* name; // name
double time; // time double time; // time
mjDoubleVec qpos; // qpos mjDoubleVec* qpos; // qpos
mjDoubleVec qvel; // qvel mjDoubleVec* qvel; // qvel
mjDoubleVec act; // act mjDoubleVec* act; // act
mjDoubleVec mpos; // mocap pos mjDoubleVec* mpos; // mocap pos
mjDoubleVec mquat; // mocap quat mjDoubleVec* mquat; // mocap quat
mjDoubleVec ctrl; // ctrl mjDoubleVec* ctrl; // ctrl
mjString info; // message appended to compiler errors mjString* info; // message appended to compiler errors
} mjsKey; } mjsKey;
typedef struct mjsDefault_ { // default specification typedef struct mjsDefault_ { // default specification
mjElement* element; // element type mjElement* element; // element type
mjString name; // class name mjString* name; // class name
mjsJoint* joint; // joint defaults mjsJoint* joint; // joint defaults
mjsGeom* geom; // geom defaults mjsGeom* geom; // geom defaults
mjsSite* site; // site defaults mjsSite* site; // site defaults
@@ -932,31 +947,31 @@ MJAPI mjElement* mjs_nextChild(mjsBody* body, mjElement* child);
//---------------------------------- Attribute setters --------------------------------------------- //---------------------------------- Attribute setters ---------------------------------------------
// Copy text to string. // Copy text to string.
MJAPI void mjs_setString(mjString dest, const char* text); MJAPI void mjs_setString(mjString* dest, const char* text);
// Split text to entries and copy to string vector. // Split text to entries and copy to string vector.
MJAPI void mjs_setStringVec(mjStringVec dest, const char* text); MJAPI void mjs_setStringVec(mjStringVec* dest, const char* text);
// Set entry in string vector. // Set entry in string vector.
MJAPI mjtByte mjs_setInStringVec(mjStringVec dest, int i, const char* text); MJAPI mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
// Append text entry to string vector. // Append text entry to string vector.
MJAPI void mjs_appendString(mjStringVec dest, const char* text); MJAPI void mjs_appendString(mjStringVec* dest, const char* text);
// Copy int array to vector. // Copy int array to vector.
MJAPI void mjs_setInt(mjIntVec dest, const int* array, int size); MJAPI void mjs_setInt(mjIntVec* dest, const int* array, int size);
// Append int array to vector of arrays. // Append int array to vector of arrays.
MJAPI void mjs_appendIntVec(mjIntVecVec dest, const int* array, int size); MJAPI void mjs_appendIntVec(mjIntVecVec* dest, const int* array, int size);
// Copy float array to vector. // Copy float array to vector.
MJAPI void mjs_setFloat(mjFloatVec dest, const float* array, int size); MJAPI void mjs_setFloat(mjFloatVec* dest, const float* array, int size);
// Append float array to vector of arrays. // Append float array to vector of arrays.
MJAPI void mjs_appendFloatVec(mjFloatVecVec dest, const float* array, int size); MJAPI void mjs_appendFloatVec(mjFloatVecVec* dest, const float* array, int size);
// Copy double array to vector. // Copy double array to vector.
MJAPI void mjs_setDouble(mjDoubleVec dest, const double* array, int size); MJAPI void mjs_setDouble(mjDoubleVec* dest, const double* array, int size);
// Set plugin attributes. // Set plugin attributes.
MJAPI void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes); MJAPI void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
@@ -965,10 +980,10 @@ MJAPI void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
//---------------------------------- Attribute getters --------------------------------------------- //---------------------------------- Attribute getters ---------------------------------------------
// Get string contents. // Get string contents.
MJAPI const char* mjs_getString(mjString source); MJAPI const char* mjs_getString(const mjString* source);
// Get double array contents and optionally its size. // Get double array contents and optionally its size.
MJAPI const double* mjs_getDouble(mjDoubleVec source, int* size); MJAPI const double* mjs_getDouble(const mjDoubleVec* source, int* size);
//---------------------------------- Other utilities ----------------------------------------------- //---------------------------------- Other utilities -----------------------------------------------
@@ -1079,7 +1094,7 @@ MJAPI void mj_setCacheSize(mjCache cache, size_t size);
MJAPI mjCache mj_globalCache(void); MJAPI mjCache mj_globalCache(void);
#ifdef __cplusplus #ifdef __cplusplus
} } // extern "C"
#endif #endif
#endif // MUJOCO_SRC_USER_USER_API_H_ #endif // MUJOCO_SRC_USER_USER_API_H_
+2 -2
View File
@@ -69,8 +69,8 @@ mjCComposite::mjCComposite(void) {
mjs_defaultPlugin(&plugin); mjs_defaultPlugin(&plugin);
plugin_name = ""; plugin_name = "";
plugin_instance_name = ""; plugin_instance_name = "";
plugin.name = (mjString)&plugin_name; plugin.name = (mjString*)&plugin_name;
plugin.instance_name = (mjString)&plugin_instance_name; plugin.instance_name = (mjString*)&plugin_instance_name;
// cable // cable
curve[0] = curve[1] = curve[2] = mjCOMPSHAPE_ZERO; curve[0] = curve[1] = curve[2] = mjCOMPSHAPE_ZERO;
+2 -2
View File
@@ -91,8 +91,8 @@ mjCFlexcomp::mjCFlexcomp(void) {
mjs_defaultOrientation(&alt); mjs_defaultOrientation(&alt);
plugin_name = ""; plugin_name = "";
plugin_instance_name = ""; plugin_instance_name = "";
plugin.name = (mjString)&plugin_name; plugin.name = (mjString*)&plugin_name;
plugin.instance_name = (mjString)&plugin_instance_name; plugin.instance_name = (mjString*)&plugin_instance_name;
} }
+56 -56
View File
@@ -196,18 +196,18 @@ mjCMesh& mjCMesh::operator=(const mjCMesh& other) {
void mjCMesh::PointToLocal() { void mjCMesh::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.file = (mjString)&spec_file_; spec.file = &spec_file_;
spec.content_type = (mjString)&spec_content_type_; spec.content_type = &spec_content_type_;
spec.uservert = (mjFloatVec)&spec_vert_; spec.uservert = &spec_vert_;
spec.usernormal = (mjFloatVec)&spec_normal_; spec.usernormal = &spec_normal_;
spec.userface = (mjIntVec)&spec_face_; spec.userface = &spec_face_;
spec.usertexcoord = (mjFloatVec)&spec_texcoord_; spec.usertexcoord = &spec_texcoord_;
spec.userfacetexcoord = (mjIntVec)&spec_facetexcoord_; spec.userfacetexcoord = &spec_facetexcoord_;
spec.plugin.name = (mjString)&plugin_name; spec.plugin.name = &plugin_name;
spec.plugin.instance_name = (mjString)&plugin_instance_name; spec.plugin.instance_name = &plugin_instance_name;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -221,13 +221,13 @@ void mjCMesh::CopyFromSpec() {
face_ = spec_face_; face_ = spec_face_;
texcoord_ = spec_texcoord_; texcoord_ = spec_texcoord_;
facetexcoord_ = spec_facetexcoord_; facetexcoord_ = spec_facetexcoord_;
file = (mjString)&file_; file = &file_;
content_type = (mjString)&content_type_; content_type = &content_type_;
uservert = (mjFloatVec)&vert_; uservert = &vert_;
usernormal = (mjFloatVec)&normal_; usernormal = &normal_;
userface = (mjIntVec)&face_; userface = &face_;
usertexcoord = (mjFloatVec)&texcoord_; usertexcoord = &texcoord_;
userfacetexcoord = (mjIntVec)&facetexcoord_; userfacetexcoord = &facetexcoord_;
plugin.active = spec.plugin.active; plugin.active = spec.plugin.active;
plugin.instance = spec.plugin.instance; plugin.instance = spec.plugin.instance;
plugin.name = spec.plugin.name; plugin.name = spec.plugin.name;
@@ -1979,19 +1979,19 @@ mjCSkin& mjCSkin::operator=(const mjCSkin& other) {
void mjCSkin::PointToLocal() { void mjCSkin::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.file = (mjString)&spec_file_; spec.file = &spec_file_;
spec.material = (mjString)&spec_material_; spec.material = &spec_material_;
spec.vert = (mjFloatVec)&spec_vert_; spec.vert = &spec_vert_;
spec.texcoord = (mjFloatVec)&spec_texcoord_; spec.texcoord = &spec_texcoord_;
spec.face = (mjIntVec)&spec_face_; spec.face = &spec_face_;
spec.bodyname = (mjStringVec)&spec_bodyname_; spec.bodyname = &spec_bodyname_;
spec.bindpos = (mjFloatVec)&spec_bindpos_; spec.bindpos = &spec_bindpos_;
spec.bindquat = (mjFloatVec)&spec_bindquat_; spec.bindquat = &spec_bindquat_;
spec.vertid = (mjIntVecVec)&spec_vertid_; spec.vertid = &spec_vertid_;
spec.vertweight = (mjFloatVecVec)&spec_vertweight_; spec.vertweight = &spec_vertweight_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -2016,16 +2016,16 @@ void mjCSkin::CopyFromSpec() {
bindquat_ = spec_bindquat_; bindquat_ = spec_bindquat_;
vertid_ = spec_vertid_; vertid_ = spec_vertid_;
vertweight_ = spec_vertweight_; vertweight_ = spec_vertweight_;
file = (mjString)&spec_file_; file = &spec_file_;
material = (mjString)&spec_material_; material = &spec_material_;
vert = (mjFloatVec)&spec_vert_; vert = &spec_vert_;
texcoord = (mjFloatVec)&spec_texcoord_; texcoord = &spec_texcoord_;
face = (mjIntVec)&spec_face_; face = &spec_face_;
bodyname = (mjStringVec)&spec_bodyname_; bodyname = &spec_bodyname_;
bindpos = (mjFloatVec)&spec_bindpos_; bindpos = &spec_bindpos_;
bindquat = (mjFloatVec)&spec_bindquat_; bindquat = &spec_bindquat_;
vertid = (mjIntVecVec)&spec_vertid_; vertid = &spec_vertid_;
vertweight = (mjFloatVecVec)&spec_vertweight_; vertweight = &spec_vertweight_;
} }
@@ -2391,14 +2391,14 @@ mjCFlex& mjCFlex::operator=(const mjCFlex& other) {
void mjCFlex::PointToLocal() { void mjCFlex::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.material = (mjString)&spec_material_; spec.material = &spec_material_;
spec.vertbody = (mjStringVec)&spec_vertbody_; spec.vertbody = &spec_vertbody_;
spec.vert = (mjDoubleVec)&spec_vert_; spec.vert = &spec_vert_;
spec.texcoord = (mjFloatVec)&spec_texcoord_; spec.texcoord = &spec_texcoord_;
spec.elem = (mjIntVec)&spec_elem_; spec.elem = &spec_elem_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -2413,17 +2413,17 @@ void mjCFlex::NameSpace(const mjCModel* m) {
void mjCFlex::CopyFromSpec() { void mjCFlex::CopyFromSpec() {
*static_cast<mjsFlex*>(this) = spec; *static_cast<mjsFlex*>(this) = spec;
spec.info = (mjString)&info; spec.info = &info;
material_ = spec_material_; material_ = spec_material_;
vertbody_ = spec_vertbody_; vertbody_ = spec_vertbody_;
vert_ = spec_vert_; vert_ = spec_vert_;
texcoord_ = spec_texcoord_; texcoord_ = spec_texcoord_;
elem_ = spec_elem_; elem_ = spec_elem_;
material = (mjString)&material_; material = &material_;
vertbody = (mjStringVec)&vertbody_; vertbody = &vertbody_;
vert = (mjDoubleVec)&vert_; vert = &vert_;
texcoord = (mjFloatVec)&texcoord_; texcoord = &texcoord_;
elem = (mjIntVec)&elem_; elem = &elem_;
// clear precompiled asset. TODO: use asset cache // clear precompiled asset. TODO: use asset cache
nedge = 0; nedge = 0;
+10 -10
View File
@@ -417,11 +417,11 @@ void mjCModel::CreateObjectLists() {
void mjCModel::PointToLocal() { void mjCModel::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.comment = (mjString)&spec_comment_; spec.comment = &spec_comment_;
spec.modelfiledir = (mjString)&spec_modelfiledir_; spec.modelfiledir = &spec_modelfiledir_;
spec.modelname = (mjString)&spec_modelname_; spec.modelname = &spec_modelname_;
spec.meshdir = (mjString)&spec_meshdir_; spec.meshdir = &spec_meshdir_;
spec.texturedir = (mjString)&spec_texturedir_; spec.texturedir = &spec_texturedir_;
} }
@@ -433,11 +433,11 @@ void mjCModel::CopyFromSpec() {
modelname_ = spec_modelname_; modelname_ = spec_modelname_;
meshdir_ = spec_meshdir_; meshdir_ = spec_meshdir_;
texturedir_ = spec_texturedir_; texturedir_ = spec_texturedir_;
comment = (mjString)&comment_; comment = &comment_;
modelfiledir = (mjString)&modelfiledir_; modelfiledir = &modelfiledir_;
modelname = (mjString)&modelname_; modelname = &modelname_;
meshdir = (mjString)&meshdir_; meshdir = &meshdir_;
texturedir = (mjString)&texturedir_; texturedir = &texturedir_;
} }
+155 -155
View File
@@ -641,7 +641,7 @@ void mjCDef::PointToLocal() {
tendon_.PointToLocal(); tendon_.PointToLocal();
actuator_.PointToLocal(); actuator_.PointToLocal();
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.joint = &joint_.spec; spec.joint = &joint_.spec;
spec.geom = &geom_.spec; spec.geom = &geom_.spec;
spec.site = &site_.spec; spec.site = &site_.spec;
@@ -950,19 +950,19 @@ mjCBody& mjCBody::operator-=(const mjCBody& subtree) {
void mjCBody::PointToLocal() { void mjCBody::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.childclass = (mjString)&classname; spec.childclass = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.plugin.name = (mjString)&plugin_name; spec.plugin.name = &plugin_name;
spec.plugin.instance_name = (mjString)&plugin_instance_name; spec.plugin.instance_name = (&plugin_instance_name);
spec.info = (mjString)&info; spec.info = &info;
} }
void mjCBody::CopyFromSpec() { void mjCBody::CopyFromSpec() {
*static_cast<mjsBody*>(this) = spec; *static_cast<mjsBody*>(this) = spec;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
plugin.active = spec.plugin.active; plugin.active = spec.plugin.active;
plugin.instance = spec.plugin.instance; plugin.instance = spec.plugin.instance;
plugin.name = spec.plugin.name; plugin.name = spec.plugin.name;
@@ -1670,9 +1670,9 @@ void mjCFrame::SetParent(mjCBody* _body) {
void mjCFrame::PointToLocal() { void mjCFrame::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.childclass = (mjString)&classname; spec.childclass = &classname;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -1766,10 +1766,10 @@ bool mjCJoint::is_actfrclimited() const { return islimited(actfrclimited, actfrc
void mjCJoint::PointToLocal() { void mjCJoint::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -1777,7 +1777,7 @@ void mjCJoint::PointToLocal() {
void mjCJoint::CopyFromSpec() { void mjCJoint::CopyFromSpec() {
*static_cast<mjsJoint*>(this) = spec; *static_cast<mjsJoint*>(this) = spec;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
userdata = (mjDoubleVec)&spec_userdata_; userdata = &spec_userdata_;
} }
@@ -1966,15 +1966,15 @@ mjCGeom& mjCGeom::operator=(const mjCGeom& other) {
// to be called after any default copy constructor // to be called after any default copy constructor
void mjCGeom::PointToLocal(void) { void mjCGeom::PointToLocal(void) {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.info = (mjString)&info; spec.info = &info;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.material = (mjString)&spec_material_; spec.material = &spec_material_;
spec.meshname = (mjString)&spec_meshname_; spec.meshname = &spec_meshname_;
spec.hfieldname = (mjString)&spec_hfieldname_; spec.hfieldname = &spec_hfieldname_;
spec.plugin.name = (mjString)&plugin_name; spec.plugin.name = &plugin_name;
spec.plugin.instance_name = (mjString)&plugin_instance_name; spec.plugin.instance_name = &plugin_instance_name;
} }
@@ -1985,10 +1985,10 @@ void mjCGeom::CopyFromSpec() {
hfieldname_ = spec_hfieldname_; hfieldname_ = spec_hfieldname_;
meshname_ = spec_meshname_; meshname_ = spec_meshname_;
material_ = spec_material_; material_ = spec_material_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
hfieldname = (mjString)&hfieldname_; hfieldname = &hfieldname_;
meshname = (mjString)&meshname_; meshname = &meshname_;
material = (mjString)&material_; material = &material_;
plugin.active = spec.plugin.active; plugin.active = spec.plugin.active;
plugin.instance = spec.plugin.instance; plugin.instance = spec.plugin.instance;
plugin.name = spec.plugin.name; plugin.name = spec.plugin.name;
@@ -2599,11 +2599,11 @@ mjCSite& mjCSite::operator=(const mjCSite& other) {
void mjCSite::PointToLocal() { void mjCSite::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.info = (mjString)&info; spec.info = &info;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.material = (mjString)&spec_material_; spec.material = &spec_material_;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
} }
@@ -2612,8 +2612,8 @@ void mjCSite::CopyFromSpec() {
*static_cast<mjsSite*>(this) = spec; *static_cast<mjsSite*>(this) = spec;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
material_ = spec_material_; material_ = spec_material_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
material = (mjString)&material_; material = &material_;
} }
@@ -2751,11 +2751,11 @@ mjCCamera& mjCCamera::operator=(const mjCCamera& other) {
void mjCCamera::PointToLocal() { void mjCCamera::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.targetbody = (mjString)&spec_targetbody_; spec.targetbody = &spec_targetbody_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -2775,8 +2775,8 @@ void mjCCamera::CopyFromSpec() {
*static_cast<mjsCamera*>(this) = spec; *static_cast<mjsCamera*>(this) = spec;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
targetbody_ = spec_targetbody_; targetbody_ = spec_targetbody_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
targetbody = (mjString)&targetbody_; targetbody = &targetbody_;
} }
@@ -2902,10 +2902,10 @@ mjCLight& mjCLight::operator=(const mjCLight& other) {
void mjCLight::PointToLocal() { void mjCLight::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.targetbody = (mjString)&spec_targetbody_; spec.targetbody = &spec_targetbody_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -2924,7 +2924,7 @@ void mjCLight::NameSpace(const mjCModel* m) {
void mjCLight::CopyFromSpec() { void mjCLight::CopyFromSpec() {
*static_cast<mjsLight*>(this) = spec; *static_cast<mjsLight*>(this) = spec;
targetbody_ = spec_targetbody_; targetbody_ = spec_targetbody_;
targetbody = (mjString)&targetbody_; targetbody = &targetbody_;
} }
@@ -3002,11 +3002,11 @@ mjCHField& mjCHField::operator=(const mjCHField& other) {
void mjCHField::PointToLocal() { void mjCHField::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.file = (mjString)&spec_file_; spec.file = &spec_file_;
spec.content_type = (mjString)&spec_content_type_; spec.content_type = &spec_content_type_;
spec.userdata = (mjFloatVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -3016,9 +3016,9 @@ void mjCHField::CopyFromSpec() {
file_ = spec_file_; file_ = spec_file_;
content_type_ = spec_content_type_; content_type_ = spec_content_type_;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
file = (mjString)&file_; file = &file_;
content_type = (mjString)&content_type_; content_type = &content_type_;
userdata = (mjFloatVec)&userdata_; userdata = &userdata_;
// clear precompiled asset. TODO: use asset cache // clear precompiled asset. TODO: use asset cache
data.clear(); data.clear();
@@ -3231,12 +3231,12 @@ mjCTexture& mjCTexture::operator=(const mjCTexture& other) {
void mjCTexture::PointToLocal() { void mjCTexture::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.file = (mjString)&spec_file_; spec.file = &spec_file_;
spec.content_type = (mjString)&spec_content_type_; spec.content_type = &spec_content_type_;
spec.cubefiles = (mjStringVec)&spec_cubefiles_; spec.cubefiles = &spec_cubefiles_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -3246,9 +3246,9 @@ void mjCTexture::CopyFromSpec() {
file_ = spec_file_; file_ = spec_file_;
content_type_ = spec_content_type_; content_type_ = spec_content_type_;
cubefiles_ = spec_cubefiles_; cubefiles_ = spec_cubefiles_;
file = (mjString)&file_; file = &file_;
content_type = (mjString)&content_type_; content_type = &content_type_;
cubefiles = (mjStringVec)&cubefiles_; cubefiles = &cubefiles_;
// clear precompiled asset. TODO: use asset cache // clear precompiled asset. TODO: use asset cache
rgb.clear(); rgb.clear();
@@ -3942,10 +3942,10 @@ mjCMaterial& mjCMaterial::operator=(const mjCMaterial& other) {
void mjCMaterial::PointToLocal() { void mjCMaterial::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.texture = (mjString)&spec_texture_; spec.texture = &spec_texture_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -3953,7 +3953,7 @@ void mjCMaterial::PointToLocal() {
void mjCMaterial::CopyFromSpec() { void mjCMaterial::CopyFromSpec() {
*static_cast<mjsMaterial*>(this) = spec; *static_cast<mjsMaterial*>(this) = spec;
texture_ = spec_texture_; texture_ = spec_texture_;
texture = (mjString)&texture_; texture = &texture_;
} }
@@ -4032,11 +4032,11 @@ mjCPair& mjCPair::operator=(const mjCPair& other) {
void mjCPair::PointToLocal() { void mjCPair::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.geomname1 = (mjString)&spec_geomname1_; spec.geomname1 = &spec_geomname1_;
spec.geomname2 = (mjString)&spec_geomname2_; spec.geomname2 = &spec_geomname2_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -4055,8 +4055,8 @@ void mjCPair::CopyFromSpec() {
*static_cast<mjsPair*>(this) = spec; *static_cast<mjsPair*>(this) = spec;
geomname1_ = spec_geomname1_; geomname1_ = spec_geomname1_;
geomname2_ = spec_geomname2_; geomname2_ = spec_geomname2_;
geomname1 = (mjString)&geomname1_; geomname1 = &geomname1_;
geomname2 = (mjString)&geomname2_; geomname2 = &geomname2_;
} }
@@ -4257,10 +4257,10 @@ mjCBodyPair& mjCBodyPair::operator=(const mjCBodyPair& other) {
void mjCBodyPair::PointToLocal() { void mjCBodyPair::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.bodyname1 = (mjString)&spec_bodyname1_; spec.bodyname1 = &spec_bodyname1_;
spec.bodyname2 = (mjString)&spec_bodyname2_; spec.bodyname2 = &spec_bodyname2_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -4279,8 +4279,8 @@ void mjCBodyPair::CopyFromSpec() {
*static_cast<mjsExclude*>(this) = spec; *static_cast<mjsExclude*>(this) = spec;
bodyname1_ = spec_bodyname1_; bodyname1_ = spec_bodyname1_;
bodyname2_ = spec_bodyname2_; bodyname2_ = spec_bodyname2_;
bodyname1 = (mjString)&bodyname1_; bodyname1 = &bodyname1_;
bodyname2 = (mjString)&bodyname2_; bodyname2 = &bodyname2_;
} }
@@ -4391,11 +4391,11 @@ mjCEquality& mjCEquality::operator=(const mjCEquality& other) {
void mjCEquality::PointToLocal() { void mjCEquality::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.name1 = (mjString)&spec_name1_; spec.name1 = &spec_name1_;
spec.name2 = (mjString)&spec_name2_; spec.name2 = &spec_name2_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -4414,8 +4414,8 @@ void mjCEquality::CopyFromSpec() {
*static_cast<mjsEquality*>(this) = spec; *static_cast<mjsEquality*>(this) = spec;
name1_ = spec_name1_; name1_ = spec_name1_;
name2_ = spec_name2_; name2_ = spec_name2_;
name1 = (mjString)&name1_; name1 = &name1_;
name2 = (mjString)&name2_; name2 = &name2_;
} }
@@ -4560,11 +4560,11 @@ bool mjCTendon::is_limited() const { return islimited(limited, range); }
void mjCTendon::PointToLocal() { void mjCTendon::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.material = (mjString)&spec_material_; spec.material = &spec_material_;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -4583,8 +4583,8 @@ void mjCTendon::CopyFromSpec() {
*static_cast<mjsTendon*>(this) = spec; *static_cast<mjsTendon*>(this) = spec;
material_ = spec_material_; material_ = spec_material_;
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
material = (mjString)&material_; material = &material_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
// clear precompiled // clear precompiled
for (int i=0; i<path.size(); i++) { for (int i=0; i<path.size(); i++) {
@@ -4892,7 +4892,7 @@ mjCWrap& mjCWrap::operator=(const mjCWrap& other) {
void mjCWrap::PointToLocal() { void mjCWrap::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -5041,15 +5041,15 @@ bool mjCActuator::is_actlimited() const { return islimited(actlimited, actrange)
void mjCActuator::PointToLocal() { void mjCActuator::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.target = (mjString)&spec_target_; spec.target = &spec_target_;
spec.refsite = (mjString)&spec_refsite_; spec.refsite = &spec_refsite_;
spec.slidersite = (mjString)&spec_slidersite_; spec.slidersite = &spec_slidersite_;
spec.plugin.name = (mjString)&plugin_name; spec.plugin.name = &plugin_name;
spec.plugin.instance_name = (mjString)&plugin_instance_name; spec.plugin.instance_name = &plugin_instance_name;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -5071,10 +5071,10 @@ void mjCActuator::CopyFromSpec() {
target_ = spec_target_; target_ = spec_target_;
refsite_ = spec_refsite_; refsite_ = spec_refsite_;
slidersite_ = spec_slidersite_; slidersite_ = spec_slidersite_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
target = (mjString)&target_; target = &target_;
refsite = (mjString)&refsite_; refsite = &refsite_;
slidersite = (mjString)&slidersite_; slidersite = &slidersite_;
plugin.active = spec.plugin.active; plugin.active = spec.plugin.active;
plugin.instance = spec.plugin.instance; plugin.instance = spec.plugin.instance;
plugin.name = spec.plugin.name; plugin.name = spec.plugin.name;
@@ -5364,14 +5364,14 @@ mjCSensor& mjCSensor::operator=(const mjCSensor& other) {
void mjCSensor::PointToLocal() { void mjCSensor::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.classname = (mjString)&classname; spec.classname = &classname;
spec.userdata = (mjDoubleVec)&spec_userdata_; spec.userdata = &spec_userdata_;
spec.objname = (mjString)&spec_objname_; spec.objname = &spec_objname_;
spec.refname = (mjString)&spec_refname_; spec.refname = &spec_refname_;
spec.plugin.name = (mjString)&plugin_name; spec.plugin.name = &plugin_name;
spec.plugin.instance_name = (mjString)&plugin_instance_name; spec.plugin.instance_name = &plugin_instance_name;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -5391,9 +5391,9 @@ void mjCSensor::CopyFromSpec() {
userdata_ = spec_userdata_; userdata_ = spec_userdata_;
objname_ = spec_objname_; objname_ = spec_objname_;
refname_ = spec_refname_; refname_ = spec_refname_;
userdata = (mjDoubleVec)&userdata_; userdata = &userdata_;
objname = (mjString)&objname_; objname = &objname_;
refname = (mjString)&refname_; refname = &refname_;
plugin.active = spec.plugin.active; plugin.active = spec.plugin.active;
plugin.instance = spec.plugin.instance; plugin.instance = spec.plugin.instance;
plugin.name = spec.plugin.name; plugin.name = spec.plugin.name;
@@ -5867,9 +5867,9 @@ mjCNumeric& mjCNumeric::operator=(const mjCNumeric& other) {
void mjCNumeric::PointToLocal() { void mjCNumeric::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.data = (mjDoubleVec)&spec_data_; spec.data = &spec_data_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -5877,7 +5877,7 @@ void mjCNumeric::PointToLocal() {
void mjCNumeric::CopyFromSpec() { void mjCNumeric::CopyFromSpec() {
*static_cast<mjsNumeric*>(this) = spec; *static_cast<mjsNumeric*>(this) = spec;
data_ = spec_data_; data_ = spec_data_;
data = (mjDoubleVec)&data_; data = &data_;
} }
@@ -5956,9 +5956,9 @@ mjCText& mjCText::operator=(const mjCText& other) {
void mjCText::PointToLocal() { void mjCText::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.data = (mjString)&spec_data_; spec.data = &spec_data_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -5966,7 +5966,7 @@ void mjCText::PointToLocal() {
void mjCText::CopyFromSpec() { void mjCText::CopyFromSpec() {
*static_cast<mjsText*>(this) = spec; *static_cast<mjsText*>(this) = spec;
data_ = spec_data_; data_ = spec_data_;
data = (mjString)&data_; data = &data_;
} }
@@ -6036,11 +6036,11 @@ mjCTuple& mjCTuple::operator=(const mjCTuple& other) {
void mjCTuple::PointToLocal() { void mjCTuple::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.objtype = (mjIntVec)&spec_objtype_; spec.objtype = (mjIntVec*)&spec_objtype_;
spec.objname = (mjStringVec)&spec_objname_; spec.objname = &spec_objname_;
spec.objprm = (mjDoubleVec)&spec_objprm_; spec.objprm = &spec_objprm_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -6061,9 +6061,9 @@ void mjCTuple::CopyFromSpec() {
objtype_ = spec_objtype_; objtype_ = spec_objtype_;
objname_ = spec_objname_; objname_ = spec_objname_;
objprm_ = spec_objprm_; objprm_ = spec_objprm_;
objtype = (mjIntVec)&objtype_; objtype = (mjIntVec*)&objtype_;
objname = (mjStringVec)&objname_; objname = &objname_;
objprm = (mjDoubleVec)&objprm_; objprm = &objprm_;
} }
@@ -6171,14 +6171,14 @@ mjCKey& mjCKey::operator=(const mjCKey& other) {
void mjCKey::PointToLocal() { void mjCKey::PointToLocal() {
spec.element = static_cast<mjElement*>(this); spec.element = static_cast<mjElement*>(this);
spec.name = (mjString)&name; spec.name = &name;
spec.qpos = (mjDoubleVec)&spec_qpos_; spec.qpos = &spec_qpos_;
spec.qvel = (mjDoubleVec)&spec_qvel_; spec.qvel = &spec_qvel_;
spec.act = (mjDoubleVec)&spec_act_; spec.act = &spec_act_;
spec.mpos = (mjDoubleVec)&spec_mpos_; spec.mpos = &spec_mpos_;
spec.mquat = (mjDoubleVec)&spec_mquat_; spec.mquat = &spec_mquat_;
spec.ctrl = (mjDoubleVec)&spec_ctrl_; spec.ctrl = &spec_ctrl_;
spec.info = (mjString)&info; spec.info = &info;
} }
@@ -6191,12 +6191,12 @@ void mjCKey::CopyFromSpec() {
mpos_ = spec_mpos_; mpos_ = spec_mpos_;
mquat_ = spec_mquat_; mquat_ = spec_mquat_;
ctrl_ = spec_ctrl_; ctrl_ = spec_ctrl_;
qpos = (mjDoubleVec)&qpos_; qpos = &qpos_;
qvel = (mjDoubleVec)&qvel_; qvel = &qvel_;
act = (mjDoubleVec)&act_; act = &act_;
mpos = (mjDoubleVec)&mpos_; mpos = &mpos_;
mquat = (mjDoubleVec)&mquat_; mquat = &mquat_;
ctrl = (mjDoubleVec)&ctrl_; ctrl = &ctrl_;
} }
@@ -6314,9 +6314,9 @@ mjCPlugin::mjCPlugin(mjCModel* _model) {
// public interface // public interface
mjs_defaultPlugin(&spec); mjs_defaultPlugin(&spec);
elemtype = mjOBJ_PLUGIN; elemtype = mjOBJ_PLUGIN;
spec.name = (mjString)&name; spec.name = &name;
spec.instance_name = (mjString)&instance_name; spec.instance_name = &instance_name;
spec.info = (mjString)&info; spec.info = &info;
} }