Rename nattributes to num_attributes for consistency.

PiperOrigin-RevId: 932973447
Change-Id: Idbf9a52c89e24f34ae360d1617cb72dfaa92aa4e
This commit is contained in:
Haroon Qureshi
2026-06-16 02:39:22 -07:00
committed by Copybara-Service
parent 8e13f3b54d
commit ecee1e0c53
6 changed files with 12 additions and 12 deletions
@@ -115,7 +115,7 @@ static void UpdateSkinFlexMeshData(mjrfMeshData* data, const mjModel* model,
num_indices = 3 * scene->flexfaceused[geom.objid];
}
data->nattributes = uvs.data() ? 3 : 2;
data->num_attributes = uvs.data() ? 3 : 2;
data->attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION;
data->attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3;
data->attributes[0].bytes = positions.data();
+1 -1
View File
@@ -221,7 +221,7 @@ void ImguiBridge::Update() {
mjrfMeshData data;
mjrf_defaultMeshData(&data);
data.nattributes = 3;
data.num_attributes = 3;
data.attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION;
data.attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT2;
data.attributes[0].bytes = cmds->VtxBuffer.Data;
+1 -1
View File
@@ -78,7 +78,7 @@ class BuiltinBuilder : public mjrfMeshData {
mjrfMeshData* PrepareMeshData() {
// Update the `mjrfMeshData` fields.
nattributes = 2;
num_attributes = 2;
attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION;
attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3;
attributes[0].bytes = reinterpret_cast<const void*>(positions_.data());
+7 -7
View File
@@ -156,7 +156,7 @@ void Mesh::BuildVertexBuffer(const mjrfMeshData& data) {
const mjrVertexAttribute* positions = nullptr;
const mjrVertexAttribute* normals = nullptr;
const mjrVertexAttribute* tangents = nullptr;
for (int i = 0; i < data.nattributes; ++i) {
for (int i = 0; i < data.num_attributes; ++i) {
if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_USAGE_POSITION) {
positions = &data.attributes[i];
} else if (data.attributes[i].usage == mjVERTEX_ATTRIBUTE_USAGE_NORMAL) {
@@ -190,7 +190,7 @@ void Mesh::BuildVertexBuffer(const mjrfMeshData& data) {
// starting from the first attribute's payload.
vb_builder.bufferCount(1);
int total_vertex_size = 0;
for (int i = 0; i < data.nattributes; ++i) {
for (int i = 0; i < data.num_attributes; ++i) {
total_vertex_size += VertexAttributeTypeSize(data.attributes[i]);
}
const void* bytes = data.attributes[0].bytes;
@@ -200,7 +200,7 @@ void Mesh::BuildVertexBuffer(const mjrfMeshData& data) {
// attributes. As such, the stride is equal to the total vertex size and
// each offset is the sum of the sizes of the preceding attributes.
int offset = 0;
for (int i = 0; i < data.nattributes; ++i) {
for (int i = 0; i < data.num_attributes; ++i) {
const mjrVertexAttribute& attrib = data.attributes[i];
const filament::VertexAttribute usage = GetUsage(attrib);
filament::VertexBuffer::AttributeType type = GetType(attrib);
@@ -218,8 +218,8 @@ void Mesh::BuildVertexBuffer(const mjrfMeshData& data) {
} else {
// For a non-interleaved vertex buffer, we assign a separate buffer to each
// attribute.
vb_builder.bufferCount(data.nattributes);
for (int i = 0; i < data.nattributes; ++i) {
vb_builder.bufferCount(data.num_attributes);
for (int i = 0; i < data.num_attributes; ++i) {
const mjrVertexAttribute& attrib = data.attributes[i];
const filament::VertexAttribute usage = GetUsage(attrib);
filament::VertexBuffer::AttributeType type = GetType(attrib);
@@ -233,11 +233,11 @@ void Mesh::BuildVertexBuffer(const mjrfMeshData& data) {
}
attributes_[i] = usage;
}
num_attributes_ = data.nattributes;
num_attributes_ = data.num_attributes;
vertex_buffer_ = vb_builder.build(*engine_);
// Assign the individual data buffers.
for (int i = 0; i < data.nattributes; ++i) {
for (int i = 0; i < data.num_attributes; ++i) {
const mjrVertexAttribute& attrib = data.attributes[i];
const void* bytes = attrib.bytes;
size_t nbytes = data.num_vertices * VertexAttributeTypeSize(attrib);
+1 -1
View File
@@ -254,7 +254,7 @@ enum { mjMAX_VERTEX_ATTRIBUTES = 16 };
struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh)
mjtSize num_vertices; // number of vertices; all vertex attributes share this size
int nattributes; // number of attributes defined
int num_attributes; // number of attributes defined
mjrVertexAttribute attributes[mjMAX_VERTEX_ATTRIBUTES]; // per-vertex attribute information
mjtBool interleaved; // true if vertex attributes are interleaved
mjtSize num_indices; // number of indices
+1 -1
View File
@@ -364,7 +364,7 @@ static void UpdateMeshData(mjrfMeshData* data, const mjModel* model, int id,
data->index_type = data->num_vertices >= std::numeric_limits<uint16_t>::max()
? mjINDEX_TYPE_U32
: mjINDEX_TYPE_U16;
data->nattributes = has_uvs ? 3 : 2;
data->num_attributes = has_uvs ? 3 : 2;
data->attributes[0].usage = mjVERTEX_ATTRIBUTE_USAGE_POSITION;
data->attributes[0].type = mjVERTEX_ATTRIBUTE_TYPE_FLOAT3;
data->attributes[0].bytes = builder->positions.data();