Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 5f53d5e1ae8..fa3fbd457d1 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -46,6 +46,7 @@
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_volume_types.h"
@@ -73,6 +74,7 @@
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
+#include "BKE_object.h"
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
@@ -462,21 +464,33 @@ static void material_data_index_remove_id(ID *id, short index)
}
}
-bool BKE_object_material_slot_used(ID *id, short actcol)
+bool BKE_object_material_slot_used(Object *object, short actcol)
{
- /* ensure we don't try get materials from non-obdata */
- BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
+ if (!BKE_object_supports_material_slots(object)) {
+ return false;
+ }
- switch (GS(id->name)) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
+ if (psys->part->omat == actcol) {
+ return true;
+ }
+ }
+
+ ID *ob_data = object->data;
+ if (ob_data == NULL || !OB_DATA_SUPPORT_ID(GS(ob_data->name))) {
+ return false;
+ }
+
+ switch (GS(ob_data->name)) {
case ID_ME:
- return BKE_mesh_material_index_used((Mesh *)id, actcol - 1);
+ return BKE_mesh_material_index_used((Mesh *)ob_data, actcol - 1);
case ID_CU:
- return BKE_curve_material_index_used((Curve *)id, actcol - 1);
+ return BKE_curve_material_index_used((Curve *)ob_data, actcol - 1);
case ID_MB:
- /* meta-elems don't have materials atm */
+ /* Meta-elements don't support materials at the moment. */
return false;
case ID_GD:
- return BKE_gpencil_material_index_used((bGPdata *)id, actcol - 1);
+ return BKE_gpencil_material_index_used((bGPdata *)ob_data, actcol - 1);
default:
return false;
}