Merge pull request #107005 from TokageItLab/fix-anim-node-param-type
Fix ambiguous AnimationNode's parameter type in default value and make `validate_type_match()` static function
This commit is contained in:
@ -5677,6 +5677,20 @@ bool Animation::is_variant_interpolatable(const Variant p_value) {
|
||||
return (type >= Variant::BOOL && type <= Variant::STRING_NAME) || type == Variant::ARRAY || type >= Variant::PACKED_INT32_ARRAY; // PackedByteArray is unsigned, so it would be better to ignore since blending uses float.
|
||||
}
|
||||
|
||||
bool Animation::validate_type_match(const Variant &p_from, Variant &r_to) {
|
||||
if (p_from.get_type() != r_to.get_type()) {
|
||||
// Cast r_to between double and int to avoid minor annoyances.
|
||||
if (p_from.get_type() == Variant::FLOAT && r_to.get_type() == Variant::INT) {
|
||||
r_to = double(r_to);
|
||||
} else if (p_from.get_type() == Variant::INT && r_to.get_type() == Variant::FLOAT) {
|
||||
r_to = int(r_to);
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(false, "Type mismatch between initial and final value: " + Variant::get_type_name(p_from.get_type()) + " and " + Variant::get_type_name(r_to.get_type()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Variant Animation::cast_to_blendwise(const Variant p_value) {
|
||||
switch (p_value.get_type()) {
|
||||
case Variant::BOOL:
|
||||
|
||||
Reference in New Issue
Block a user