Convert internal representation of vertices to double. Also replace remove duplicate vertices with fast hash implementation.
PiperOrigin-RevId: 734516595 Change-Id: Ic78556688d5f2b75d69cd286b8d060e2cdeb7c48
This commit is contained in:
committed by
Copybara-Service
parent
e4ee00e695
commit
4d024f9421
+29
-12
@@ -15,6 +15,7 @@
|
||||
#ifndef MUJOCO_SRC_USER_USER_OBJECTS_H_
|
||||
#define MUJOCO_SRC_USER_USER_OBJECTS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <cstddef>
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
@@ -195,7 +196,7 @@ class mjCBase : public mjCBase_ {
|
||||
|
||||
// Get and sanitize content type from raw_text if not empty, otherwise parse
|
||||
// content type from resource_name; throw on failure
|
||||
std::string GetAssetContentType(std::string_view resource_name, std::string_view raw_text);
|
||||
static std::string GetAssetContentType(std::string_view resource_name, std::string_view raw_text);
|
||||
|
||||
// Add frame transformation
|
||||
void SetFrame(mjCFrame* _frame);
|
||||
@@ -842,9 +843,10 @@ class mjCMesh_ : public mjCBase {
|
||||
std::string plugin_name;
|
||||
std::string plugin_instance_name;
|
||||
|
||||
std::string content_type_; // content type of file
|
||||
std::string content_type_ = ""; // content type of file
|
||||
std::string file_; // mesh file
|
||||
std::vector<float> vert_; // vertex data
|
||||
mjResource* resource_ = nullptr; // resource for mesh file
|
||||
std::vector<double> vert_; // vertex data
|
||||
std::vector<float> normal_; // normal data
|
||||
std::vector<float> texcoord_; // texcoord data
|
||||
std::vector<int> face_; // vertex indices
|
||||
@@ -886,7 +888,7 @@ class mjCMesh_ : public mjCBase {
|
||||
double surface_; // surface of the mesh
|
||||
|
||||
// size of mesh data to be copied into mjModel
|
||||
int szgraph_; // size of graph data in ints
|
||||
int szgraph_ = 0; // size of graph data in ints
|
||||
bool needhull_; // needs convex hull for collisions
|
||||
int maxhullvert_; // max vertex count of convex hull
|
||||
|
||||
@@ -923,8 +925,8 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
||||
const double* Refquat() const { return refquat; }
|
||||
const double* Scale() const { return scale; }
|
||||
bool SmoothNormal() const { return smoothnormal; }
|
||||
const std::vector<float>& Vert() const { return vert_; }
|
||||
float Vert(int i) const { return vert_[i]; }
|
||||
const std::vector<double>& Vert() const { return vert_; }
|
||||
double Vert(int i) const { return vert_[i]; }
|
||||
const std::vector<float>& UserVert() const { return spec_vert_; }
|
||||
const std::vector<float>& UserNormal() const { return spec_normal_; }
|
||||
const std::vector<float>& Texcoord() const { return texcoord_; }
|
||||
@@ -997,18 +999,33 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
||||
// sets properties of a bounding volume given a face id
|
||||
void SetBoundingVolume(int faceid);
|
||||
|
||||
void LoadOBJ(mjResource* resource); // load mesh in wavefront OBJ format
|
||||
void LoadSTL(mjResource* resource); // load mesh in STL BIN format
|
||||
void LoadMSH(mjResource* resource); // load mesh in MSH BIN format
|
||||
// load from OBJ, STL, or MSH file; throws mjCError on failure
|
||||
void LoadFromResource(mjResource* resource, bool remove_repeated = false);
|
||||
|
||||
void RemoveRepeated(); // remove repeated vertices
|
||||
static bool IsObj(std::string_view filename, std::string_view ct = "");
|
||||
static bool IsSTL(std::string_view filename, std::string_view ct = "");
|
||||
static bool IsMSH(std::string_view filename, std::string_view ct = "");
|
||||
|
||||
bool IsObj() const;
|
||||
bool IsSTL() const;
|
||||
bool IsMSH() const;
|
||||
|
||||
private:
|
||||
void TryCompile(const mjVFS* vfs);
|
||||
|
||||
// load mesh from cache asset, return true on success (OBJ files are only supported)
|
||||
bool LoadCachedMesh(mjCCache *cache, const mjResource* resource);
|
||||
|
||||
// store mesh into asset cache (OBJ files are only supported)
|
||||
void CacheMesh(mjCCache *cache, const mjResource* resource,
|
||||
std::string_view asset_type);
|
||||
void CacheMesh(mjCCache *cache, const mjResource* resource);
|
||||
|
||||
// convert vertices to double precision and remove repeated vertices if requested
|
||||
void ProcessVertices(const std::vector<float>& vert, bool remove_repeated = false);
|
||||
|
||||
|
||||
void LoadOBJ(mjResource* resource, bool remove_repeated); // load mesh in wavefront OBJ format
|
||||
void LoadSTL(mjResource* resource); // load mesh in STL BIN format
|
||||
void LoadMSH(mjResource* resource, bool remove_repeated); // load mesh in MSH BIN format
|
||||
|
||||
void LoadSDF(); // generate mesh using marching cubes
|
||||
void MakeGraph(); // make graph of convex hull
|
||||
|
||||
Reference in New Issue
Block a user