Closed Green-Sky closed 1 year ago
I wanted to look at all the fixtures of a body for serialization purposes and noticed the https://github.com/erincatto/box2d/blob/9dc24a6fd4f32442c4bcf80791de47a0a7d25afb/include/box2d/b2_body.h#L360-L362 getter set of methods. BUT there is no way to know the length of the array! both m_fixtureCount and fixture.m_next are private/protected and inaccessible from outside.
fixtures
body
m_fixtureCount
fixture.m_next
To fix this, it would be trivial to expose a GetFixtureCount() returning m_fixtureCount.
GetFixtureCount()
Since this is a linked list, other ways would be possible, but they are not as easy.
The count is not in the API because I consider it an internal detail that may change. Also notice that there is no count for the joints and contacts.
I wanted to look at all the
fixtures
of abody
for serialization purposes and noticed the https://github.com/erincatto/box2d/blob/9dc24a6fd4f32442c4bcf80791de47a0a7d25afb/include/box2d/b2_body.h#L360-L362 getter set of methods. BUT there is no way to know the length of the array! bothm_fixtureCount
andfixture.m_next
are private/protected and inaccessible from outside.To fix this, it would be trivial to expose a
GetFixtureCount()
returningm_fixtureCount
.Since this is a linked list, other ways would be possible, but they are not as easy.