Closed opera-aberglund closed 11 months ago
Have you considered using code like the following to copy base members?
auto poly = PolygonShapeConf{hx, hy};
auto chain = ChainShapeConf{};
const auto copyBaseShapeConf = static_cast<const BaseShapeConf&>(poly);
static_cast<BaseShapeConf&>(chain) = copyBaseShapeConf;
I believe this would work at least for those members without invoking undefined behavior.
Have you considered using code like the following to copy base members?
auto poly = PolygonShapeConf{hx, hy}; auto chain = ChainShapeConf{}; const auto copyBaseShapeConf = static_cast<const BaseShapeConf&>(poly); static_cast<BaseShapeConf&>(chain) = copyBaseShapeConf;
I believe this would work at least for those members without invoking undefined behavior.
This did work! I never thought of that trick to copy the base values, thanks!
Desired Behavior:
When creating multiple new shapes at once, it would be nice to be able to set the common attributes first that are derived from the
BaseShapeConfig
class (like friction, restitution ...) by creating an instance of theShapeConf
class. Then, use that config when creating the other shape configs (likeChainShapeConf
,EdgeShapeConf
...).Actual Behavior:
I have to call
.UseFriction
,.UseRestitution
on each and every different shape, which creates a lot of code duplication when I want them to share the same configuration for these attributes.