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
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-12-22 23:00:23 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-01-11 18:00:23 +0300
commit943852c0dc17bff74e3cc91d17c2eeb66adacf33 (patch)
tree875ddff567d967f327a553b0c1c3f4a4105e6f03 /source
parentbda2cd8ba5d14a39aef1927d168f2817d20bbaa8 (diff)
Mesh Batch Cache: Put context evaluation out of batch cache
This is in order to be able to call DRW_mesh_batch_cache_create_requested outside of the draw manager
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_cache.c11
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h5
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c23
3 files changed, 18 insertions, 21 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 96e263cdc30..6fe477b50c6 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -3749,16 +3749,23 @@ bool DRW_vbo_requested(GPUVertBuf *vbo)
void drw_batch_cache_generate_requested(Object *ob)
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const ToolSettings *ts = draw_ctx->scene->toolsettings;
+ const int mode = CTX_data_mode_enum_ex(draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
+ const bool is_paint_mode = ELEM(mode, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
+ const bool use_hide = (ob->type == OB_MESH) && ((is_paint_mode && (ob == draw_ctx->obact)) ||
+ ((mode == CTX_MODE_EDIT_MESH) && BKE_object_is_in_editmode(ob)));
+
struct Mesh *mesh_eval = ob->runtime.mesh_eval;
switch (ob->type) {
case OB_MESH:
- DRW_mesh_batch_cache_create_requested(ob, (Mesh *)ob->data);
+ DRW_mesh_batch_cache_create_requested(ob, (Mesh *)ob->data, ts, is_paint_mode, use_hide);
break;
case OB_CURVE:
case OB_FONT:
case OB_SURF:
if (mesh_eval) {
- DRW_mesh_batch_cache_create_requested(ob, mesh_eval);
+ DRW_mesh_batch_cache_create_requested(ob, mesh_eval, ts, is_paint_mode, use_hide);
}
DRW_curve_batch_cache_create_requested(ob);
break;
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 64a1a72ed37..385147039d6 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -37,6 +37,7 @@ struct ModifierData;
struct ParticleSystem;
struct PTCacheEdit;
struct SpaceImage;
+struct ToolSettings;
struct Curve;
struct Lattice;
@@ -97,7 +98,9 @@ struct GPUBatch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
struct GPUBatch *DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt);
/* Mesh */
-void DRW_mesh_batch_cache_create_requested(struct Object *ob, struct Mesh *me);
+void DRW_mesh_batch_cache_create_requested(
+ struct Object *ob, struct Mesh *me,
+ const struct ToolSettings *ts, const bool is_paint_mode, const bool use_hide);
struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index fd9c44431b7..54f42c310e1 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -5277,30 +5277,17 @@ void DRW_mesh_cache_uvedit(
* \{ */
/* Can be called for any surface type. Mesh *me is the final mesh. */
-void DRW_mesh_batch_cache_create_requested(Object *ob, Mesh *me)
+void DRW_mesh_batch_cache_create_requested(
+ Object *ob, Mesh *me,
+ const ToolSettings *ts, const bool is_paint_mode, const bool use_hide)
{
- const DRWContextState *draw_ctx = DRW_context_state_get();
- const int mode = CTX_data_mode_enum_ex(draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
- const bool is_paint_mode = ELEM(mode, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
- const bool use_hide = (
- (ob->type == OB_MESH) &&
- ((is_paint_mode && (ob == draw_ctx->obact)) ||
- ((mode == CTX_MODE_EDIT_MESH) && BKE_object_is_in_editmode(ob))));
- bool use_face_sel = false;
-
- /* Tex paint face select */
- if (is_paint_mode && (ob->type == OB_MESH) && (draw_ctx->obact == ob)) {
- const Mesh *me_orig = DEG_get_original_object(ob)->data;
- use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
- }
-
MeshBatchCache *cache = mesh_batch_cache_get(me);
/* Check vertex weights. */
- if (cache->batch.surface_weights != 0) {
+ if ((cache->batch.surface_weights != 0) && (ts != NULL)) {
struct DRW_MeshWeightState wstate;
BLI_assert(ob->type == OB_MESH);
- drw_mesh_weight_state_extract(ob, me, draw_ctx->scene->toolsettings, is_paint_mode, &wstate);
+ drw_mesh_weight_state_extract(ob, me, ts, is_paint_mode, &wstate);
mesh_batch_cache_check_vertex_group(cache, &wstate);
drw_mesh_weight_state_copy(&cache->weight_state, &wstate);
drw_mesh_weight_state_clear(&wstate);