box2d icon indicating copy to clipboard operation
box2d copied to clipboard

All b2Body uses 32-bytes for their debug name. Maybe this can be debug only?

Open MelvMay-Unity opened this issue 3 months ago • 2 comments

I don't use the Box2D body name as I can use user-data to give it context but it uses 32-bytes so I've essentially removed it with some defines.

Would it be worthwhile adding in some define to remove it if not used?

MelvMay-Unity avatar Oct 04 '25 13:10 MelvMay-Unity

I could use a string pool and make it 4 bytes. Are you concerned about some memory constrained devices?

erincatto avatar Oct 19 '25 17:10 erincatto

I've found body names to be useful with debug draw and debugging in general. I've even setup a natvis to show them for a b2BodyId.

If I was concerned about memory I would have something like B2_SHIPPING that would remove names and remove debug draw code.

Also the place where the name is stored is fairly cold and doesn't affect performance much.

erincatto avatar Nov 07 '25 06:11 erincatto