Calculating the center of mass of these space crafts and keeping it updated, from a programming stand-point, would be a pretty trivial computation. It would be just a matter of adding a few more stats(i.e. mass*distance x, mass*distance y, mass*distance z) to the ship to keep a running tally of where the center is, if each block had a particular mass that would just be one more stat.
The calculation can be a running tally because for every block added you can just add that particular mass*distance to value it already has (and adding to the total mass if applicable). Similarly when a block is removed (either by salvaging it or by damage), updating the mass*distance can be done when the calculation to see if the block is removed is done. If the block is removed then the running tally is updated by adding the negative value of the mass*distance of that block to the total.
Also random note, no idea why you would want to direct your graphics processing unit to do arithmetic of this nature, that is the job of the CPU.