From 2bc97d840876cd3d955d705ea4718861ce365917 Mon Sep 17 00:00:00 2001 From: Haroon Qureshi Date: Thu, 23 Apr 2026 07:58:32 -0700 Subject: [PATCH] Rename types to conform to mjr naming conventions. PiperOrigin-RevId: 904458866 Change-Id: Id9ca27b698e0e40469524ba4454ab9721a65e785 --- .../filament/filament/builtins.cc | 18 ++--- .../filament/filament/imgui_bridge.cc | 12 +-- src/experimental/filament/filament/mesh.cc | 69 ++++++++--------- src/experimental/filament/filament/mesh.h | 74 +++++++++---------- .../filament/filament/model_objects.cc | 44 +++++------ 5 files changed, 109 insertions(+), 108 deletions(-) diff --git a/src/experimental/filament/filament/builtins.cc b/src/experimental/filament/filament/builtins.cc index 86a6a5c5..fc7b8c23 100644 --- a/src/experimental/filament/filament/builtins.cc +++ b/src/experimental/filament/filament/builtins.cc @@ -59,16 +59,16 @@ static std::size_t NumIndicesPerSide(int num_quads_per_axis) { return kNumIndicesPerQuad * num_quads_per_axis * num_quads_per_axis; } -class BuiltinBuilder : MeshData { +class BuiltinBuilder : mjrMeshData { public: - BuiltinBuilder() { DefaultMeshData(this); } + BuiltinBuilder() { mjr_defaultMeshData(this); } virtual ~BuiltinBuilder() = default; template static std::unique_ptr Create(filament::Engine* engine, Args&&... args) { auto builder = new T(std::forward(args)...); - MeshData* mesh_data = builder->PrepareMeshData(); + mjrMeshData* mesh_data = builder->PrepareMeshData(); mesh_data->release_callback = +[](void* user_data) { delete static_cast(user_data); }; @@ -76,13 +76,13 @@ class BuiltinBuilder : MeshData { return std::make_unique(engine, *mesh_data); } - MeshData* PrepareMeshData() { - // Update the `MeshData` fields. + mjrMeshData* PrepareMeshData() { + // Update the `mjrMeshData` fields. nattributes = 2; - attributes[0].usage = mjVERTEX_ATTRIBUTE_POSITION; + attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION; attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3; attributes[0].bytes = reinterpret_cast(positions_.data()); - attributes[1].usage = mjVERTEX_ATTRIBUTE_TANGENTS; + attributes[1].usage = mjVERTEX_ATTRIBUTE_USAGE_TANGENTS; attributes[1].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT4; attributes[1].bytes = reinterpret_cast(orientations_.data()); nvertices = positions_.size(); @@ -91,8 +91,8 @@ class BuiltinBuilder : MeshData { nindices = indices_.size(); primitive_type = primitive_type_ == filament::backend::PrimitiveType::TRIANGLES - ? mjPRIM_TYPE_TRIANGLES - : mjPRIM_TYPE_LINES; + ? mjMESH_PRIMITIVE_TYPE_TRIANGLES + : mjMESH_PRIMITIVE_TYPE_LINES; index_type = mjINDEX_TYPE_USHORT; bounds_min[0] = bounds_.getMin().x; bounds_min[1] = bounds_.getMin().y; diff --git a/src/experimental/filament/filament/imgui_bridge.cc b/src/experimental/filament/filament/imgui_bridge.cc index 2e533fad..86b440f5 100644 --- a/src/experimental/filament/filament/imgui_bridge.cc +++ b/src/experimental/filament/filament/imgui_bridge.cc @@ -217,16 +217,16 @@ void ImguiBridge::Update() { for (int n = 0; n < commands->CmdListsCount; ++n) { const ImDrawList* cmds = commands->CmdLists[n]; - MeshData data; - DefaultMeshData(&data); + mjrMeshData data; + mjr_defaultMeshData(&data); data.nattributes = 3; - data.attributes[0].usage = mjVERTEX_ATTRIBUTE_POSITION; + data.attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION; data.attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT2; data.attributes[0].bytes = cmds->VtxBuffer.Data; - data.attributes[1].usage = mjVERTEX_ATTRIBUTE_UV; + data.attributes[1].usage = mjVERTEX_ATTRIBUTE_USAGE_UV; data.attributes[1].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT2; data.attributes[1].bytes = cmds->VtxBuffer.Data + sizeof(float) * 2; - data.attributes[2].usage = mjVERTEX_ATTRIBUTE_COLOR; + data.attributes[2].usage = mjVERTEX_ATTRIBUTE_USAGE_COLOR; data.attributes[2].type = mjVERTEX_ATTRIBUTE_TYPE_UBYTE4; data.attributes[2].bytes = cmds->VtxBuffer.Data + sizeof(float) * 4; data.interleaved = true; @@ -234,7 +234,7 @@ void ImguiBridge::Update() { data.nindices = cmds->IdxBuffer.Size; data.indices = cmds->IdxBuffer.Data; data.index_type = mjINDEX_TYPE_USHORT; - data.primitive_type = mjPRIM_TYPE_TRIANGLES; + data.primitive_type = mjMESH_PRIMITIVE_TYPE_TRIANGLES; meshes_.push_back(std::make_unique(scene_view_->GetEngine(), data)); const Mesh* mesh = meshes_.back().get(); diff --git a/src/experimental/filament/filament/mesh.cc b/src/experimental/filament/filament/mesh.cc index 0736cbd9..1e958658 100644 --- a/src/experimental/filament/filament/mesh.cc +++ b/src/experimental/filament/filament/mesh.cc @@ -37,17 +37,17 @@ namespace mujoco { using filament::math::float3; using filament::math::float4; -static filament::VertexAttribute GetUsage(const VertexAttribute& attrib) { +static filament::VertexAttribute GetUsage(const mjrVertexAttribute& attrib) { switch (attrib.usage) { - case mjVERTEX_ATTRIBUTE_POSITION: + case mjVERTEX_ATTRIBUTE_USAGE_POSITION: return filament::VertexAttribute::POSITION; - case mjVERTEX_ATTRIBUTE_NORMAL: + case mjVERTEX_ATTRIBUTE_USAGE_NORMAL: return filament::VertexAttribute::TANGENTS; - case mjVERTEX_ATTRIBUTE_TANGENTS: + case mjVERTEX_ATTRIBUTE_USAGE_TANGENTS: return filament::VertexAttribute::TANGENTS; - case mjVERTEX_ATTRIBUTE_UV: + case mjVERTEX_ATTRIBUTE_USAGE_UV: return filament::VertexAttribute::UV0; - case mjVERTEX_ATTRIBUTE_COLOR: + case mjVERTEX_ATTRIBUTE_USAGE_COLOR: return filament::VertexAttribute::COLOR; default: mju_error("Unsupported vertex attribute usage: %d", attrib.usage); @@ -56,7 +56,7 @@ static filament::VertexAttribute GetUsage(const VertexAttribute& attrib) { } static filament::VertexBuffer::AttributeType GetType( - const VertexAttribute& attrib) { + const mjrVertexAttribute& attrib) { switch (attrib.type) { case mjVERTEX_ATTRIBUTE_TYPE_FLOAT2: return filament::VertexBuffer::AttributeType::FLOAT2; @@ -72,7 +72,7 @@ static filament::VertexBuffer::AttributeType GetType( } } -int VertexAttributeTypeSize(const VertexAttribute& attrib) { +int VertexAttributeTypeSize(const mjrVertexAttribute& attrib) { switch (attrib.type) { case mjVERTEX_ATTRIBUTE_TYPE_FLOAT2: return sizeof(float) * 2; @@ -99,14 +99,14 @@ int FillSequence(std::byte* buffer, std::size_t num_bytes) { return num; } -// Initializes the MeshData to default values. -void DefaultMeshData(MeshData* data) { - std::memset(data, 0, sizeof(MeshData)); +// Initializes the mjrMeshData to default values. +void mjr_defaultMeshData(mjrMeshData* data) { + std::memset(data, 0, sizeof(mjrMeshData)); } -Mesh::Mesh(filament::Engine* engine, const MeshData& data) +Mesh::Mesh(filament::Engine* engine, const mjrMeshData& data) : engine_(engine) { - type_ = data.primitive_type == mjPRIM_TYPE_TRIANGLES + type_ = data.primitive_type == mjMESH_PRIMITIVE_TYPE_TRIANGLES ? filament::RenderableManager::PrimitiveType::TRIANGLES : filament::RenderableManager::PrimitiveType::LINES; @@ -133,9 +133,9 @@ Mesh::~Mesh() { } } -void Mesh::BuildVertexBuffer(const MeshData& data) { +void Mesh::BuildVertexBuffer(const mjrMeshData& data) { if (data.nvertices == 0) { - mju_error("MeshData has no vertices."); + mju_error("mjrMeshData has no vertices."); } // The filament BufferDescriptor callback for releasing the memory. We assume @@ -147,26 +147,26 @@ void Mesh::BuildVertexBuffer(const MeshData& data) { // Pointers to specific attributes in the mesh data, used for additional // validation and processing. - const VertexAttribute* positions = nullptr; - const VertexAttribute* normals = nullptr; - const VertexAttribute* tangents = nullptr; + const mjrVertexAttribute* positions = nullptr; + const mjrVertexAttribute* normals = nullptr; + const mjrVertexAttribute* tangents = nullptr; for (int i = 0; i < data.nattributes; ++i) { - if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_POSITION) { + if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_USAGE_POSITION) { positions = &data.attributes[i]; - } else if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_NORMAL) { + } else if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_USAGE_NORMAL) { normals = &data.attributes[i]; - } else if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_TANGENTS) { + } else if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_USAGE_TANGENTS) { tangents = &data.attributes[i]; } } if (!positions) { - mju_error("MeshData has no positions."); + mju_error("mjrMeshData has no positions."); } - if (data.attributes[0].usage != mjVERTEX_ATTRIBUTE_POSITION) { + if (data.attributes[0].usage != mjVERTEX_ATTRIBUTE_USAGE_POSITION) { mju_error("Positions must be the first attribute."); } if (normals && tangents) { - mju_error("MeshData has both normals and tangents."); + mju_error("mjrMeshData has both normals and tangents."); } if (normals && data.interleaved) { // We need to build orientations from normals and so we require each @@ -195,7 +195,7 @@ void Mesh::BuildVertexBuffer(const MeshData& data) { // each offset is the sum of the sizes of the preceding attributes. int offset = 0; for (int i = 0; i < data.nattributes; ++i) { - const VertexAttribute& attrib = data.attributes[i]; + const mjrVertexAttribute& attrib = data.attributes[i]; const filament::VertexAttribute usage = GetUsage(attrib); filament::VertexBuffer::AttributeType type = GetType(attrib); vb_builder.attribute(usage, 0, type, offset, total_vertex_size); @@ -212,10 +212,10 @@ void Mesh::BuildVertexBuffer(const MeshData& data) { // attribute. vb_builder.bufferCount(data.nattributes); for (int i = 0; i < data.nattributes; ++i) { - const VertexAttribute& attrib = data.attributes[i]; + const mjrVertexAttribute& attrib = data.attributes[i]; const filament::VertexAttribute usage = GetUsage(attrib); filament::VertexBuffer::AttributeType type = GetType(attrib); - if (attrib.usage == mjVERTEX_ATTRIBUTE_NORMAL) { + if (attrib.usage == mjVERTEX_ATTRIBUTE_USAGE_NORMAL) { // We will replace normals with orientations. type = filament::VertexBuffer::AttributeType::FLOAT4; } @@ -230,10 +230,10 @@ void Mesh::BuildVertexBuffer(const MeshData& data) { // Assign the individual data buffers. for (int i = 0; i < data.nattributes; ++i) { - const VertexAttribute& attrib = data.attributes[i]; + const mjrVertexAttribute& attrib = data.attributes[i]; const void* bytes = attrib.bytes; size_t nbytes = data.nvertices * VertexAttributeTypeSize(attrib); - if (attrib.usage == mjVERTEX_ATTRIBUTE_NORMAL) { + if (attrib.usage == mjVERTEX_ATTRIBUTE_USAGE_NORMAL) { // Replace normals with orientations. nbytes = data.nvertices * sizeof(float4); bytes = BuildOrientationsFromNormals(data.nvertices, attrib); @@ -243,7 +243,7 @@ void Mesh::BuildVertexBuffer(const MeshData& data) { } } -void Mesh::BuildIndexBuffer(const MeshData& data) { +void Mesh::BuildIndexBuffer(const mjrMeshData& data) { if (data.nindices == 0) { return; } @@ -283,7 +283,8 @@ void Mesh::BuildIndexBuffer(const MeshData& data) { index_buffer_->setBuffer(*engine_, std::move(desc)); } -float4* Mesh::BuildOrientationsFromNormals(int nvertices, const VertexAttribute& normals) { +float4* Mesh::BuildOrientationsFromNormals(int nvertices, + const mjrVertexAttribute& normals) { float4* orientations = new float4[nvertices]; release_callbacks_.push_back([=]() { delete[] orientations; @@ -295,7 +296,7 @@ float4* Mesh::BuildOrientationsFromNormals(int nvertices, const VertexAttribute& return orientations; } -void Mesh::UpdateBounds(const MeshData& data) { +void Mesh::UpdateBounds(const mjrMeshData& data) { float3 bounds_min = ReadFloat3(data.bounds_min); float3 bounds_max = ReadFloat3(data.bounds_max); if (bounds_min != bounds_max) { @@ -304,8 +305,8 @@ void Mesh::UpdateBounds(const MeshData& data) { bounds_min = float3(FLT_MAX, FLT_MAX, FLT_MAX); bounds_max = float3(-FLT_MAX, -FLT_MAX, -FLT_MAX); - if (data.attributes[0].usage != mjVERTEX_ATTRIBUTE_POSITION) { - mju_error("MeshData has no positions."); + if (data.attributes[0].usage != mjVERTEX_ATTRIBUTE_USAGE_POSITION) { + mju_error("mjrMeshData has no positions."); } const float* positions = reinterpret_cast(data.attributes[0].bytes); diff --git a/src/experimental/filament/filament/mesh.h b/src/experimental/filament/filament/mesh.h index b75ad6de..ab259bc4 100644 --- a/src/experimental/filament/filament/mesh.h +++ b/src/experimental/filament/filament/mesh.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -29,66 +28,67 @@ #include #include #include +#include // Functions for creating filament vertex and index buffers. namespace mujoco { -// Maximum number of vertex attributes that can be used by a mesh. -static constexpr int kMaxVertexAttributes = 16; - // The type of data stored in an index buffer. -typedef enum mjtIndexType_ { +typedef enum mjrIndexType_ { mjINDEX_TYPE_USHORT = 0, mjINDEX_TYPE_UINT = 1, -} mjtIndexType; +} mjrIndexType; // The type of primitive to be drawn by vertex data. -typedef enum mjtMeshPrimitiveType_ { - mjPRIM_TYPE_TRIANGLES = 0, - mjPRIM_TYPE_LINES = 1, -} mjtMeshPrimitiveType; +typedef enum mjrMeshPrimitiveType_ { + mjMESH_PRIMITIVE_TYPE_TRIANGLES = 0, + mjMESH_PRIMITIVE_TYPE_LINES = 1, +} mjrMeshPrimitiveType; // The usage/purpose of an attribute of a vertex. -typedef enum mjtVertexAttributeUsage_ { - mjVERTEX_ATTRIBUTE_POSITION = 0, - mjVERTEX_ATTRIBUTE_NORMAL = 1, - mjVERTEX_ATTRIBUTE_TANGENTS = 2, - mjVERTEX_ATTRIBUTE_UV = 3, - mjVERTEX_ATTRIBUTE_COLOR = 4, -} mjtVertexAttributeUsage; +typedef enum mjrVertexAttributeUsage_ { + mjVERTEX_ATTRIBUTE_USAGE_POSITION = 0, + mjVERTEX_ATTRIBUTE_USAGE_NORMAL = 1, + mjVERTEX_ATTRIBUTE_USAGE_TANGENTS = 2, + mjVERTEX_ATTRIBUTE_USAGE_UV = 3, + mjVERTEX_ATTRIBUTE_USAGE_COLOR = 4, +} mjrVertexAttributeUsage; // The data format of an attribute of a vertex. -typedef enum mjtVertexAttributeType_ { +typedef enum mjrVertexAttributeType_ { mjVERTEX_ATTRIBUTE_TYPE_FLOAT2 = 0, mjVERTEX_ATTRIBUTE_TYPE_FLOAT3 = 1, mjVERTEX_ATTRIBUTE_TYPE_FLOAT4 = 2, mjVERTEX_ATTRIBUTE_TYPE_UBYTE4 = 3, -} mjtVertexAttributeType; +} mjrVertexAttributeType; + +// Maximum number of vertex attributes that can be used by a mesh. +enum { mjMAX_VERTEX_ATTRIBUTES = 16 }; // Information about a single attribute of a vertex. -struct VertexAttribute { +struct mjrVertexAttribute { // The data for the attribute. const void* bytes; // The usage/purpose of the attribute. - mjtVertexAttributeUsage usage; + mjrVertexAttributeUsage usage; // The data format of the attribute. - mjtVertexAttributeType type; + mjrVertexAttributeType type; }; // The binary contents of a mesh. -struct MeshData { +struct mjrMeshData { // The number of vertices in the mesh. Each of the vertex arrays below is // assumed to have this number of elements. - size_t nvertices; + mjtSize nvertices; // The number of attributes for each vertex in the mesh. int nattributes; // Information about each attribute of a vertex in the mesh. See `interleaved` // for more details. - VertexAttribute attributes[kMaxVertexAttributes]; + mjrVertexAttribute attributes[mjMAX_VERTEX_ATTRIBUTES]; // Whether the vertex attributes are interleaved or not. // @@ -99,24 +99,24 @@ struct MeshData { // // If false, assume each attribute is stored in a separate array as defined // by the `data` field of the attribute. - bool interleaved; + mjtByte interleaved; // The number of indices in the mesh. The indices array is assumed to have // this number of elements. - size_t nindices; + mjtSize nindices; // The indices of the mesh, stored as either ushort or uint depending on the // index type. const void* indices; // The type of data stored in the indices array. - mjtIndexType index_type; + mjrIndexType index_type; // The type of primitive to be drawn by vertex data. - mjtMeshPrimitiveType primitive_type; + mjrMeshPrimitiveType primitive_type; // Whether to compute the bounds of the mesh using the vertex positions. - bool compute_bounds; + mjtByte compute_bounds; // The bounds of the mesh. If bounds_min == bounds_max, then we assume that // that the bounds are not set (i.e. the bounds is empty). @@ -133,13 +133,13 @@ struct MeshData { }; // Initializes the MeshData to default values. -void DefaultMeshData(MeshData* data); +void mjr_defaultMeshData(mjrMeshData* data); // Owns a Vertex and Index buffer representing a geometry mesh. class Mesh { public: // Creates a Mesh from the given MeshData. - Mesh(filament::Engine* engine, const MeshData& data); + Mesh(filament::Engine* engine, const mjrMeshData& data); ~Mesh(); @@ -165,12 +165,12 @@ class Mesh { Mesh& operator=(const Mesh&) = delete; private: - void BuildVertexBuffer(const MeshData& data); - void BuildIndexBuffer(const MeshData& data); - void UpdateBounds(const MeshData& data); + void BuildVertexBuffer(const mjrMeshData& data); + void BuildIndexBuffer(const mjrMeshData& data); + void UpdateBounds(const mjrMeshData& data); filament::math::float4* BuildOrientationsFromNormals( - int nvertices, const VertexAttribute& normals); + int nvertices, const mjrVertexAttribute& normals); void ReleaseResources(); @@ -181,7 +181,7 @@ class Mesh { filament::RenderableManager::PrimitiveType::TRIANGLES; std::optional bounds_; std::vector> release_callbacks_; - std::array attributes_; + std::array attributes_; int num_attributes_ = 0; }; diff --git a/src/experimental/filament/filament/model_objects.cc b/src/experimental/filament/filament/model_objects.cc index 931670e0..742c3609 100644 --- a/src/experimental/filament/filament/model_objects.cc +++ b/src/experimental/filament/filament/model_objects.cc @@ -412,7 +412,7 @@ static std::span GetIndices(const mjModel* model, } } -static void UpdateMeshData(MeshData* data, const mjModel* model, int id, +static void UpdatemjrMeshData(mjrMeshData* data, const mjModel* model, int id, MeshType mesh_type) { if (!IsValidIndex(model, id, mesh_type)) { mju_error("Invalid index %d for type %d", id, mesh_type); @@ -440,7 +440,7 @@ static void UpdateMeshData(MeshData* data, const mjModel* model, int id, break; } - data->primitive_type = mjPRIM_TYPE_TRIANGLES; + data->primitive_type = mjMESH_PRIMITIVE_TYPE_TRIANGLES; data->nvertices = num_vertices; data->nindices = data->nvertices; data->indices = nullptr; @@ -448,14 +448,14 @@ static void UpdateMeshData(MeshData* data, const mjModel* model, int id, ? mjINDEX_TYPE_UINT : mjINDEX_TYPE_USHORT; data->nattributes = has_uvs ? 3 : 2; - data->attributes[0].usage = mjVERTEX_ATTRIBUTE_POSITION; + data->attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION; data->attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3; data->attributes[0].bytes = builder->positions.data(); - data->attributes[1].usage = mjVERTEX_ATTRIBUTE_TANGENTS; + data->attributes[1].usage = mjVERTEX_ATTRIBUTE_USAGE_TANGENTS; data->attributes[1].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT4; data->attributes[1].bytes = builder->orientations.data(); if (has_uvs) { - data->attributes[2].usage = mjVERTEX_ATTRIBUTE_UV; + data->attributes[2].usage = mjVERTEX_ATTRIBUTE_USAGE_UV; data->attributes[2].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT2; data->attributes[2].bytes = builder->uvs.data(); } @@ -467,7 +467,7 @@ static void UpdateMeshData(MeshData* data, const mjModel* model, int id, data->bounds_max[2] = builder->bounds_max.z; } -void UpdateSkinFlexMeshData(MeshData* data, const mjModel* model, +void UpdateSkinFlexmjrMeshData(mjrMeshData* data, const mjModel* model, const mjvScene* scene, const mjvGeom& geom) { auto positions = GetPositions(model, scene, geom); auto normals = GetNormals(model, scene, geom); @@ -480,20 +480,20 @@ void UpdateSkinFlexMeshData(MeshData* data, const mjModel* model, } data->nattributes = uvs.data() ? 3 : 2; - data->attributes[0].usage = mjVERTEX_ATTRIBUTE_POSITION; + data->attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION; data->attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3; data->attributes[0].bytes = positions.data(); - data->attributes[1].usage = mjVERTEX_ATTRIBUTE_NORMAL; + data->attributes[1].usage = mjVERTEX_ATTRIBUTE_USAGE_NORMAL; data->attributes[1].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3; data->attributes[1].bytes = normals.data(); - data->attributes[2].usage = mjVERTEX_ATTRIBUTE_UV; + data->attributes[2].usage = mjVERTEX_ATTRIBUTE_USAGE_UV; data->attributes[2].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT2; data->attributes[2].bytes = uvs.data(); data->nvertices = positions.size() / 3; data->nindices = num_indices; data->indices = indices.data(); data->index_type = mjINDEX_TYPE_UINT; - data->primitive_type = mjPRIM_TYPE_TRIANGLES; + data->primitive_type = mjMESH_PRIMITIVE_TYPE_TRIANGLES; data->compute_bounds = true; data->release_callback = nullptr; data->user_data = nullptr; @@ -554,15 +554,15 @@ void ModelObjects::UploadMesh(const mjModel* model, int id) { meshes_.erase(id); convex_hulls_.erase(id); - MeshData data; - DefaultMeshData(&data); - UpdateMeshData(&data, model, id, MeshType::kNormal); + mjrMeshData data; + mjr_defaultMeshData(&data); + UpdatemjrMeshData(&data, model, id, MeshType::kNormal); meshes_[id] = std::make_unique(engine_, data); if (model->mesh_graphadr[id] >= 0) { - MeshData convex_hull_data; - DefaultMeshData(&convex_hull_data); - UpdateMeshData(&convex_hull_data, model, id, MeshType::kConvexHull); + mjrMeshData convex_hull_data; + mjr_defaultMeshData(&convex_hull_data); + UpdatemjrMeshData(&convex_hull_data, model, id, MeshType::kConvexHull); convex_hulls_[id] = std::make_unique(engine_, convex_hull_data); } } @@ -624,16 +624,16 @@ void ModelObjects::UploadHeightField(const mjModel* model, int id) { height_fields_.erase(id); - MeshData data; - DefaultMeshData(&data); - UpdateMeshData(&data, model, id, MeshType::kHeightField); + mjrMeshData data; + mjr_defaultMeshData(&data); + UpdatemjrMeshData(&data, model, id, MeshType::kHeightField); height_fields_[id] = std::make_unique(engine_, data); } void ModelObjects::CreateSkinFlexMesh(const mjvScene* scene, const mjvGeom& geom) { - MeshData data; - DefaultMeshData(&data); - UpdateSkinFlexMeshData(&data, model_, scene, geom); + mjrMeshData data; + mjr_defaultMeshData(&data); + UpdateSkinFlexmjrMeshData(&data, model_, scene, geom); dynamic_meshes_[geom.objid] = std::make_unique(engine_, data); }