Merge branch 'google-deepmind:main' into main
This commit is contained in:
@@ -935,29 +935,22 @@ bool mjCFlexcomp::MakeMesh(mjCModel* model, char* error, int error_sz) {
|
|||||||
// LoadOBJ uses userXXX, extra processing needed
|
// LoadOBJ uses userXXX, extra processing needed
|
||||||
if (isobj) {
|
if (isobj) {
|
||||||
// check sizes
|
// check sizes
|
||||||
if (mesh.get_uservert().empty() || mesh.get_userface().empty()) {
|
if (mesh.vert_.empty() || mesh.face_.empty()) {
|
||||||
return comperr(error, "Vertex and face data required", error_sz);
|
return comperr(error, "Vertex and face data required", error_sz);
|
||||||
}
|
}
|
||||||
if (mesh.get_uservert().size()%3) {
|
if (mesh.vert_.size()%3) {
|
||||||
return comperr(error, "Vertex data must be multiple of 3", error_sz);
|
return comperr(error, "Vertex data must be multiple of 3", error_sz);
|
||||||
}
|
}
|
||||||
if (mesh.get_userface().size()%3) {
|
if (mesh.face_.size()%3) {
|
||||||
return comperr(error, "Face data must be multiple of 3", error_sz);
|
return comperr(error, "Face data must be multiple of 3", error_sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy vectors and clear
|
|
||||||
mesh.nvert_ = mesh.uservert_.size()/3;
|
|
||||||
mesh.nface_ = mesh.userface_.size()/3;
|
|
||||||
mesh.vert_ = VecToArray(mesh.uservert_, true);
|
|
||||||
mesh.face_ = VecToArray(mesh.userface_, true);
|
|
||||||
|
|
||||||
// remove repeated vertices (not called in LoadOBJ)
|
// remove repeated vertices (not called in LoadOBJ)
|
||||||
mesh.RemoveRepeated();
|
mesh.RemoveRepeated();
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy faces
|
// copy faces
|
||||||
element = vector<int> (mesh.nface()*3);
|
element = mesh.face_;
|
||||||
memcpy(element.data(), mesh.face_, mesh.nface_*3*sizeof(int));
|
|
||||||
|
|
||||||
// copy vertices, convert from float to mjtNum
|
// copy vertices, convert from float to mjtNum
|
||||||
point = vector<mjtNum> (mesh.nvert()*3);
|
point = vector<mjtNum> (mesh.nvert()*3);
|
||||||
|
|||||||
+309
-439
File diff suppressed because it is too large
Load Diff
+21
-30
@@ -722,24 +722,25 @@ class mjCMesh_ : public mjCBase {
|
|||||||
|
|
||||||
std::string content_type_; // content type of file
|
std::string content_type_; // content type of file
|
||||||
std::string file_; // mesh file
|
std::string file_; // mesh file
|
||||||
std::vector<float> uservert_; // user vertex data
|
std::vector<float> vert_; // vertex data
|
||||||
std::vector<float> usernormal_; // user normal data
|
std::vector<float> normal_; // normal data
|
||||||
std::vector<float> usertexcoord_; // user texcoord data
|
std::vector<float> texcoord_; // texcoord data
|
||||||
std::vector<int> userface_; // user vertex indices
|
std::vector<int> face_; // vertex indices
|
||||||
std::vector<int> userfacenormal_; // user normal indices
|
std::vector<int> facenormal_; // normal indices
|
||||||
|
std::vector<int> facetexcoord_; // texcoord indices
|
||||||
|
|
||||||
std::string spec_content_type_;
|
std::string spec_content_type_;
|
||||||
std::string spec_file_;
|
std::string spec_file_;
|
||||||
std::vector<float> spec_uservert_;
|
std::vector<float> spec_vert_;
|
||||||
std::vector<float> spec_usernormal_;
|
std::vector<float> spec_normal_;
|
||||||
std::vector<float> spec_usertexcoord_;
|
std::vector<float> spec_texcoord_;
|
||||||
std::vector<int> spec_userface_;
|
std::vector<int> spec_face_;
|
||||||
std::vector<int> spec_userfacenormal_;
|
std::vector<int> spec_facenormal_;
|
||||||
|
std::vector<int> spec_facetexcoord_;
|
||||||
|
|
||||||
// used by the compiler
|
// used by the compiler
|
||||||
bool visual_; // true: the mesh is only visual
|
bool visual_; // true: the mesh is only visual
|
||||||
std::vector<int> userfacetexcoord_; // user texcoord indices
|
std::vector< std::pair<int, int> > halfedge_; // half-edge data
|
||||||
std::vector< std::pair<int, int> > useredge_; // user half-edge data
|
|
||||||
|
|
||||||
// mesh properties that indicate a well-formed mesh
|
// mesh properties that indicate a well-formed mesh
|
||||||
std::pair<int, int> invalidorientation_; // indices of invalid edge; -1 if none
|
std::pair<int, int> invalidorientation_; // indices of invalid edge; -1 if none
|
||||||
@@ -763,10 +764,6 @@ class mjCMesh_ : public mjCBase {
|
|||||||
double surface_; // surface of the mesh
|
double surface_; // surface of the mesh
|
||||||
|
|
||||||
// size of mesh data to be copied into mjModel
|
// size of mesh data to be copied into mjModel
|
||||||
int nvert_; // number of vertices
|
|
||||||
int nnormal_; // number of normals
|
|
||||||
int ntexcoord_; // number of texcoords
|
|
||||||
int nface_; // number of faces
|
|
||||||
int szgraph_; // size of graph data in ints
|
int szgraph_; // size of graph data in ints
|
||||||
bool needhull_; // needs convex hull for collisions
|
bool needhull_; // needs convex hull for collisions
|
||||||
|
|
||||||
@@ -802,19 +799,19 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
|||||||
void set_needhull(bool needhull);
|
void set_needhull(bool needhull);
|
||||||
|
|
||||||
// public getters for user data
|
// public getters for user data
|
||||||
const std::vector<float>& get_uservert() const { return uservert_; }
|
const std::vector<float>& get_uservert() const { return spec_vert_; }
|
||||||
const std::vector<float>& get_usernormal() const { return usernormal_; }
|
const std::vector<float>& get_usernormal() const { return spec_normal_; }
|
||||||
const std::vector<float>& get_usertexcoord() const { return usertexcoord_; }
|
const std::vector<float>& get_usertexcoord() const { return spec_texcoord_; }
|
||||||
const std::vector<int>& get_userface() const { return userface_; }
|
const std::vector<int>& get_userface() const { return spec_face_; }
|
||||||
|
|
||||||
// mesh properties computed by Compile
|
// mesh properties computed by Compile
|
||||||
const double* aamm() const { return aamm_; }
|
const double* aamm() const { return aamm_; }
|
||||||
|
|
||||||
// number of vertices, normals, texture coordinates, and faces
|
// number of vertices, normals, texture coordinates, and faces
|
||||||
int nvert() const { return nvert_; }
|
int nvert() const { return vert_.size()/3; }
|
||||||
int nnormal() const { return nnormal_; }
|
int nnormal() const { return normal_.size()/3; }
|
||||||
int ntexcoord() const { return ntexcoord_; }
|
int ntexcoord() const { return texcoord_.size()/2; }
|
||||||
int nface() const { return nface_; }
|
int nface() const { return face_.size()/3; }
|
||||||
|
|
||||||
// return size of graph data in ints
|
// return size of graph data in ints
|
||||||
int szgraph() const { return szgraph_; }
|
int szgraph() const { return szgraph_; }
|
||||||
@@ -863,13 +860,7 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
|||||||
void CheckMesh(mjtGeomInertia type); // check if the mesh is valid
|
void CheckMesh(mjtGeomInertia type); // check if the mesh is valid
|
||||||
|
|
||||||
// mesh data to be copied into mjModel
|
// mesh data to be copied into mjModel
|
||||||
float* vert_; // vertex data (3*nvert), relative to (pos, quat)
|
|
||||||
float* normal_; // vertex normal data (3*nnormal)
|
|
||||||
double* center_; // face circumcenter data (3*nface)
|
double* center_; // face circumcenter data (3*nface)
|
||||||
float* texcoord_; // vertex texcoord data (2*ntexcoord or NULL)
|
|
||||||
int* face_; // face vertex indices (3*nface)
|
|
||||||
int* facenormal_; // face normal indices (3*nface)
|
|
||||||
int* facetexcoord_; // face texcoord indices (3*nface)
|
|
||||||
int* graph_; // convex graph data
|
int* graph_; // convex graph data
|
||||||
|
|
||||||
// compute the volume and center-of-mass of the mesh given the face center
|
// compute the volume and center-of-mass of the mesh given the face center
|
||||||
|
|||||||
Reference in New Issue
Block a user