diff options
Diffstat (limited to 'scene/resources/mesh.cpp')
-rw-r--r-- | scene/resources/mesh.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 244ee09c22..c6e492fcb3 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -92,10 +92,23 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { return true; } - if (sname.begins_with("materials/")) { + 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; + } - int idx=sname.get_slice("/",1).to_int()-1; - surface_set_material(idx,p_value); + if (sname=="custom_aabb/custom_aabb") { + + set_custom_aabb(p_value); return true; } @@ -160,10 +173,21 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const { r_ret = get_morph_target_mode(); return true; - } else if (sname.begins_with("materials/")) { + } else 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") + r_ret=surface_get_material(idx); + else if (what=="name") + r_ret=surface_get_name(idx); + return true; + } else if (sname=="custom_aabb/custom_aabb") { - int idx=sname.get_slice("/",1).to_int()-1; - r_ret=surface_get_material(idx); + r_ret=custom_aabb; return true; } else if (!sname.begins_with("surfaces")) @@ -200,8 +224,12 @@ void Mesh::_get_property_list( List<PropertyInfo> *p_list) const { for (int i=0;i<surfaces.size();i++) { p_list->push_back( PropertyInfo( Variant::DICTIONARY,"surfaces/"+itos(i), PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ) ); - p_list->push_back( PropertyInfo( Variant::OBJECT,"materials/"+itos(i+1), PROPERTY_HINT_RESOURCE_TYPE,"Material",PROPERTY_USAGE_EDITOR ) ); + p_list->push_back( PropertyInfo( Variant::STRING,"surface_"+itos(i+1)+"/name", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ) ); + p_list->push_back( PropertyInfo( Variant::OBJECT,"surface_"+itos(i+1)+"/material", PROPERTY_HINT_RESOURCE_TYPE,"Material",PROPERTY_USAGE_EDITOR ) ); } + + p_list->push_back( PropertyInfo( Variant::_AABB,"custom_aabb/custom_aabb" ) ); + } @@ -473,6 +501,19 @@ AABB Mesh::get_aabb() const { return aabb; } + +void Mesh::set_custom_aabb(const AABB& p_custom) { + + custom_aabb=p_custom; + VS::get_singleton()->mesh_set_custom_aabb(mesh,custom_aabb); +} + +AABB Mesh::get_custom_aabb() const { + + return custom_aabb; +} + + DVector<Face3> Mesh::get_faces() const { @@ -700,6 +741,8 @@ void Mesh::_bind_methods() { ObjectTypeDB::bind_method(_MD("center_geometry"),&Mesh::center_geometry); ObjectTypeDB::set_method_flags(get_type_static(),_SCS("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR); + ObjectTypeDB::bind_method(_MD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb); + ObjectTypeDB::bind_method(_MD("get_custom_aabb"),&Mesh::get_custom_aabb); BIND_CONSTANT( NO_INDEX_ARRAY ); |