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