MAXON_CORENODE_REGISTER_CONVERSION registers a conversion core node. The core node compiler uses such nodes to implicitly convert values where required. Also you can ask CoreNodesLib::GetConversion() for a ConversionSequence of several conversion core nodes which is capable of converting from a source type to a destination type.
If the conversion is implemented by a constructor of TO which takes a #FROM argument the MAXON_CORENODE_REGISTER_CONVERSION macro alone is sufficient to implement and register the conversion node. Otherwise you have to specialize the ConversionNode template before you use the MAXON_CORENODE_REGISTER_CONVERSION macro:
template <> class ConversionNode<Float, TimeValue> : public ConversionNodeBase<Float, TimeValue>
{
public:
static ResultOk<void> Process(Float& out, const TimeValue& value)
{
out = value.GetSeconds();
return OK;
}
};
MAXON_CORENODE_REGISTER_CONVERSION(Float, TimeValue, CONVERSION_FLAGS::NONE);
- Warning
- Take care of properly setting up the flags. The example uses CONVERSION_FLAGS::NONE because there is a one-to-one correspondence between Float and TimeValue. However typically you have narrowing conversions (such as from String to Float) or widening conversions (such as from Float to String), then you must not use CONVERSION_FLAGS::NONE, see CONVERSION_FLAGS. If not set properly the core nodes compiler might implicitly choose undesirable conversions.
- Parameters
-
[in] | TO | The destination type of the conversion. |
[in] | FROM | The source type of the conversion. |
[in] | flags | The conversion flags, take care of setting the correct flags (see warning). |