bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { String sname = p_name; if (p_name == "blend_shape/names") { PoolVector<String> sk = p_value; int sz = sk.size(); PoolVector<String>::Read r = sk.read(); for (int i = 0; i < sz; i++) add_blend_shape(r[i]); return true; } if (p_name == "blend_shape/mode") { set_blend_shape_mode(BlendShapeMode(int(p_value))); return true; } if (sname.begins_with("surface_")) { int sl = sname.find("/"); if (sl == -1) return false; int idx = sname.substr(8, sl - 8).to_int() - 1; String what = sname.get_slicec('/', 1); if (what == "material") surface_set_material(idx, p_value); else if (what == "name") surface_set_name(idx, p_value); return true; } if (!sname.begins_with("surfaces")) return false; int idx = sname.get_slicec('/', 1).to_int(); String what = sname.get_slicec('/', 2); if (idx == surfaces.size()) { //create Dictionary d = p_value; ERR_FAIL_COND_V(!d.has("primitive"), false); if (d.has("arrays")) { //old format ERR_FAIL_COND_V(!d.has("morph_arrays"), false); add_surface_from_arrays(PrimitiveType(int(d["primitive"])), d["arrays"], d["morph_arrays"]); } else if (d.has("array_data")) { PoolVector<uint8_t> array_data = d["array_data"]; PoolVector<uint8_t> array_index_data; if (d.has("array_index_data")) array_index_data = d["array_index_data"]; ERR_FAIL_COND_V(!d.has("format"), false); uint32_t format = d["format"]; uint32_t primitive = d["primitive"]; ERR_FAIL_COND_V(!d.has("vertex_count"), false); int vertex_count = d["vertex_count"]; int index_count = 0; if (d.has("index_count")) index_count = d["index_count"]; Vector<PoolVector<uint8_t> > blend_shapes; if (d.has("blend_shape_data")) { Array blend_shape_data = d["blend_shape_data"]; for (int i = 0; i < blend_shape_data.size(); i++) { PoolVector<uint8_t> shape = blend_shape_data[i]; blend_shapes.push_back(shape); } } ERR_FAIL_COND_V(!d.has("aabb"), false); AABB aabb = d["aabb"]; Vector<AABB> bone_aabb; if (d.has("skeleton_aabb")) { Array baabb = d["skeleton_aabb"]; bone_aabb.resize(baabb.size()); for (int i = 0; i < baabb.size(); i++) { bone_aabb[i] = baabb[i]; } } add_surface(format, PrimitiveType(primitive), array_data, vertex_count, array_index_data, index_count, aabb, blend_shapes, bone_aabb); } else { ERR_FAIL_V(false); } if (d.has("material")) { surface_set_material(idx, d["material"]); } if (d.has("name")) { surface_set_name(idx, d["name"]); } return true; } return false; }
bool Mesh::_set(const StringName& p_name, const Variant& p_value) { String sname=p_name; if (p_name=="morph_target/names") { DVector<String> sk=p_value; int sz = sk.size(); DVector<String>::Read r = sk.read(); for(int i=0;i<sz;i++) add_morph_target(r[i]); return true; } if (p_name=="morph_target/mode") { set_morph_target_mode(MorphTargetMode(int(p_value))); return true; } if (sname.begins_with("surface_")) { int sl=sname.find("/"); if (sl==-1) return false; int idx=sname.substr(8,sl-8).to_int()-1; String what = sname.get_slice("/",1); if (what=="material") surface_set_material(idx,p_value); else if (what=="name") surface_set_name(idx,p_value); return true; } if (sname=="custom_aabb/custom_aabb") { set_custom_aabb(p_value); return true; } if (!sname.begins_with("surfaces")) return false; int idx=sname.get_slice("/",1).to_int(); String what=sname.get_slice("/",2); if (idx==surfaces.size()) { if (what=="custom") { add_custom_surface(p_value); return true; } //create Dictionary d=p_value; ERR_FAIL_COND_V(!d.has("primitive"),false); ERR_FAIL_COND_V(!d.has("arrays"),false); ERR_FAIL_COND_V(!d.has("morph_arrays"),false); bool alphasort = d.has("alphasort") && bool(d["alphasort"]); add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort); if (d.has("material")) { surface_set_material(idx,d["material"]); } if (d.has("name")) { surface_set_name(idx,d["name"]); } return true; } if (what=="custom_aabb") { surface_set_custom_aabb(idx,p_value); return true; } return false; }