Vertex paint with draw manager

Reviewers: fclem

Subscribers: campbellbarton, dfelinto

Differential Revision: https://developer.blender.org/D2658
This commit is contained in:
Luca Rood 2017-05-04 19:59:27 +02:00
parent b5b9b2d04d
commit 3103b819aa
19 changed files with 370 additions and 183 deletions

View File

@ -130,12 +130,33 @@ class COLLECTION_PT_paint_weight_mode_settings(CollectionButtonsPanel, Panel):
col.template_override_property(collection_props, scene_props, "use_shading")
col.template_override_property(collection_props, scene_props, "use_wire")
class COLLECTION_PT_paint_vertex_mode_settings(CollectionButtonsPanel, Panel):
bl_label = "Vertex Paint Mode Settings"
@classmethod
def poll(cls, context):
ob = context.object
return ob and (ob.mode == 'VERTEX_PAINT')
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['VertexPaintMode']
collection = context.layer_collection
collection_props = collection.engine_overrides['VertexPaintMode']
col = layout.column()
col.template_override_property(collection_props, scene_props, "use_shading")
col.template_override_property(collection_props, scene_props, "use_wire")
classes = (
COLLECTION_PT_context_collection,
COLLECTION_PT_clay_settings,
COLLECTION_PT_object_mode_settings,
COLLECTION_PT_edit_mode_settings,
COLLECTION_PT_paint_weight_mode_settings,
COLLECTION_PT_paint_vertex_mode_settings,
)
if __name__ == "__main__": # only for live edit.

View File

@ -411,7 +411,7 @@ void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
BKE_MESH_BATCH_DIRTY_SELECT,
BKE_MESH_BATCH_DIRTY_WEIGHT,
BKE_MESH_BATCH_DIRTY_PAINT,
};
void BKE_mesh_batch_cache_dirty(struct Mesh *me, int mode);
void BKE_mesh_batch_cache_free(struct Mesh *me);

View File

@ -74,7 +74,7 @@ bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
BLI_addtail(&ob->defbase, defgroup);
defgroup_unique_name(defgroup, ob);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
return defgroup;
}

View File

@ -1105,6 +1105,22 @@ static void layer_collection_create_mode_settings_paint_weight(IDProperty *root,
IDP_AddToGroup(root, props);
}
static void layer_collection_create_mode_settings_paint_vertex(IDProperty *root, const bool populate)
{
IDProperty *props;
IDPropertyTemplate val = {0};
props = IDP_New(IDP_GROUP, &val, "VertexPaintMode");
props->subtype = IDP_GROUP_SUB_MODE_PAINT_VERTEX;
/* properties */
if (populate) {
PAINT_VERTEX_collection_settings_create(props);
}
IDP_AddToGroup(root, props);
}
static void collection_create_render_settings(IDProperty *root, const bool populate)
{
CollectionEngineSettingsCB_Type *ces_type;
@ -1121,6 +1137,7 @@ static void collection_create_mode_settings(IDProperty *root, const bool populat
layer_collection_create_mode_settings_object(root, populate);
layer_collection_create_mode_settings_edit(root, populate);
layer_collection_create_mode_settings_paint_weight(root, populate);
layer_collection_create_mode_settings_paint_vertex(root, populate);
}
static int idproperty_group_subtype(const int mode_type)
@ -1137,6 +1154,9 @@ static int idproperty_group_subtype(const int mode_type)
case COLLECTION_MODE_PAINT_WEIGHT:
idgroup_type = IDP_GROUP_SUB_MODE_PAINT_WEIGHT;
break;
case COLLECTION_MODE_PAINT_VERTEX:
idgroup_type = IDP_GROUP_SUB_MODE_PAINT_VERTEX;
break;
default:
case COLLECTION_MODE_NONE:
return IDP_GROUP_SUB_ENGINE_RENDER;

View File

@ -407,7 +407,7 @@ void BKE_object_defgroup_remove(Object *ob, bDeformGroup *defgroup)
else
object_defgroup_remove_object_mode(ob, defgroup);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
}
/**

View File

@ -90,5 +90,6 @@ void OBJECT_collection_settings_create(struct IDProperty *properties);
void EDIT_MESH_collection_settings_create(struct IDProperty *properties);
void EDIT_ARMATURE_collection_settings_create(struct IDProperty *properties);
void PAINT_WEIGHT_collection_settings_create(struct IDProperty *properties);
void PAINT_VERTEX_collection_settings_create(struct IDProperty *properties);
#endif /* __DRW_ENGINE_H__ */

View File

@ -1777,6 +1777,14 @@ Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, ob->actdef - 1);
}
Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
return DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(me);
}
/* Return list of batches */
Batch **DRW_cache_mesh_surface_shaded_get(Object *ob)
{
@ -1810,12 +1818,12 @@ Batch *DRW_cache_mesh_verts_get(Object *ob)
return DRW_mesh_batch_cache_get_all_verts(me);
}
Batch *DRW_cache_mesh_edges_weight_overlay_get(Object *ob, bool use_wire, bool use_sel)
Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel, bool use_theme)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel);
return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel, use_theme);
}
Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)

