Rename get_surface_material to get_surface_override_material

This commit is contained in:
clayjohn 2021-04-13 20:45:16 -07:00
parent b4b7c97d38
commit 92731d292c
16 changed files with 46 additions and 46 deletions

View File

@ -43,7 +43,7 @@
Returns the [Material] that will be used by the [Mesh] when drawing. This can return the [member GeometryInstance3D.material_override], the surface override [Material] defined in this [MeshInstance3D], or the surface [Material] defined in the [Mesh]. For example, if [member GeometryInstance3D.material_override] is used, all surfaces will return the override material. Returns the [Material] that will be used by the [Mesh] when drawing. This can return the [member GeometryInstance3D.material_override], the surface override [Material] defined in this [MeshInstance3D], or the surface [Material] defined in the [Mesh]. For example, if [member GeometryInstance3D.material_override] is used, all surfaces will return the override material.
</description> </description>
</method> </method>
<method name="get_surface_material" qualifiers="const"> <method name="get_surface_override_material" qualifiers="const">
<return type="Material"> <return type="Material">
</return> </return>
<argument index="0" name="surface" type="int"> <argument index="0" name="surface" type="int">
@ -52,14 +52,14 @@
Returns the override [Material] for the specified surface of the [Mesh] resource. Returns the override [Material] for the specified surface of the [Mesh] resource.
</description> </description>
</method> </method>
<method name="get_surface_material_count" qualifiers="const"> <method name="get_surface_override_material_count" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Returns the number of surface materials. Returns the number of surface override materials. This is equivalent to [method Mesh.get_surface_count].
</description> </description>
</method> </method>
<method name="set_surface_material"> <method name="set_surface_override_material">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="surface" type="int"> <argument index="0" name="surface" type="int">

View File

@ -1317,7 +1317,7 @@
Sets the scenario that the instance is in. The scenario is the 3D world that the objects will be displayed in. Sets the scenario that the instance is in. The scenario is the 3D world that the objects will be displayed in.
</description> </description>
</method> </method>
<method name="instance_set_surface_material"> <method name="instance_set_surface_override_material">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="instance" type="RID"> <argument index="0" name="instance" type="RID">
@ -1327,7 +1327,7 @@
<argument index="2" name="material" type="RID"> <argument index="2" name="material" type="RID">
</argument> </argument>
<description> <description>
Sets the material of a specific surface. Equivalent to [method MeshInstance3D.set_surface_material]. Sets the override material of a specific surface. Equivalent to [method MeshInstance3D.set_surface_override_material].
</description> </description>
</method> </method>
<method name="instance_set_transform"> <method name="instance_set_transform">

View File

@ -1241,7 +1241,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
if (mesh.is_valid()) { if (mesh.is_valid()) {
mesh_node->set_mesh(mesh); mesh_node->set_mesh(mesh);
for (int i = 0; i < mesh->get_surface_count(); i++) { for (int i = 0; i < mesh->get_surface_count(); i++) {
mesh_node->set_surface_material(i, src_mesh_node->get_surface_material(i)); mesh_node->set_surface_override_material(i, src_mesh_node->get_surface_material(i));
} }
} }
} }

View File

