| 419 | } //namespace |
| 420 | |
| 421 | bool FakeMesh::_set(const StringName &p_name, const Variant &p_value) { |
| 422 | String sname = p_name; |
| 423 | |
| 424 | if (sname.begins_with("surface_")) { |
| 425 | int sl = sname.find_char('/'); |
| 426 | if (sl == -1) { |
| 427 | return false; |
| 428 | } |
| 429 | int idx = sname.substr(8, sl - 8).to_int(); |
| 430 | |
| 431 | String what = sname.get_slicec('/', 1); |
| 432 | if (what == "material") { |
| 433 | surfaces.write[idx].material = get_material(p_value, load_type); |
| 434 | } else if (what == "name") { |
| 435 | surfaces.write[idx].name = p_value; |
| 436 | } |
| 437 | return true; |
| 438 | } |
| 439 | |
| 440 | #ifndef DISABLE_DEPRECATED |
| 441 | // Kept for compatibility from 3.x to 4.0. |
| 442 | if (p_name == "blend_shape/names") { |
| 443 | _set_blend_shape_names(p_value); |
| 444 | return true; |
| 445 | } |
| 446 | |
| 447 | if (p_name == "blend_shape/mode") { |
| 448 | set_blend_shape_mode(BlendShapeMode(int(p_value))); |
| 449 | return true; |
| 450 | } |
| 451 | |
| 452 | if (!sname.begins_with("surfaces")) { |
| 453 | return false; |
| 454 | } |
| 455 | |
| 456 | WARN_DEPRECATED_MSG(vformat( |
| 457 | "Mesh uses old surface format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene. Path: \"%s\"", |
| 458 | get_path())); |
| 459 | |
| 460 | int idx = sname.get_slicec('/', 1).to_int(); |
| 461 | String what = sname.get_slicec('/', 2); |
| 462 | |
| 463 | if (idx == surfaces.size()) { |
| 464 | //create |
| 465 | Dictionary d = p_value; |
| 466 | ERR_FAIL_COND_V(!d.has("primitive"), false); |
| 467 | |
| 468 | if (d.has("arrays")) { |
| 469 | //oldest format (2.x) |
| 470 | ERR_FAIL_COND_V(!d.has("morph_arrays"), false); |
| 471 | Array morph_arrays = d["morph_arrays"]; |
| 472 | for (int i = 0; i < morph_arrays.size(); i++) { |
| 473 | morph_arrays[i] = _convert_old_array(morph_arrays[i]); |
| 474 | } |
| 475 | add_surface_from_arrays(_old_primitives[int(d["primitive"])], _convert_old_array(d["arrays"]), morph_arrays); |
| 476 | |
| 477 | } else if (d.has("array_data")) { |
| 478 | //print_line("array data (old style"); |
nothing calls this directly
no test coverage detected