Setting the centroid to the center of mass

Is there a way to ensure that a body's centroid is the same as the center of mass? To calculate the center of mass you need to add shapes to the body, but to add shapes you need to know the centroid!

In my game, players can create boxes/circles of arbitrary size and position, then link them together with welds (this merges them into one body.), so doing it manually is not an option.

Thanks!
I'm pretty sure the centroid is the center of mass, and it's calculated for you
if all the shape you add have the same density (mass/m^2) then centroid and center of mass are equals.
I would create 2 body, if you has to use different density for shape: one with same density, find out the centroid, then store it somewhere, destroy the body and build the real one. Or just hack the code used to find the centre of mass and use it (you can simplify it because you don't need the mass) 😁

Original thread: https://box2d.org/forum/viewtopic.php?t=6696