View File

@ -95,10 +95,11 @@ struct Batch *DRW_cache_face_centers_get(struct Object *ob);
struct Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
struct Batch *DRW_cache_mesh_edges_get(struct Object *ob);
struct Batch *DRW_cache_mesh_verts_get(struct Object *ob);
struct Batch *DRW_cache_mesh_edges_weight_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
struct Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel, bool use_theme);
struct Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob);
struct Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob);
struct Batch **DRW_cache_mesh_surface_shaded_get(struct Object *ob);

View File

@ -68,13 +68,14 @@ struct Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
/* Mesh */
struct Batch **DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel);
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel, bool use_theme);
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup);
struct Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
struct Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);

View File

@ -50,6 +50,8 @@
#include "GPU_batch.h"
#include "UI_resources.h"
#include "draw_cache_impl.h" /* own include */
static void mesh_batch_cache_clear(Mesh *me);
@ -124,6 +126,7 @@ typedef struct MeshRenderData {
MLoopCol **mloopcol;
float (**mtangent)[4];
MDeformVert *dvert;
MLoopCol *loopcol;
BMVert *eve_act;
BMEdge *eed_act;
@ -156,7 +159,8 @@ typedef struct MeshRenderData {
int *loose_verts;
float (*poly_normals)[3];
float (*vert_color)[3];
float (*vert_weight_color)[3];
char (*vert_color)[3];
short (*poly_normals_short)[3];
short (*vert_normals_short)[3];
bool *edge_selection;
@ -171,6 +175,7 @@ enum {
MR_DATATYPE_OVERLAY = 1 << 5,
MR_DATATYPE_SHADING = 1 << 6,
MR_DATATYPE_DVERT = 1 << 7,
MR_DATATYPE_LOOPCOL = 1 << 8,
};
/**
@ -313,6 +318,10 @@ static MeshRenderData *mesh_render_data_create(Mesh *me, const int types)
rdata->vert_len = me->totvert;
rdata->dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
}
if (types & MR_DATATYPE_LOOPCOL) {
rdata->loop_len = me->totloop;
rdata->loopcol = CustomData_get_layer(&me->ldata, CD_MLOOPCOL);
}
}
if (types & MR_DATATYPE_SHADING) {
@ -472,8 +481,9 @@ static void mesh_render_data_free(MeshRenderData *rdata)
MEM_SAFE_FREE(rdata->uv_names);
MEM_SAFE_FREE(rdata->vcol_names);
MEM_SAFE_FREE(rdata->tangent_names);
MEM_SAFE_FREE(rdata->vert_color);
MEM_SAFE_FREE(rdata->vert_weight_color);
MEM_SAFE_FREE(rdata->edge_selection);
MEM_SAFE_FREE(rdata->vert_color);
MEM_freeN(rdata);
}
@ -1031,7 +1041,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
return false;
}
float (*vweight)[3] = rdata->vert_color;
float (*vweight)[3] = rdata->vert_weight_color;
short (*pnors_short)[3] = rdata->poly_normals_short;
short (*vnors_short)[3] = rdata->vert_normals_short;
@ -1069,7 +1079,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
BLI_assert(cd_dvert_offset != -1);
vweight = rdata->vert_color = MEM_mallocN(sizeof(*vweight) * rdata->vert_len, __func__);
vweight = rdata->vert_weight_color = MEM_mallocN(sizeof(*vweight) * rdata->vert_len, __func__);
BM_ITER_MESH_INDEX(vert, &viter, bm, BM_VERT, i) {
const MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, cd_dvert_offset);
float weight = defvert_find_weight(dvert, defgroup);
@ -1082,7 +1092,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
}
}
else {
vweight = rdata->vert_color = MEM_callocN(sizeof(*vweight) * rdata->vert_len, __func__);
vweight = rdata->vert_weight_color = MEM_callocN(sizeof(*vweight) * rdata->vert_len, __func__);
for (int i = 0; i < rdata->vert_len; i++) {
vweight[i][2] = 0.5f;
@ -1105,7 +1115,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
}
else {
const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
float (*vweight)[3] = rdata->vert_color;
float (*vweight)[3] = rdata->vert_weight_color;
short (*pnors_short)[3] = rdata->poly_normals_short;
if (!pnors_short) {
@ -1126,7 +1136,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
if (!vweight) {
if (rdata->dvert) {
vweight = rdata->vert_color = MEM_mallocN(sizeof(*vweight) * rdata->vert_len, __func__);
vweight = rdata->vert_weight_color = MEM_mallocN(sizeof(*vweight) * rdata->vert_len, __func__);
for (int i = 0; i < rdata->vert_len; i++) {
float weight = defvert_find_weight(&rdata->dvert[i], defgroup);
@ -1139,7 +1149,7 @@ static bool mesh_render_data_looptri_cos_weights_get(
}
}
else {
vweight = rdata->vert_color = MEM_callocN(sizeof(*vweight) * rdata->vert_len, __func__);
vweight = rdata->vert_weight_color = MEM_callocN(sizeof(*vweight) * rdata->vert_len, __func__);
for (int i = 0; i < rdata->vert_len; i++) {
vweight[i][2] = 0.5f;
@ -1164,10 +1174,80 @@ static bool mesh_render_data_looptri_cos_weights_get(
return true;
}
static bool mesh_render_data_looptri_cos_vert_colors_get(
MeshRenderData *rdata, const int tri_idx,
float *(*r_vert_cos)[3], char *(*r_vert_colors)[3],
short **r_tri_nor, short *(*r_vert_nors)[3], bool *r_is_smooth)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL));
if (rdata->edit_bmesh) {
return false;
}
else {
const MLoopTri *mlt = &rdata->mlooptri[tri_idx];
char (*vcol)[3] = rdata->vert_color;
short (*pnors_short)[3] = rdata->poly_normals_short;
if (!pnors_short) {
float (*pnors)[3] = rdata->poly_normals;
if (!pnors) {
pnors = rdata->poly_normals = MEM_mallocN(sizeof(*pnors) * rdata->poly_len, __func__);
BKE_mesh_calc_normals_poly(
rdata->mvert, NULL, rdata->vert_len,
rdata->mloop, rdata->mpoly, rdata->loop_len, rdata->poly_len, pnors, true);
}
pnors_short = rdata->poly_normals_short = MEM_mallocN(sizeof(*pnors_short) * rdata->poly_len, __func__);
for (int i = 0; i < rdata->poly_len; i++) {
normal_float_to_short_v3(pnors_short[i], pnors[i]);
}
}
if (!vcol) {
if (rdata->loopcol) {
vcol = rdata->vert_color = MEM_mallocN(sizeof(*vcol) * rdata->loop_len, __func__);
for (int i = 0; i < rdata->loop_len; i++) {
vcol[i][0] = rdata->loopcol[i].r;
vcol[i][1] = rdata->loopcol[i].g;
vcol[i][2] = rdata->loopcol[i].b;
}
}
else {
vcol = rdata->vert_color = MEM_mallocN(sizeof(*vcol) * rdata->loop_len, __func__);
for (int i = 0; i < rdata->loop_len; i++) {
vcol[i][0] = 255;
vcol[i][1] = 255;
vcol[i][2] = 255;
}
}
}
(*r_vert_cos)[0] = rdata->mvert[rdata->mloop[mlt->tri[0]].v].co;
(*r_vert_cos)[1] = rdata->mvert[rdata->mloop[mlt->tri[1]].v].co;
(*r_vert_cos)[2] = rdata->mvert[rdata->mloop[mlt->tri[2]].v].co;
(*r_vert_colors)[0] = vcol[mlt->tri[0]];
(*r_vert_colors)[1] = vcol[mlt->tri[1]];
(*r_vert_colors)[2] = vcol[mlt->tri[2]];
*r_tri_nor = pnors_short[mlt->poly];
(*r_vert_nors)[0] = rdata->mvert[rdata->mloop[mlt->tri[0]].v].no;
(*r_vert_nors)[1] = rdata->mvert[rdata->mloop[mlt->tri[1]].v].no;
(*r_vert_nors)[2] = rdata->mvert[rdata->mloop[mlt->tri[2]].v].no;
*r_is_smooth = (rdata->mpoly[mlt->poly].flag & ME_SMOOTH) != 0;
}
return true;
}
static bool mesh_render_data_edge_cos_sel_get(
MeshRenderData *rdata, const int edge_idx,
float r_vert_cos[2][3], float r_vert_col[3],
bool use_wire, bool use_sel)
bool use_wire, bool use_sel, bool use_theme)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
@ -1198,9 +1278,14 @@ static bool mesh_render_data_edge_cos_sel_get(
}
if (use_sel && rdata->edge_selection[edge_idx]) {
r_vert_col[0] = 1.0f;
r_vert_col[1] = 1.0f;
r_vert_col[2] = 1.0f;
if (use_theme) {
UI_GetThemeColorShade3fv(TH_EDGE_SELECT, -50, r_vert_col);
}
else {
r_vert_col[0] = 1.0f;
r_vert_col[1] = 1.0f;
r_vert_col[2] = 1.0f;
}
}
else {
if (use_wire) {
@ -1463,11 +1548,13 @@ typedef struct MeshBatchCache {
VertexBuffer *pos_with_normals;
VertexBuffer *pos_with_weights;
VertexBuffer *pos_with_vert_colors;
VertexBuffer *edge_pos_with_sel;
VertexBuffer *tri_pos_with_sel;
VertexBuffer *pos_with_sel;
Batch *triangles_with_normals;
Batch *triangles_with_weights;
Batch *triangles_with_vert_colors;
Batch *points_with_normals;
Batch *fancy_edges; /* owns its vertex buffer (not shared) */
@ -1492,7 +1579,7 @@ typedef struct MeshBatchCache {
/* settings to determine if cache is invalid */
bool is_dirty;
bool is_weight_dirty;
bool is_paint_dirty;
int edge_len;
int tri_len;
int poly_len;
@ -1520,7 +1607,7 @@ static bool mesh_batch_cache_valid(Mesh *me)
return false;
}
if (cache->is_weight_dirty) {
if (cache->is_paint_dirty) {
return false;
}
@ -1567,7 +1654,7 @@ static void mesh_batch_cache_init(Mesh *me)
cache->mat_len = mesh_render_mat_len_get(me);
cache->is_dirty = false;
cache->is_weight_dirty = false;
cache->is_paint_dirty = false;
}
static MeshBatchCache *mesh_batch_cache_get(Mesh *me)
@ -1596,8 +1683,8 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
BATCH_DISCARD_ALL_SAFE(cache->overlay_loose_edges);
BATCH_DISCARD_ALL_SAFE(cache->overlay_facedots);
break;
case BKE_MESH_BATCH_DIRTY_WEIGHT:
cache->is_weight_dirty = true;
case BKE_MESH_BATCH_DIRTY_PAINT:
cache->is_paint_dirty = true;
break;
default:
BLI_assert(0);
@ -1631,6 +1718,7 @@ static void mesh_batch_cache_clear(Mesh *me)
BATCH_DISCARD_SAFE(cache->points_with_normals);
VERTEXBUFFER_DISCARD_SAFE(cache->pos_with_normals);
BATCH_DISCARD_ALL_SAFE(cache->triangles_with_weights);
BATCH_DISCARD_ALL_SAFE(cache->triangles_with_vert_colors);
BATCH_DISCARD_ALL_SAFE(cache->fancy_edges);
@ -1946,6 +2034,72 @@ static VertexBuffer *mesh_batch_cache_get_pos_normals_and_weights(
return cache->pos_with_weights;
}
static VertexBuffer *mesh_batch_cache_get_pos_normals_and_vert_colors(
MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(
rdata->types &
(MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL));
if (cache->pos_with_vert_colors == NULL) {
unsigned int vidx = 0, cidx = 0, nidx = 0;
static VertexFormat format = { 0 };
static unsigned int pos_id, col_id, nor_id;
if (format.attrib_ct == 0) {
/* initialize vertex format */
pos_id = VertexFormat_add_attrib(&format, "pos", COMP_F32, 3, KEEP_FLOAT);
nor_id = VertexFormat_add_attrib(&format, "nor", COMP_I16, 3, NORMALIZE_INT_TO_FLOAT);
col_id = VertexFormat_add_attrib(&format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
}
const int tri_len = mesh_render_data_looptri_len_get(rdata);
VertexBuffer *vbo = cache->pos_with_vert_colors = VertexBuffer_create_with_format(&format);
const int vbo_len_capacity = tri_len * 3;
int vbo_len_used = 0;
VertexBuffer_allocate_data(vbo, vbo_len_capacity);
for (int i = 0; i < tri_len; i++) {
float *tri_vert_cos[3];
char *tri_vert_colors[3];
short *tri_nor, *tri_vert_nors[3];
bool is_smooth;
if (mesh_render_data_looptri_cos_vert_colors_get(
rdata, i, &tri_vert_cos, &tri_vert_colors, &tri_nor, &tri_vert_nors, &is_smooth))
{
VertexBuffer_set_attrib(vbo, col_id, cidx++, tri_vert_colors[0]);
VertexBuffer_set_attrib(vbo, col_id, cidx++, tri_vert_colors[1]);
VertexBuffer_set_attrib(vbo, col_id, cidx++, tri_vert_colors[2]);
VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[0]);
VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[1]);
VertexBuffer_set_attrib(vbo, pos_id, vidx++, tri_vert_cos[2]);
if (is_smooth) {
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_vert_nors[0]);
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_vert_nors[1]);
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_vert_nors[2]);
}
else {
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_nor);
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_nor);
VertexBuffer_set_attrib(vbo, nor_id, nidx++, tri_nor);
}
}
}
vbo_len_used = vidx;
if (vbo_len_capacity != vbo_len_used) {
VertexBuffer_resize_data(vbo, vbo_len_used);
}
}
return cache->pos_with_vert_colors;
}
static VertexBuffer *mesh_batch_cache_get_pos_and_nor_in_order(MeshRenderData *rdata, MeshBatchCache *cache)
{
BLI_assert(rdata->types & MR_DATATYPE_VERT);
@ -2065,7 +2219,7 @@ static ElementList **mesh_batch_cache_get_shaded_triangles_in_order(MeshRenderDa
}
static VertexBuffer *mesh_batch_cache_get_edge_pos_with_sel(
MeshRenderData *rdata, MeshBatchCache *cache, bool use_wire, bool use_sel)
MeshRenderData *rdata, MeshBatchCache *cache, bool use_wire, bool use_sel, bool use_theme)
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP));
@ -2092,7 +2246,7 @@ static VertexBuffer *mesh_batch_cache_get_edge_pos_with_sel(
static float edge_vert_cos[2][3], edge_vert_col[3];
if (mesh_render_data_edge_cos_sel_get(
rdata, i, edge_vert_cos, edge_vert_col, use_wire, use_sel))
rdata, i, edge_vert_cos, edge_vert_col, use_wire, use_sel, use_theme))
{
VertexBuffer_set_attrib(vbo, col_id, cidx++, edge_vert_col);
VertexBuffer_set_attrib(vbo, col_id, cidx++, edge_vert_col);
@ -2278,6 +2432,24 @@ Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int
return cache->triangles_with_weights;
}
Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
if (cache->triangles_with_vert_colors == NULL) {
const int datatype =
MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL;
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
cache->triangles_with_vert_colors = Batch_create(
PRIM_TRIANGLES, mesh_batch_cache_get_pos_normals_and_vert_colors(rdata, cache), NULL);
mesh_render_data_free(rdata);
}
return cache->triangles_with_vert_colors;
}
Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@ -2588,7 +2760,7 @@ Batch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me)
return cache->shaded_triangles;
}
Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel)
Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel, bool use_theme)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@ -2598,7 +2770,7 @@ Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bo
MeshRenderData *rdata = mesh_render_data_create(me, datatype);
cache->overlay_weight_edges = Batch_create(
PRIM_LINES, mesh_batch_cache_get_edge_pos_with_sel(rdata, cache, use_wire, use_sel), NULL);
PRIM_LINES, mesh_batch_cache_get_edge_pos_with_sel(rdata, cache, use_wire, use_sel, use_theme), NULL);
mesh_render_data_free(rdata);
}

