Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize num_face_vertices_ type in mjCMesh object to be the type of tiny_obj_loader. #2390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/user/user_mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#include "user/user_objects.h"
#include "user/user_resource.h"
#include "user/user_util.h"
#include <tiny_obj_loader.h>

extern "C" {
#include "qhull_ra.h"
Expand Down Expand Up @@ -394,7 +393,7 @@ void mjCMesh::CacheMesh(mjCCache* cache, const mjResource* resource,
+ (sizeof(int) * vertex_index_.size())
+ (sizeof(int) * normal_index_.size())
+ (sizeof(int) * texcoord_index_.size())
+ (sizeof(unsigned char) * num_face_vertices_.size());
+ (sizeof(face_vertices_type) * num_face_vertices_.size());

std::shared_ptr<const void> cached_data(mesh, +[](const void* data) {
const mjCMesh* mesh = static_cast<const mjCMesh*>(data);
Expand Down
5 changes: 4 additions & 1 deletion src/user/user_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <tiny_obj_loader.h>

#include <mujoco/mjtnum.h>
#include <mujoco/mjmodel.h>
Expand All @@ -32,6 +33,8 @@
#include "user/user_cache.h"
#include "user/user_util.h"

using face_vertices_type = decltype(tinyobj::mesh_t::num_face_vertices)::value_type;

// forward declarations of all mjC/X classes
class mjCError;
class mjCBase;
Expand Down Expand Up @@ -993,7 +996,7 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
std::vector<int> vertex_index_;
std::vector<int> normal_index_;
std::vector<int> texcoord_index_;
std::vector<unsigned char> num_face_vertices_;
std::vector<face_vertices_type> num_face_vertices_;

// compute the volume and center-of-mass of the mesh given the face center
void ComputeVolume(double CoM[3], mjtGeomInertia gtype, const double facecen[3]);
Expand Down