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:
authorCampbell Barton <ideasman42@gmail.com>2017-05-29 13:15:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-05-29 13:17:42 +0300
commit51d1e204b8015cf823170ca769fcf6917c4f6f46 (patch)
tree2c8c728e03db3397e54af07c91c51915664c10a0 /source/blender
parent4e39b316718017b63e8370f2c0eb52a83c4d3292 (diff)
Fix texture paint crash when there are no UV's
Missing check in own recent commits, also only use texture-paint drawing on active object.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index b8ee9dd1e83..8a8decac94c 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -284,46 +284,51 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
{
PAINT_TEXTURE_PassList *psl = ((PAINT_TEXTURE_Data *)vedata)->psl;
PAINT_TEXTURE_StorageList *stl = ((PAINT_TEXTURE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
UNUSED_VARS(psl, stl);
- if (ob->type == OB_MESH) {
+ if ((ob->type == OB_MESH) && (draw_ctx->obact == ob)) {
/* Get geometry cache */
const Mesh *me = ob->data;
- const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
+ bool ok = false;
- if (use_material_slots) {
- struct Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
- if ((me->totcol == 0) || (geom_array == NULL)) {
- struct Batch *geom = DRW_cache_mesh_surface_get(ob);
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
- }
- else {
- for (int i = 0; i < me->totcol; i++) {
- if (stl->g_data->shgroup_image_array[i]) {
- DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
- }
- else {
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
+ if (me->mloopuv != NULL) {
+ if (use_material_slots) {
+ struct Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
+ if ((me->totcol == 0) || (geom_array == NULL)) {
+ struct Batch *geom = DRW_cache_mesh_surface_get(ob);
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
+ ok = true;
+ }
+ else {
+ for (int i = 0; i < me->totcol; i++) {
+ if (stl->g_data->shgroup_image_array[i]) {
+ DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
+ }
+ ok = true;
}
}
}
- }
- else {
- struct Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
- if (geom && stl->g_data->shgroup_image_array[0]) {
- DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
- }
else {
- if (geom == NULL) {
- geom = DRW_cache_mesh_surface_get(ob);
+ struct Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
+ if (geom && stl->g_data->shgroup_image_array[0]) {
+ DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
+ ok = true;
}
- DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
}
}
+ if (!ok) {
+ struct Batch *geom = DRW_cache_mesh_surface_get(ob);
+ DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
+ }
+
/* Face Mask */
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
if (use_face_sel) {