View File

@ -1189,7 +1189,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if (do_outlines) {
Object *obedit = scene->obedit;
if (ob != obedit && !(sl->basact->object == ob && ob->mode & OB_MODE_WEIGHT_PAINT)) {
if (ob != obedit && !(sl->basact->object == ob && ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT))) {
struct Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
theme_id = DRW_object_wire_theme_get(ob, sl, NULL);

View File

@ -33,52 +33,29 @@
#include "draw_mode_engines.h"
/* If needed, contains all global/Theme colors
* Add needed theme colors / values to DRW_globals_update() and update UBO
* Not needed for constant color. */
#include "DNA_mesh_types.h"
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GlobalsUboStorage ts; /* draw_common.c */
/* *********** LISTS *********** */
/* All lists are per viewport specific datas.
* They are all free when viewport changes engines
* or is free itself. Use PAINT_VERTEX_engine_init() to
* initialize most of them and PAINT_VERTEX_cache_init()
* for PAINT_VERTEX_PassList */
typedef struct PAINT_VERTEX_PassList {
/* Declare all passes here and init them in
* PAINT_VERTEX_cache_init().
* Only contains (DRWPass *) */
struct DRWPass *pass;
struct DRWPass *vcolor_faces;
struct DRWPass *wire_overlay;
} PAINT_VERTEX_PassList;
typedef struct PAINT_VERTEX_FramebufferList {
/* Contains all framebuffer objects needed by this engine.
* Only contains (GPUFrameBuffer *) */
struct GPUFrameBuffer *fb;
} PAINT_VERTEX_FramebufferList;
typedef struct PAINT_VERTEX_TextureList {
/* Contains all framebuffer textures / utility textures
* needed by this engine. Only viewport specific textures
* (not per object). Only contains (GPUTexture *) */
struct GPUTexture *texture;
} PAINT_VERTEX_TextureList;
typedef struct PAINT_VERTEX_StorageList {
/* Contains any other memory block that the engine needs.
* Only directly MEM_(m/c)allocN'ed blocks because they are
* free with MEM_freeN() when viewport is freed.
* (not per object) */
struct CustomStruct *block;
struct PAINT_VERTEX_PrivateData *g_data;
} PAINT_VERTEX_StorageList;
typedef struct PAINT_VERTEX_Data {
/* Struct returned by DRW_viewport_engine_data_get.
* If you don't use one of these, just make it a (void *) */
// void *fbl;
void *engine_type; /* Required */
PAINT_VERTEX_FramebufferList *fbl;
PAINT_VERTEX_TextureList *txl;
@ -89,54 +66,30 @@ typedef struct PAINT_VERTEX_Data {
/* *********** STATIC *********** */
static struct {
/* Custom shaders :
* Add sources to source/blender/draw/modes/shaders
* init in PAINT_VERTEX_engine_init();
* free in PAINT_VERTEX_engine_free(); */
struct GPUShader *custom_shader;
struct GPUShader *vcolor_face_shader;
struct GPUShader *wire_overlay_shader;
} e_data = {NULL}; /* Engine data */
typedef struct PAINT_VERTEX_PrivateData {
/* This keeps the references of the shading groups for
* easy access in PAINT_VERTEX_cache_populate() */
DRWShadingGroup *group;
DRWShadingGroup *fvcolor_shgrp;
DRWShadingGroup *lwire_shgrp;
} PAINT_VERTEX_PrivateData; /* Transient data */
/* *********** FUNCTIONS *********** */
/* Init Textures, Framebuffers, Storage and Shaders.
* It is called for every frames.
* (Optional) */
static void PAINT_VERTEX_engine_init(void *vedata)
static void PAINT_VERTEX_engine_init(void *UNUSED(vedata))
{
PAINT_VERTEX_TextureList *txl = ((PAINT_VERTEX_Data *)vedata)->txl;
PAINT_VERTEX_FramebufferList *fbl = ((PAINT_VERTEX_Data *)vedata)->fbl;
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
if (!e_data.vcolor_face_shader) {
e_data.vcolor_face_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR_ALPHA);
}
UNUSED_VARS(txl, fbl, stl);
/* Init Framebuffers like this: order is attachment order (for color texs) */
/*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/
/* DRW_framebuffer_init takes care of checking if
* the framebuffer is valid and has the right size*/
/*
* float *viewport_size = DRW_viewport_size_get();
* DRW_framebuffer_init(&fbl->occlude_wire_fb,
* (int)viewport_size[0], (int)viewport_size[1],
* tex, 2);
*/
if (!e_data.custom_shader) {
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
if (!e_data.wire_overlay_shader) {
e_data.wire_overlay_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
}
}
/* Here init all passes and shading groups
* Assume that all Passes are NULL */
static float world_light;
static void PAINT_VERTEX_cache_init(void *vedata)
{
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
@ -149,108 +102,69 @@ static void PAINT_VERTEX_cache_init(void *vedata)
{
/* Create a pass */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->pass = DRW_pass_create("My Pass", state);
psl->vcolor_faces = DRW_pass_create("Vert Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
/* Create a shadingGroup using a function in draw_common.c or custom one */
/*
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
* -- or --
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
*/
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
stl->g_data->fvcolor_shgrp = DRW_shgroup_create(e_data.vcolor_face_shader, psl->vcolor_faces);
/* Uniforms need a pointer to it's value so be sure it's accessible at
* any given time (i.e. use static vars) */
static float color[4] = {0.2f, 0.5f, 0.3f, 1.0};
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
static float light[3] = {-0.3f, 0.5f, 1.0f};
static float alpha = 1.0f;
DRW_shgroup_uniform_vec3(stl->g_data->fvcolor_shgrp, "light", light, 1);
DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "alpha", &alpha, 1);
DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "global", &world_light, 1);
}
{
psl->wire_overlay = DRW_pass_create("Wire Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
stl->g_data->lwire_shgrp = DRW_shgroup_create(e_data.wire_overlay_shader, psl->wire_overlay);
}
}
/* Add geometry to shadingGroups. Execute for each objects */
static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
{
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
SceneLayer *sl = draw_ctx->sl;
UNUSED_VARS(psl, stl);
if (ob->type == OB_MESH && ob == sl->basact->object) {
IDProperty *ces_mode_pw = BKE_object_collection_engine_get(ob, COLLECTION_MODE_PAINT_VERTEX, "");
bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
char flag = ((Mesh *)ob->data)->editflag;
struct Batch *geom;
if (ob->type == OB_MESH) {
/* Get geometry cache */
struct Batch *geom = DRW_cache_mesh_surface_get(ob);
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
/* Add geom to a shading group */
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
geom = DRW_cache_mesh_surface_vert_colors_get(ob);
DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
if (flag & ME_EDIT_PAINT_FACE_SEL || use_wire) {
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, flag & ME_EDIT_PAINT_FACE_SEL, true);
DRW_shgroup_call_add(stl->g_data->lwire_shgrp, geom, ob->obmat);
}
}
}
/* Optional: Post-cache_populate callback */
static void PAINT_VERTEX_cache_finish(void *vedata)
{
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
/* Do something here! dependant on the objects gathered */
UNUSED_VARS(psl, stl);
}
/* Draw time ! Control rendering pipeline from here */
static void PAINT_VERTEX_draw_scene(void *vedata)
{
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
PAINT_VERTEX_FramebufferList *fbl = ((PAINT_VERTEX_Data *)vedata)->fbl;
/* Default framebuffer and texture */
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
UNUSED_VARS(fbl, dfbl, dtxl);
/* Show / hide entire passes, swap framebuffers ... whatever you fancy */
/*
* DRW_framebuffer_texture_detach(dtxl->depth);
* DRW_framebuffer_bind(fbl->custom_fb);
* DRW_draw_pass(psl->pass);
* DRW_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0, 0);
* DRW_framebuffer_bind(dfbl->default_fb);
*/
/* ... or just render passes on default framebuffer. */
DRW_draw_pass(psl->pass);
/* If you changed framebuffer, double check you rebind
* the default one with its textures attached before finishing */
DRW_draw_pass(psl->vcolor_faces);
DRW_draw_pass(psl->wire_overlay);
}
/* Cleanup when destroying the engine.
* This is not per viewport ! only when quitting blender.
* Mostly used for freeing shaders */
static void PAINT_VERTEX_engine_free(void)
{
// DRW_SHADER_FREE_SAFE(custom_shader);
}
/* Create collection settings here.
*
* Be sure to add this function there :
* source/blender/draw/DRW_engine.h
* source/blender/blenkernel/intern/layer.c
* source/blenderplayer/bad_level_call_stubs/stubs.c
*
* And relevant collection settings to :
* source/blender/makesrna/intern/rna_scene.c
* source/blender/blenkernel/intern/layer.c
*/
#if 0
void PAINT_VERTEX_collection_settings_create(CollectionEngineSettings *ces)
void PAINT_VERTEX_collection_settings_create(IDProperty *properties)
{
BLI_assert(ces);
// BKE_collection_engine_property_add_int(ces, "my_bool_prop", false);
// BKE_collection_engine_property_add_int(ces, "my_int_prop", 0);
// BKE_collection_engine_property_add_float(ces, "my_float_prop", 0.0f);
BLI_assert(properties &&
properties->type == IDP_GROUP &&
properties->subtype == IDP_GROUP_SUB_MODE_PAINT_VERTEX);
BKE_collection_engine_property_add_bool(properties, "use_shading", true);
BKE_collection_engine_property_add_bool(properties, "use_wire", false);
}
#endif
static const DrawEngineDataSize PAINT_VERTEX_data_size = DRW_VIEWPORT_DATA_SIZE(PAINT_VERTEX_Data);
@ -262,7 +176,7 @@ DrawEngineType draw_engine_paint_vertex_type = {
&PAINT_VERTEX_engine_free,
&PAINT_VERTEX_cache_init,
&PAINT_VERTEX_cache_populate,
&PAINT_VERTEX_cache_finish,
NULL, /* draw_background but not needed by mode engines */
NULL,
NULL,
&PAINT_VERTEX_draw_scene
};

View File

@ -86,7 +86,7 @@ static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata))
if (e_data.actdef != draw_ctx->sl->basact->object->actdef) {
e_data.actdef = draw_ctx->sl->basact->object->actdef;
BKE_mesh_batch_cache_dirty(draw_ctx->sl->basact->object->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(draw_ctx->sl->basact->object->data, BKE_MESH_BATCH_DIRTY_PAINT);
}
if (!e_data.weight_face_shader) {
@ -164,7 +164,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
if (flag & ME_EDIT_PAINT_FACE_SEL || use_wire) {
geom = DRW_cache_mesh_edges_weight_overlay_get(ob, use_wire, flag & ME_EDIT_PAINT_FACE_SEL);
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, flag & ME_EDIT_PAINT_FACE_SEL, false);
DRW_shgroup_call_add(stl->g_data->lwire_shgrp, geom, ob->obmat);
}

View File

@ -107,7 +107,7 @@ void paintface_flush_flags(Object *ob, short flag)
GPU_drawobject_free(dm);
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
}
void paintface_hide(Object *ob, const bool unselected)
@ -518,7 +518,7 @@ void paintvert_flush_flags(Object *ob)
}
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
}
/* note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)

View File

@ -2382,7 +2382,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* also needed for "View Selected" on last stroke */
paint_last_stroke_update(scene, vc->ar, mval);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
DAG_id_tag_update(ob->data, 0);
ED_region_tag_redraw(vc->ar);
@ -2861,6 +2861,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* also needed for "View Selected" on last stroke */
paint_last_stroke_update(scene, vc->ar, mval);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
ED_region_tag_redraw(vc->ar);
if (vpd->use_fast_update == false) {

View File

@ -104,6 +104,7 @@ enum {
IDP_GROUP_SUB_ENGINE_RENDER = 3, /* render engine settings */
IDP_GROUP_SUB_OVERRIDE = 4, /* data override */
IDP_GROUP_SUB_MODE_PAINT_WEIGHT = 5, /* weight paint mode settings */
IDP_GROUP_SUB_MODE_PAINT_VERTEX = 6, /* vertex paint mode settings */
};
/*->flag*/

View File

@ -121,6 +121,7 @@ typedef enum CollectionEngineSettingsType {
COLLECTION_MODE_OBJECT = 1,
COLLECTION_MODE_EDIT = 2,
COLLECTION_MODE_PAINT_WEIGHT = 5,
COLLECTION_MODE_PAINT_VERTEX = 6,
} CollectionModeSettingsType;
/* *************************************************************** */

View File

@ -239,11 +239,18 @@ static void rna_Mesh_update_data_edit_color(Main *bmain, Scene *scene, PointerRN
static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
{
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
rna_Mesh_update_data(bmain, scene, ptr);
}
static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr)
{
BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_PAINT);
rna_Mesh_update_data(bmain, scene, ptr);
}
static void rna_Mesh_update_select(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
@ -270,7 +277,7 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_FACE_SEL;
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
rna_Mesh_update_draw(bmain, scene, ptr);
}
@ -282,7 +289,7 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
me->editflag &= ~ME_EDIT_PAINT_VERT_SEL;
}
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_PAINT);
rna_Mesh_update_draw(bmain, scene, ptr);
}
@ -2940,13 +2947,13 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
"rna_Mesh_vertex_color_active_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop, "rna_Mesh_vertex_color_active_index_get",
"rna_Mesh_vertex_color_active_index_set", "rna_Mesh_vertex_color_index_range");
RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
}
static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop)