@ -93,7 +93,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
mesh = mesh->duplicate(); mesh = mesh->duplicate();
for (int j = 0; j < mesh->get_surface_count(); ++j) { for (int j = 0; j < mesh->get_surface_count(); ++j) {
Ref<Material> mat = mi->get_surface_material(j); Ref<Material> mat = mi->get_surface_override_material(j);
if (mat.is_valid()) { if (mat.is_valid()) {
mesh->surface_set_material(j, mat); mesh->surface_set_material(j, mat);

View File

@ -4958,8 +4958,8 @@ GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshIns
if (godot_array_mesh.is_valid()) { if (godot_array_mesh.is_valid()) {
surface_name = godot_array_mesh->surface_get_name(surface_i); surface_name = godot_array_mesh->surface_get_name(surface_i);
} }
if (p_mesh_instance->get_surface_material(surface_i).is_valid()) { if (p_mesh_instance->get_surface_override_material(surface_i).is_valid()) {
mat = p_mesh_instance->get_surface_material(surface_i); mat = p_mesh_instance->get_surface_override_material(surface_i);
} }
if (p_mesh_instance->get_material_override().is_valid()) { if (p_mesh_instance->get_material_override().is_valid()) {
mat = p_mesh_instance->get_material_override(); mat = p_mesh_instance->get_material_override();

View File

@ -259,7 +259,7 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
if (all_override.is_valid()) { if (all_override.is_valid()) {
mf.overrides.push_back(all_override); mf.overrides.push_back(all_override);
} else { } else {
mf.overrides.push_back(mi->get_surface_material(i)); mf.overrides.push_back(mi->get_surface_override_material(i));
} }
} }

View File

@ -343,7 +343,7 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
pm.local_xform = xf; pm.local_xform = xf;
pm.mesh = mesh; pm.mesh = mesh;
for (int i = 0; i < mesh->get_surface_count(); i++) { for (int i = 0; i < mesh->get_surface_count(); i++) {
pm.instance_materials.push_back(mi->get_surface_material(i)); pm.instance_materials.push_back(mi->get_surface_override_material(i));
} }
pm.override_material = mi->get_material_override(); pm.override_material = mi->get_material_override();
plot_meshes.push_back(pm); plot_meshes.push_back(pm);

View File

@ -53,11 +53,11 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
if (p_name.operator String().begins_with("material/")) { if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int(); int idx = p_name.operator String().get_slicec('/', 1).to_int();
if (idx >= materials.size() || idx < 0) { if (idx >= surface_override_materials.size() || idx < 0) {
return false; return false;
} }
set_surface_material(idx, p_value); set_surface_override_material(idx, p_value);
return true; return true;
} }
@ -77,10 +77,10 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name.operator String().begins_with("material/")) { if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int(); int idx = p_name.operator String().get_slicec('/', 1).to_int();
if (idx >= materials.size() || idx < 0) { if (idx >= surface_override_materials.size() || idx < 0) {
return false; return false;
} }
r_ret = materials[idx]; r_ret = surface_override_materials[idx];
return true; return true;
} }
return false; return false;
@ -100,7 +100,7 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
if (mesh.is_valid()) { if (mesh.is_valid()) {
for (int i = 0; i < mesh->get_surface_count(); i++) { for (int i = 0; i < mesh->get_surface_count(); i++) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "material/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE)); p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_material_override/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DEFERRED_SET_RESOURCE));
} }
} }
} }
@ -126,7 +126,7 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
} }
mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed)); mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
materials.resize(mesh->get_surface_count()); surface_override_materials.resize(mesh->get_surface_count());
set_base(mesh->get_rid()); set_base(mesh->get_rid());
} else { } else {
@ -277,26 +277,26 @@ void MeshInstance3D::_notification(int p_what) {
} }
} }
int MeshInstance3D::get_surface_material_count() const { int MeshInstance3D::get_surface_override_material_count() const {
return materials.size(); return surface_override_materials.size();
} }
void MeshInstance3D::set_surface_material(int p_surface, const Ref<Material> &p_material) { void MeshInstance3D::set_surface_override_material(int p_surface, const Ref<Material> &p_material) {
ERR_FAIL_INDEX(p_surface, materials.size()); ERR_FAIL_INDEX(p_surface, surface_override_materials.size());
materials.write[p_surface] = p_material; surface_override_materials.write[p_surface] = p_material;
if (materials[p_surface].is_valid()) { if (surface_override_materials[p_surface].is_valid()) {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid()); RS::get_singleton()->instance_set_surface_override_material(get_instance(), p_surface, surface_override_materials[p_surface]->get_rid());
} else { } else {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID()); RS::get_singleton()->instance_set_surface_override_material(get_instance(), p_surface, RID());
} }
} }
Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const { Ref<Material> MeshInstance3D::get_surface_override_material(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, materials.size(), Ref<Material>()); ERR_FAIL_INDEX_V(p_surface, surface_override_materials.size(), Ref<Material>());
return materials[p_surface]; return surface_override_materials[p_surface];
} }
Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
@ -305,7 +305,7 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
return material_override; return material_override;
} }
Ref<Material> surface_material = get_surface_material(p_surface); Ref<Material> surface_material = get_surface_override_material(p_surface);
if (surface_material.is_valid()) { if (surface_material.is_valid()) {
return surface_material; return surface_material;
} }
@ -320,7 +320,7 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
void MeshInstance3D::_mesh_changed() { void MeshInstance3D::_mesh_changed() {
ERR_FAIL_COND(mesh.is_null()); ERR_FAIL_COND(mesh.is_null());
materials.resize(mesh->get_surface_count()); surface_override_materials.resize(mesh->get_surface_count());
} }
void MeshInstance3D::create_debug_tangents() { void MeshInstance3D::create_debug_tangents() {
@ -408,9 +408,9 @@ void MeshInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_skin", "skin"), &MeshInstance3D::set_skin); ClassDB::bind_method(D_METHOD("set_skin", "skin"), &MeshInstance3D::set_skin);
ClassDB::bind_method(D_METHOD("get_skin"), &MeshInstance3D::get_skin); ClassDB::bind_method(D_METHOD("get_skin"), &MeshInstance3D::get_skin);
ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance3D::get_surface_material_count); ClassDB::bind_method(D_METHOD("get_surface_override_material_count"), &MeshInstance3D::get_surface_override_material_count);
ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance3D::set_surface_material); ClassDB::bind_method(D_METHOD("set_surface_override_material", "surface", "material"), &MeshInstance3D::set_surface_override_material);
ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance3D::get_surface_material); ClassDB::bind_method(D_METHOD("get_surface_override_material", "surface"), &MeshInstance3D::get_surface_override_material);
ClassDB::bind_method(D_METHOD("get_active_material", "surface"), &MeshInstance3D::get_active_material); ClassDB::bind_method(D_METHOD("get_active_material", "surface"), &MeshInstance3D::get_active_material);
ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision); ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision);

View File

@ -52,7 +52,7 @@ protected:
}; };
Map<StringName, BlendShapeTrack> blend_shape_tracks; Map<StringName, BlendShapeTrack> blend_shape_tracks;
Vector<Ref<Material>> materials; Vector<Ref<Material>> surface_override_materials;
void _mesh_changed(); void _mesh_changed();
void _resolve_skeleton_path(); void _resolve_skeleton_path();
@ -75,9 +75,9 @@ public:
void set_skeleton_path(const NodePath &p_skeleton); void set_skeleton_path(const NodePath &p_skeleton);
NodePath get_skeleton_path(); NodePath get_skeleton_path();
int get_surface_material_count() const; int get_surface_override_material_count() const;
void set_surface_material(int p_surface, const Ref<Material> &p_material); void set_surface_override_material(int p_surface, const Ref<Material> &p_material);
Ref<Material> get_surface_material(int p_surface) const; Ref<Material> get_surface_override_material(int p_surface) const;
Ref<Material> get_active_material(int p_surface) const; Ref<Material> get_active_material(int p_surface) const;
Node *create_trimesh_collision_node(); Node *create_trimesh_collision_node();

View File

@ -452,7 +452,7 @@ void SoftBody3D::become_mesh_owner() {
mesh_owner = true; mesh_owner = true;
Vector<Ref<Material>> copy_materials; Vector<Ref<Material>> copy_materials;
copy_materials.append_array(materials); copy_materials.append_array(surface_override_materials);
ERR_FAIL_COND(!mesh->get_surface_count()); ERR_FAIL_COND(!mesh->get_surface_count());
@ -472,7 +472,7 @@ void SoftBody3D::become_mesh_owner() {
set_mesh(soft_mesh); set_mesh(soft_mesh);
for (int i = copy_materials.size() - 1; 0 <= i; --i) { for (int i = copy_materials.size() - 1; 0 <= i; --i) {
set_surface_material(i, copy_materials[i]); set_surface_override_material(i, copy_materials[i]);
} }
} }
} }

View File

@ -69,7 +69,7 @@ public:
virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0; virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0; virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0;
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0; virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material) = 0; virtual void instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) = 0;
virtual void instance_set_visible(RID p_instance, bool p_visible) = 0; virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb) = 0; virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb) = 0;

View File

@ -752,7 +752,7 @@ void RendererSceneCull::instance_set_blend_shape_weight(RID p_instance, int p_sh
} }
} }
void RendererSceneCull::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) { void RendererSceneCull::instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) {
Instance *instance = instance_owner.getornull(p_instance); Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance); ERR_FAIL_COND(!instance);

View File

@ -840,7 +840,7 @@ public:
virtual void instance_set_transform(RID p_instance, const Transform &p_transform); virtual void instance_set_transform(RID p_instance, const Transform &p_transform);
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id); virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id);
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight); virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight);
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material); virtual void instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material);
virtual void instance_set_visible(RID p_instance, bool p_visible); virtual void instance_set_visible(RID p_instance, bool p_visible);
virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb); virtual void instance_set_custom_aabb(RID p_instance, AABB p_aabb);

View File

@ -703,7 +703,7 @@ public:
FUNC2(instance_set_transform, RID, const Transform &) FUNC2(instance_set_transform, RID, const Transform &)
FUNC2(instance_attach_object_instance_id, RID, ObjectID) FUNC2(instance_attach_object_instance_id, RID, ObjectID)
FUNC3(instance_set_blend_shape_weight, RID, int, float) FUNC3(instance_set_blend_shape_weight, RID, int, float)
FUNC3(instance_set_surface_material, RID, int, RID) FUNC3(instance_set_surface_override_material, RID, int, RID)
FUNC2(instance_set_visible, RID, bool) FUNC2(instance_set_visible, RID, bool)
FUNC2(instance_set_custom_aabb, RID, AABB) FUNC2(instance_set_custom_aabb, RID, AABB)

View File

@ -1706,7 +1706,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform); ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform);
ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id); ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id);
ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight); ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight);
ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_material); ClassDB::bind_method(D_METHOD("instance_set_surface_override_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_override_material);
ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible); ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible);
// ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &RenderingServer::instance_set_use_lightmap); // ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &RenderingServer::instance_set_use_lightmap);
ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb); ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb);

View File

@ -1124,7 +1124,7 @@ public:
virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0; virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0; virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0;
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0; virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material) = 0; virtual void instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) = 0;
virtual void instance_set_visible(RID p_instance, bool p_visible) = 0; virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
virtual void instance_set_custom_aabb(RID p_instance, AABB aabb) = 0; virtual void instance_set_custom_aabb(RID p_instance, AABB aabb) = 0;