feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -39,18 +39,18 @@
ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first.");
Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = {
{ &linear::in, &linear::in, &linear::in, &linear::in }, // Linear is the same for each easing.
{ &sine::in, &sine::out, &sine::in_out, &sine::out_in },
{ &quint::in, &quint::out, &quint::in_out, &quint::out_in },
{ &quart::in, &quart::out, &quart::in_out, &quart::out_in },
{ &quad::in, &quad::out, &quad::in_out, &quad::out_in },
{ &expo::in, &expo::out, &expo::in_out, &expo::out_in },
{ &elastic::in, &elastic::out, &elastic::in_out, &elastic::out_in },
{ &cubic::in, &cubic::out, &cubic::in_out, &cubic::out_in },
{ &circ::in, &circ::out, &circ::in_out, &circ::out_in },
{ &bounce::in, &bounce::out, &bounce::in_out, &bounce::out_in },
{ &back::in, &back::out, &back::in_out, &back::out_in },
{ &spring::in, &spring::out, &spring::in_out, &spring::out_in },
{ &Linear::in, &Linear::in, &Linear::in, &Linear::in }, // Linear is the same for each easing.
{ &Sine::in, &Sine::out, &Sine::in_out, &Sine::out_in },
{ &Quint::in, &Quint::out, &Quint::in_out, &Quint::out_in },
{ &Quart::in, &Quart::out, &Quart::in_out, &Quart::out_in },
{ &Quad::in, &Quad::out, &Quad::in_out, &Quad::out_in },
{ &Expo::in, &Expo::out, &Expo::in_out, &Expo::out_in },
{ &Elastic::in, &Elastic::out, &Elastic::in_out, &Elastic::out_in },
{ &Cubic::in, &Cubic::out, &Cubic::in_out, &Cubic::out_in },
{ &Circ::in, &Circ::out, &Circ::in_out, &Circ::out_in },
{ &Bounce::in, &Bounce::out, &Bounce::in_out, &Bounce::out_in },
{ &Back::in, &Back::out, &Back::in_out, &Back::out_in },
{ &Spring::in, &Spring::out, &Spring::in_out, &Spring::out_in },
};
void Tweener::set_tween(const Ref<Tween> &p_tween) {
@ -63,7 +63,7 @@ void Tweener::start() {
}
Ref<Tween> Tweener::_get_tween() {
return Ref<Tween>(ObjectDB::get_instance(tween_id));
return ObjectDB::get_ref<Tween>(tween_id);
}
void Tweener::_finish() {
@ -212,6 +212,7 @@ void Tween::play() {
void Tween::kill() {
running = false; // For the sake of is_running().
valid = false;
dead = true;
}
@ -432,7 +433,7 @@ bool Tween::can_process(bool p_tree_paused) const {
Node *Tween::get_bound_node() const {
if (is_bound) {
return Object::cast_to<Node>(ObjectDB::get_instance(bound_node));
return ObjectDB::get_instance<Node>(bound_node);
} else {
return nullptr;
}
@ -542,6 +543,20 @@ Tween::Tween(SceneTree *p_parent_tree) {
valid = true;
}
double PropertyTweener::_get_custom_interpolated_value(const Variant &p_value) {
const Variant *argptr = &p_value;
Variant result;
Callable::CallError ce;
custom_method.callp(&argptr, 1, result, ce);
if (ce.error != Callable::CallError::CALL_OK) {
ERR_FAIL_V_MSG(false, "Error calling custom method from PropertyTweener: " + Variant::get_callable_error_text(custom_method, &argptr, 1, ce) + ".");
} else if (result.get_type() != Variant::FLOAT) {
ERR_FAIL_V_MSG(false, vformat("Wrong return type in PropertyTweener custom method. Expected float, got %s.", Variant::get_type_name(result.get_type())));
}
return result;
}
Ref<PropertyTweener> PropertyTweener::from(const Variant &p_value) {
Ref<Tween> tween = _get_tween();
ERR_FAIL_COND_V(tween.is_null(), nullptr);
@ -638,17 +653,7 @@ bool PropertyTweener::step(double &r_delta) {
if (time < duration) {
if (custom_method.is_valid()) {
const Variant t = tween->interpolate_variant(0.0, 1.0, time, duration, trans_type, ease_type);
const Variant *argptr = &t;
Variant result;
Callable::CallError ce;
custom_method.callp(&argptr, 1, result, ce);
if (ce.error != Callable::CallError::CALL_OK) {
ERR_FAIL_V_MSG(false, "Error calling custom method from PropertyTweener: " + Variant::get_callable_error_text(custom_method, &argptr, 1, ce) + ".");
} else if (result.get_type() != Variant::FLOAT) {
ERR_FAIL_V_MSG(false, vformat("Wrong return type in PropertyTweener custom method. Expected float, got %s.", Variant::get_type_name(result.get_type())));
}
double result = _get_custom_interpolated_value(t);
target_instance->set_indexed(property, Animation::interpolate_variant(initial_val, final_val, result));
} else {
target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
@ -656,7 +661,12 @@ bool PropertyTweener::step(double &r_delta) {
r_delta = 0;
return true;
} else {
target_instance->set_indexed(property, final_val);
if (custom_method.is_valid()) {
double final_t = _get_custom_interpolated_value(1.0);
target_instance->set_indexed(property, Animation::interpolate_variant(initial_val, final_val, final_t));
} else {
target_instance->set_indexed(property, final_val);
}
r_delta = elapsed_time - delay - duration;
_finish();
return false;