View File

@ -441,7 +441,8 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
{COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""},
{COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""},
{COLLECTION_MODE_PAINT_WEIGHT, "PAINT_WIGHT", 0, "Weight Paint", ""},
{COLLECTION_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""},
{COLLECTION_MODE_PAINT_WEIGHT, "PAINT_VERTEX", 0, "Vertex Paint", ""},
{0, NULL, 0, NULL, NULL}
};
@ -1953,6 +1954,9 @@ static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr)
case IDP_GROUP_SUB_MODE_PAINT_WEIGHT:
return &RNA_LayerCollectionModeSettingsPaintWeight;
break;
case IDP_GROUP_SUB_MODE_PAINT_VERTEX:
return &RNA_LayerCollectionModeSettingsPaintVertex;
break;
default:
BLI_assert(!"Mode not fully implemented");
break;
@ -2496,6 +2500,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, PaintWeightMode, COLLECTION_MODE_PAINT_WEIGHT, _NAME_)
#define RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, PaintVertexMode, COLLECTION_MODE_PAINT_VERTEX, _NAME_)
/* clay engine */
#ifdef WITH_CLAY_ENGINE
RNA_LAYER_ENGINE_CLAY_GET_SET_INT(matcap_icon)
@ -2525,6 +2532,10 @@ RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(backwire_opacity)
RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_shading)
RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_wire)
/* vertex paint engine */
RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_shading)
RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_wire)
#undef RNA_LAYER_ENGINE_GET_SET
static void rna_LayerCollectionEngineSettings_update(bContext *C, PointerRNA *UNUSED(ptr))
@ -2534,14 +2545,14 @@ static void rna_LayerCollectionEngineSettings_update(bContext *C, PointerRNA *UN
DAG_id_tag_update(&scene->id, 0);
}
static void rna_LayerCollectionEngineSettings_weight_wire_update(bContext *C, PointerRNA *UNUSED(ptr))
static void rna_LayerCollectionEngineSettings_wire_update(bContext *C, PointerRNA *UNUSED(ptr))
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *ob = OBACT_NEW;
if (ob != NULL && ob->type == OB_MESH) {
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_WEIGHT);
BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_PAINT);
}
/* TODO(sergey): Use proper flag for tagging here. */
@ -6201,7 +6212,33 @@ static void rna_def_layer_collection_mode_settings_paint_weight(BlenderRNA *brna
RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_wire_get", "rna_LayerEngineSettings_PaintWeightMode_use_wire_set");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_weight_wire_update");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
RNA_define_verify_sdna(1); /* not in sdna */
}
static void rna_def_layer_collection_mode_settings_paint_vertex(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintVertex", "LayerCollectionSettings");
RNA_def_struct_ui_text(srna, "Collections Vertex Paint Mode Settings", "Vertex Paint Mode specific settings to be overridden per collection");
RNA_define_verify_sdna(0); /* not in sdna */
/* see RNA_LAYER_ENGINE_GET_SET macro */
prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing");
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_shading_get", "rna_LayerEngineSettings_PaintVertexMode_use_shading_set");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update");
prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh");
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_wire_get", "rna_LayerEngineSettings_PaintVertexMode_use_wire_set");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update");
RNA_define_verify_sdna(1); /* not in sdna */
}
@ -6246,6 +6283,7 @@ static void rna_def_layer_collection_settings(BlenderRNA *brna)
rna_def_layer_collection_mode_settings_object(brna);
rna_def_layer_collection_mode_settings_edit(brna);
rna_def_layer_collection_mode_settings_paint_weight(brna);
rna_def_layer_collection_mode_settings_paint_vertex(brna);
RNA_define_verify_sdna(1);
}