Draw module: code style, encapsulate static vars
This commit is contained in:
parent
69a17bce1a
commit
fc72a2ff4b
|
@ -44,7 +44,7 @@ extern char datatoc_clay_vert_glsl[];
|
|||
extern char datatoc_ssao_alchemy_glsl[];
|
||||
extern char datatoc_ssao_groundtruth_glsl[];
|
||||
|
||||
/* Storage */
|
||||
/* *********** LISTS *********** */
|
||||
|
||||
/* UBOs data needs to be 16 byte aligned (size of vec4) */
|
||||
/* Reminder : float, int, bool are 4 bytes */
|
||||
|
@ -64,24 +64,6 @@ typedef struct CLAY_UBO_Storage {
|
|||
CLAY_UBO_Material materials[MAX_CLAY_MAT];
|
||||
} CLAY_UBO_Storage;
|
||||
|
||||
static struct CLAY_data {
|
||||
/* Depth Pre Pass */
|
||||
struct GPUShader *depth_sh;
|
||||
/* Shading Pass */
|
||||
struct GPUShader *clay_sh;
|
||||
|
||||
/* Matcap textures */
|
||||
struct GPUTexture *matcap_array;
|
||||
float matcap_colors[24][3];
|
||||
|
||||
/* Ssao */
|
||||
float winmat[4][4];
|
||||
float viewvecs[3][4];
|
||||
float ssao_params[4];
|
||||
struct GPUTexture *jitter_tx;
|
||||
struct GPUTexture *sampling_tx;
|
||||
} data = {NULL};
|
||||
|
||||
/* GPUViewport.storage
|
||||
* Is freed everytime the viewport engine changes */
|
||||
typedef struct CLAY_Storage {
|
||||
|
@ -91,9 +73,6 @@ typedef struct CLAY_Storage {
|
|||
DRWShadingGroup *shgrps[MAX_CLAY_MAT];
|
||||
} CLAY_Storage;
|
||||
|
||||
/* Just a serie of int from 0 to MAX_CLAY_MAT-1 */
|
||||
static int ubo_mat_idxs[MAX_CLAY_MAT] = {0};
|
||||
|
||||
/* keep it under MAX_STORAGE */
|
||||
typedef struct CLAY_StorageList {
|
||||
struct CLAY_Storage *storage;
|
||||
|
@ -132,6 +111,38 @@ typedef struct CLAY_Data {
|
|||
CLAY_StorageList *stl;
|
||||
} CLAY_Data;
|
||||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
static struct {
|
||||
/* Depth Pre Pass */
|
||||
struct GPUShader *depth_sh;
|
||||
/* Shading Pass */
|
||||
struct GPUShader *clay_sh;
|
||||
|
||||
/* Matcap textures */
|
||||
struct GPUTexture *matcap_array;
|
||||
float matcap_colors[24][3];
|
||||
|
||||
/* Ssao */
|
||||
float winmat[4][4];
|
||||
float viewvecs[3][4];
|
||||
float ssao_params[4];
|
||||
struct GPUTexture *jitter_tx;
|
||||
struct GPUTexture *sampling_tx;
|
||||
|
||||
/* Just a serie of int from 0 to MAX_CLAY_MAT-1 */
|
||||
int ubo_mat_idxs[MAX_CLAY_MAT];
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
DRWShadingGroup *depth_shgrp;
|
||||
DRWShadingGroup *depth_shgrp_select;
|
||||
DRWShadingGroup *depth_shgrp_active;
|
||||
DRWShadingGroup *depth_shgrp_cull;
|
||||
DRWShadingGroup *depth_shgrp_cull_select;
|
||||
DRWShadingGroup *depth_shgrp_cull_active;
|
||||
CLAY_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
//#define GTAO
|
||||
|
||||
|
@ -148,15 +159,15 @@ static void add_icon_to_rect(PreviewImage *prv, float *final_rect, int layer)
|
|||
/* Find overall color */
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
data.matcap_colors[layer][0] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 0];
|
||||
data.matcap_colors[layer][1] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 1];
|
||||
data.matcap_colors[layer][2] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 2];
|
||||
e_data.matcap_colors[layer][0] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 0];
|
||||
e_data.matcap_colors[layer][1] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 1];
|
||||
e_data.matcap_colors[layer][2] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 2];
|
||||
}
|
||||
}
|
||||
|
||||
data.matcap_colors[layer][0] /= 16.0f * 2.0f; /* the * 2 is to darken for shadows */
|
||||
data.matcap_colors[layer][1] /= 16.0f * 2.0f;
|
||||
data.matcap_colors[layer][2] /= 16.0f * 2.0f;
|
||||
e_data.matcap_colors[layer][0] /= 16.0f * 2.0f; /* the * 2 is to darken for shadows */
|
||||
e_data.matcap_colors[layer][1] /= 16.0f * 2.0f;
|
||||
e_data.matcap_colors[layer][2] /= 16.0f * 2.0f;
|
||||
}
|
||||
|
||||
static struct GPUTexture *load_matcaps(PreviewImage *prv[24], int nbr)
|
||||
|
@ -273,13 +284,13 @@ RenderEngineSettings *CLAY_render_settings_create(void)
|
|||
|
||||
static void CLAY_engine_init(void)
|
||||
{
|
||||
CLAY_Data *vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_StorageList *stl = vedata->stl;
|
||||
CLAY_TextureList *txl = vedata->txl;
|
||||
CLAY_FramebufferList *fbl = vedata->fbl;
|
||||
CLAY_Data *ved = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_StorageList *stl = ved->stl;
|
||||
CLAY_TextureList *txl = ved->txl;
|
||||
CLAY_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Create Texture Array */
|
||||
if (!data.matcap_array) {
|
||||
if (!e_data.matcap_array) {
|
||||
PreviewImage *prv[24]; /* For now use all of the 24 internal matcaps */
|
||||
|
||||
/* TODO only load used matcaps */
|
||||
|
@ -308,27 +319,27 @@ static void CLAY_engine_init(void)
|
|||
prv[22] = UI_icon_to_preview(ICON_MATCAP_23);
|
||||
prv[23] = UI_icon_to_preview(ICON_MATCAP_24);
|
||||
|
||||
data.matcap_array = load_matcaps(prv, 24);
|
||||
e_data.matcap_array = load_matcaps(prv, 24);
|
||||
}
|
||||
|
||||
/* AO Jitter */
|
||||
if (!data.jitter_tx) {
|
||||
data.jitter_tx = create_jitter_texture();
|
||||
if (!e_data.jitter_tx) {
|
||||
e_data.jitter_tx = create_jitter_texture();
|
||||
}
|
||||
|
||||
/* AO Samples */
|
||||
/* TODO use hammersley sequence */
|
||||
if (!data.sampling_tx) {
|
||||
data.sampling_tx = create_spiral_sample_texture(500);
|
||||
if (!e_data.sampling_tx) {
|
||||
e_data.sampling_tx = create_spiral_sample_texture(500);
|
||||
}
|
||||
|
||||
/* Depth prepass */
|
||||
if (!data.depth_sh) {
|
||||
data.depth_sh = DRW_shader_create_3D_depth_only();
|
||||
if (!e_data.depth_sh) {
|
||||
e_data.depth_sh = DRW_shader_create_3D_depth_only();
|
||||
}
|
||||
|
||||
/* Shading pass */
|
||||
if (!data.clay_sh) {
|
||||
if (!e_data.clay_sh) {
|
||||
DynStr *ds = BLI_dynstr_new();
|
||||
const char *max_mat =
|
||||
"#define MAX_MATERIAL 512\n"
|
||||
|
@ -346,7 +357,7 @@ static void CLAY_engine_init(void)
|
|||
|
||||
matcap_with_ao = BLI_dynstr_get_cstring(ds);
|
||||
|
||||
data.clay_sh = DRW_shader_create(datatoc_clay_vert_glsl, NULL, matcap_with_ao, max_mat);
|
||||
e_data.clay_sh = DRW_shader_create(datatoc_clay_vert_glsl, NULL, matcap_with_ao, max_mat);
|
||||
|
||||
BLI_dynstr_free(ds);
|
||||
MEM_freeN(matcap_with_ao);
|
||||
|
@ -360,10 +371,10 @@ static void CLAY_engine_init(void)
|
|||
stl->mat_ubo = DRW_uniformbuffer_create(sizeof(CLAY_UBO_Storage), NULL);
|
||||
}
|
||||
|
||||
if (ubo_mat_idxs[1] == 0) {
|
||||
if (e_data.ubo_mat_idxs[1] == 0) {
|
||||
/* Just int to have pointers to them */
|
||||
for (int i = 0; i < MAX_CLAY_MAT; ++i) {
|
||||
ubo_mat_idxs[i] = i;
|
||||
e_data.ubo_mat_idxs[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,14 +403,14 @@ static void CLAY_engine_init(void)
|
|||
|
||||
DRW_get_dfdy_factors(dfdyfacs);
|
||||
|
||||
data.ssao_params[0] = settings->ssao_samples;
|
||||
data.ssao_params[1] = size[0] / 64.0;
|
||||
data.ssao_params[2] = size[1] / 64.0;
|
||||
data.ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */
|
||||
e_data.ssao_params[0] = settings->ssao_samples;
|
||||
e_data.ssao_params[1] = size[0] / 64.0;
|
||||
e_data.ssao_params[2] = size[1] / 64.0;
|
||||
e_data.ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */
|
||||
|
||||
/* invert the view matrix */
|
||||
DRW_viewport_matrix_get(data.winmat, DRW_MAT_WIN);
|
||||
invert_m4_m4(invproj, data.winmat);
|
||||
DRW_viewport_matrix_get(e_data.winmat, DRW_MAT_WIN);
|
||||
invert_m4_m4(invproj, e_data.winmat);
|
||||
|
||||
/* convert the view vectors to view space */
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
@ -410,19 +421,19 @@ static void CLAY_engine_init(void)
|
|||
mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]);
|
||||
viewvecs[i][3] = 1.0;
|
||||
|
||||
copy_v4_v4(data.viewvecs[i], viewvecs[i]);
|
||||
copy_v4_v4(e_data.viewvecs[i], viewvecs[i]);
|
||||
}
|
||||
|
||||
/* we need to store the differences */
|
||||
data.viewvecs[1][0] -= data.viewvecs[0][0];
|
||||
data.viewvecs[1][1] = data.viewvecs[2][1] - data.viewvecs[0][1];
|
||||
e_data.viewvecs[1][0] -= e_data.viewvecs[0][0];
|
||||
e_data.viewvecs[1][1] = e_data.viewvecs[2][1] - e_data.viewvecs[0][1];
|
||||
|
||||
/* calculate a depth offset as well */
|
||||
if (!is_persp) {
|
||||
float vec_far[] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
||||
mul_m4_v4(invproj, vec_far);
|
||||
mul_v3_fl(vec_far, 1.0f / vec_far[3]);
|
||||
data.viewvecs[1][2] = vec_far[2] - data.viewvecs[0][2];
|
||||
e_data.viewvecs[1][2] = vec_far[2] - e_data.viewvecs[0][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -433,21 +444,21 @@ static DRWShadingGroup *CLAY_shgroup_create(DRWPass *pass, int *material_id)
|
|||
CLAY_TextureList *txl = vedata->txl;
|
||||
const int depthloc = 0, matcaploc = 1, jitterloc = 2, sampleloc = 3;
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(data.clay_sh, pass);
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.clay_sh, pass);
|
||||
|
||||
DRW_shgroup_uniform_vec2(grp, "screenres", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_buffer(grp, "depthtex", &txl->depth_dup, depthloc);
|
||||
DRW_shgroup_uniform_texture(grp, "matcaps", data.matcap_array, matcaploc);
|
||||
DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)data.winmat);
|
||||
DRW_shgroup_uniform_vec4(grp, "viewvecs", (float *)data.viewvecs, 3);
|
||||
DRW_shgroup_uniform_vec4(grp, "ssao_params", data.ssao_params, 1);
|
||||
DRW_shgroup_uniform_vec3(grp, "matcaps_color", (float *)data.matcap_colors, 24);
|
||||
DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array, matcaploc);
|
||||
DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)e_data.winmat);
|
||||
DRW_shgroup_uniform_vec4(grp, "viewvecs", (float *)e_data.viewvecs, 3);
|
||||
DRW_shgroup_uniform_vec4(grp, "ssao_params", e_data.ssao_params, 1);
|
||||
DRW_shgroup_uniform_vec3(grp, "matcaps_color", (float *)e_data.matcap_colors, 24);
|
||||
|
||||
DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1);
|
||||
|
||||
#ifndef GTAO
|
||||
DRW_shgroup_uniform_texture(grp, "ssao_jitter", data.jitter_tx, jitterloc);
|
||||
DRW_shgroup_uniform_texture(grp, "ssao_samples", data.sampling_tx, sampleloc);
|
||||
DRW_shgroup_uniform_texture(grp, "ssao_jitter", e_data.jitter_tx, jitterloc);
|
||||
DRW_shgroup_uniform_texture(grp, "ssao_samples", e_data.sampling_tx, sampleloc);
|
||||
#endif
|
||||
|
||||
return grp;
|
||||
|
@ -586,7 +597,7 @@ static DRWShadingGroup *CLAY_object_shgrp_get(Object *ob, CLAY_StorageList *stl,
|
|||
ssao_attenuation, matcap_icon);
|
||||
|
||||
if (shgrps[id] == NULL) {
|
||||
shgrps[id] = CLAY_shgroup_create(psl->clay_pass, &ubo_mat_idxs[id]);
|
||||
shgrps[id] = CLAY_shgroup_create(psl->clay_pass, &e_data.ubo_mat_idxs[id]);
|
||||
/* if it's the first shgrp, pass bind the material UBO */
|
||||
if (stl->storage->ubo_current_id == 1) {
|
||||
DRW_shgroup_uniform_block(shgrps[0], "material_block", stl->mat_ubo, 0);
|
||||
|
@ -596,38 +607,31 @@ static DRWShadingGroup *CLAY_object_shgrp_get(Object *ob, CLAY_StorageList *stl,
|
|||
return shgrps[id];
|
||||
}
|
||||
|
||||
static DRWShadingGroup *depth_shgrp;
|
||||
static DRWShadingGroup *depth_shgrp_select;
|
||||
static DRWShadingGroup *depth_shgrp_active;
|
||||
static DRWShadingGroup *depth_shgrp_cull;
|
||||
static DRWShadingGroup *depth_shgrp_cull_select;
|
||||
static DRWShadingGroup *depth_shgrp_cull_active;
|
||||
|
||||
static void CLAY_cache_init(void)
|
||||
{
|
||||
CLAY_Data *vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_PassList *psl = vedata->psl;
|
||||
CLAY_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_PassList *psl = g_data.vedata->psl;
|
||||
CLAY_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Depth Pass */
|
||||
{
|
||||
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
depth_shgrp = DRW_shgroup_create(data.depth_sh, psl->depth_pass);
|
||||
g_data.depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
|
||||
depth_shgrp_select = DRW_shgroup_create(data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(depth_shgrp_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
g_data.depth_shgrp_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(g_data.depth_shgrp_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
|
||||
depth_shgrp_active = DRW_shgroup_create(data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(depth_shgrp_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
|
||||
g_data.depth_shgrp_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(g_data.depth_shgrp_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
|
||||
|
||||
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
|
||||
depth_shgrp_cull = DRW_shgroup_create(data.depth_sh, psl->depth_pass_cull);
|
||||
g_data.depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
|
||||
depth_shgrp_cull_select = DRW_shgroup_create(data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(depth_shgrp_cull_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
g_data.depth_shgrp_cull_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(g_data.depth_shgrp_cull_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
|
||||
depth_shgrp_cull_active = DRW_shgroup_create(data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(depth_shgrp_cull_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
|
||||
g_data.depth_shgrp_cull_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(g_data.depth_shgrp_cull_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
|
||||
}
|
||||
|
||||
/* Clay Pass */
|
||||
|
@ -640,9 +644,8 @@ static void CLAY_cache_init(void)
|
|||
|
||||
static void CLAY_cache_populate(Object *ob)
|
||||
{
|
||||
CLAY_Data *vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_PassList *psl = vedata->psl;
|
||||
CLAY_StorageList *stl = vedata->stl;
|
||||
CLAY_PassList *psl = g_data.vedata->psl;
|
||||
CLAY_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
struct Batch *geom;
|
||||
DRWShadingGroup *clay_shgrp;
|
||||
|
@ -660,11 +663,11 @@ static void CLAY_cache_populate(Object *ob)
|
|||
/* Depth Prepass */
|
||||
/* waiting for proper flag */
|
||||
// if ((ob->base_flag & BASE_ACTIVE) != 0)
|
||||
// DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull_active : depth_shgrp_active, geom, ob->obmat);
|
||||
// DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull_active : g_data.depth_shgrp_active, geom, ob->obmat);
|
||||
if ((ob->base_flag & BASE_SELECTED) != 0)
|
||||
DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull_select : depth_shgrp_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull_select : g_data.depth_shgrp_select, geom, ob->obmat);
|
||||
else
|
||||
DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull : depth_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull : g_data.depth_shgrp, geom, ob->obmat);
|
||||
|
||||
/* Shading */
|
||||
clay_shgrp = CLAY_object_shgrp_get(ob, stl, psl);
|
||||
|
@ -674,17 +677,16 @@ static void CLAY_cache_populate(Object *ob)
|
|||
|
||||
static void CLAY_cache_finish(void)
|
||||
{
|
||||
CLAY_Data *vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_StorageList *stl = vedata->stl;
|
||||
CLAY_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
DRW_uniformbuffer_update(stl->mat_ubo, &stl->storage->mat_storage);
|
||||
}
|
||||
|
||||
static void CLAY_draw_scene(void)
|
||||
{
|
||||
CLAY_Data *vedata = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_PassList *psl = vedata->psl;
|
||||
CLAY_FramebufferList *fbl = vedata->fbl;
|
||||
CLAY_Data *ved = DRW_viewport_engine_data_get("Clay");
|
||||
CLAY_PassList *psl = ved->psl;
|
||||
CLAY_FramebufferList *fbl = ved->fbl;
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
||||
/* Pass 1 : Depth pre-pass */
|
||||
|
@ -716,17 +718,17 @@ static void CLAY_collection_settings_create(RenderEngine *UNUSED(engine), Collec
|
|||
|
||||
static void CLAY_engine_free(void)
|
||||
{
|
||||
if (data.clay_sh) {
|
||||
DRW_shader_free(data.clay_sh);
|
||||
if (e_data.clay_sh) {
|
||||
DRW_shader_free(e_data.clay_sh);
|
||||
}
|
||||
if (data.matcap_array) {
|
||||
DRW_texture_free(data.matcap_array);
|
||||
if (e_data.matcap_array) {
|
||||
DRW_texture_free(e_data.matcap_array);
|
||||
}
|
||||
if (data.jitter_tx) {
|
||||
DRW_texture_free(data.jitter_tx);
|
||||
if (e_data.jitter_tx) {
|
||||
DRW_texture_free(e_data.jitter_tx);
|
||||
}
|
||||
if (data.sampling_tx) {
|
||||
DRW_texture_free(data.sampling_tx);
|
||||
if (e_data.sampling_tx) {
|
||||
DRW_texture_free(e_data.sampling_tx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ extern char datatoc_tonemap_frag_glsl[];
|
|||
|
||||
static void EEVEE_engine_init(void)
|
||||
{
|
||||
g_data.vedata = DRW_viewport_engine_data_get(EEVEE_ENGINE);
|
||||
EEVEE_TextureList *txl = g_data.vedata->txl;
|
||||
EEVEE_FramebufferList *fbl = g_data.vedata->fbl;
|
||||
EEVEE_StorageList *stl = g_data.vedata->stl;
|
||||
EEVEE_Data *ved = DRW_viewport_engine_data_get(EEVEE_ENGINE);
|
||||
EEVEE_TextureList *txl = ved->txl;
|
||||
EEVEE_FramebufferList *fbl = ved->fbl;
|
||||
EEVEE_StorageList *stl = ved->stl;
|
||||
|
||||
DRWFboTexture tex = {&txl->color, DRW_BUF_RGBA_32};
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
#include "draw_mode_engines.h"
|
||||
|
||||
extern GlobalsUboStorage ts;
|
||||
|
||||
/* *********** LISTS *********** */
|
||||
/* keep it under MAX_PASSES */
|
||||
typedef struct EDIT_ARMATURE_PassList {
|
||||
struct DRWPass *bone_solid;
|
||||
|
@ -47,16 +50,19 @@ typedef struct EDIT_ARMATURE_Data {
|
|||
void *stl;
|
||||
} EDIT_ARMATURE_Data;
|
||||
|
||||
static DRWShadingGroup *relationship_lines;
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
extern GlobalsUboStorage ts;
|
||||
static struct {
|
||||
DRWShadingGroup *relationship_lines;
|
||||
EDIT_ARMATURE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
static EDIT_ARMATURE_Data *vedata;
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void EDIT_ARMATURE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditArmatureMode");
|
||||
EDIT_ARMATURE_PassList *psl = vedata->psl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditArmatureMode");
|
||||
EDIT_ARMATURE_PassList *psl = g_data.vedata->psl;
|
||||
|
||||
{
|
||||
/* Solid bones */
|
||||
|
@ -76,20 +82,19 @@ static void EDIT_ARMATURE_cache_init(void)
|
|||
psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
|
||||
|
||||
/* Relationship Lines */
|
||||
relationship_lines = shgroup_dynlines_uniform_color(psl->relationship, ts.colorWire);
|
||||
DRW_shgroup_state_set(relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
g_data.relationship_lines = shgroup_dynlines_uniform_color(psl->relationship, ts.colorWire);
|
||||
DRW_shgroup_state_set(g_data.relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void EDIT_ARMATURE_cache_populate(Object *ob)
|
||||
{
|
||||
bArmature *arm = ob->data;
|
||||
EDIT_ARMATURE_PassList *psl = vedata->psl;
|
||||
EDIT_ARMATURE_PassList *psl = g_data.vedata->psl;
|
||||
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
if (arm->edbo) {
|
||||
DRW_shgroup_armature_edit(ob, psl->bone_solid, psl->bone_wire, relationship_lines);
|
||||
DRW_shgroup_armature_edit(ob, psl->bone_solid, psl->bone_wire, g_data.relationship_lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct EDIT_CURVE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_CURVE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_CURVE_engine_init();
|
||||
* free in EDIT_CURVE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
EDIT_CURVE_Data *vedata;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_CURVE_engine_init();
|
||||
* free in EDIT_CURVE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static EDIT_CURVE_Data *vedata;
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_CURVE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static EDIT_CURVE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void EDIT_CURVE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditCurveMode");
|
||||
EDIT_CURVE_TextureList *txl = vedata->txl;
|
||||
EDIT_CURVE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_CURVE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditCurveMode");
|
||||
EDIT_CURVE_TextureList *txl = g_data.vedata->txl;
|
||||
EDIT_CURVE_FramebufferList *fbl = g_data.vedata->fbl;
|
||||
EDIT_CURVE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void EDIT_CURVE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void EDIT_CURVE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_CURVE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditCurveMode");
|
||||
EDIT_CURVE_PassList *psl = vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditCurveMode");
|
||||
EDIT_CURVE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void EDIT_CURVE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void EDIT_CURVE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void EDIT_CURVE_cache_populate(Object *ob)
|
||||
{
|
||||
EDIT_CURVE_PassList *psl = vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = vedata->stl;
|
||||
EDIT_CURVE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void EDIT_CURVE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void EDIT_CURVE_cache_finish(void)
|
||||
{
|
||||
EDIT_CURVE_PassList *psl = vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = vedata->stl;
|
||||
EDIT_CURVE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_CURVE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void EDIT_CURVE_draw_scene(void)
|
|||
{
|
||||
EDIT_CURVE_Data *ved = DRW_viewport_engine_data_get("EditCurveMode");
|
||||
EDIT_CURVE_PassList *psl = ved->psl;
|
||||
EDIT_CURVE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_CURVE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct EDIT_LATTICE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_LATTICE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_LATTICE_engine_init();
|
||||
* free in EDIT_LATTICE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_LATTICE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_LATTICE_engine_init();
|
||||
* free in EDIT_LATTICE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static EDIT_LATTICE_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
EDIT_LATTICE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static EDIT_LATTICE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void EDIT_LATTICE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditLatticeMode");
|
||||
EDIT_LATTICE_TextureList *txl = vedata->txl;
|
||||
EDIT_LATTICE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_LATTICE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditLatticeMode");
|
||||
EDIT_LATTICE_TextureList *txl = g_data.vedata->txl;
|
||||
EDIT_LATTICE_FramebufferList *fbl = g_data.vedata->fbl;
|
||||
EDIT_LATTICE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void EDIT_LATTICE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void EDIT_LATTICE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_LATTICE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditLatticeMode");
|
||||
EDIT_LATTICE_PassList *psl = vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditLatticeMode");
|
||||
EDIT_LATTICE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void EDIT_LATTICE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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] = {1.0f, 0.0f, 0.0f, 1.0};
|
||||
DRW_shgroup_uniform_vec4(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void EDIT_LATTICE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void EDIT_LATTICE_cache_populate(Object *ob)
|
||||
{
|
||||
EDIT_LATTICE_PassList *psl = vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = vedata->stl;
|
||||
EDIT_LATTICE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void EDIT_LATTICE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void EDIT_LATTICE_cache_finish(void)
|
||||
{
|
||||
EDIT_LATTICE_PassList *psl = vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = vedata->stl;
|
||||
EDIT_LATTICE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_LATTICE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void EDIT_LATTICE_draw_scene(void)
|
|||
{
|
||||
EDIT_LATTICE_Data *ved = DRW_viewport_engine_data_get("EditLatticeMode");
|
||||
EDIT_LATTICE_PassList *psl = ved->psl;
|
||||
EDIT_LATTICE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_LATTICE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,26 @@
|
|||
|
||||
#include "draw_mode_engines.h"
|
||||
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
|
||||
extern char datatoc_edit_overlay_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_geom_tri_glsl[];
|
||||
extern char datatoc_edit_overlay_geom_edge_glsl[];
|
||||
extern char datatoc_edit_overlay_loosevert_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_facedot_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_facedot_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_mix_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_mix_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_facefill_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_facefill_frag_glsl[];
|
||||
extern char datatoc_edit_normals_vert_glsl[];
|
||||
extern char datatoc_edit_normals_geom_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
|
||||
|
||||
/* *********** LISTS *********** */
|
||||
/* keep it under MAX_PASSES */
|
||||
typedef struct EDIT_MESH_PassList {
|
||||
struct DRWPass *depth_hidden_wire;
|
||||
|
@ -62,61 +82,52 @@ typedef struct EDIT_MESH_Data {
|
|||
void *stl;
|
||||
} EDIT_MESH_Data;
|
||||
|
||||
static DRWShadingGroup *depth_shgrp_hidden_wire;
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
static DRWShadingGroup *fnormals_shgrp;
|
||||
static DRWShadingGroup *vnormals_shgrp;
|
||||
static DRWShadingGroup *lnormals_shgrp;
|
||||
static struct {
|
||||
struct GPUShader *overlay_tri_sh;
|
||||
struct GPUShader *overlay_tri_fast_sh;
|
||||
struct GPUShader *overlay_tri_vcol_sh;
|
||||
struct GPUShader *overlay_tri_vcol_fast_sh;
|
||||
struct GPUShader *overlay_edge_sh;
|
||||
struct GPUShader *overlay_edge_vcol_sh;
|
||||
struct GPUShader *overlay_vert_sh;
|
||||
struct GPUShader *overlay_facedot_sh;
|
||||
struct GPUShader *overlay_mix_sh;
|
||||
struct GPUShader *overlay_facefill_sh;
|
||||
struct GPUShader *normals_face_sh;
|
||||
struct GPUShader *normals_sh;
|
||||
struct GPUShader *depth_sh;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static DRWShadingGroup *face_overlay_shgrp;
|
||||
static DRWShadingGroup *ledges_overlay_shgrp;
|
||||
static DRWShadingGroup *lverts_overlay_shgrp;
|
||||
static DRWShadingGroup *facedot_overlay_shgrp;
|
||||
static struct {
|
||||
DRWShadingGroup *depth_shgrp_hidden_wire;
|
||||
|
||||
static DRWShadingGroup *face_occluded_shgrp;
|
||||
static DRWShadingGroup *ledges_occluded_shgrp;
|
||||
static DRWShadingGroup *lverts_occluded_shgrp;
|
||||
static DRWShadingGroup *facedot_occluded_shgrp;
|
||||
static DRWShadingGroup *facefill_occluded_shgrp;
|
||||
DRWShadingGroup *fnormals_shgrp;
|
||||
DRWShadingGroup *vnormals_shgrp;
|
||||
DRWShadingGroup *lnormals_shgrp;
|
||||
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
DRWShadingGroup *face_overlay_shgrp;
|
||||
DRWShadingGroup *ledges_overlay_shgrp;
|
||||
DRWShadingGroup *lverts_overlay_shgrp;
|
||||
DRWShadingGroup *facedot_overlay_shgrp;
|
||||
|
||||
static struct GPUShader *overlay_tri_sh = NULL;
|
||||
static struct GPUShader *overlay_tri_fast_sh = NULL;
|
||||
static struct GPUShader *overlay_tri_vcol_sh = NULL;
|
||||
static struct GPUShader *overlay_tri_vcol_fast_sh = NULL;
|
||||
static struct GPUShader *overlay_edge_sh = NULL;
|
||||
static struct GPUShader *overlay_edge_vcol_sh = NULL;
|
||||
static struct GPUShader *overlay_vert_sh = NULL;
|
||||
static struct GPUShader *overlay_facedot_sh = NULL;
|
||||
static struct GPUShader *overlay_mix_sh = NULL;
|
||||
static struct GPUShader *overlay_facefill_sh = NULL;
|
||||
static struct GPUShader *normals_face_sh = NULL;
|
||||
static struct GPUShader *normals_sh = NULL;
|
||||
static struct GPUShader *depth_sh = NULL;
|
||||
DRWShadingGroup *face_occluded_shgrp;
|
||||
DRWShadingGroup *ledges_occluded_shgrp;
|
||||
DRWShadingGroup *lverts_occluded_shgrp;
|
||||
DRWShadingGroup *facedot_occluded_shgrp;
|
||||
DRWShadingGroup *facefill_occluded_shgrp;
|
||||
|
||||
extern char datatoc_edit_overlay_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_geom_tri_glsl[];
|
||||
extern char datatoc_edit_overlay_geom_edge_glsl[];
|
||||
extern char datatoc_edit_overlay_loosevert_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_facedot_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_facedot_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_mix_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_mix_frag_glsl[];
|
||||
extern char datatoc_edit_overlay_facefill_vert_glsl[];
|
||||
extern char datatoc_edit_overlay_facefill_frag_glsl[];
|
||||
extern char datatoc_edit_normals_vert_glsl[];
|
||||
extern char datatoc_edit_normals_geom_glsl[];
|
||||
EDIT_MESH_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void EDIT_MESH_engine_init(void)
|
||||
{
|
||||
EDIT_MESH_Data *vedata = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_TextureList *txl = vedata->txl;
|
||||
EDIT_MESH_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_MESH_Data *ved = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_TextureList *txl = ved->txl;
|
||||
EDIT_MESH_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
float *viewport_size = DRW_viewport_size_get();
|
||||
|
||||
|
@ -126,62 +137,62 @@ static void EDIT_MESH_engine_init(void)
|
|||
(int)viewport_size[0], (int)viewport_size[1],
|
||||
tex, 2);
|
||||
|
||||
if (!overlay_tri_sh) {
|
||||
overlay_tri_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_tri_sh) {
|
||||
e_data.overlay_tri_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_tri_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, "#define EDGE_FIX\n");
|
||||
}
|
||||
if (!overlay_tri_fast_sh) {
|
||||
overlay_tri_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_tri_fast_sh) {
|
||||
e_data.overlay_tri_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_tri_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_tri_vcol_sh) {
|
||||
overlay_tri_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_tri_vcol_sh) {
|
||||
e_data.overlay_tri_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_tri_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, "#define EDGE_FIX\n"
|
||||
"#define VERTEX_SELECTION\n");
|
||||
}
|
||||
if (!overlay_tri_vcol_fast_sh) {
|
||||
overlay_tri_vcol_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_tri_vcol_fast_sh) {
|
||||
e_data.overlay_tri_vcol_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_tri_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n");
|
||||
}
|
||||
if (!overlay_edge_sh) {
|
||||
overlay_edge_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_edge_sh) {
|
||||
e_data.overlay_edge_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_edge_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_edge_vcol_sh) {
|
||||
overlay_edge_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
if (!e_data.overlay_edge_vcol_sh) {
|
||||
e_data.overlay_edge_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl,
|
||||
datatoc_edit_overlay_geom_edge_glsl,
|
||||
datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n");
|
||||
}
|
||||
if (!overlay_vert_sh) {
|
||||
overlay_vert_sh = DRW_shader_create(datatoc_edit_overlay_loosevert_vert_glsl, NULL,
|
||||
if (!e_data.overlay_vert_sh) {
|
||||
e_data.overlay_vert_sh = DRW_shader_create(datatoc_edit_overlay_loosevert_vert_glsl, NULL,
|
||||
datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n");
|
||||
}
|
||||
if (!overlay_facedot_sh) {
|
||||
overlay_facedot_sh = DRW_shader_create(datatoc_edit_overlay_facedot_vert_glsl, NULL,
|
||||
if (!e_data.overlay_facedot_sh) {
|
||||
e_data.overlay_facedot_sh = DRW_shader_create(datatoc_edit_overlay_facedot_vert_glsl, NULL,
|
||||
datatoc_edit_overlay_facedot_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_mix_sh) {
|
||||
overlay_mix_sh = DRW_shader_create_fullscreen(datatoc_edit_overlay_mix_frag_glsl, NULL);
|
||||
if (!e_data.overlay_mix_sh) {
|
||||
e_data.overlay_mix_sh = DRW_shader_create_fullscreen(datatoc_edit_overlay_mix_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_facefill_sh) {
|
||||
overlay_facefill_sh = DRW_shader_create(datatoc_edit_overlay_facefill_vert_glsl, NULL,
|
||||
if (!e_data.overlay_facefill_sh) {
|
||||
e_data.overlay_facefill_sh = DRW_shader_create(datatoc_edit_overlay_facefill_vert_glsl, NULL,
|
||||
datatoc_edit_overlay_facefill_frag_glsl, NULL);
|
||||
}
|
||||
if (!normals_face_sh) {
|
||||
normals_face_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl,
|
||||
if (!e_data.normals_face_sh) {
|
||||
e_data.normals_face_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl,
|
||||
datatoc_gpu_shader_uniform_color_frag_glsl, "#define FACE_NORMALS\n");
|
||||
}
|
||||
if (!normals_sh) {
|
||||
normals_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl,
|
||||
if (!e_data.normals_sh) {
|
||||
e_data.normals_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl,
|
||||
datatoc_gpu_shader_uniform_color_frag_glsl, NULL);
|
||||
}
|
||||
if (!depth_sh) {
|
||||
depth_sh = DRW_shader_create_3D_depth_only();
|
||||
if (!e_data.depth_sh) {
|
||||
e_data.depth_sh = DRW_shader_create_3D_depth_only();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,20 +207,20 @@ static DRWPass *edit_mesh_create_overlay_pass(DRWShadingGroup **face_shgrp, DRWS
|
|||
ToolSettings *tsettings = scene->toolsettings;
|
||||
|
||||
if ((tsettings->selectmode & SCE_SELECT_VERTEX) != 0) {
|
||||
ledge_sh = overlay_edge_vcol_sh;
|
||||
ledge_sh = e_data.overlay_edge_vcol_sh;
|
||||
|
||||
if ((rv3d->rflag & RV3D_NAVIGATING) != 0)
|
||||
tri_sh = overlay_tri_vcol_fast_sh;
|
||||
tri_sh = e_data.overlay_tri_vcol_fast_sh;
|
||||
else
|
||||
tri_sh = overlay_tri_vcol_sh;
|
||||
tri_sh = e_data.overlay_tri_vcol_sh;
|
||||
}
|
||||
else {
|
||||
ledge_sh = overlay_edge_sh;
|
||||
ledge_sh = e_data.overlay_edge_sh;
|
||||
|
||||
if ((rv3d->rflag & RV3D_NAVIGATING) != 0)
|
||||
tri_sh = overlay_tri_fast_sh;
|
||||
tri_sh = e_data.overlay_tri_fast_sh;
|
||||
else
|
||||
tri_sh = overlay_tri_sh;
|
||||
tri_sh = e_data.overlay_tri_sh;
|
||||
}
|
||||
|
||||
DRWPass *pass = DRW_pass_create("Edit Mesh Face Overlay Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_POINT | statemod);
|
||||
|
@ -223,12 +234,12 @@ static DRWPass *edit_mesh_create_overlay_pass(DRWShadingGroup **face_shgrp, DRWS
|
|||
DRW_shgroup_uniform_vec2(*ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
|
||||
if ((tsettings->selectmode & (SCE_SELECT_VERTEX)) != 0) {
|
||||
*lverts_shgrp = DRW_shgroup_create(overlay_vert_sh, pass);
|
||||
*lverts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass);
|
||||
DRW_shgroup_uniform_vec2(*lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
|
||||
}
|
||||
|
||||
if ((tsettings->selectmode & (SCE_SELECT_FACE)) != 0) {
|
||||
*facedot_shgrp = DRW_shgroup_create(overlay_facedot_sh, pass);
|
||||
*facedot_shgrp = DRW_shgroup_create(e_data.overlay_facedot_sh, pass);
|
||||
}
|
||||
|
||||
return pass;
|
||||
|
@ -240,9 +251,9 @@ static float size_normal;
|
|||
|
||||
static void EDIT_MESH_cache_init(void)
|
||||
{
|
||||
EDIT_MESH_Data *vedata = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_TextureList *txl = vedata->txl;
|
||||
EDIT_MESH_PassList *psl = vedata->psl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_TextureList *txl = g_data.vedata->txl;
|
||||
EDIT_MESH_PassList *psl = g_data.vedata->psl;
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
const struct bContext *C = DRW_get_context();
|
||||
|
@ -255,47 +266,47 @@ static void EDIT_MESH_cache_init(void)
|
|||
{
|
||||
/* Complementary Depth Pass */
|
||||
psl->depth_hidden_wire = DRW_pass_create("Depth Pass Hidden Wire", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
|
||||
depth_shgrp_hidden_wire = DRW_shgroup_create(depth_sh, psl->depth_hidden_wire);
|
||||
g_data.depth_shgrp_hidden_wire = DRW_shgroup_create(e_data.depth_sh, psl->depth_hidden_wire);
|
||||
}
|
||||
|
||||
{
|
||||
/* Normals */
|
||||
psl->normals = DRW_pass_create("Edit Mesh Normals Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS);
|
||||
|
||||
fnormals_shgrp = DRW_shgroup_create(normals_face_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(fnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(fnormals_shgrp, "color", ts.colorNormal, 1);
|
||||
g_data.fnormals_shgrp = DRW_shgroup_create(e_data.normals_face_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(g_data.fnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.fnormals_shgrp, "color", ts.colorNormal, 1);
|
||||
|
||||
vnormals_shgrp = DRW_shgroup_create(normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(vnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(vnormals_shgrp, "color", ts.colorVNormal, 1);
|
||||
g_data.vnormals_shgrp = DRW_shgroup_create(e_data.normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(g_data.vnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.vnormals_shgrp, "color", ts.colorVNormal, 1);
|
||||
|
||||
lnormals_shgrp = DRW_shgroup_create(normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(lnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(lnormals_shgrp, "color", ts.colorLNormal, 1);
|
||||
g_data.lnormals_shgrp = DRW_shgroup_create(e_data.normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(g_data.lnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.lnormals_shgrp, "color", ts.colorLNormal, 1);
|
||||
}
|
||||
|
||||
if (!do_zbufclip) {
|
||||
psl->edit_face_overlay = edit_mesh_create_overlay_pass(&face_overlay_shgrp, &ledges_overlay_shgrp, &lverts_overlay_shgrp,
|
||||
&facedot_overlay_shgrp, &face_mod, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND);
|
||||
psl->edit_face_overlay = edit_mesh_create_overlay_pass(&g_data.face_overlay_shgrp, &g_data.ledges_overlay_shgrp, &g_data.lverts_overlay_shgrp,
|
||||
&g_data.facedot_overlay_shgrp, &face_mod, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND);
|
||||
}
|
||||
else {
|
||||
/* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
|
||||
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&face_occluded_shgrp, &ledges_occluded_shgrp, &lverts_occluded_shgrp,
|
||||
&facedot_occluded_shgrp, &zero, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH);
|
||||
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&g_data.face_occluded_shgrp, &g_data.ledges_occluded_shgrp, &g_data.lverts_occluded_shgrp,
|
||||
&g_data.facedot_occluded_shgrp, &zero, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH);
|
||||
|
||||
/* however we loose the front faces value (because we need the depth of occluded wires and
|
||||
* faces are alpha blended ) so we recover them in a new pass. */
|
||||
psl->facefill_occlude = DRW_pass_create("Front Face Color", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND);
|
||||
facefill_occluded_shgrp = DRW_shgroup_create(overlay_facefill_sh, psl->facefill_occlude);
|
||||
DRW_shgroup_uniform_block(facefill_occluded_shgrp, "globalsBlock", globals_ubo, 0);
|
||||
g_data.facefill_occluded_shgrp = DRW_shgroup_create(e_data.overlay_facefill_sh, psl->facefill_occlude);
|
||||
DRW_shgroup_uniform_block(g_data.facefill_occluded_shgrp, "globalsBlock", globals_ubo, 0);
|
||||
|
||||
/* we need a full screen pass to combine the result */
|
||||
struct Batch *quad = DRW_cache_fullscreen_quad_get();
|
||||
static float mat[4][4]; /* not even used but avoid crash */
|
||||
|
||||
psl->mix_occlude = DRW_pass_create("Mix Occluded Wires", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND);
|
||||
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(overlay_mix_sh, psl->mix_occlude);
|
||||
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.overlay_mix_sh, psl->mix_occlude);
|
||||
DRW_shgroup_call_add(mix_shgrp, quad, mat);
|
||||
DRW_shgroup_uniform_float(mix_shgrp, "alpha", &backwire_opacity, 1);
|
||||
DRW_shgroup_uniform_buffer(mix_shgrp, "wireColor", &txl->occlude_wire_color_tx, 0);
|
||||
|
@ -349,31 +360,31 @@ static void EDIT_MESH_cache_populate(Object *ob)
|
|||
|
||||
if (do_occlude_wire) {
|
||||
geom = DRW_cache_surface_get(ob);
|
||||
DRW_shgroup_call_add(depth_shgrp_hidden_wire, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.depth_shgrp_hidden_wire, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (fnormals_do) {
|
||||
geom = DRW_cache_face_centers_get(ob);
|
||||
DRW_shgroup_call_add(fnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.fnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (vnormals_do) {
|
||||
geom = DRW_cache_verts_get(ob);
|
||||
DRW_shgroup_call_add(vnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.vnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (lnormals_do) {
|
||||
geom = DRW_cache_surface_verts_get(ob);
|
||||
DRW_shgroup_call_add(lnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.lnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if ((v3d->flag & V3D_ZBUF_SELECT) == 0) {
|
||||
edit_mesh_add_ob_to_pass(scene, ob, face_occluded_shgrp, ledges_occluded_shgrp,
|
||||
lverts_occluded_shgrp, facedot_occluded_shgrp, facefill_occluded_shgrp);
|
||||
edit_mesh_add_ob_to_pass(scene, ob, g_data.face_occluded_shgrp, g_data.ledges_occluded_shgrp,
|
||||
g_data.lverts_occluded_shgrp, g_data.facedot_occluded_shgrp, g_data.facefill_occluded_shgrp);
|
||||
}
|
||||
else {
|
||||
edit_mesh_add_ob_to_pass(scene, ob, face_overlay_shgrp, ledges_overlay_shgrp,
|
||||
lverts_overlay_shgrp, facedot_overlay_shgrp, NULL);
|
||||
edit_mesh_add_ob_to_pass(scene, ob, g_data.face_overlay_shgrp, g_data.ledges_overlay_shgrp,
|
||||
g_data.lverts_overlay_shgrp, g_data.facedot_overlay_shgrp, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,9 +392,9 @@ static void EDIT_MESH_cache_populate(Object *ob)
|
|||
|
||||
static void EDIT_MESH_draw_scene(void)
|
||||
{
|
||||
EDIT_MESH_Data *vedata = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_PassList *psl = vedata->psl;
|
||||
EDIT_MESH_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_MESH_Data *ved = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_PassList *psl = ved->psl;
|
||||
EDIT_MESH_FramebufferList *fbl = ved->fbl;
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
|
@ -429,30 +440,30 @@ void EDIT_MESH_collection_settings_create(CollectionEngineSettings *ces)
|
|||
|
||||
static void EDIT_MESH_engine_free(void)
|
||||
{
|
||||
if (overlay_tri_sh)
|
||||
DRW_shader_free(overlay_tri_sh);
|
||||
if (overlay_tri_fast_sh)
|
||||
DRW_shader_free(overlay_tri_fast_sh);
|
||||
if (overlay_tri_vcol_sh)
|
||||
DRW_shader_free(overlay_tri_vcol_sh);
|
||||
if (overlay_tri_vcol_fast_sh)
|
||||
DRW_shader_free(overlay_tri_vcol_fast_sh);
|
||||
if (overlay_edge_sh)
|
||||
DRW_shader_free(overlay_edge_sh);
|
||||
if (overlay_edge_vcol_sh)
|
||||
DRW_shader_free(overlay_edge_vcol_sh);
|
||||
if (overlay_vert_sh)
|
||||
DRW_shader_free(overlay_vert_sh);
|
||||
if (overlay_facedot_sh)
|
||||
DRW_shader_free(overlay_facedot_sh);
|
||||
if (overlay_mix_sh)
|
||||
DRW_shader_free(overlay_mix_sh);
|
||||
if (overlay_facefill_sh)
|
||||
DRW_shader_free(overlay_facefill_sh);
|
||||
if (normals_face_sh)
|
||||
DRW_shader_free(normals_face_sh);
|
||||
if (normals_sh)
|
||||
DRW_shader_free(normals_sh);
|
||||
if (e_data.overlay_tri_sh)
|
||||
DRW_shader_free(e_data.overlay_tri_sh);
|
||||
if (e_data.overlay_tri_fast_sh)
|
||||
DRW_shader_free(e_data.overlay_tri_fast_sh);
|
||||
if (e_data.overlay_tri_vcol_sh)
|
||||
DRW_shader_free(e_data.overlay_tri_vcol_sh);
|
||||
if (e_data.overlay_tri_vcol_fast_sh)
|
||||
DRW_shader_free(e_data.overlay_tri_vcol_fast_sh);
|
||||
if (e_data.overlay_edge_sh)
|
||||
DRW_shader_free(e_data.overlay_edge_sh);
|
||||
if (e_data.overlay_edge_vcol_sh)
|
||||
DRW_shader_free(e_data.overlay_edge_vcol_sh);
|
||||
if (e_data.overlay_vert_sh)
|
||||
DRW_shader_free(e_data.overlay_vert_sh);
|
||||
if (e_data.overlay_facedot_sh)
|
||||
DRW_shader_free(e_data.overlay_facedot_sh);
|
||||
if (e_data.overlay_mix_sh)
|
||||
DRW_shader_free(e_data.overlay_mix_sh);
|
||||
if (e_data.overlay_facefill_sh)
|
||||
DRW_shader_free(e_data.overlay_facefill_sh);
|
||||
if (e_data.normals_face_sh)
|
||||
DRW_shader_free(e_data.normals_face_sh);
|
||||
if (e_data.normals_sh)
|
||||
DRW_shader_free(e_data.normals_sh);
|
||||
}
|
||||
|
||||
DrawEngineType draw_engine_edit_mesh_type = {
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct EDIT_METABALL_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_METABALL_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_METABALL_engine_init();
|
||||
* free in EDIT_METABALL_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_METABALL_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_METABALL_engine_init();
|
||||
* free in EDIT_METABALL_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static EDIT_METABALL_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
EDIT_METABALL_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static EDIT_METABALL_Data *vedata;
|
|||
* (Optional) */
|
||||
static void EDIT_METABALL_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_TextureList *txl = vedata->txl;
|
||||
EDIT_METABALL_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_METABALL_StorageList *stl = vedata->stl;
|
||||
EDIT_METABALL_Data *ved = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_TextureList *txl = ved->txl;
|
||||
EDIT_METABALL_FramebufferList *fbl = ved->fbl;
|
||||
EDIT_METABALL_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void EDIT_METABALL_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void EDIT_METABALL_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_METABALL_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_PassList *psl = vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void EDIT_METABALL_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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.0f, 1.0f, 0.0f, 1.0};
|
||||
DRW_shgroup_uniform_vec4(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void EDIT_METABALL_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void EDIT_METABALL_cache_populate(Object *ob)
|
||||
{
|
||||
EDIT_METABALL_PassList *psl = vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = vedata->stl;
|
||||
EDIT_METABALL_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void EDIT_METABALL_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void EDIT_METABALL_cache_finish(void)
|
||||
{
|
||||
EDIT_METABALL_PassList *psl = vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = vedata->stl;
|
||||
EDIT_METABALL_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_METABALL_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void EDIT_METABALL_draw_scene(void)
|
|||
{
|
||||
EDIT_METABALL_Data *ved = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_PassList *psl = ved->psl;
|
||||
EDIT_METABALL_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_METABALL_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct EDIT_SURFACE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_SURFACE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_SURFACE_engine_init();
|
||||
* free in EDIT_SURFACE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_SURFACE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_SURFACE_engine_init();
|
||||
* free in EDIT_SURFACE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static EDIT_SURFACE_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
EDIT_SURFACE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static EDIT_SURFACE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void EDIT_SURFACE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_TextureList *txl = vedata->txl;
|
||||
EDIT_SURFACE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_SURFACE_StorageList *stl = vedata->stl;
|
||||
EDIT_SURFACE_Data *ved = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_TextureList *txl = ved->txl;
|
||||
EDIT_SURFACE_FramebufferList *fbl = ved->fbl;
|
||||
EDIT_SURFACE_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void EDIT_SURFACE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void EDIT_SURFACE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_SURFACE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_PassList *psl = vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void EDIT_SURFACE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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.0f, 0.0f, 1.0f, 1.0};
|
||||
DRW_shgroup_uniform_vec4(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void EDIT_SURFACE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void EDIT_SURFACE_cache_populate(Object *ob)
|
||||
{
|
||||
EDIT_SURFACE_PassList *psl = vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = vedata->stl;
|
||||
EDIT_SURFACE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void EDIT_SURFACE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void EDIT_SURFACE_cache_finish(void)
|
||||
{
|
||||
EDIT_SURFACE_PassList *psl = vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = vedata->stl;
|
||||
EDIT_SURFACE_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_SURFACE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void EDIT_SURFACE_draw_scene(void)
|
|||
{
|
||||
EDIT_SURFACE_Data *ved = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_PassList *psl = ved->psl;
|
||||
EDIT_SURFACE_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_SURFACE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct EDIT_TEXT_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_TEXT_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_TEXT_engine_init();
|
||||
* free in EDIT_TEXT_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_TEXT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in EDIT_TEXT_engine_init();
|
||||
* free in EDIT_TEXT_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static EDIT_TEXT_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
EDIT_TEXT_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static EDIT_TEXT_Data *vedata;
|
|||
* (Optional) */
|
||||
static void EDIT_TEXT_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_TextureList *txl = vedata->txl;
|
||||
EDIT_TEXT_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_TEXT_StorageList *stl = vedata->stl;
|
||||
EDIT_TEXT_Data *ved = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_TextureList *txl = ved->txl;
|
||||
EDIT_TEXT_FramebufferList *fbl = ved->fbl;
|
||||
EDIT_TEXT_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void EDIT_TEXT_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void EDIT_TEXT_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_TEXT_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_PassList *psl = vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void EDIT_TEXT_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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] = {1.0f, 0.0f, 0.0f, 1.0};
|
||||
DRW_shgroup_uniform_vec4(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void EDIT_TEXT_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void EDIT_TEXT_cache_populate(Object *ob)
|
||||
{
|
||||
EDIT_TEXT_PassList *psl = vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = vedata->stl;
|
||||
EDIT_TEXT_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void EDIT_TEXT_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void EDIT_TEXT_cache_finish(void)
|
||||
{
|
||||
EDIT_TEXT_PassList *psl = vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = vedata->stl;
|
||||
EDIT_TEXT_PassList *psl = g_data.vedata->psl;
|
||||
EDIT_TEXT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void EDIT_TEXT_draw_scene(void)
|
|||
{
|
||||
EDIT_TEXT_Data *ved = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_PassList *psl = ved->psl;
|
||||
EDIT_TEXT_FramebufferList *fbl = vedata->fbl;
|
||||
EDIT_TEXT_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
#include "draw_mode_engines.h"
|
||||
#include "draw_common.h"
|
||||
|
||||
extern GlobalsUboStorage ts;
|
||||
|
||||
extern char datatoc_object_occluded_outline_frag_glsl[];
|
||||
|
||||
/* *********** LISTS *********** */
|
||||
/* keep it under MAX_PASSES */
|
||||
typedef struct OBJECT_PassList {
|
||||
struct DRWPass *non_meshes;
|
||||
|
@ -60,86 +65,90 @@ typedef struct OBJECT_Data {
|
|||
void *stl;
|
||||
} OBJECT_Data;
|
||||
|
||||
/* Empties */
|
||||
static DRWShadingGroup *plain_axes;
|
||||
static DRWShadingGroup *cube;
|
||||
static DRWShadingGroup *circle;
|
||||
static DRWShadingGroup *sphere;
|
||||
static DRWShadingGroup *cone;
|
||||
static DRWShadingGroup *single_arrow;
|
||||
static DRWShadingGroup *single_arrow_line;
|
||||
static DRWShadingGroup *arrows;
|
||||
static DRWShadingGroup *axis_names;
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* Speaker */
|
||||
static DRWShadingGroup *speaker;
|
||||
static struct {
|
||||
/* Empties */
|
||||
DRWShadingGroup *plain_axes;
|
||||
DRWShadingGroup *cube;
|
||||
DRWShadingGroup *circle;
|
||||
DRWShadingGroup *sphere;
|
||||
DRWShadingGroup *cone;
|
||||
DRWShadingGroup *single_arrow;
|
||||
DRWShadingGroup *single_arrow_line;
|
||||
DRWShadingGroup *arrows;
|
||||
DRWShadingGroup *axis_names;
|
||||
|
||||
/* Lamps */
|
||||
static DRWShadingGroup *lamp_center;
|
||||
static DRWShadingGroup *lamp_center_group;
|
||||
static DRWShadingGroup *lamp_groundpoint;
|
||||
static DRWShadingGroup *lamp_groundline;
|
||||
static DRWShadingGroup *lamp_circle;
|
||||
static DRWShadingGroup *lamp_circle_shadow;
|
||||
static DRWShadingGroup *lamp_sunrays;
|
||||
static DRWShadingGroup *lamp_distance;
|
||||
static DRWShadingGroup *lamp_buflimit;
|
||||
static DRWShadingGroup *lamp_buflimit_points;
|
||||
static DRWShadingGroup *lamp_area;
|
||||
static DRWShadingGroup *lamp_hemi;
|
||||
static DRWShadingGroup *lamp_spot_cone;
|
||||
static DRWShadingGroup *lamp_spot_blend;
|
||||
static DRWShadingGroup *lamp_spot_pyramid;
|
||||
static DRWShadingGroup *lamp_spot_blend_rect;
|
||||
/* Speaker */
|
||||
DRWShadingGroup *speaker;
|
||||
|
||||
/* Helpers */
|
||||
static DRWShadingGroup *relationship_lines;
|
||||
/* Lamps */
|
||||
DRWShadingGroup *lamp_center;
|
||||
DRWShadingGroup *lamp_center_group;
|
||||
DRWShadingGroup *lamp_groundpoint;
|
||||
DRWShadingGroup *lamp_groundline;
|
||||
DRWShadingGroup *lamp_circle;
|
||||
DRWShadingGroup *lamp_circle_shadow;
|
||||
DRWShadingGroup *lamp_sunrays;
|
||||
DRWShadingGroup *lamp_distance;
|
||||
DRWShadingGroup *lamp_buflimit;
|
||||
DRWShadingGroup *lamp_buflimit_points;
|
||||
DRWShadingGroup *lamp_area;
|
||||
DRWShadingGroup *lamp_hemi;
|
||||
DRWShadingGroup *lamp_spot_cone;
|
||||
DRWShadingGroup *lamp_spot_blend;
|
||||
DRWShadingGroup *lamp_spot_pyramid;
|
||||
DRWShadingGroup *lamp_spot_blend_rect;
|
||||
|
||||
/* Objects Centers */
|
||||
static DRWShadingGroup *center_active;
|
||||
static DRWShadingGroup *center_selected;
|
||||
static DRWShadingGroup *center_deselected;
|
||||
/* Helpers */
|
||||
DRWShadingGroup *relationship_lines;
|
||||
|
||||
/* Camera */
|
||||
static DRWShadingGroup *camera;
|
||||
static DRWShadingGroup *camera_tria;
|
||||
static DRWShadingGroup *camera_focus;
|
||||
static DRWShadingGroup *camera_clip;
|
||||
static DRWShadingGroup *camera_clip_points;
|
||||
static DRWShadingGroup *camera_mist;
|
||||
static DRWShadingGroup *camera_mist_points;
|
||||
/* Objects Centers */
|
||||
DRWShadingGroup *center_active;
|
||||
DRWShadingGroup *center_selected;
|
||||
DRWShadingGroup *center_deselected;
|
||||
|
||||
/* Outlines */
|
||||
static DRWShadingGroup *outlines_active;
|
||||
static DRWShadingGroup *outlines_active_group;
|
||||
static DRWShadingGroup *outlines_select;
|
||||
static DRWShadingGroup *outlines_select_group;
|
||||
static DRWShadingGroup *outlines_transform;
|
||||
static DRWShadingGroup *outlines_transp_select;
|
||||
static DRWShadingGroup *outlines_transp_select_group;
|
||||
static DRWShadingGroup *outlines_transp_active;
|
||||
static DRWShadingGroup *outlines_transp_active_group;
|
||||
static DRWShadingGroup *outlines_transp_transform;
|
||||
/* Camera */
|
||||
DRWShadingGroup *camera;
|
||||
DRWShadingGroup *camera_tria;
|
||||
DRWShadingGroup *camera_focus;
|
||||
DRWShadingGroup *camera_clip;
|
||||
DRWShadingGroup *camera_clip_points;
|
||||
DRWShadingGroup *camera_mist;
|
||||
DRWShadingGroup *camera_mist_points;
|
||||
|
||||
extern GlobalsUboStorage ts;
|
||||
/* Outlines */
|
||||
DRWShadingGroup *outlines_active;
|
||||
DRWShadingGroup *outlines_active_group;
|
||||
DRWShadingGroup *outlines_select;
|
||||
DRWShadingGroup *outlines_select_group;
|
||||
DRWShadingGroup *outlines_transform;
|
||||
DRWShadingGroup *outlines_transp_select;
|
||||
DRWShadingGroup *outlines_transp_select_group;
|
||||
DRWShadingGroup *outlines_transp_active;
|
||||
DRWShadingGroup *outlines_transp_active_group;
|
||||
DRWShadingGroup *outlines_transp_transform;
|
||||
|
||||
static OBJECT_Data *vedata;
|
||||
OBJECT_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
static struct GPUShader *outline_sh = NULL;
|
||||
static struct {
|
||||
struct GPUShader *outline_sh;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
extern char datatoc_object_occluded_outline_frag_glsl[];
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void OBJECT_engine_init(void)
|
||||
{
|
||||
if (!outline_sh) {
|
||||
outline_sh = DRW_shader_create_3D(datatoc_object_occluded_outline_frag_glsl, NULL);
|
||||
if (!e_data.outline_sh) {
|
||||
e_data.outline_sh = DRW_shader_create_3D(datatoc_object_occluded_outline_frag_glsl, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void OBJECT_engine_free(void)
|
||||
{
|
||||
if (outline_sh)
|
||||
DRW_shader_free(outline_sh);
|
||||
if (e_data.outline_sh)
|
||||
DRW_shader_free(e_data.outline_sh);
|
||||
}
|
||||
|
||||
static DRWShadingGroup *shgroup_outline(DRWPass *pass, int state_flag, const float col[4], struct GPUShader *sh)
|
||||
|
@ -154,8 +163,8 @@ static DRWShadingGroup *shgroup_outline(DRWPass *pass, int state_flag, const flo
|
|||
static void OBJECT_cache_init(void)
|
||||
{
|
||||
/* DRW_viewport_engine_data_get is rather slow, better not do it on every objects */
|
||||
vedata = DRW_viewport_engine_data_get("ObjectMode");
|
||||
OBJECT_PassList *psl = vedata->psl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("ObjectMode");
|
||||
OBJECT_PassList *psl = g_data.vedata->psl;
|
||||
|
||||
{
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE_LARGE;
|
||||
|
@ -164,15 +173,15 @@ static void OBJECT_cache_init(void)
|
|||
struct GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
/* Select */
|
||||
outlines_select = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorSelect, sh);
|
||||
outlines_select_group = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorGroupActive, sh);
|
||||
g_data.outlines_select = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorSelect, sh);
|
||||
g_data.outlines_select_group = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorGroupActive, sh);
|
||||
|
||||
/* Transform */
|
||||
outlines_transform = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorTransform, sh);
|
||||
g_data.outlines_transform = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_SELECT, ts.colorTransform, sh);
|
||||
|
||||
/* Active */
|
||||
outlines_active = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorActive, sh);
|
||||
outlines_active_group = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorGroupActive, sh);
|
||||
g_data.outlines_active = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorActive, sh);
|
||||
g_data.outlines_active_group = shgroup_outline(psl->outlines, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorGroupActive, sh);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -181,15 +190,15 @@ static void OBJECT_cache_init(void)
|
|||
psl->outlines_transp = DRW_pass_create("See-through Outlines Pass", state);
|
||||
|
||||
/* Select */
|
||||
outlines_transp_select = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorSelect, outline_sh);
|
||||
outlines_transp_select_group = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorGroupActive, outline_sh);
|
||||
g_data.outlines_transp_select = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorSelect, e_data.outline_sh);
|
||||
g_data.outlines_transp_select_group = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorGroupActive, e_data.outline_sh);
|
||||
|
||||
/* Transform */
|
||||
outlines_transp_transform = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorTransform, outline_sh);
|
||||
g_data.outlines_transp_transform = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_SELECT, ts.colorTransform, e_data.outline_sh);
|
||||
|
||||
/* Active */
|
||||
outlines_transp_active = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorActive, outline_sh);
|
||||
outlines_transp_active_group = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorGroupActive, outline_sh);
|
||||
g_data.outlines_transp_active = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorActive, e_data.outline_sh);
|
||||
g_data.outlines_transp_active_group = shgroup_outline(psl->outlines_transp, DRW_STATE_TEST_STENCIL_ACTIVE, ts.colorGroupActive, e_data.outline_sh);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -214,53 +223,53 @@ static void OBJECT_cache_init(void)
|
|||
|
||||
/* Empties */
|
||||
geom = DRW_cache_plain_axes_get();
|
||||
plain_axes = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.plain_axes = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_cube_get();
|
||||
cube = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.cube = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_circle_get();
|
||||
circle = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.circle = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_empty_sphere_get();
|
||||
sphere = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.sphere = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_empty_cone_get();
|
||||
cone = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.cone = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_arrow_get();
|
||||
single_arrow = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.single_arrow = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
single_arrow_line = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.single_arrow_line = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_arrows_get();
|
||||
arrows = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.arrows = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_axis_names_get();
|
||||
axis_names = shgroup_instance_axis_names(psl->non_meshes, geom);
|
||||
g_data.axis_names = shgroup_instance_axis_names(psl->non_meshes, geom);
|
||||
|
||||
/* Speaker */
|
||||
geom = DRW_cache_speaker_get();
|
||||
speaker = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.speaker = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Camera */
|
||||
geom = DRW_cache_camera_get();
|
||||
camera = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
g_data.camera = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_camera_tria_get();
|
||||
camera_tria = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
g_data.camera_tria = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_plain_axes_get();
|
||||
camera_focus = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.camera_focus = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
camera_clip = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
camera_mist = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.camera_clip = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.camera_mist = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_endpoints_get();
|
||||
camera_clip_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.camera_clip_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Lamps */
|
||||
/* TODO
|
||||
|
@ -269,48 +278,48 @@ static void OBJECT_cache_init(void)
|
|||
|
||||
/* start with buflimit because we don't want stipples */
|
||||
geom = DRW_cache_single_line_get();
|
||||
lamp_buflimit = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_buflimit = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
lamp_center = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorLampNoAlpha, &ts.sizeLampCenter);
|
||||
lamp_center_group = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorGroup, &ts.sizeLampCenter);
|
||||
g_data.lamp_center = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorLampNoAlpha, &ts.sizeLampCenter);
|
||||
g_data.lamp_center_group = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorGroup, &ts.sizeLampCenter);
|
||||
|
||||
geom = DRW_cache_lamp_get();
|
||||
lamp_circle = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
lamp_circle_shadow = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircleShadow);
|
||||
g_data.lamp_circle = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
g_data.lamp_circle_shadow = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircleShadow);
|
||||
|
||||
geom = DRW_cache_lamp_sunrays_get();
|
||||
lamp_sunrays = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
g_data.lamp_sunrays = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
|
||||
lamp_groundline = shgroup_groundlines_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
lamp_groundpoint = shgroup_groundpoints_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
g_data.lamp_groundline = shgroup_groundlines_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
g_data.lamp_groundpoint = shgroup_groundpoints_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
|
||||
geom = DRW_cache_lamp_area_get();
|
||||
lamp_area = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_area = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_hemi_get();
|
||||
lamp_hemi = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_hemi = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
lamp_distance = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_distance = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_endpoints_get();
|
||||
lamp_buflimit_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_buflimit_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_spot_get();
|
||||
lamp_spot_cone = shgroup_spot_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_spot_cone = shgroup_spot_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_circle_get();
|
||||
lamp_spot_blend = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_spot_blend = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_spot_square_get();
|
||||
lamp_spot_pyramid = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_spot_pyramid = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_square_get();
|
||||
lamp_spot_blend_rect = shgroup_instance(psl->non_meshes, geom);
|
||||
g_data.lamp_spot_blend_rect = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Relationship Lines */
|
||||
relationship_lines = shgroup_dynlines_uniform_color(psl->non_meshes, ts.colorWire);
|
||||
DRW_shgroup_state_set(relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
g_data.relationship_lines = shgroup_dynlines_uniform_color(psl->non_meshes, ts.colorWire);
|
||||
DRW_shgroup_state_set(g_data.relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -332,17 +341,17 @@ static void OBJECT_cache_init(void)
|
|||
DRW_shgroup_uniform_float(grp, "outlineWidth", &outlineWidth, 1);
|
||||
DRW_shgroup_uniform_vec4(grp, "color", ts.colorActive, 1);
|
||||
DRW_shgroup_uniform_vec4(grp, "outlineColor", ts.colorOutline, 1);
|
||||
center_active = grp;
|
||||
g_data.center_active = grp;
|
||||
|
||||
/* Select */
|
||||
grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
|
||||
DRW_shgroup_uniform_vec4(grp, "color", ts.colorSelect, 1);
|
||||
center_selected = grp;
|
||||
g_data.center_selected = grp;
|
||||
|
||||
/* Deselect */
|
||||
grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
|
||||
DRW_shgroup_uniform_vec4(grp, "color", ts.colorDeselect, 1);
|
||||
center_deselected = grp;
|
||||
g_data.center_deselected = grp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,29 +364,29 @@ static void DRW_shgroup_lamp(Object *ob)
|
|||
|
||||
/* Don't draw the center if it's selected or active */
|
||||
if (theme_id == TH_GROUP)
|
||||
DRW_shgroup_dynamic_call_add(lamp_center_group, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_center_group, ob->obmat[3]);
|
||||
else if (theme_id == TH_LAMP)
|
||||
DRW_shgroup_dynamic_call_add(lamp_center, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_center, ob->obmat[3]);
|
||||
|
||||
/* First circle */
|
||||
DRW_shgroup_dynamic_call_add(lamp_circle, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_circle, ob->obmat[3], color);
|
||||
|
||||
/* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
|
||||
if (la->type != LA_HEMI) {
|
||||
if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_circle_shadow, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_circle_shadow, ob->obmat[3], color);
|
||||
}
|
||||
}
|
||||
|
||||
/* Distance */
|
||||
if (ELEM(la->type, LA_HEMI, LA_SUN, LA_AREA)) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_distance, color, &zero, &la->dist, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_distance, color, &zero, &la->dist, ob->obmat);
|
||||
}
|
||||
|
||||
copy_m4_m4(la->shapemat, ob->obmat);
|
||||
|
||||
if (la->type == LA_SUN) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_sunrays, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_sunrays, ob->obmat[3], color);
|
||||
}
|
||||
else if (la->type == LA_SPOT) {
|
||||
float size[3], sizemat[4][4];
|
||||
|
@ -397,33 +406,33 @@ static void DRW_shgroup_lamp(Object *ob)
|
|||
mul_m4_m4m4(la->spotblendmat, la->spotconemat, sizemat);
|
||||
|
||||
if (la->mode & LA_SQUARE) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_spot_pyramid, color, &one, la->spotconemat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_pyramid, color, &one, la->spotconemat);
|
||||
|
||||
/* hide line if it is zero size or overlaps with outer border,
|
||||
* previously it adjusted to always to show it but that seems
|
||||
* confusing because it doesn't show the actual blend size */
|
||||
if (blend != 0.0f && blend != 1.0f) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_spot_blend_rect, color, &one, la->spotblendmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_blend_rect, color, &one, la->spotblendmat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
DRW_shgroup_dynamic_call_add(lamp_spot_cone, color, la->spotconemat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_cone, color, la->spotconemat);
|
||||
|
||||
/* hide line if it is zero size or overlaps with outer border,
|
||||
* previously it adjusted to always to show it but that seems
|
||||
* confusing because it doesn't show the actual blend size */
|
||||
if (blend != 0.0f && blend != 1.0f) {
|
||||
DRW_shgroup_dynamic_call_add(lamp_spot_blend, color, &one, la->spotblendmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_blend, color, &one, la->spotblendmat);
|
||||
}
|
||||
}
|
||||
|
||||
normalize_m4(la->shapemat);
|
||||
DRW_shgroup_dynamic_call_add(lamp_buflimit, color, &la->clipsta, &la->clipend, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(lamp_buflimit_points, color, &la->clipsta, &la->clipend, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_buflimit, color, &la->clipsta, &la->clipend, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_buflimit_points, color, &la->clipsta, &la->clipend, ob->obmat);
|
||||
}
|
||||
else if (la->type == LA_HEMI) {
|
||||
static float hemisize = 2.0f;
|
||||
DRW_shgroup_dynamic_call_add(lamp_hemi, color, &hemisize, la->shapemat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_hemi, color, &hemisize, la->shapemat);
|
||||
}
|
||||
else if (la->type == LA_AREA) {
|
||||
float size[3] = {1.0f, 1.0f, 1.0f}, sizemat[4][4];
|
||||
|
@ -434,12 +443,12 @@ static void DRW_shgroup_lamp(Object *ob)
|
|||
mul_m4_m4m4(la->shapemat, la->shapemat, sizemat);
|
||||
}
|
||||
|
||||
DRW_shgroup_dynamic_call_add(lamp_area, color, &la->area_size, la->shapemat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_area, color, &la->area_size, la->shapemat);
|
||||
}
|
||||
|
||||
/* Line and point going to the ground */
|
||||
DRW_shgroup_dynamic_call_add(lamp_groundline, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(lamp_groundpoint, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_groundline, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_groundpoint, ob->obmat[3]);
|
||||
}
|
||||
|
||||
static void DRW_shgroup_camera(Object *ob)
|
||||
|
@ -477,11 +486,11 @@ static void DRW_shgroup_camera(Object *ob)
|
|||
cam->drwtria[1][0] = shift[0];
|
||||
cam->drwtria[1][1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(camera, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
|
||||
/* Active cam */
|
||||
if (is_active) {
|
||||
DRW_shgroup_dynamic_call_add(camera_tria, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_tria, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
}
|
||||
|
||||
/* draw the rest in normalize object space */
|
||||
|
@ -498,10 +507,10 @@ static void DRW_shgroup_camera(Object *ob)
|
|||
size_to_mat4(sizemat, size);
|
||||
mul_m4_m4m4(cam->drwfocusmat, cam->drwfocusmat, sizemat);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(camera_focus, (is_active ? col_hi : col), &cam->drawsize, cam->drwfocusmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_focus, (is_active ? col_hi : col), &cam->drawsize, cam->drwfocusmat);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(camera_clip, color, &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(camera_clip_points, (is_active ? col_hi : col), &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_clip, color, &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_clip_points, (is_active ? col_hi : col), &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
}
|
||||
|
||||
if (cam->flag & CAM_SHOWMIST) {
|
||||
|
@ -510,8 +519,8 @@ static void DRW_shgroup_camera(Object *ob)
|
|||
if (world) {
|
||||
static float col[3] = {0.5f, 0.5f, 0.5f}, col_hi[3] = {1.0f, 1.0f, 1.0f};
|
||||
world->mistend = world->miststa + world->mistdist;
|
||||
DRW_shgroup_dynamic_call_add(camera_mist, color, &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(camera_mist_points, (is_active ? col_hi : col), &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_mist, color, &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_mist_points, (is_active ? col_hi : col), &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,27 +532,27 @@ static void DRW_shgroup_empty(Object *ob)
|
|||
|
||||
switch (ob->empty_drawtype) {
|
||||
case OB_PLAINAXES:
|
||||
DRW_shgroup_dynamic_call_add(plain_axes, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.plain_axes, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_SINGLE_ARROW:
|
||||
DRW_shgroup_dynamic_call_add(single_arrow, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(single_arrow_line, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.single_arrow, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.single_arrow_line, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_CUBE:
|
||||
DRW_shgroup_dynamic_call_add(cube, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.cube, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_CIRCLE:
|
||||
DRW_shgroup_dynamic_call_add(circle, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.circle, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_EMPTY_SPHERE:
|
||||
DRW_shgroup_dynamic_call_add(sphere, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.sphere, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_EMPTY_CONE:
|
||||
DRW_shgroup_dynamic_call_add(cone, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.cone, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_ARROWS:
|
||||
DRW_shgroup_dynamic_call_add(arrows, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(axis_names, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.arrows, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.axis_names, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -554,24 +563,24 @@ static void DRW_shgroup_speaker(Object *ob)
|
|||
static float one = 1.0f;
|
||||
DRW_object_wire_theme_get(ob, &color);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(speaker, color, &one, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(g_data.speaker, color, &one, ob->obmat);
|
||||
}
|
||||
|
||||
static void DRW_shgroup_relationship_lines(Object *ob)
|
||||
{
|
||||
if (ob->parent) {
|
||||
DRW_shgroup_dynamic_call_add(relationship_lines, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(relationship_lines, ob->parent->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.relationship_lines, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.relationship_lines, ob->parent->obmat[3]);
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_shgroup_object_center(Object *ob)
|
||||
{
|
||||
if ((ob->base_flag & BASE_SELECTED) != 0) {
|
||||
DRW_shgroup_dynamic_call_add(center_selected, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.center_selected, ob->obmat[3]);
|
||||
}
|
||||
else if (0) {
|
||||
DRW_shgroup_dynamic_call_add(center_deselected, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.center_deselected, ob->obmat[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,20 +604,20 @@ static void OBJECT_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_wire_outline_get(ob);
|
||||
switch (theme_id) {
|
||||
case TH_ACTIVE:
|
||||
DRW_shgroup_call_add(outlines_active, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(outlines_transp_active, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_active, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_transp_active, geom, ob->obmat);
|
||||
break;
|
||||
case TH_SELECT:
|
||||
DRW_shgroup_call_add(outlines_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(outlines_transp_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_transp_select, geom, ob->obmat);
|
||||
break;
|
||||
case TH_GROUP_ACTIVE:
|
||||
DRW_shgroup_call_add(outlines_select_group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(outlines_transp_select_group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_select_group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_transp_select_group, geom, ob->obmat);
|
||||
break;
|
||||
case TH_TRANSFORM:
|
||||
DRW_shgroup_call_add(outlines_transform, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(outlines_transp_transform, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_transform, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.outlines_transp_transform, geom, ob->obmat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -631,9 +640,9 @@ static void OBJECT_cache_populate(Object *ob)
|
|||
{
|
||||
bArmature *arm = ob->data;
|
||||
if (arm->edbo == NULL) {
|
||||
DRW_shgroup_armature_object(ob, vedata->psl->bone_solid,
|
||||
vedata->psl->bone_wire,
|
||||
relationship_lines);
|
||||
DRW_shgroup_armature_object(ob, g_data.vedata->psl->bone_solid,
|
||||
g_data.vedata->psl->bone_wire,
|
||||
g_data.relationship_lines);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct PAINT_TEXTURE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_TEXTURE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PAINT_TEXTURE_engine_init();
|
||||
* free in PAINT_TEXTURE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_TEXTURE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PAINT_TEXTURE_engine_init();
|
||||
* free in PAINT_TEXTURE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static PAINT_TEXTURE_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
PAINT_TEXTURE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static PAINT_TEXTURE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void PAINT_TEXTURE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_TextureList *txl = vedata->txl;
|
||||
PAINT_TEXTURE_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_TEXTURE_StorageList *stl = vedata->stl;
|
||||
PAINT_TEXTURE_Data *ved = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_TextureList *txl = ved->txl;
|
||||
PAINT_TEXTURE_FramebufferList *fbl = ved->fbl;
|
||||
PAINT_TEXTURE_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void PAINT_TEXTURE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void PAINT_TEXTURE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_TEXTURE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_PassList *psl = vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void PAINT_TEXTURE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void PAINT_TEXTURE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void PAINT_TEXTURE_cache_populate(Object *ob)
|
||||
{
|
||||
PAINT_TEXTURE_PassList *psl = vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = vedata->stl;
|
||||
PAINT_TEXTURE_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void PAINT_TEXTURE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void PAINT_TEXTURE_cache_finish(void)
|
||||
{
|
||||
PAINT_TEXTURE_PassList *psl = vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = vedata->stl;
|
||||
PAINT_TEXTURE_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void PAINT_TEXTURE_draw_scene(void)
|
|||
{
|
||||
PAINT_TEXTURE_Data *ved = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_PassList *psl = ved->psl;
|
||||
PAINT_TEXTURE_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_TEXTURE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct PAINT_VERTEX_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_VERTEX_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
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;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_VERTEX_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PAINT_VERTEX_engine_init();
|
||||
* free in PAINT_VERTEX_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static PAINT_VERTEX_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
PAINT_VERTEX_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static PAINT_VERTEX_Data *vedata;
|
|||
* (Optional) */
|
||||
static void PAINT_VERTEX_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_TextureList *txl = vedata->txl;
|
||||
PAINT_VERTEX_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_VERTEX_StorageList *stl = vedata->stl;
|
||||
PAINT_VERTEX_Data *ved = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_TextureList *txl = ved->txl;
|
||||
PAINT_VERTEX_FramebufferList *fbl = ved->fbl;
|
||||
PAINT_VERTEX_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void PAINT_VERTEX_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void PAINT_VERTEX_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_VERTEX_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_PassList *psl = vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void PAINT_VERTEX_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void PAINT_VERTEX_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void PAINT_VERTEX_cache_populate(Object *ob)
|
||||
{
|
||||
PAINT_VERTEX_PassList *psl = vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = vedata->stl;
|
||||
PAINT_VERTEX_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void PAINT_VERTEX_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void PAINT_VERTEX_cache_finish(void)
|
||||
{
|
||||
PAINT_VERTEX_PassList *psl = vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = vedata->stl;
|
||||
PAINT_VERTEX_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_VERTEX_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void PAINT_VERTEX_draw_scene(void)
|
|||
{
|
||||
PAINT_VERTEX_Data *ved = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_PassList *psl = ved->psl;
|
||||
PAINT_VERTEX_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_VERTEX_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#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. */
|
||||
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
|
||||
|
@ -85,26 +91,24 @@ typedef struct PAINT_WEIGHT_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_WEIGHT_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PAINT_WEIGHT_engine_init();
|
||||
* free in PAINT_WEIGHT_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_WEIGHT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PAINT_WEIGHT_engine_init();
|
||||
* free in PAINT_WEIGHT_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static PAINT_WEIGHT_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
PAINT_WEIGHT_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +117,10 @@ static PAINT_WEIGHT_Data *vedata;
|
|||
* (Optional) */
|
||||
static void PAINT_WEIGHT_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_TextureList *txl = vedata->txl;
|
||||
PAINT_WEIGHT_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_WEIGHT_StorageList *stl = vedata->stl;
|
||||
PAINT_WEIGHT_Data *ved = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_TextureList *txl = ved->txl;
|
||||
PAINT_WEIGHT_FramebufferList *fbl = ved->fbl;
|
||||
PAINT_WEIGHT_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +139,8 @@ static void PAINT_WEIGHT_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +148,9 @@ static void PAINT_WEIGHT_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_WEIGHT_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_PassList *psl = vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +161,16 @@ static void PAINT_WEIGHT_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +178,8 @@ static void PAINT_WEIGHT_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void PAINT_WEIGHT_cache_populate(Object *ob)
|
||||
{
|
||||
PAINT_WEIGHT_PassList *psl = vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = vedata->stl;
|
||||
PAINT_WEIGHT_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +188,15 @@ static void PAINT_WEIGHT_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void PAINT_WEIGHT_cache_finish(void)
|
||||
{
|
||||
PAINT_WEIGHT_PassList *psl = vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = vedata->stl;
|
||||
PAINT_WEIGHT_PassList *psl = g_data.vedata->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +207,7 @@ static void PAINT_WEIGHT_draw_scene(void)
|
|||
{
|
||||
PAINT_WEIGHT_Data *ved = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_PassList *psl = ved->psl;
|
||||
PAINT_WEIGHT_FramebufferList *fbl = vedata->fbl;
|
||||
PAINT_WEIGHT_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -85,26 +85,24 @@ typedef struct PARTICLE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PARTICLE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PARTICLE_engine_init();
|
||||
* free in PARTICLE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PARTICLE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in PARTICLE_engine_init();
|
||||
* free in PARTICLE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static PARTICLE_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
PARTICLE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +111,10 @@ static PARTICLE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void PARTICLE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("ParticleMode");
|
||||
PARTICLE_TextureList *txl = vedata->txl;
|
||||
PARTICLE_FramebufferList *fbl = vedata->fbl;
|
||||
PARTICLE_StorageList *stl = vedata->stl;
|
||||
PARTICLE_Data *ved = DRW_viewport_engine_data_get("ParticleMode");
|
||||
PARTICLE_TextureList *txl = ved->txl;
|
||||
PARTICLE_FramebufferList *fbl = ved->fbl;
|
||||
PARTICLE_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +133,8 @@ static void PARTICLE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +142,9 @@ static void PARTICLE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PARTICLE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("ParticleMode");
|
||||
PARTICLE_PassList *psl = vedata->psl;
|
||||
PARTICLE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("ParticleMode");
|
||||
PARTICLE_PassList *psl = g_data.vedata->psl;
|
||||
PARTICLE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +155,16 @@ static void PARTICLE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +172,8 @@ static void PARTICLE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void PARTICLE_cache_populate(Object *ob)
|
||||
{
|
||||
PARTICLE_PassList *psl = vedata->psl;
|
||||
PARTICLE_StorageList *stl = vedata->stl;
|
||||
PARTICLE_PassList *psl = g_data.vedata->psl;
|
||||
PARTICLE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +182,15 @@ static void PARTICLE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void PARTICLE_cache_finish(void)
|
||||
{
|
||||
PARTICLE_PassList *psl = vedata->psl;
|
||||
PARTICLE_StorageList *stl = vedata->stl;
|
||||
PARTICLE_PassList *psl = g_data.vedata->psl;
|
||||
PARTICLE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +201,7 @@ static void PARTICLE_draw_scene(void)
|
|||
{
|
||||
PARTICLE_Data *ved = DRW_viewport_engine_data_get("ParticleMode");
|
||||
PARTICLE_PassList *psl = ved->psl;
|
||||
PARTICLE_FramebufferList *fbl = vedata->fbl;
|
||||
PARTICLE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -85,26 +85,24 @@ typedef struct POSE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in POSE_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in POSE_engine_init();
|
||||
* free in POSE_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in POSE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in POSE_engine_init();
|
||||
* free in POSE_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static POSE_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
POSE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +111,10 @@ static POSE_Data *vedata;
|
|||
* (Optional) */
|
||||
static void POSE_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PoseMode");
|
||||
POSE_TextureList *txl = vedata->txl;
|
||||
POSE_FramebufferList *fbl = vedata->fbl;
|
||||
POSE_StorageList *stl = vedata->stl;
|
||||
POSE_Data *ved = DRW_viewport_engine_data_get("PoseMode");
|
||||
POSE_TextureList *txl = ved->txl;
|
||||
POSE_FramebufferList *fbl = ved->fbl;
|
||||
POSE_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +133,8 @@ static void POSE_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +142,9 @@ static void POSE_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void POSE_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("PoseMode");
|
||||
POSE_PassList *psl = vedata->psl;
|
||||
POSE_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("PoseMode");
|
||||
POSE_PassList *psl = g_data.vedata->psl;
|
||||
POSE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +155,16 @@ static void POSE_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +172,8 @@ static void POSE_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void POSE_cache_populate(Object *ob)
|
||||
{
|
||||
POSE_PassList *psl = vedata->psl;
|
||||
POSE_StorageList *stl = vedata->stl;
|
||||
POSE_PassList *psl = g_data.vedata->psl;
|
||||
POSE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +182,15 @@ static void POSE_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void POSE_cache_finish(void)
|
||||
{
|
||||
POSE_PassList *psl = vedata->psl;
|
||||
POSE_StorageList *stl = vedata->stl;
|
||||
POSE_PassList *psl = g_data.vedata->psl;
|
||||
POSE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +201,7 @@ static void POSE_draw_scene(void)
|
|||
{
|
||||
POSE_Data *ved = DRW_viewport_engine_data_get("PoseMode");
|
||||
POSE_PassList *psl = ved->psl;
|
||||
POSE_FramebufferList *fbl = vedata->fbl;
|
||||
POSE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
|
@ -85,26 +85,24 @@ typedef struct SCULPT_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in SCULPT_cache_populate() */
|
||||
static DRWShadingGroup *group;
|
||||
static struct {
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in SCULPT_engine_init();
|
||||
* free in SCULPT_engine_free(); */
|
||||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
/* If needed, contains all global/Theme colors
|
||||
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
||||
* Not needed for constant color. */
|
||||
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
|
||||
extern struct GlobalsUboStorage ts; /* draw_common.c */
|
||||
static struct {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in SCULPT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* Custom shaders :
|
||||
* Add sources to source/blender/draw/modes/shaders
|
||||
* init in SCULPT_engine_init();
|
||||
* free in SCULPT_engine_free(); */
|
||||
static struct GPUShader *custom_shader = NULL;
|
||||
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
static SCULPT_Data *vedata;
|
||||
/* This keeps the reference of the viewport engine data because
|
||||
* DRW_viewport_engine_data_get is slow and we don't want to
|
||||
* call it for every object */
|
||||
SCULPT_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -113,10 +111,10 @@ static SCULPT_Data *vedata;
|
|||
* (Optional) */
|
||||
static void SCULPT_engine_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("SculptMode");
|
||||
SCULPT_TextureList *txl = vedata->txl;
|
||||
SCULPT_FramebufferList *fbl = vedata->fbl;
|
||||
SCULPT_StorageList *stl = vedata->stl;
|
||||
SCULPT_Data *ved = DRW_viewport_engine_data_get("SculptMode");
|
||||
SCULPT_TextureList *txl = ved->txl;
|
||||
SCULPT_FramebufferList *fbl = ved->fbl;
|
||||
SCULPT_StorageList *stl = ved->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -135,8 +133,8 @@ static void SCULPT_engine_init(void)
|
|||
* tex, 2);
|
||||
*/
|
||||
|
||||
if (!custom_shader) {
|
||||
custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (!e_data.custom_shader) {
|
||||
e_data.custom_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,9 +142,9 @@ static void SCULPT_engine_init(void)
|
|||
* Assume that all Passes are NULL */
|
||||
static void SCULPT_cache_init(void)
|
||||
{
|
||||
vedata = DRW_viewport_engine_data_get("SculptMode");
|
||||
SCULPT_PassList *psl = vedata->psl;
|
||||
SCULPT_StorageList *stl = vedata->stl;
|
||||
g_data.vedata = DRW_viewport_engine_data_get("SculptMode");
|
||||
SCULPT_PassList *psl = g_data.vedata->psl;
|
||||
SCULPT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
|
@ -157,16 +155,16 @@ static void SCULPT_cache_init(void)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
group = DRW_shgroup_create(custom_shader, psl->pass);
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,8 +172,8 @@ static void SCULPT_cache_init(void)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void SCULPT_cache_populate(Object *ob)
|
||||
{
|
||||
SCULPT_PassList *psl = vedata->psl;
|
||||
SCULPT_StorageList *stl = vedata->stl;
|
||||
SCULPT_PassList *psl = g_data.vedata->psl;
|
||||
SCULPT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
|
@ -184,15 +182,15 @@ static void SCULPT_cache_populate(Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* Optional: Post-cache_populate callback */
|
||||
static void SCULPT_cache_finish(void)
|
||||
{
|
||||
SCULPT_PassList *psl = vedata->psl;
|
||||
SCULPT_StorageList *stl = vedata->stl;
|
||||
SCULPT_PassList *psl = g_data.vedata->psl;
|
||||
SCULPT_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
/* Do something here! dependant on the objects gathered */
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
@ -203,7 +201,7 @@ static void SCULPT_draw_scene(void)
|
|||
{
|
||||
SCULPT_Data *ved = DRW_viewport_engine_data_get("SculptMode");
|
||||
SCULPT_PassList *psl = ved->psl;
|
||||
SCULPT_FramebufferList *fbl = vedata->fbl;
|
||||
SCULPT_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
|
|
Loading…
Reference in New Issue