Merge pull request #93017 from Chaosus/vs_mesh_emitter_drag_and_drop
Allow drag & drop Mesh to create MeshEmitter in visual shaders
This commit is contained in:
commit
18895b8aac
|
@ -3667,6 +3667,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, cons
|
||||||
bool is_curve = (Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()) != nullptr);
|
bool is_curve = (Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()) != nullptr);
|
||||||
bool is_curve_xyz = (Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()) != nullptr);
|
bool is_curve_xyz = (Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()) != nullptr);
|
||||||
bool is_parameter = (Object::cast_to<VisualShaderNodeParameter>(vsnode.ptr()) != nullptr);
|
bool is_parameter = (Object::cast_to<VisualShaderNodeParameter>(vsnode.ptr()) != nullptr);
|
||||||
|
bool is_mesh_emitter = (Object::cast_to<VisualShaderNodeParticleMeshEmitter>(vsnode.ptr()) != nullptr);
|
||||||
|
|
||||||
Point2 position = graph->get_scroll_offset();
|
Point2 position = graph->get_scroll_offset();
|
||||||
|
|
||||||
|
@ -3879,6 +3880,12 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, cons
|
||||||
if (is_texture2d_array) {
|
if (is_texture2d_array) {
|
||||||
undo_redo->force_fixed_history();
|
undo_redo->force_fixed_history();
|
||||||
undo_redo->add_do_method(vsnode.ptr(), "set_texture_array", ResourceLoader::load(p_resource_path));
|
undo_redo->add_do_method(vsnode.ptr(), "set_texture_array", ResourceLoader::load(p_resource_path));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_mesh_emitter) {
|
||||||
|
undo_redo->add_do_method(vsnode.ptr(), "set_mesh", ResourceLoader::load(p_resource_path));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6062,6 +6069,11 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
||||||
saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE);
|
saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE);
|
||||||
saved_node_pos_dirty = true;
|
saved_node_pos_dirty = true;
|
||||||
_add_node(cubemap_node_option_idx, {}, arr[i], i);
|
_add_node(cubemap_node_option_idx, {}, arr[i], i);
|
||||||
|
} else if (type == "Mesh" && visual_shader->get_mode() == Shader::MODE_PARTICLES &&
|
||||||
|
(visual_shader->get_shader_type() == VisualShader::TYPE_START || visual_shader->get_shader_type() == VisualShader::TYPE_START_CUSTOM)) {
|
||||||
|
saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE);
|
||||||
|
saved_node_pos_dirty = true;
|
||||||
|
_add_node(mesh_emitter_option_idx, {}, arr[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7013,7 +7025,10 @@ VisualShaderEditor::VisualShaderEditor() {
|
||||||
add_options.push_back(AddOption("MultiplyByAxisAngle (*)", "Particles/Transform", "VisualShaderNodeParticleMultiplyByAxisAngle", TTR("A node for help to multiply a position input vector by rotation using specific axis. Intended to work with emitters."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT | TYPE_FLAGS_PROCESS | TYPE_FLAGS_COLLIDE, Shader::MODE_PARTICLES));
|
add_options.push_back(AddOption("MultiplyByAxisAngle (*)", "Particles/Transform", "VisualShaderNodeParticleMultiplyByAxisAngle", TTR("A node for help to multiply a position input vector by rotation using specific axis. Intended to work with emitters."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT | TYPE_FLAGS_PROCESS | TYPE_FLAGS_COLLIDE, Shader::MODE_PARTICLES));
|
||||||
|
|
||||||
add_options.push_back(AddOption("BoxEmitter", "Particles/Emitters", "VisualShaderNodeParticleBoxEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
add_options.push_back(AddOption("BoxEmitter", "Particles/Emitters", "VisualShaderNodeParticleBoxEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
||||||
|
|
||||||
|
mesh_emitter_option_idx = add_options.size();
|
||||||
add_options.push_back(AddOption("MeshEmitter", "Particles/Emitters", "VisualShaderNodeParticleMeshEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
add_options.push_back(AddOption("MeshEmitter", "Particles/Emitters", "VisualShaderNodeParticleMeshEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
||||||
|
|
||||||
add_options.push_back(AddOption("RingEmitter", "Particles/Emitters", "VisualShaderNodeParticleRingEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
add_options.push_back(AddOption("RingEmitter", "Particles/Emitters", "VisualShaderNodeParticleRingEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
||||||
add_options.push_back(AddOption("SphereEmitter", "Particles/Emitters", "VisualShaderNodeParticleSphereEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
add_options.push_back(AddOption("SphereEmitter", "Particles/Emitters", "VisualShaderNodeParticleSphereEmitter", "", {}, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_EMIT, Shader::MODE_PARTICLES));
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,7 @@ class VisualShaderEditor : public ShaderEditor {
|
||||||
int custom_node_option_idx;
|
int custom_node_option_idx;
|
||||||
int curve_node_option_idx;
|
int curve_node_option_idx;
|
||||||
int curve_xyz_node_option_idx;
|
int curve_xyz_node_option_idx;
|
||||||
|
int mesh_emitter_option_idx;
|
||||||
List<String> keyword_list;
|
List<String> keyword_list;
|
||||||
|
|
||||||
List<VisualShaderNodeParameterRef> uniform_refs;
|
List<VisualShaderNodeParameterRef> uniform_refs;
|
||||||
|
|
Loading…
Reference in New Issue