feat: real-time distance modifier curve updates
This commit is contained in:
parent
fc6034242e
commit
c5457ffbc0
4 changed files with 61 additions and 25 deletions
|
|
@ -35,7 +35,6 @@ void Terrain::child_exiting(Node *node) {
|
|||
if (Engine::get_singleton()->is_editor_hint() && !is_queued_for_deletion()) {
|
||||
mod->disconnect(TerrainModifier::sig_changed, callable_mp(this, &self_type::on_terrain_changed));
|
||||
}
|
||||
|
||||
on_terrain_changed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,22 @@ void TerrainModifier::_bind_methods() {
|
|||
ADD_SIGNAL(MethodInfo(sig_changed));
|
||||
}
|
||||
|
||||
void TerrainModifier::_notification(int what) {
|
||||
switch (what) {
|
||||
default:
|
||||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
set_notify_transform(true);
|
||||
}
|
||||
case NOTIFICATION_TRANSFORM_CHANGED:
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
emit_signal(sig_changed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float TerrainModifier::blend(float under, float over) {
|
||||
float const difference{ under - over };
|
||||
float const distance{ Math::abs(difference) };
|
||||
|
|
@ -38,20 +54,8 @@ float TerrainModifier::blend(float under, float over) {
|
|||
}
|
||||
}
|
||||
|
||||
void TerrainModifier::_notification(int what) {
|
||||
switch (what) {
|
||||
default:
|
||||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
set_notify_transform(true);
|
||||
}
|
||||
case NOTIFICATION_TRANSFORM_CHANGED:
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
emit_signal(sig_changed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void TerrainModifier::changed() {
|
||||
emit_signal(sig_changed);
|
||||
}
|
||||
|
||||
float TerrainModifier::evaluate_at(Vector2 world_coordinate, float before) {
|
||||
|
|
@ -117,9 +121,17 @@ PackedStringArray TerrainModifierDistance::get_configuration_warnings() const {
|
|||
}
|
||||
|
||||
void TerrainModifierDistance::set_distance_weight_curve(Ref<Curve> curve) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (this->distance_weight_curve.is_valid()) {
|
||||
this->distance_weight_curve->disconnect_changed(callable_mp(cast_to<TerrainModifier>(this), &self_type::changed));
|
||||
}
|
||||
if (curve.is_valid()) {
|
||||
curve->connect_changed(callable_mp(cast_to<TerrainModifier>(this), &self_type::changed));
|
||||
}
|
||||
}
|
||||
this->distance_weight_curve = curve;
|
||||
update_configuration_warnings();
|
||||
emit_signal(sig_changed);
|
||||
changed();
|
||||
}
|
||||
|
||||
Ref<Curve> TerrainModifierDistance::get_distance_weight_curve() const {
|
||||
|
|
@ -127,9 +139,17 @@ Ref<Curve> TerrainModifierDistance::get_distance_weight_curve() const {
|
|||
}
|
||||
|
||||
void TerrainModifierDistance::set_distance_height_curve(Ref<Curve> curve) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (this->distance_height_curve.is_valid()) {
|
||||
this->distance_height_curve->disconnect_changed(callable_mp(cast_to<TerrainModifier>(this), &self_type::changed));
|
||||
}
|
||||
if (curve.is_valid()) {
|
||||
curve->connect_changed(callable_mp(cast_to<TerrainModifier>(this), &self_type::changed));
|
||||
}
|
||||
}
|
||||
this->distance_height_curve = curve;
|
||||
update_configuration_warnings();
|
||||
emit_signal(sig_changed);
|
||||
changed();
|
||||
}
|
||||
|
||||
Ref<Curve> TerrainModifierDistance::get_distance_height_curve() const {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public:
|
|||
|
||||
protected:
|
||||
void _notification(int what);
|
||||
void changed();
|
||||
float blend(float under, float over);
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue