| 67 | #endif // NAVIGATION_3D_DISABLED |
| 68 | |
| 69 | bool GridMap::_set(const StringName &p_name, const Variant &p_value) { |
| 70 | String name = p_name; |
| 71 | |
| 72 | if (name == "data") { |
| 73 | Dictionary d = p_value; |
| 74 | |
| 75 | if (d.has("cells")) { |
| 76 | Vector<int> cells = d["cells"]; |
| 77 | int amount = cells.size(); |
| 78 | const int *r = cells.ptr(); |
| 79 | ERR_FAIL_COND_V(amount % 3, false); // not even |
| 80 | cell_map.clear(); |
| 81 | for (int i = 0; i < amount / 3; i++) { |
| 82 | IndexKey ik; |
| 83 | ik.key = decode_uint64((const uint8_t *)&r[i * 3]); |
| 84 | Cell cell; |
| 85 | cell.cell = decode_uint32((const uint8_t *)&r[i * 3 + 2]); |
| 86 | cell_map[ik] = cell; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | _recreate_octant_data(); |
| 91 | |
| 92 | } else if (name == "baked_meshes") { |
| 93 | clear_baked_meshes(); |
| 94 | |
| 95 | Array meshes = p_value; |
| 96 | |
| 97 | RID scenario; |
| 98 | if (is_inside_tree()) { |
| 99 | scenario = get_world_3d()->get_scenario(); |
| 100 | } |
| 101 | |
| 102 | for (int i = 0; i < meshes.size(); i++) { |
| 103 | BakedMesh bm; |
| 104 | bm.mesh = meshes[i]; |
| 105 | ERR_CONTINUE(bm.mesh.is_null()); |
| 106 | bm.instance = RS::get_singleton()->instance_create(); |
| 107 | RS::get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid()); |
| 108 | RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id()); |
| 109 | if (is_inside_tree()) { |
| 110 | RS::get_singleton()->instance_set_scenario(bm.instance, scenario); |
| 111 | RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform()); |
| 112 | } |
| 113 | baked_meshes.push_back(bm); |
| 114 | } |
| 115 | |
| 116 | _recreate_octant_data(); |
| 117 | |
| 118 | } else { |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | bool GridMap::_get(const StringName &p_name, Variant &r_ret) const { |
| 126 | String name = p_name; |
nothing calls this directly
no test coverage detected