Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/material.c
| Show All 28 Lines | |||||
| * \ingroup bke | * \ingroup bke | ||||
| */ | */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| Show All 29 Lines | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| /* used in UI and render */ | /* used in UI and render */ | ||||
| Material defmaterial; | Material defmaterial; | ||||
| static CLG_LogRef LOG = {"bke.material"}; | |||||
| /* called on startup, creator.c */ | /* called on startup, creator.c */ | ||||
| void init_def_material(void) | void init_def_material(void) | ||||
| { | { | ||||
| BKE_material_init(&defmaterial); | BKE_material_init(&defmaterial); | ||||
| } | } | ||||
| /** Free (or release) any data used by this material (does not free the material itself). */ | /** Free (or release) any data used by this material (does not free the material itself). */ | ||||
| void BKE_material_free(Material *ma) | void BKE_material_free(Material *ma) | ||||
| ▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | Material **give_current_material_p(Object *ob, short act) | ||||
| totcolp = give_totcolp(ob); | totcolp = give_totcolp(ob); | ||||
| if (totcolp == NULL || ob->totcol == 0) return NULL; | if (totcolp == NULL || ob->totcol == 0) return NULL; | ||||
| /* return NULL for invalid 'act', can happen for mesh face indices */ | /* return NULL for invalid 'act', can happen for mesh face indices */ | ||||
| if (act > ob->totcol) | if (act > ob->totcol) | ||||
| return NULL; | return NULL; | ||||
| else if (act <= 0) { | else if (act <= 0) { | ||||
| if (act < 0) { | if (act < 0) { | ||||
| printf("Negative material index!\n"); | CLOG_ERROR(&LOG, "Negative material index!"); | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (ob->matbits && ob->matbits[act - 1]) { /* in object */ | if (ob->matbits && ob->matbits[act - 1]) { /* in object */ | ||||
| ma_p = &ob->mat[act - 1]; | ma_p = &ob->mat[act - 1]; | ||||
| } | } | ||||
| else { /* in data */ | else { /* in data */ | ||||
| ▲ Show 20 Lines • Show All 397 Lines • ▼ Show 20 Lines | bool BKE_object_material_slot_remove(Main *bmain, Object *ob) | ||||
| short a, actcol; | short a, actcol; | ||||
| if (ob == NULL || ob->totcol == 0) { | if (ob == NULL || ob->totcol == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* this should never happen and used to crash */ | /* this should never happen and used to crash */ | ||||
| if (ob->actcol <= 0) { | if (ob->actcol <= 0) { | ||||
| printf("%s: invalid material index %d, report a bug!\n", __func__, ob->actcol); | CLOG_FATAL(&LOG, "invalid material index %d, report a bug!", ob->actcol); | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* take a mesh/curve/mball as starting point, remove 1 index, | /* take a mesh/curve/mball as starting point, remove 1 index, | ||||
| * AND with all objects that share the ob->data | * AND with all objects that share the ob->data | ||||
| * | * | ||||
| * after that check indices in mesh/curve/mball!!! | * after that check indices in mesh/curve/mball!!! | ||||
| ▲ Show 20 Lines • Show All 489 Lines • Show Last 20 Lines | |||||