Only calculate texture paint slots from mtex if renderer is blender
internal. This should eliminate some confusion when people use external render engines.
This commit is contained in:
@@ -86,8 +86,8 @@ short find_material_index(struct Object *ob, struct Material *ma);
|
||||
bool object_add_material_slot(struct Object *ob);
|
||||
bool object_remove_material_slot(struct Object *ob);
|
||||
|
||||
void BKE_texpaint_slot_refresh_cache(struct Material *ma, bool use_nodes);
|
||||
void BKE_texpaint_slots_refresh_object(struct Object *ob, bool use_nodes);
|
||||
void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma);
|
||||
void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob);
|
||||
void BKE_texpaint_slots_clear(struct Material *ma);
|
||||
|
||||
/* rna api */
|
||||
|
||||
@@ -131,6 +131,7 @@ int get_render_shadow_samples(struct RenderData *r, int samples);
|
||||
float get_render_aosss_error(struct RenderData *r, float error);
|
||||
|
||||
bool BKE_scene_use_new_shading_nodes(struct Scene *scene);
|
||||
bool BKE_scene_uses_blender_internal(struct Scene *scene);
|
||||
|
||||
void BKE_scene_disable_color_management(struct Scene *scene);
|
||||
bool BKE_scene_check_color_management_enabled(const struct Scene *scene);
|
||||
|
||||
@@ -2497,11 +2497,10 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
|
||||
}
|
||||
|
||||
if (ELEM(idtype, ID_MA, ID_TE)) {
|
||||
const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(sce);
|
||||
for (obt = bmain->object.first; obt; obt = obt->id.next) {
|
||||
if (obt->mode & OB_MODE_TEXTURE_PAINT) {
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
BKE_texpaint_slots_refresh_object(obt, new_shading_nodes);
|
||||
BKE_texpaint_slots_refresh_object(sce, obt);
|
||||
lib_id_recalc_data_tag(bmain, &obt->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_curve.h"
|
||||
|
||||
@@ -1326,12 +1327,15 @@ static bool get_mtex_slot_valid_texpaint(struct MTex *mtex)
|
||||
mtex->tex->ima);
|
||||
}
|
||||
|
||||
void BKE_texpaint_slot_refresh_cache(Material *ma, bool use_nodes)
|
||||
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
|
||||
{
|
||||
MTex **mtex;
|
||||
short count = 0;
|
||||
short index = 0, i;
|
||||
|
||||
bool use_nodes = BKE_scene_use_new_shading_nodes(scene);
|
||||
bool is_bi = BKE_scene_uses_blender_internal(scene);
|
||||
|
||||
if (!ma)
|
||||
return;
|
||||
|
||||
@@ -1340,10 +1344,10 @@ void BKE_texpaint_slot_refresh_cache(Material *ma, bool use_nodes)
|
||||
ma->texpaintslot = NULL;
|
||||
}
|
||||
|
||||
if (use_nodes) {
|
||||
if (use_nodes || ma->use_nodes) {
|
||||
bNode *node, *active_node;
|
||||
|
||||
if (!(ma->use_nodes && ma->nodetree))
|
||||
if (!(ma->nodetree))
|
||||
return;
|
||||
|
||||
for (node = ma->nodetree->nodes.first; node; node = node->next) {
|
||||
@@ -1369,7 +1373,7 @@ void BKE_texpaint_slot_refresh_cache(Material *ma, bool use_nodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (is_bi) {
|
||||
for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
|
||||
if (get_mtex_slot_valid_texpaint(*mtex)) {
|
||||
count++;
|
||||
@@ -1407,13 +1411,13 @@ void BKE_texpaint_slot_refresh_cache(Material *ma, bool use_nodes)
|
||||
return;
|
||||
}
|
||||
|
||||
void BKE_texpaint_slots_refresh_object(struct Object *ob, bool use_nodes)
|
||||
void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < ob->totcol + 1; i++) {
|
||||
Material *ma = give_current_material(ob, i);
|
||||
BKE_texpaint_slot_refresh_cache(ma, use_nodes);
|
||||
BKE_texpaint_slot_refresh_cache(scene, ma);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1900,6 +1900,12 @@ bool BKE_scene_use_new_shading_nodes(Scene *scene)
|
||||
return (type && type->flag & RE_USE_SHADING_NODES);
|
||||
}
|
||||
|
||||
bool BKE_scene_uses_blender_internal(struct Scene *scene)
|
||||
{
|
||||
return strcmp("BLENDER_INTERNAL", scene->r.engine);
|
||||
}
|
||||
|
||||
|
||||
void BKE_scene_base_flag_to_objects(struct Scene *scene)
|
||||
{
|
||||
Base *base = scene->base.first;
|
||||
|
||||
@@ -1445,10 +1445,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Material *ma;
|
||||
|
||||
bool use_nodes = BKE_scene_use_new_shading_nodes(scene);
|
||||
/* This has to stay here to regenerate the texture paint
|
||||
* cache in case we are loading a file */
|
||||
BKE_texpaint_slots_refresh_object(ob, use_nodes);
|
||||
BKE_texpaint_slots_refresh_object(scene, ob);
|
||||
|
||||
paint_proj_mesh_data_ensure(C, ob, op);
|
||||
|
||||
|
||||
@@ -4886,7 +4886,7 @@ bool proj_paint_add_slot(bContext *C, Material *ma, wmOperator *op)
|
||||
ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float,
|
||||
gen_type, color);
|
||||
|
||||
BKE_texpaint_slot_refresh_cache(ma, false);
|
||||
BKE_texpaint_slot_refresh_cache(scene, ma);
|
||||
BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, mtex->tex);
|
||||
WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima);
|
||||
@@ -4993,7 +4993,7 @@ static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator
|
||||
MEM_freeN(ma->mtex[i]);
|
||||
ma->mtex[i] = NULL;
|
||||
|
||||
BKE_texpaint_slot_refresh_cache(ma, false);
|
||||
BKE_texpaint_slot_refresh_cache(scene, ma);
|
||||
DAG_id_tag_update(&ma->id, 0);
|
||||
WM_event_add_notifier(C, NC_MATERIAL, CTX_data_scene(C));
|
||||
/* we need a notifier for data change since we change the displayed modifier uvs */
|
||||
|
||||
Reference in New Issue
Block a user