Format header to conform to style guide.

Also moves some types to the mjrender.h header.

PiperOrigin-RevId: 929189125
Change-Id: I19e5598210898c0defb663c60d7ecfb9a19bcd38
This commit is contained in:
Haroon Qureshi
2026-06-09 07:42:23 -07:00
committed by Copybara-Service
parent 991c131d59
commit e6e5229126
17 changed files with 549 additions and 521 deletions
+55
View File
@@ -947,6 +947,61 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjFONT_BIG', 2),
]),
)),
('mjrPixelFormat',
EnumDecl(
name='mjrPixelFormat',
declname='enum mjrPixelFormat_',
values=dict([
('mjPIXEL_FORMAT_UNKNOWN', 0),
('mjPIXEL_FORMAT_R8', 1),
('mjPIXEL_FORMAT_RGB8', 2),
('mjPIXEL_FORMAT_RGBA8', 3),
('mjPIXEL_FORMAT_R32F', 4),
('mjPIXEL_FORMAT_DEPTH32F', 5),
('mjPIXEL_FORMAT_KTX', 6),
]),
)),
('mjrVertexAttributeUsage',
EnumDecl(
name='mjrVertexAttributeUsage',
declname='enum mjrVertexAttributeUsage_',
values=dict([
('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),
]),
)),
('mjrVertexAttributeType',
EnumDecl(
name='mjrVertexAttributeType',
declname='enum mjrVertexAttributeType_',
values=dict([
('mjVERTEX_ATTRIBUTE_TYPE_FLOAT2', 0),
('mjVERTEX_ATTRIBUTE_TYPE_FLOAT3', 1),
('mjVERTEX_ATTRIBUTE_TYPE_FLOAT4', 2),
('mjVERTEX_ATTRIBUTE_TYPE_UBYTE4', 3),
]),
)),
('mjrIndexType',
EnumDecl(
name='mjrIndexType',
declname='enum mjrIndexType_',
values=dict([
('mjINDEX_TYPE_U16', 0),
('mjINDEX_TYPE_U32', 1),
]),
)),
('mjrMeshPrimitiveType',
EnumDecl(
name='mjrMeshPrimitiveType',
declname='enum mjrMeshPrimitiveType_',
values=dict([
('mjMESH_PRIMITIVE_TYPE_TRIANGLES', 0),
('mjMESH_PRIMITIVE_TYPE_LINES', 1),
]),
)),
('mjtButton',
EnumDecl(
name='mjtButton',
+24
View File
@@ -10840,6 +10840,30 @@ STRUCTS: Mapping[str, StructDecl] = dict([
),
),
)),
('mjrVertexAttribute',
StructDecl(
name='mjrVertexAttribute',
declname='struct mjrVertexAttribute_',
fields=(
StructFieldDecl(
name='bytes',
type=PointerType(
inner_type=ValueType(name='void', is_const=True),
),
doc='vertex data',
),
StructFieldDecl(
name='usage',
type=ValueType(name='int'),
doc='mjrVertexAttributeUsage; e.g. position, normal, etc.',
),
StructFieldDecl(
name='type',
type=ValueType(name='int'),
doc='mjrVertexAttributeType; e.g. float3, ubyte4, etc.',
),
),
)),
('mjrContext',
StructDecl(
name='mjrContext',
+1
View File
@@ -76,6 +76,7 @@ using MjWarningStat = ::mjWarningStat;
// From mjrender.h
using MjrRect = ::mjrRect;
using MjrContext = ::mjrContext;
using MjrVertexAttribute = ::mjrVertexAttribute;
// From mjvisualize.h
using MjvPerturb = ::mjvPerturb;
+17
View File
@@ -959,6 +959,23 @@ This is useful for example when the MJB is not available as a file on disk.)"));
X(height);
#undef X
// ==================== MJRVERTEXATTRIBUTE ===================================
py::class_<raw::MjrVertexAttribute> mjrVertexAttribute(m, "MjrVertexAttribute");
mjrVertexAttribute.def(py::init([](int usage, int type) {
return raw::MjrVertexAttribute{nullptr, usage, type};
}),
py::arg("usage") = 0, py::arg("type") = 0);
mjrVertexAttribute.def("__copy__",
[](const raw::MjrVertexAttribute& other) { return raw::MjrVertexAttribute(other); });
mjrVertexAttribute.def("__deepcopy__", [](const raw::MjrVertexAttribute& other, py::dict) {
return raw::MjrVertexAttribute(other);
});
DefineStructFunctions(mjrVertexAttribute);
#define X(var) mjrVertexAttribute.def_readwrite(#var, &raw::MjrVertexAttribute::var)
X(usage);
X(type);
#undef X
// ==================== MJVPERTURB ===========================================
py::class_<MjvPerturbWrapper> mjvPerturb(m, "MjvPerturb");
mjvPerturb.def(py::init<>());