Improve editing of min/max particle properties
This commit is contained in:
parent
1f5d4a62e9
commit
ce9fec9b4d
|
@ -9,6 +9,14 @@
|
|||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_param" qualifiers="const">
|
||||
<return type="Vector2" />
|
||||
<param index="0" name="param" type="int" enum="ParticleProcessMaterial.Parameter" />
|
||||
<description>
|
||||
Returns the minimum and maximum values of the given [param param] as a vector.
|
||||
The [code]x[/code] component of the returned vector corresponds to minimum and the [code]y[/code] component corresponds to maximum.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_param_max" qualifiers="const">
|
||||
<return type="float" />
|
||||
<param index="0" name="param" type="int" enum="ParticleProcessMaterial.Parameter" />
|
||||
|
@ -37,6 +45,15 @@
|
|||
Returns [code]true[/code] if the specified particle flag is enabled. See [enum ParticleFlags] for options.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_param">
|
||||
<return type="void" />
|
||||
<param index="0" name="param" type="int" enum="ParticleProcessMaterial.Parameter" />
|
||||
<param index="1" name="value" type="Vector2" />
|
||||
<description>
|
||||
Sets the minimum and maximum values of the given [param param].
|
||||
The [code]x[/code] component of the argument vector corresponds to minimum and the [code]y[/code] component corresponds to maximum.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_param_max">
|
||||
<return type="void" />
|
||||
<param index="0" name="param" type="int" enum="ParticleProcessMaterial.Parameter" />
|
||||
|
|
|
@ -149,6 +149,9 @@ void EditorProperty::_notification(int p_what) {
|
|||
if (c->is_set_as_top_level()) {
|
||||
continue;
|
||||
}
|
||||
if (!c->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
if (c == bottom_editor) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
#include "editor/plugins/mesh_library_editor_plugin.h"
|
||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
||||
#include "editor/plugins/packed_scene_translation_parser_plugin.h"
|
||||
#include "editor/plugins/particle_process_material_editor_plugin.h"
|
||||
#include "editor/plugins/root_motion_editor_plugin.h"
|
||||
#include "editor/plugins/script_text_editor.h"
|
||||
#include "editor/plugins/text_editor.h"
|
||||
|
@ -6974,6 +6975,10 @@ EditorNode::EditorNode() {
|
|||
Ref<EditorInspectorVisualShaderModePlugin> smp;
|
||||
smp.instantiate();
|
||||
EditorInspector::add_inspector_plugin(smp);
|
||||
|
||||
Ref<EditorInspectorParticleProcessMaterialPlugin> ppm;
|
||||
ppm.instantiate();
|
||||
EditorInspector::add_inspector_plugin(ppm);
|
||||
}
|
||||
|
||||
editor_selection = memnew(EditorSelection);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg height="16" viewBox="0 0 12 16" width="12" xmlns="http://www.w3.org/2000/svg"><path d="m10 2-9.99983819 6 9.99983819 6z" fill="#fff" stroke-width=".866025"/></svg>
|
After Width: | Height: | Size: 169 B |
|
@ -0,0 +1 @@
|
|||
<svg height="16" viewBox="0 0 12 16" width="12" xmlns="http://www.w3.org/2000/svg"><path d="m2 2 10 6-10 6z" fill="#fff" stroke-width=".866025"/></svg>
|
After Width: | Height: | Size: 152 B |
|
@ -0,0 +1,471 @@
|
|||
/**************************************************************************/
|
||||
/* particle_process_material_editor_plugin.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "particle_process_material_editor_plugin.h"
|
||||
|
||||
#include "editor/editor_property_name_processor.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_spin_slider.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/resources/particle_process_material.h"
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_update_sizing() {
|
||||
edit_size = range_edit_widget->get_size();
|
||||
margin = Vector2(range_slider_left_icon->get_width(), (edit_size.y - range_slider_left_icon->get_height()) * 0.5);
|
||||
usable_area = edit_size - margin * 2;
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_range_edit_draw() {
|
||||
ERR_FAIL_COND(range_slider_left_icon.is_null());
|
||||
ERR_FAIL_COND(range_slider_right_icon.is_null());
|
||||
_update_sizing();
|
||||
|
||||
bool widget_active = mouse_inside || drag != Drag::NONE;
|
||||
|
||||
// FIXME: Need to offset by 1 due to some outline bug.
|
||||
range_edit_widget->draw_rect(Rect2(margin + Vector2(1, 1), usable_area - Vector2(1, 1)), widget_active ? background_color.lerp(normal_color, 0.3) : background_color, false, 1.0);
|
||||
|
||||
Color draw_color;
|
||||
|
||||
if (widget_active) {
|
||||
float icon_offset = _get_left_offset() - range_slider_left_icon->get_width() - 1;
|
||||
|
||||
if (drag == Drag::LEFT || drag == Drag::SCALE) {
|
||||
draw_color = drag_color;
|
||||
} else if (hover == Hover::LEFT) {
|
||||
draw_color = hovered_color;
|
||||
} else {
|
||||
draw_color = normal_color;
|
||||
}
|
||||
range_edit_widget->draw_texture(range_slider_left_icon, Vector2(icon_offset, margin.y), draw_color);
|
||||
|
||||
icon_offset = _get_right_offset();
|
||||
|
||||
if (drag == Drag::RIGHT || drag == Drag::SCALE) {
|
||||
draw_color = drag_color;
|
||||
} else if (hover == Hover::RIGHT) {
|
||||
draw_color = hovered_color;
|
||||
} else {
|
||||
draw_color = normal_color;
|
||||
}
|
||||
range_edit_widget->draw_texture(range_slider_right_icon, Vector2(icon_offset, margin.y), draw_color);
|
||||
}
|
||||
|
||||
if (drag == Drag::MIDDLE || drag == Drag::SCALE) {
|
||||
draw_color = drag_color;
|
||||
} else if (hover == Hover::MIDDLE) {
|
||||
draw_color = hovered_color;
|
||||
} else {
|
||||
draw_color = normal_color;
|
||||
}
|
||||
range_edit_widget->draw_rect(_get_middle_rect(), draw_color);
|
||||
|
||||
Rect2 midpoint_rect(Vector2(margin.x + usable_area.x * (_get_min_ratio() + _get_max_ratio()) * 0.5 - 1, margin.y + 2),
|
||||
Vector2(2, usable_area.y - 4));
|
||||
|
||||
range_edit_widget->draw_rect(midpoint_rect, midpoint_color);
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_range_edit_gui_input(const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
|
||||
// Prevent unnecessary computations.
|
||||
if ((mb.is_null() || mb->get_button_index() != MouseButton::LEFT) && (mm.is_null())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(range_slider_left_icon.is_null());
|
||||
ERR_FAIL_COND(range_slider_right_icon.is_null());
|
||||
_update_sizing();
|
||||
|
||||
if (mb.is_valid()) {
|
||||
const Drag prev_drag = drag;
|
||||
|
||||
if (mb->is_pressed()) {
|
||||
if (mb->is_shift_pressed()) {
|
||||
drag = Drag::SCALE;
|
||||
drag_from_value = (max_range->get_value() - min_range->get_value()) * 0.5;
|
||||
drag_midpoint = (max_range->get_value() + min_range->get_value()) * 0.5;
|
||||
} else if (hover == Hover::LEFT) {
|
||||
drag = Drag::LEFT;
|
||||
drag_from_value = min_range->get_value();
|
||||
} else if (hover == Hover::RIGHT) {
|
||||
drag = Drag::RIGHT;
|
||||
drag_from_value = max_range->get_value();
|
||||
} else {
|
||||
drag = Drag::MIDDLE;
|
||||
drag_from_value = min_range->get_value();
|
||||
}
|
||||
drag_origin = mb->get_position().x;
|
||||
} else {
|
||||
drag = Drag::NONE;
|
||||
}
|
||||
|
||||
if (drag != prev_drag) {
|
||||
range_edit_widget->queue_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
float property_length = property_range.y - property_range.x;
|
||||
if (mm.is_valid()) {
|
||||
switch (drag) {
|
||||
case Drag::NONE: {
|
||||
const Hover prev_hover = hover;
|
||||
float left_icon_offset = _get_left_offset() - range_slider_left_icon->get_width() - 1;
|
||||
|
||||
if (Rect2(Vector2(left_icon_offset, 0), range_slider_left_icon->get_size()).has_point(mm->get_position())) {
|
||||
hover = Hover::LEFT;
|
||||
} else if (Rect2(Vector2(_get_right_offset(), 0), range_slider_right_icon->get_size()).has_point(mm->get_position())) {
|
||||
hover = Hover::RIGHT;
|
||||
} else if (_get_middle_rect().has_point(mm->get_position())) {
|
||||
hover = Hover::MIDDLE;
|
||||
} else {
|
||||
hover = Hover::NONE;
|
||||
}
|
||||
|
||||
if (hover != prev_hover) {
|
||||
range_edit_widget->queue_redraw();
|
||||
}
|
||||
} break;
|
||||
|
||||
case Drag::LEFT:
|
||||
case Drag::RIGHT: {
|
||||
float new_value = drag_from_value + (mm->get_position().x - drag_origin) / usable_area.x * property_length;
|
||||
if (drag == Drag::LEFT) {
|
||||
new_value = MIN(new_value, max_range->get_value());
|
||||
_set_clamped_values(new_value, max_range->get_value());
|
||||
} else {
|
||||
new_value = MAX(new_value, min_range->get_value());
|
||||
_set_clamped_values(min_range->get_value(), new_value);
|
||||
}
|
||||
} break;
|
||||
|
||||
case Drag::MIDDLE: {
|
||||
float delta = (mm->get_position().x - drag_origin) / usable_area.x * property_length;
|
||||
float diff = max_range->get_value() - min_range->get_value();
|
||||
delta = CLAMP(drag_from_value + delta, property_range.x, property_range.y - diff) - drag_from_value;
|
||||
_set_clamped_values(drag_from_value + delta, drag_from_value + delta + diff);
|
||||
} break;
|
||||
|
||||
case Drag::SCALE: {
|
||||
float delta = (mm->get_position().x - drag_origin) / usable_area.x * property_length + drag_from_value;
|
||||
_set_clamped_values(MIN(drag_midpoint, drag_midpoint - delta), MAX(drag_midpoint, drag_midpoint + delta));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_set_mouse_inside(bool p_inside) {
|
||||
mouse_inside = p_inside;
|
||||
if (!p_inside) {
|
||||
hover = Hover::NONE;
|
||||
}
|
||||
range_edit_widget->queue_redraw();
|
||||
}
|
||||
|
||||
float ParticleProcessMaterialMinMaxPropertyEditor::_get_min_ratio() const {
|
||||
return (min_range->get_value() - property_range.x) / (property_range.y - property_range.x);
|
||||
}
|
||||
|
||||
float ParticleProcessMaterialMinMaxPropertyEditor::_get_max_ratio() const {
|
||||
return (max_range->get_value() - property_range.x) / (property_range.y - property_range.x);
|
||||
}
|
||||
|
||||
float ParticleProcessMaterialMinMaxPropertyEditor::_get_left_offset() const {
|
||||
return margin.x + usable_area.x * _get_min_ratio();
|
||||
}
|
||||
|
||||
float ParticleProcessMaterialMinMaxPropertyEditor::_get_right_offset() const {
|
||||
return margin.x + usable_area.x * _get_max_ratio();
|
||||
}
|
||||
|
||||
Rect2 ParticleProcessMaterialMinMaxPropertyEditor::_get_middle_rect() const {
|
||||
if (Math::is_equal_approx(min_range->get_value(), max_range->get_value())) {
|
||||
return Rect2();
|
||||
}
|
||||
|
||||
return Rect2(
|
||||
Vector2(_get_left_offset() - 1, margin.y),
|
||||
Vector2(usable_area.x * (_get_max_ratio() - _get_min_ratio()) + 1, usable_area.y));
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_set_clamped_values(float p_min, float p_max) {
|
||||
// This is required for editing widget in case the properties have or_less or or_greater hint.
|
||||
min_range->set_value(MAX(p_min, property_range.x));
|
||||
max_range->set_value(MIN(p_max, property_range.y));
|
||||
_update_slider_values();
|
||||
_sync_property();
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_sync_property() {
|
||||
const Vector2 value = Vector2(min_range->get_value(), max_range->get_value());
|
||||
emit_changed(get_edited_property(), value, "", true);
|
||||
range_edit_widget->queue_redraw();
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_update_mode() {
|
||||
max_edit->set_read_only(false);
|
||||
|
||||
switch (slider_mode) {
|
||||
case Mode::RANGE: {
|
||||
min_edit->set_label("min");
|
||||
max_edit->set_label("max");
|
||||
max_edit->set_block_signals(true);
|
||||
max_edit->set_min(max_range->get_min());
|
||||
max_edit->set_max(max_range->get_max());
|
||||
max_edit->set_block_signals(false);
|
||||
|
||||
min_edit->set_allow_lesser(min_range->is_lesser_allowed());
|
||||
min_edit->set_allow_greater(min_range->is_greater_allowed());
|
||||
max_edit->set_allow_lesser(max_range->is_lesser_allowed());
|
||||
max_edit->set_allow_greater(max_range->is_greater_allowed());
|
||||
} break;
|
||||
|
||||
case Mode::MIDPOINT: {
|
||||
min_edit->set_label("val");
|
||||
max_edit->set_label(U"±");
|
||||
max_edit->set_block_signals(true);
|
||||
max_edit->set_min(0);
|
||||
max_edit->set_block_signals(false);
|
||||
|
||||
min_edit->set_allow_lesser(min_range->is_lesser_allowed());
|
||||
min_edit->set_allow_greater(max_range->is_greater_allowed());
|
||||
max_edit->set_allow_lesser(false);
|
||||
max_edit->set_allow_greater(min_range->is_lesser_allowed() && max_range->is_greater_allowed());
|
||||
} break;
|
||||
}
|
||||
_update_slider_values();
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_toggle_mode(bool p_edit_mode) {
|
||||
slider_mode = p_edit_mode ? Mode::MIDPOINT : Mode::RANGE;
|
||||
EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "particle_spin_mode", int(slider_mode));
|
||||
_update_mode();
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_update_slider_values() {
|
||||
switch (slider_mode) {
|
||||
case Mode::RANGE: {
|
||||
min_edit->set_value_no_signal(min_range->get_value());
|
||||
max_edit->set_value_no_signal(max_range->get_value());
|
||||
} break;
|
||||
|
||||
case Mode::MIDPOINT: {
|
||||
min_edit->set_value_no_signal((min_range->get_value() + max_range->get_value()) * 0.5);
|
||||
max_edit->set_value_no_signal((max_range->get_value() - min_range->get_value()) * 0.5);
|
||||
|
||||
max_edit->set_block_signals(true);
|
||||
max_edit->set_max(_get_max_spread());
|
||||
max_edit->set_read_only(max_edit->get_max() == 0);
|
||||
max_edit->set_block_signals(false);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_sync_sliders(float, const EditorSpinSlider *p_changed_slider) {
|
||||
switch (slider_mode) {
|
||||
case Mode::RANGE: {
|
||||
if (p_changed_slider == max_edit) {
|
||||
min_edit->set_value_no_signal(MIN(min_edit->get_value(), max_edit->get_value()));
|
||||
}
|
||||
min_range->set_value(min_edit->get_value());
|
||||
if (p_changed_slider == min_edit) {
|
||||
max_edit->set_value_no_signal(MAX(min_edit->get_value(), max_edit->get_value()));
|
||||
}
|
||||
max_range->set_value(max_edit->get_value());
|
||||
_sync_property();
|
||||
} break;
|
||||
|
||||
case Mode::MIDPOINT: {
|
||||
if (p_changed_slider == min_edit) {
|
||||
max_edit->set_block_signals(true); // If max changes, value may change.
|
||||
max_edit->set_max(_get_max_spread());
|
||||
max_edit->set_read_only(max_edit->get_max() == 0);
|
||||
max_edit->set_block_signals(false);
|
||||
}
|
||||
min_range->set_value(min_edit->get_value() - max_edit->get_value());
|
||||
max_range->set_value(min_edit->get_value() + max_edit->get_value());
|
||||
_sync_property();
|
||||
} break;
|
||||
}
|
||||
|
||||
property_range.x = MIN(min_range->get_value(), min_range->get_min());
|
||||
property_range.y = MAX(max_range->get_value(), max_range->get_max());
|
||||
}
|
||||
|
||||
float ParticleProcessMaterialMinMaxPropertyEditor::_get_max_spread() const {
|
||||
float max_spread = max_range->get_max() - min_range->get_min();
|
||||
|
||||
if (max_edit->is_greater_allowed()) {
|
||||
return max_spread;
|
||||
}
|
||||
|
||||
if (!min_edit->is_lesser_allowed()) {
|
||||
max_spread = MIN(max_spread, min_edit->get_value() - min_edit->get_min());
|
||||
}
|
||||
|
||||
if (!min_edit->is_greater_allowed()) {
|
||||
max_spread = MIN(max_spread, min_edit->get_max() - min_edit->get_value());
|
||||
}
|
||||
|
||||
return max_spread;
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
toggle_mode_button->set_icon(get_editor_theme_icon(SNAME("Anchor")));
|
||||
range_slider_left_icon = get_editor_theme_icon(SNAME("RangeSliderLeft"));
|
||||
range_slider_right_icon = get_editor_theme_icon(SNAME("RangeSliderRight"));
|
||||
|
||||
min_edit->add_theme_color_override(SNAME("label_color"), get_theme_color(SNAME("property_color_x"), EditorStringName(Editor)));
|
||||
max_edit->add_theme_color_override(SNAME("label_color"), get_theme_color(SNAME("property_color_y"), EditorStringName(Editor)));
|
||||
|
||||
const bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
|
||||
const Color accent_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
|
||||
background_color = dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);
|
||||
normal_color = dark_theme ? Color(0.5, 0.5, 0.5) : Color(0.8, 0.8, 0.8);
|
||||
hovered_color = dark_theme ? Color(0.8, 0.8, 0.8) : Color(0.6, 0.6, 0.6);
|
||||
drag_color = hovered_color.lerp(accent_color, 0.8);
|
||||
midpoint_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
|
||||
|
||||
range_edit_widget->set_custom_minimum_size(Vector2(0, range_slider_left_icon->get_height() + 8));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::setup(float p_min, float p_max, float p_step, bool p_allow_less, bool p_allow_greater, bool p_degrees) {
|
||||
property_range = Vector2(p_min, p_max);
|
||||
|
||||
// Initially all Ranges share properties.
|
||||
for (Range *range : Vector<Range *>{ min_range, min_edit, max_range, max_edit }) {
|
||||
range->set_min(p_min);
|
||||
range->set_max(p_max);
|
||||
range->set_step(p_step);
|
||||
range->set_allow_lesser(p_allow_less);
|
||||
range->set_allow_greater(p_allow_greater);
|
||||
}
|
||||
|
||||
if (p_degrees) {
|
||||
min_edit->set_suffix(U" \u00B0");
|
||||
max_edit->set_suffix(U" \u00B0");
|
||||
}
|
||||
_update_mode();
|
||||
}
|
||||
|
||||
void ParticleProcessMaterialMinMaxPropertyEditor::update_property() {
|
||||
const Vector2i value = get_edited_property_value();
|
||||
min_range->set_value(value.x);
|
||||
max_range->set_value(value.y);
|
||||
_update_slider_values();
|
||||
range_edit_widget->queue_redraw();
|
||||
}
|
||||
|
||||
ParticleProcessMaterialMinMaxPropertyEditor::ParticleProcessMaterialMinMaxPropertyEditor() {
|
||||
VBoxContainer *content_vb = memnew(VBoxContainer);
|
||||
content_vb->add_theme_constant_override(SNAME("separation"), 0);
|
||||
add_child(content_vb);
|
||||
|
||||
// Helper Range objects to keep absolute min and max values.
|
||||
min_range = memnew(Range);
|
||||
min_range->hide();
|
||||
add_child(min_range);
|
||||
|
||||
max_range = memnew(Range);
|
||||
max_range->hide();
|
||||
add_child(max_range);
|
||||
|
||||
// Range edit widget.
|
||||
HBoxContainer *hb = memnew(HBoxContainer);
|
||||
content_vb->add_child(hb);
|
||||
|
||||
range_edit_widget = memnew(Control);
|
||||
range_edit_widget->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
range_edit_widget->set_tooltip_text(TTR("Hold Shift to scale around midpoint instead of moving."));
|
||||
hb->add_child(range_edit_widget);
|
||||
range_edit_widget->connect(SNAME("draw"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_range_edit_draw));
|
||||
range_edit_widget->connect(SNAME("gui_input"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_range_edit_gui_input));
|
||||
range_edit_widget->connect(SNAME("mouse_entered"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_set_mouse_inside).bind(true));
|
||||
range_edit_widget->connect(SNAME("mouse_exited"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_set_mouse_inside).bind(false));
|
||||
|
||||
// Range controls for actual editing. Their min/max may depend on editing mode.
|
||||
hb = memnew(HBoxContainer);
|
||||
content_vb->add_child(hb);
|
||||
|
||||
min_edit = memnew(EditorSpinSlider);
|
||||
min_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hb->add_child(min_edit);
|
||||
min_edit->connect(SNAME("value_changed"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_sync_sliders).bind(min_edit));
|
||||
|
||||
max_edit = memnew(EditorSpinSlider);
|
||||
max_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hb->add_child(max_edit);
|
||||
max_edit->connect(SNAME("value_changed"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_sync_sliders).bind(max_edit));
|
||||
|
||||
toggle_mode_button = memnew(Button);
|
||||
toggle_mode_button->set_toggle_mode(true);
|
||||
toggle_mode_button->set_tooltip_text(TTR("Toggle between minimum/maximum and base value/spread modes."));
|
||||
hb->add_child(toggle_mode_button);
|
||||
toggle_mode_button->connect(SNAME("toggled"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_toggle_mode));
|
||||
|
||||
set_bottom_editor(content_vb);
|
||||
}
|
||||
|
||||
bool EditorInspectorParticleProcessMaterialPlugin::can_handle(Object *p_object) {
|
||||
return Object::cast_to<ParticleProcessMaterial>(p_object);
|
||||
}
|
||||
|
||||
bool EditorInspectorParticleProcessMaterialPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
|
||||
if (!ParticleProcessMaterial::has_min_max_property(p_path)) {
|
||||
return false;
|
||||
}
|
||||
ERR_FAIL_COND_V(p_hint != PROPERTY_HINT_RANGE, false);
|
||||
|
||||
Ref<ParticleProcessMaterial> mat = Ref<ParticleProcessMaterial>(p_object);
|
||||
ERR_FAIL_COND_V(mat.is_null(), false);
|
||||
|
||||
PackedStringArray range_hint = p_hint_text.split(",");
|
||||
float min = range_hint[0].to_float();
|
||||
float max = range_hint[1].to_float();
|
||||
float step = range_hint[2].to_float();
|
||||
bool allow_less = range_hint.find("or_less", 3) > -1;
|
||||
bool allow_greater = range_hint.find("or_greater", 3) > -1;
|
||||
bool degrees = range_hint.find("degrees", 3) > -1;
|
||||
|
||||
ParticleProcessMaterialMinMaxPropertyEditor *ed = memnew(ParticleProcessMaterialMinMaxPropertyEditor);
|
||||
ed->setup(min, max, step, allow_less, allow_greater, degrees);
|
||||
add_property_editor(p_path, ed);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/**************************************************************************/
|
||||
/* particle_process_material_editor_plugin.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef PARTICLE_PROCESS_MATERIAL_EDITOR_PLUGIN_H
|
||||
#define PARTICLE_PROCESS_MATERIAL_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor/editor_properties.h"
|
||||
|
||||
class Button;
|
||||
class EditorSpinSlider;
|
||||
class Label;
|
||||
class ParticleProcessMaterial;
|
||||
class Range;
|
||||
class VBoxContainer;
|
||||
|
||||
class ParticleProcessMaterialMinMaxPropertyEditor : public EditorProperty {
|
||||
GDCLASS(ParticleProcessMaterialMinMaxPropertyEditor, EditorProperty);
|
||||
|
||||
enum class Hover {
|
||||
NONE,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE,
|
||||
};
|
||||
|
||||
enum class Drag {
|
||||
NONE,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE,
|
||||
SCALE,
|
||||
};
|
||||
|
||||
enum class Mode {
|
||||
RANGE,
|
||||
MIDPOINT,
|
||||
};
|
||||
|
||||
Ref<Texture2D> range_slider_left_icon;
|
||||
Ref<Texture2D> range_slider_right_icon;
|
||||
|
||||
Color background_color;
|
||||
Color normal_color;
|
||||
Color hovered_color;
|
||||
Color drag_color;
|
||||
Color midpoint_color;
|
||||
|
||||
Control *range_edit_widget = nullptr;
|
||||
Button *toggle_mode_button = nullptr;
|
||||
Range *min_range = nullptr;
|
||||
Range *max_range = nullptr;
|
||||
|
||||
EditorSpinSlider *min_edit = nullptr;
|
||||
EditorSpinSlider *max_edit = nullptr;
|
||||
|
||||
Vector2 edit_size;
|
||||
Vector2 margin;
|
||||
Vector2 usable_area;
|
||||
|
||||
Vector2 property_range;
|
||||
|
||||
bool mouse_inside = false;
|
||||
Hover hover = Hover::NONE;
|
||||
|
||||
Drag drag = Drag::NONE;
|
||||
float drag_from_value = 0.0;
|
||||
float drag_midpoint = 0.0;
|
||||
float drag_origin = 0.0;
|
||||
|
||||
Mode slider_mode = Mode::RANGE;
|
||||
|
||||
void _update_sizing();
|
||||
void _range_edit_draw();
|
||||
void _range_edit_gui_input(const Ref<InputEvent> &p_event);
|
||||
void _set_mouse_inside(bool p_inside);
|
||||
|
||||
float _get_min_ratio() const;
|
||||
float _get_max_ratio() const;
|
||||
float _get_left_offset() const;
|
||||
float _get_right_offset() const;
|
||||
Rect2 _get_middle_rect() const;
|
||||
|
||||
void _set_clamped_values(float p_min, float p_max);
|
||||
void _sync_property();
|
||||
|
||||
void _update_mode();
|
||||
void _toggle_mode(bool p_edit_mode);
|
||||
void _update_slider_values();
|
||||
void _sync_sliders(float, const EditorSpinSlider *p_changed_slider);
|
||||
float _get_max_spread() const;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
void setup(float p_min, float p_max, float p_step, bool p_allow_less, bool p_allow_greater, bool p_degrees);
|
||||
virtual void update_property() override;
|
||||
|
||||
ParticleProcessMaterialMinMaxPropertyEditor();
|
||||
};
|
||||
|
||||
class EditorInspectorParticleProcessMaterialPlugin : public EditorInspectorPlugin {
|
||||
GDCLASS(EditorInspectorParticleProcessMaterialPlugin, EditorInspectorPlugin);
|
||||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object) override;
|
||||
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
|
||||
};
|
||||
|
||||
#endif // PARTICLE_PROCESS_MATERIAL_EDITOR_PLUGIN_H
|
|
@ -35,6 +35,7 @@
|
|||
Mutex ParticleProcessMaterial::material_mutex;
|
||||
SelfList<ParticleProcessMaterial>::List *ParticleProcessMaterial::dirty_materials = nullptr;
|
||||
HashMap<ParticleProcessMaterial::MaterialKey, ParticleProcessMaterial::ShaderData, ParticleProcessMaterial::MaterialKey> ParticleProcessMaterial::shader_map;
|
||||
RBSet<String> ParticleProcessMaterial::min_max_properties;
|
||||
ParticleProcessMaterial::ShaderNames *ParticleProcessMaterial::shader_names = nullptr;
|
||||
|
||||
void ParticleProcessMaterial::init_shaders() {
|
||||
|
@ -1181,6 +1182,10 @@ bool ParticleProcessMaterial::_is_shader_dirty() const {
|
|||
return element.in_list();
|
||||
}
|
||||
|
||||
bool ParticleProcessMaterial::has_min_max_property(const String &p_name) {
|
||||
return min_max_properties.has(p_name);
|
||||
}
|
||||
|
||||
void ParticleProcessMaterial::set_direction(Vector3 p_direction) {
|
||||
direction = p_direction;
|
||||
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction);
|
||||
|
@ -1217,6 +1222,15 @@ Vector3 ParticleProcessMaterial::get_velocity_pivot() {
|
|||
return velocity_pivot;
|
||||
}
|
||||
|
||||
void ParticleProcessMaterial::set_param(Parameter p_param, const Vector2 &p_value) {
|
||||
set_param_min(p_param, p_value.x);
|
||||
set_param_max(p_param, p_value.y);
|
||||
}
|
||||
|
||||
Vector2 ParticleProcessMaterial::get_param(Parameter p_param) const {
|
||||
return Vector2(get_param_min(p_param), get_param_max(p_param));
|
||||
}
|
||||
|
||||
void ParticleProcessMaterial::set_param_min(Parameter p_param, float p_value) {
|
||||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
|
||||
|
@ -1805,11 +1819,9 @@ void ParticleProcessMaterial::_validate_property(PropertyInfo &p_property) const
|
|||
p_property.name == "turbulence_noise_speed" ||
|
||||
p_property.name == "turbulence_noise_speed_random" ||
|
||||
p_property.name == "turbulence_influence_over_life" ||
|
||||
p_property.name == "turbulence_influence_min" ||
|
||||
p_property.name == "turbulence_influence_max" ||
|
||||
p_property.name == "turbulence_initial_displacement_min" ||
|
||||
p_property.name == "turbulence_initial_displacement_max") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
p_property.name == "turbulence_influence" ||
|
||||
p_property.name == "turbulence_initial_displacement") {
|
||||
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1829,6 +1841,10 @@ void ParticleProcessMaterial::_validate_property(PropertyInfo &p_property) const
|
|||
if ((p_property.name == "orbit_velocity_min" || p_property.name == "orbit_velocity_max") && (!tex_parameters[PARAM_ORBIT_VELOCITY].is_valid() && !particle_flags[PARTICLE_FLAG_DISABLE_Z])) {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
if (p_property.usage & PROPERTY_USAGE_EDITOR && (p_property.name.ends_with("_min") || p_property.name.ends_with("_max"))) {
|
||||
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleProcessMaterial::set_sub_emitter_mode(SubEmitterMode p_sub_emitter_mode) {
|
||||
|
@ -1942,6 +1958,9 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_flatness", "amount"), &ParticleProcessMaterial::set_flatness);
|
||||
ClassDB::bind_method(D_METHOD("get_flatness"), &ParticleProcessMaterial::get_flatness);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ParticleProcessMaterial::set_param);
|
||||
ClassDB::bind_method(D_METHOD("get_param", "param"), &ParticleProcessMaterial::get_param);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_param_min", "param", "value"), &ParticleProcessMaterial::set_param_min);
|
||||
ClassDB::bind_method(D_METHOD("get_param_min", "param"), &ParticleProcessMaterial::get_param_min);
|
||||
|
||||
|
@ -2064,6 +2083,12 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_collision_bounce", "bounce"), &ParticleProcessMaterial::set_collision_bounce);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_bounce"), &ParticleProcessMaterial::get_collision_bounce);
|
||||
|
||||
#define ADD_MIN_MAX_PROPERTY(m_property, m_range, m_parameter_name) \
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::VECTOR2, m_property, PROPERTY_HINT_RANGE, m_range, PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "set_param", "get_param", m_parameter_name); \
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, m_property "_min", PROPERTY_HINT_RANGE, m_range), "set_param_min", "get_param_min", m_parameter_name); \
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, m_property "_max", PROPERTY_HINT_RANGE, m_range), "set_param_max", "get_param_max", m_parameter_name); \
|
||||
min_max_properties.insert(m_property);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lifetime_randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_lifetime_randomness", "get_lifetime_randomness");
|
||||
ADD_GROUP("Particle Flags", "particle_flag_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "particle_flag_align_y"), "set_particle_flag", "get_particle_flag", PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY);
|
||||
|
@ -2086,8 +2111,7 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_radius"), "set_emission_ring_radius", "get_emission_ring_radius");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_inner_radius"), "set_emission_ring_inner_radius", "get_emission_ring_inner_radius");
|
||||
ADD_SUBGROUP("Angle", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angle_min", PROPERTY_HINT_RANGE, "-720,720,0.1,or_less,or_greater,degrees"), "set_param_min", "get_param_min", PARAM_ANGLE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angle_max", PROPERTY_HINT_RANGE, "-720,720,0.1,or_less,or_greater,degrees"), "set_param_max", "get_param_max", PARAM_ANGLE);
|
||||
ADD_MIN_MAX_PROPERTY("angle", "-720,720,0.1,or_less,or_greater,degrees", PARAM_ANGLE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angle_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGLE);
|
||||
ADD_SUBGROUP("Velocity", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inherit_velocity_ratio", PROPERTY_HINT_RANGE, "0.0,1.0,0.001,or_less,or_greater"), "set_inherit_velocity_ratio", "get_inherit_velocity_ratio");
|
||||
|
@ -2095,25 +2119,20 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "direction"), "set_direction", "get_direction");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "spread", PROPERTY_HINT_RANGE, "0,180,0.001"), "set_spread", "get_spread");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "flatness", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_flatness", "get_flatness");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "initial_velocity_min", PROPERTY_HINT_RANGE, "0,1000,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_INITIAL_LINEAR_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "initial_velocity_max", PROPERTY_HINT_RANGE, "0,1000,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_INITIAL_LINEAR_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("initial_velocity", "0,1000,0.01,or_less,or_greater", PARAM_INITIAL_LINEAR_VELOCITY);
|
||||
ADD_GROUP("Animated Velocity", "");
|
||||
ADD_SUBGROUP("Velocity Limit", "");
|
||||
ADD_SUBGROUP("Angular Velocity", "angular_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_velocity_min", PROPERTY_HINT_RANGE, "-720,720,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_ANGULAR_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_velocity_max", PROPERTY_HINT_RANGE, "-720,720,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_ANGULAR_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("angular_velocity", "-720,720,0.01,or_less,or_greater", PARAM_ANGULAR_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "angular_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANGULAR_VELOCITY);
|
||||
ADD_SUBGROUP("Directional Velocity", "directional_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_velocity_min", PROPERTY_HINT_RANGE, "-720,720,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_DIRECTIONAL_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_velocity_max", PROPERTY_HINT_RANGE, "-720,720,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_DIRECTIONAL_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("directional_velocity", "-720,720,0.01,or_less,or_greater", PARAM_DIRECTIONAL_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "directional_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_DIRECTIONAL_VELOCITY);
|
||||
ADD_SUBGROUP("Orbit Velocity", "orbit_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_min", PROPERTY_HINT_RANGE, "-2,2,0.001,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_ORBIT_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_max", PROPERTY_HINT_RANGE, "-2,2,0.001,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_ORBIT_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("orbit_velocity", "-2,2,0.001,or_less,or_greater", PARAM_ORBIT_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_ORBIT_VELOCITY);
|
||||
ADD_SUBGROUP("Radial Velocity", "radial_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "radial_velocity_min", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_RADIAL_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "radial_velocity_max", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_RADIAL_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("radial_velocity", "-1000,1000,0.01,or_less,or_greater", PARAM_RADIAL_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "radial_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_RADIAL_VELOCITY);
|
||||
ADD_SUBGROUP("Velocity Limit", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "velocity_limit_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_velocity_limit_curve", "get_velocity_limit_curve");
|
||||
|
@ -2121,32 +2140,26 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ADD_SUBGROUP("Gravity", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity"), "set_gravity", "get_gravity");
|
||||
ADD_SUBGROUP("Linear Accel", "linear_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_accel_min", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_LINEAR_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_accel_max", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_LINEAR_ACCEL);
|
||||
ADD_MIN_MAX_PROPERTY("linear_accel", "-100,100,0.01,or_less,or_greater", PARAM_LINEAR_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "linear_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_LINEAR_ACCEL);
|
||||
ADD_SUBGROUP("Radial Accel", "radial_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "radial_accel_min", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_RADIAL_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "radial_accel_max", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_RADIAL_ACCEL);
|
||||
ADD_MIN_MAX_PROPERTY("radial_accel", "-100,100,0.01,or_less,or_greater", PARAM_RADIAL_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "radial_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_RADIAL_ACCEL);
|
||||
ADD_SUBGROUP("Tangential Accel", "tangential_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "tangential_accel_min", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_TANGENTIAL_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "tangential_accel_max", PROPERTY_HINT_RANGE, "-100,100,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_TANGENTIAL_ACCEL);
|
||||
ADD_MIN_MAX_PROPERTY("tangential_accel", "-100,100,0.01,or_less,or_greater", PARAM_TANGENTIAL_ACCEL);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "tangential_accel_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_TANGENTIAL_ACCEL);
|
||||
ADD_SUBGROUP("Damping", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "damping_min", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_param_min", "get_param_min", PARAM_DAMPING);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "damping_max", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_param_max", "get_param_max", PARAM_DAMPING);
|
||||
ADD_MIN_MAX_PROPERTY("damping", "0,100,0.001,or_greater", PARAM_DAMPING);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "damping_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_DAMPING);
|
||||
ADD_SUBGROUP("Attractor Interaction", "attractor_interaction_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "attractor_interaction_enabled"), "set_attractor_interaction_enabled", "is_attractor_interaction_enabled");
|
||||
|
||||
ADD_GROUP("Display", "");
|
||||
ADD_SUBGROUP("Scale", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "scale_min", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param_min", "get_param_min", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "scale_max", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param_max", "get_param_max", PARAM_SCALE);
|
||||
ADD_MIN_MAX_PROPERTY("scale", "0,1000,0.01,or_greater", PARAM_SCALE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE);
|
||||
ADD_SUBGROUP("Scale Over Velocity", "");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "scale_over_velocity_min", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param_min", "get_param_min", PARAM_SCALE_OVER_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "scale_over_velocity_max", PROPERTY_HINT_RANGE, "0,1000,0.01,or_greater"), "set_param_max", "get_param_max", PARAM_SCALE_OVER_VELOCITY);
|
||||
ADD_MIN_MAX_PROPERTY("scale_over_velocity", "0,1000,0.01,or_greater", PARAM_SCALE_OVER_VELOCITY);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "scale_over_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_SCALE_OVER_VELOCITY);
|
||||
|
||||
ADD_SUBGROUP("Color Curves", "");
|
||||
|
@ -2156,15 +2169,12 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "alpha_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_alpha_curve", "get_alpha_curve");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_emission_curve", "get_emission_curve");
|
||||
ADD_SUBGROUP("Hue Variation", "hue_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "hue_variation_min", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_param_min", "get_param_min", PARAM_HUE_VARIATION);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "hue_variation_max", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_param_max", "get_param_max", PARAM_HUE_VARIATION);
|
||||
ADD_MIN_MAX_PROPERTY("hue_variation", "-1,1,0.01", PARAM_HUE_VARIATION);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "hue_variation_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_HUE_VARIATION);
|
||||
ADD_SUBGROUP("Animation", "anim_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anim_speed_min", PROPERTY_HINT_RANGE, "0,16,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_ANIM_SPEED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anim_speed_max", PROPERTY_HINT_RANGE, "0,16,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_ANIM_SPEED);
|
||||
ADD_MIN_MAX_PROPERTY("anim_speed", "0,16,0.01,or_less,or_greater", PARAM_ANIM_SPEED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_speed_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_SPEED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anim_offset_min", PROPERTY_HINT_RANGE, "0,1,0.0001"), "set_param_min", "get_param_min", PARAM_ANIM_OFFSET);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anim_offset_max", PROPERTY_HINT_RANGE, "0,1,0.0001"), "set_param_max", "get_param_max", PARAM_ANIM_OFFSET);
|
||||
ADD_MIN_MAX_PROPERTY("anim_offset", "0,1,0.0001", PARAM_ANIM_OFFSET);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anim_offset_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_ANIM_OFFSET);
|
||||
|
||||
ADD_GROUP("Turbulence", "turbulence_");
|
||||
|
@ -2173,10 +2183,8 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "turbulence_noise_scale", PROPERTY_HINT_RANGE, "0,10,0.001,or_greater"), "set_turbulence_noise_scale", "get_turbulence_noise_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "turbulence_noise_speed"), "set_turbulence_noise_speed", "get_turbulence_noise_speed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "turbulence_noise_speed_random", PROPERTY_HINT_RANGE, "0,4,0.01"), "set_turbulence_noise_speed_random", "get_turbulence_noise_speed_random");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "turbulence_influence_min", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param_min", "get_param_min", PARAM_TURB_VEL_INFLUENCE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "turbulence_influence_max", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param_max", "get_param_max", PARAM_TURB_VEL_INFLUENCE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "turbulence_initial_displacement_min", PROPERTY_HINT_RANGE, "-100,100,0.1"), "set_param_min", "get_param_min", PARAM_TURB_INIT_DISPLACEMENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "turbulence_initial_displacement_max", PROPERTY_HINT_RANGE, "-100,100,0.1"), "set_param_max", "get_param_max", PARAM_TURB_INIT_DISPLACEMENT);
|
||||
ADD_MIN_MAX_PROPERTY("turbulence_influence", "0,1,0.001", PARAM_TURB_VEL_INFLUENCE);
|
||||
ADD_MIN_MAX_PROPERTY("turbulence_initial_displacement", "-100,100,0.1", PARAM_TURB_INIT_DISPLACEMENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "turbulence_influence_over_life", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_param_texture", "get_param_texture", PARAM_TURB_INFLUENCE_OVER_LIFE);
|
||||
|
||||
ADD_GROUP("Collision", "collision_");
|
||||
|
@ -2237,6 +2245,8 @@ void ParticleProcessMaterial::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(COLLISION_RIGID);
|
||||
BIND_ENUM_CONSTANT(COLLISION_HIDE_ON_CONTACT);
|
||||
BIND_ENUM_CONSTANT(COLLISION_MAX);
|
||||
|
||||
#undef ADD_MIN_MAX_PROPERTY
|
||||
}
|
||||
|
||||
ParticleProcessMaterial::ParticleProcessMaterial() :
|
||||
|
|
|
@ -149,6 +149,7 @@ private:
|
|||
};
|
||||
|
||||
static HashMap<MaterialKey, ShaderData, MaterialKey> shader_map;
|
||||
static RBSet<String> min_max_properties;
|
||||
|
||||
MaterialKey current_key;
|
||||
|
||||
|
@ -361,6 +362,8 @@ protected:
|
|||
void _validate_property(PropertyInfo &p_property) const;
|
||||
|
||||
public:
|
||||
static bool has_min_max_property(const String &p_name);
|
||||
|
||||
void set_direction(Vector3 p_direction);
|
||||
Vector3 get_direction() const;
|
||||
|
||||
|
@ -373,6 +376,9 @@ public:
|
|||
void set_velocity_pivot(const Vector3 &p_pivot);
|
||||
Vector3 get_velocity_pivot();
|
||||
|
||||
void set_param(Parameter p_param, const Vector2 &p_value);
|
||||
Vector2 get_param(Parameter p_param) const;
|
||||
|
||||
void set_param_min(Parameter p_param, float p_value);
|
||||
float get_param_min(Parameter p_param) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue