Merge pull request #72473 from aXu-AP/animatablebody3d-editor-move-fix

Fix AnimatableBody3D not being movable in editor
This commit is contained in:
Rémi Verschelde 2023-02-01 07:28:47 +01:00
commit a350b42e4b
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 32 additions and 8 deletions

View file

@ -333,6 +333,11 @@ void AnimatableBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
}
void AnimatableBody3D::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
return;
}
#endif
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform();

View file

@ -6923,15 +6923,34 @@ void VisualShaderNodeSwitch::_bind_methods() { // static
}
String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
bool use_mix = false;
switch (op_type) {
case OP_TYPE_FLOAT: {
use_mix = true;
} break;
case OP_TYPE_VECTOR_2D: {
use_mix = true;
} break;
case OP_TYPE_VECTOR_3D: {
use_mix = true;
} break;
case OP_TYPE_VECTOR_4D: {
use_mix = true;
} break;
default: {
} break;
}
String code;
code += " if(" + p_input_vars[0] + ")\n";
code += " {\n";
code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n";
code += " }\n";
code += " else\n";
code += " {\n";
code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n";
code += " }\n";
if (use_mix) {
code += " " + p_output_vars[0] + " = mix(" + p_input_vars[2] + ", " + p_input_vars[1] + ", float(" + p_input_vars[0] + "));\n";
} else {
code += " if (" + p_input_vars[0] + ") {\n";
code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n";
code += " } else {\n";
code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n";
code += " }\n";
}
return code;
}