Draw Engines: Make g_data struct part of the viewport storage
This makes viewport cache construction independant from each others and will allow multithread down the road.
This commit is contained in:
parent
7ee41920fa
commit
deda6a43fc
|
@ -76,6 +76,7 @@ typedef struct CLAY_Storage {
|
|||
typedef struct CLAY_StorageList {
|
||||
struct CLAY_Storage *storage;
|
||||
struct GPUUniformBuffer *mat_ubo;
|
||||
struct g_data *g_data;
|
||||
} CLAY_StorageList;
|
||||
|
||||
/* keep it under MAX_BUFFERS */
|
||||
|
@ -100,6 +101,7 @@ typedef struct CLAY_PassList {
|
|||
struct DRWPass *depth_pass;
|
||||
struct DRWPass *depth_pass_cull;
|
||||
struct DRWPass *clay_pass;
|
||||
struct g_data *g_data;
|
||||
} CLAY_PassList;
|
||||
|
||||
typedef struct CLAY_Data {
|
||||
|
@ -134,15 +136,14 @@ static struct {
|
|||
int ubo_mat_idxs[MAX_CLAY_MAT];
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* Functions */
|
||||
|
||||
|
@ -604,13 +605,18 @@ static void CLAY_cache_init(void *vedata)
|
|||
CLAY_PassList *psl = ((CLAY_Data *)vedata)->psl;
|
||||
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
/* Depth Pass */
|
||||
{
|
||||
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
g_data.depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
|
||||
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
|
||||
g_data.depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
}
|
||||
|
||||
/* Clay Pass */
|
||||
|
@ -640,7 +646,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
|
|||
geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Depth Prepass */
|
||||
DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull : g_data.depth_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
|
||||
|
||||
/* Shading */
|
||||
clay_shgrp = CLAY_object_shgrp_get(vedata, ob, stl, psl);
|
||||
|
|
|
@ -37,17 +37,6 @@ static struct {
|
|||
struct GPUShader *tonemap;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
DRWShadingGroup *default_lit_grp;
|
||||
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;
|
||||
EEVEE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
extern char datatoc_lit_surface_frag_glsl[];
|
||||
extern char datatoc_lit_surface_vert_glsl[];
|
||||
extern char datatoc_tonemap_frag_glsl[];
|
||||
|
@ -91,33 +80,38 @@ static void EEVEE_cache_init(void *vedata)
|
|||
EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl;
|
||||
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
g_data.depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
|
||||
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);
|
||||
stl->g_data->depth_shgrp_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(stl->g_data->depth_shgrp_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
|
||||
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);
|
||||
stl->g_data->depth_shgrp_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
DRW_shgroup_state_set(stl->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);
|
||||
g_data.depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
|
||||
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);
|
||||
stl->g_data->depth_shgrp_cull_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(stl->g_data->depth_shgrp_cull_select, DRW_STATE_WRITE_STENCIL_SELECT);
|
||||
|
||||
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);
|
||||
stl->g_data->depth_shgrp_cull_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
||||
DRW_shgroup_state_set(stl->g_data->depth_shgrp_cull_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
|
||||
}
|
||||
|
||||
{
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_EQUAL;
|
||||
psl->pass = DRW_pass_create("Default Light Pass", state);
|
||||
|
||||
g_data.default_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->pass);
|
||||
DRW_shgroup_uniform_block(g_data.default_lit_grp, "light_block", stl->lights_ubo, 0);
|
||||
DRW_shgroup_uniform_int(g_data.default_lit_grp, "light_count", &stl->lights_info->light_count, 1);
|
||||
stl->g_data->default_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->pass);
|
||||
DRW_shgroup_uniform_block(stl->g_data->default_lit_grp, "light_block", stl->lights_ubo, 0);
|
||||
DRW_shgroup_uniform_int(stl->g_data->default_lit_grp, "light_count", &stl->lights_info->light_count, 1);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -149,11 +143,11 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
|
|||
// if ((ob->base_flag & BASE_ACTIVE) != 0)
|
||||
// DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull_active : depth_shgrp_active, geom, ob->obmat);
|
||||
if ((ob->base_flag & BASE_SELECTED) != 0)
|
||||
DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull_select : g_data.depth_shgrp_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull_select : stl->g_data->depth_shgrp_select, geom, ob->obmat);
|
||||
else
|
||||
DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull : g_data.depth_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
|
||||
|
||||
DRW_shgroup_call_add(g_data.default_lit_grp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->default_lit_grp, geom, ob->obmat);
|
||||
}
|
||||
else if (ob->type == OB_LAMP) {
|
||||
EEVEE_lights_cache_add(stl, ob);
|
||||
|
|
|
@ -35,9 +35,6 @@ typedef struct EEVEE_Light {
|
|||
float spot_size, spot_blend, area_x, area_y;
|
||||
} EEVEE_Light;
|
||||
|
||||
static struct {
|
||||
ListBase lamps; /* Lamps gathered during cache iteration */
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
void EEVEE_lights_init(EEVEE_StorageList *stl)
|
||||
{
|
||||
|
@ -49,13 +46,13 @@ void EEVEE_lights_init(EEVEE_StorageList *stl)
|
|||
|
||||
void EEVEE_lights_cache_init(EEVEE_StorageList *stl)
|
||||
{
|
||||
BLI_listbase_clear(&g_data.lamps);
|
||||
BLI_listbase_clear(&stl->g_data->lamps);
|
||||
stl->lights_info->light_count = 0;
|
||||
}
|
||||
|
||||
void EEVEE_lights_cache_add(EEVEE_StorageList *stl, Object *ob)
|
||||
{
|
||||
BLI_addtail(&g_data.lamps, BLI_genericNodeN(ob));
|
||||
BLI_addtail(&stl->g_data->lamps, BLI_genericNodeN(ob));
|
||||
stl->lights_info->light_count += 1;
|
||||
}
|
||||
|
||||
|
@ -70,12 +67,12 @@ void EEVEE_lights_cache_finish(EEVEE_StorageList *stl)
|
|||
|
||||
if (light_ct > 0) {
|
||||
int i = 0;
|
||||
for (LinkData *link = g_data.lamps.first; link && i < MAX_LIGHT; link = link->next, i++) {
|
||||
for (LinkData *link = stl->g_data->lamps.first; link && i < MAX_LIGHT; link = link->next, i++) {
|
||||
Object *ob = (Object *)link->data;
|
||||
stl->lights_ref[i] = ob;
|
||||
}
|
||||
}
|
||||
BLI_freelistN(&g_data.lamps);
|
||||
BLI_freelistN(&stl->g_data->lamps);
|
||||
|
||||
/* We changed light data so we need to upload it */
|
||||
EEVEE_lights_update(stl);
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct EEVEE_StorageList {
|
|||
struct EEVEE_Light *lights_data; /* Array, Packed lights data info, duplication of what is in the Uniform Buffer in Vram */
|
||||
struct Object **lights_ref; /* List of all lights in the buffer. */
|
||||
struct GPUUniformBuffer *lights_ubo;
|
||||
struct g_data *g_data;
|
||||
} EEVEE_StorageList;
|
||||
|
||||
typedef struct EEVEE_LightsInfo {
|
||||
|
@ -64,6 +65,18 @@ typedef struct EEVEE_Data {
|
|||
EEVEE_StorageList *stl;
|
||||
} EEVEE_Data;
|
||||
|
||||
typedef struct g_data{
|
||||
struct DRWShadingGroup *default_lit_grp;
|
||||
struct DRWShadingGroup *depth_shgrp;
|
||||
struct DRWShadingGroup *depth_shgrp_select;
|
||||
struct DRWShadingGroup *depth_shgrp_active;
|
||||
struct DRWShadingGroup *depth_shgrp_cull;
|
||||
struct DRWShadingGroup *depth_shgrp_cull_select;
|
||||
struct DRWShadingGroup *depth_shgrp_cull_active;
|
||||
|
||||
struct ListBase lamps; /* Lamps gathered during cache iteration */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* eevee_lights.c */
|
||||
void EEVEE_lights_init(EEVEE_StorageList *stl);
|
||||
void EEVEE_lights_cache_init(EEVEE_StorageList *stl);
|
||||
|
|
|
@ -42,6 +42,11 @@ typedef struct EDIT_ARMATURE_PassList {
|
|||
struct DRWPass *relationship;
|
||||
} EDIT_ARMATURE_PassList;
|
||||
|
||||
/* keep it under MAX_STORAGE */
|
||||
typedef struct EDIT_ARMATURE_StorageList {
|
||||
struct g_data *g_data;
|
||||
} EDIT_ARMATURE_StorageList;
|
||||
|
||||
typedef struct EDIT_ARMATURE_Data {
|
||||
char engine_name[32];
|
||||
void *fbl;
|
||||
|
@ -52,17 +57,21 @@ typedef struct EDIT_ARMATURE_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
DRWShadingGroup *relationship_lines;
|
||||
EDIT_ARMATURE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void EDIT_ARMATURE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
||||
EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl;
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Solid bones */
|
||||
|
@ -82,8 +91,8 @@ static void EDIT_ARMATURE_cache_init(void *vedata)
|
|||
psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
|
||||
|
||||
/* Relationship Lines */
|
||||
g_data.relationship_lines = shgroup_dynlines_uniform_color(psl->relationship, ts.colorWire);
|
||||
DRW_shgroup_state_set(g_data.relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
stl->g_data->relationship_lines = shgroup_dynlines_uniform_color(psl->relationship, ts.colorWire);
|
||||
DRW_shgroup_state_set(stl->g_data->relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,10 +100,11 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
|
|||
{
|
||||
bArmature *arm = ob->data;
|
||||
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
||||
EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl;
|
||||
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
if (arm->edbo) {
|
||||
DRW_shgroup_armature_edit(ob, psl->bone_solid, psl->bone_wire, g_data.relationship_lines);
|
||||
DRW_shgroup_armature_edit(ob, psl->bone_solid, psl->bone_wire, stl->g_data->relationship_lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct EDIT_CURVE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} EDIT_CURVE_StorageList;
|
||||
|
||||
typedef struct EDIT_CURVE_Data {
|
||||
|
@ -99,16 +100,13 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
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;
|
||||
typedef struct g_data {
|
||||
|
||||
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_CURVE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,7 +115,6 @@ static struct {
|
|||
* (Optional) */
|
||||
static void EDIT_CURVE_engine_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_CURVE_TextureList *txl = ((EDIT_CURVE_Data *)vedata)->txl;
|
||||
EDIT_CURVE_FramebufferList *fbl = ((EDIT_CURVE_Data *)vedata)->fbl;
|
||||
EDIT_CURVE_StorageList *stl = ((EDIT_CURVE_Data *)vedata)->stl;
|
||||
|
@ -148,11 +145,13 @@ static void EDIT_CURVE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_CURVE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_CURVE_PassList *psl = ((EDIT_CURVE_Data *)vedata)->psl;
|
||||
EDIT_CURVE_StorageList *stl = ((EDIT_CURVE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +160,16 @@ static void EDIT_CURVE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +187,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct EDIT_LATTICE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} EDIT_LATTICE_StorageList;
|
||||
|
||||
typedef struct EDIT_LATTICE_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_LATTICE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,7 +113,6 @@ static struct {
|
|||
* (Optional) */
|
||||
static void EDIT_LATTICE_engine_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_LATTICE_TextureList *txl = ((EDIT_LATTICE_Data *)vedata)->txl;
|
||||
EDIT_LATTICE_FramebufferList *fbl = ((EDIT_LATTICE_Data *)vedata)->fbl;
|
||||
EDIT_LATTICE_StorageList *stl = ((EDIT_LATTICE_Data *)vedata)->stl;
|
||||
|
@ -148,11 +143,13 @@ static void EDIT_LATTICE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_LATTICE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_LATTICE_PassList *psl = ((EDIT_LATTICE_Data *)vedata)->psl;
|
||||
EDIT_LATTICE_StorageList *stl = ((EDIT_LATTICE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void EDIT_LATTICE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,11 @@ typedef struct EDIT_MESH_TextureList {
|
|||
struct GPUTexture *occlude_wire_color_tx;
|
||||
} EDIT_MESH_TextureList;
|
||||
|
||||
/* keep it under MAX_STORAGE */
|
||||
typedef struct EDIT_MESH_StorageList {
|
||||
struct g_data *g_data;
|
||||
} EDIT_MESH_StorageList;
|
||||
|
||||
typedef struct EDIT_MESH_Data {
|
||||
char engine_name[32];
|
||||
EDIT_MESH_FramebufferList *fbl;
|
||||
|
@ -101,7 +106,7 @@ static struct {
|
|||
struct GPUShader *depth_sh;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
DRWShadingGroup *depth_shgrp_hidden_wire;
|
||||
|
||||
DRWShadingGroup *fnormals_shgrp;
|
||||
|
@ -119,15 +124,13 @@ static struct {
|
|||
DRWShadingGroup *facedot_occluded_shgrp;
|
||||
DRWShadingGroup *facefill_occluded_shgrp;
|
||||
|
||||
EDIT_MESH_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void EDIT_MESH_engine_init(void *vedata)
|
||||
{
|
||||
EDIT_MESH_Data *ved = DRW_viewport_engine_data_get("EditMeshMode");
|
||||
EDIT_MESH_TextureList *txl = ved->txl;
|
||||
EDIT_MESH_TextureList *txl = ((EDIT_MESH_Data *)vedata)->txl;
|
||||
EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl;
|
||||
|
||||
float *viewport_size = DRW_viewport_size_get();
|
||||
|
@ -263,9 +266,9 @@ static float size_normal;
|
|||
|
||||
static void EDIT_MESH_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_MESH_TextureList *txl = ((EDIT_MESH_Data *)vedata)->txl;
|
||||
EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl;
|
||||
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
const struct bContext *C = DRW_get_context();
|
||||
|
@ -274,44 +277,49 @@ static void EDIT_MESH_cache_init(void *vedata)
|
|||
bool do_zbufclip = ((v3d->flag & V3D_ZBUF_SELECT) == 0);
|
||||
|
||||
static float zero = 0.0f;
|
||||
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* 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);
|
||||
g_data.depth_shgrp_hidden_wire = DRW_shgroup_create(e_data.depth_sh, psl->depth_hidden_wire);
|
||||
stl->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);
|
||||
|
||||
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);
|
||||
stl->g_data->fnormals_shgrp = DRW_shgroup_create(e_data.normals_face_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(stl->g_data->fnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->fnormals_shgrp, "color", ts.colorNormal, 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);
|
||||
stl->g_data->vnormals_shgrp = DRW_shgroup_create(e_data.normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(stl->g_data->vnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->vnormals_shgrp, "color", ts.colorVNormal, 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);
|
||||
stl->g_data->lnormals_shgrp = DRW_shgroup_create(e_data.normals_sh, psl->normals);
|
||||
DRW_shgroup_uniform_float(stl->g_data->lnormals_shgrp, "normalSize", &size_normal, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->lnormals_shgrp, "color", ts.colorLNormal, 1);
|
||||
}
|
||||
|
||||
if (!do_zbufclip) {
|
||||
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);
|
||||
psl->edit_face_overlay = edit_mesh_create_overlay_pass(&stl->g_data->face_overlay_shgrp, &stl->g_data->ledges_overlay_shgrp, &stl->g_data->lverts_overlay_shgrp,
|
||||
&stl->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(&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);
|
||||
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&stl->g_data->face_occluded_shgrp, &stl->g_data->ledges_occluded_shgrp, &stl->g_data->lverts_occluded_shgrp,
|
||||
&stl->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);
|
||||
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);
|
||||
stl->g_data->facefill_occluded_shgrp = DRW_shgroup_create(e_data.overlay_facefill_sh, psl->facefill_occlude);
|
||||
DRW_shgroup_uniform_block(stl->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();
|
||||
|
@ -348,8 +356,9 @@ static void edit_mesh_add_ob_to_pass(Scene *scene, Object *ob, DRWShadingGroup *
|
|||
}
|
||||
}
|
||||
|
||||
static void EDIT_MESH_cache_populate(void *UNUSED(vedata), Object *ob)
|
||||
static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
|
||||
const struct bContext *C = DRW_get_context();
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -371,31 +380,31 @@ static void EDIT_MESH_cache_populate(void *UNUSED(vedata), Object *ob)
|
|||
|
||||
if (do_occlude_wire) {
|
||||
geom = DRW_cache_surface_get(ob);
|
||||
DRW_shgroup_call_add(g_data.depth_shgrp_hidden_wire, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->depth_shgrp_hidden_wire, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (fnormals_do) {
|
||||
geom = DRW_cache_face_centers_get(ob);
|
||||
DRW_shgroup_call_add(g_data.fnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->fnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (vnormals_do) {
|
||||
geom = DRW_cache_verts_get(ob);
|
||||
DRW_shgroup_call_add(g_data.vnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->vnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if (lnormals_do) {
|
||||
geom = DRW_cache_surface_verts_get(ob);
|
||||
DRW_shgroup_call_add(g_data.lnormals_shgrp, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->lnormals_shgrp, geom, ob->obmat);
|
||||
}
|
||||
|
||||
if ((v3d->flag & V3D_ZBUF_SELECT) == 0) {
|
||||
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);
|
||||
edit_mesh_add_ob_to_pass(scene, ob, stl->g_data->face_occluded_shgrp, stl->g_data->ledges_occluded_shgrp,
|
||||
stl->g_data->lverts_occluded_shgrp, stl->g_data->facedot_occluded_shgrp, stl->g_data->facefill_occluded_shgrp);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
edit_mesh_add_ob_to_pass(scene, ob, stl->g_data->face_overlay_shgrp, stl->g_data->ledges_overlay_shgrp,
|
||||
stl->g_data->lverts_overlay_shgrp, stl->g_data->facedot_overlay_shgrp, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct EDIT_METABALL_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} EDIT_METABALL_StorageList;
|
||||
|
||||
typedef struct EDIT_METABALL_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_METABALL_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void EDIT_METABALL_engine_init(void *vedata)
|
||||
{
|
||||
EDIT_METABALL_Data *ved = DRW_viewport_engine_data_get("EditMetaballMode");
|
||||
EDIT_METABALL_TextureList *txl = ved->txl;
|
||||
EDIT_METABALL_TextureList *txl = ((EDIT_METABALL_Data *)vedata)->txl;
|
||||
EDIT_METABALL_FramebufferList *fbl = ((EDIT_METABALL_Data *)vedata)->fbl;
|
||||
EDIT_METABALL_StorageList *stl = ved->stl;
|
||||
EDIT_METABALL_StorageList *stl = ((EDIT_METABALL_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void EDIT_METABALL_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_METABALL_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
|
||||
EDIT_METABALL_StorageList *stl = ((EDIT_METABALL_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void EDIT_METABALL_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct EDIT_SURFACE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} EDIT_SURFACE_StorageList;
|
||||
|
||||
typedef struct EDIT_SURFACE_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_SURFACE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void EDIT_SURFACE_engine_init(void *vedata)
|
||||
{
|
||||
EDIT_SURFACE_Data *ved = DRW_viewport_engine_data_get("EditSurfaceMode");
|
||||
EDIT_SURFACE_TextureList *txl = ved->txl;
|
||||
EDIT_SURFACE_TextureList *txl = ((EDIT_SURFACE_Data *)vedata)->txl;
|
||||
EDIT_SURFACE_FramebufferList *fbl = ((EDIT_SURFACE_Data *)vedata)->fbl;
|
||||
EDIT_SURFACE_StorageList *stl = ved->stl;
|
||||
EDIT_SURFACE_StorageList *stl = ((EDIT_SURFACE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void EDIT_SURFACE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_SURFACE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_SURFACE_PassList *psl = ((EDIT_SURFACE_Data *)vedata)->psl;
|
||||
EDIT_SURFACE_StorageList *stl = ((EDIT_SURFACE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void EDIT_SURFACE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void EDIT_SURFACE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct EDIT_TEXT_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} EDIT_TEXT_StorageList;
|
||||
|
||||
typedef struct EDIT_TEXT_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in EDIT_TEXT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void EDIT_TEXT_engine_init(void *vedata)
|
||||
{
|
||||
EDIT_TEXT_Data *ved = DRW_viewport_engine_data_get("EditTextMode");
|
||||
EDIT_TEXT_TextureList *txl = ved->txl;
|
||||
EDIT_TEXT_TextureList *txl = ((EDIT_TEXT_Data *)vedata)->txl;
|
||||
EDIT_TEXT_FramebufferList *fbl = ((EDIT_TEXT_Data *)vedata)->fbl;
|
||||
EDIT_TEXT_StorageList *stl = ved->stl;
|
||||
EDIT_TEXT_StorageList *stl = ((EDIT_TEXT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void EDIT_TEXT_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void EDIT_TEXT_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
EDIT_TEXT_PassList *psl = ((EDIT_TEXT_Data *)vedata)->psl;
|
||||
EDIT_TEXT_StorageList *stl = ((EDIT_TEXT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void EDIT_TEXT_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,11 @@ typedef struct OBJECT_TextureList {
|
|||
struct GPUTexture *outlines_blur_tx;
|
||||
} OBJECT_TextureList;
|
||||
|
||||
/* keep it under MAX_STORAGE */
|
||||
typedef struct OBJECT_StorageList {
|
||||
struct g_data *g_data;
|
||||
} OBJECT_StorageList;
|
||||
|
||||
typedef struct OBJECT_Data {
|
||||
char engine_name[32];
|
||||
void *fbl;
|
||||
|
@ -97,7 +102,7 @@ typedef struct OBJECT_Data {
|
|||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data{
|
||||
/* Empties */
|
||||
DRWShadingGroup *plain_axes;
|
||||
DRWShadingGroup *cube;
|
||||
|
@ -154,8 +159,7 @@ static struct {
|
|||
DRWShadingGroup *outlines_select_group;
|
||||
DRWShadingGroup *outlines_transform;
|
||||
|
||||
OBJECT_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
static struct {
|
||||
struct GPUShader *outline_resolve_sh;
|
||||
|
@ -187,7 +191,6 @@ enum {
|
|||
|
||||
static void OBJECT_engine_init(void *vedata)
|
||||
{
|
||||
|
||||
OBJECT_TextureList *txl = ((OBJECT_Data *)vedata)->txl;
|
||||
OBJECT_FramebufferList *fbl = ((OBJECT_Data *)vedata)->fbl;
|
||||
|
||||
|
@ -376,12 +379,16 @@ static DRWShadingGroup *shgroup_outline(DRWPass *pass, const float col[4], struc
|
|||
|
||||
static void OBJECT_cache_init(void *vedata)
|
||||
{
|
||||
/* DRW_viewport_engine_data_get is rather slow, better not do it on every objects */
|
||||
|
||||
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
|
||||
OBJECT_TextureList *txl = ((OBJECT_Data *)vedata)->txl;
|
||||
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE;
|
||||
psl->outlines = DRW_pass_create("Outlines Pass", state);
|
||||
|
@ -389,15 +396,15 @@ static void OBJECT_cache_init(void *vedata)
|
|||
struct GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
/* Select */
|
||||
g_data.outlines_select = shgroup_outline(psl->outlines, ts.colorSelect, sh);
|
||||
g_data.outlines_select_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
|
||||
stl->g_data->outlines_select = shgroup_outline(psl->outlines, ts.colorSelect, sh);
|
||||
stl->g_data->outlines_select_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
|
||||
|
||||
/* Transform */
|
||||
g_data.outlines_transform = shgroup_outline(psl->outlines, ts.colorTransform, sh);
|
||||
stl->g_data->outlines_transform = shgroup_outline(psl->outlines, ts.colorTransform, sh);
|
||||
|
||||
/* Active */
|
||||
g_data.outlines_active = shgroup_outline(psl->outlines, ts.colorActive, sh);
|
||||
g_data.outlines_active_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
|
||||
stl->g_data->outlines_active = shgroup_outline(psl->outlines, ts.colorActive, sh);
|
||||
stl->g_data->outlines_active_group = shgroup_outline(psl->outlines, ts.colorGroupActive, sh);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -536,53 +543,53 @@ static void OBJECT_cache_init(void *vedata)
|
|||
|
||||
/* Empties */
|
||||
geom = DRW_cache_plain_axes_get();
|
||||
g_data.plain_axes = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->plain_axes = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_cube_get();
|
||||
g_data.cube = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->cube = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_circle_get();
|
||||
g_data.circle = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->circle = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_empty_sphere_get();
|
||||
g_data.sphere = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->sphere = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_empty_cone_get();
|
||||
g_data.cone = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->cone = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_arrow_get();
|
||||
g_data.single_arrow = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->single_arrow = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
g_data.single_arrow_line = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->single_arrow_line = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_arrows_get();
|
||||
g_data.arrows = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->arrows = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_axis_names_get();
|
||||
g_data.axis_names = shgroup_instance_axis_names(psl->non_meshes, geom);
|
||||
stl->g_data->axis_names = shgroup_instance_axis_names(psl->non_meshes, geom);
|
||||
|
||||
/* Speaker */
|
||||
geom = DRW_cache_speaker_get();
|
||||
g_data.speaker = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->speaker = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Camera */
|
||||
geom = DRW_cache_camera_get();
|
||||
g_data.camera = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_camera_tria_get();
|
||||
g_data.camera_tria = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera_tria = shgroup_camera_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_plain_axes_get();
|
||||
g_data.camera_focus = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera_focus = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
g_data.camera_clip = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
g_data.camera_mist = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera_clip = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera_mist = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_endpoints_get();
|
||||
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);
|
||||
stl->g_data->camera_clip_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->camera_mist_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Lamps */
|
||||
/* TODO
|
||||
|
@ -591,48 +598,48 @@ static void OBJECT_cache_init(void *vedata)
|
|||
|
||||
/* start with buflimit because we don't want stipples */
|
||||
geom = DRW_cache_single_line_get();
|
||||
g_data.lamp_buflimit = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_buflimit = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
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);
|
||||
stl->g_data->lamp_center = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorLampNoAlpha, &ts.sizeLampCenter);
|
||||
stl->g_data->lamp_center_group = shgroup_dynpoints_uniform_color(psl->non_meshes, ts.colorGroup, &ts.sizeLampCenter);
|
||||
|
||||
geom = DRW_cache_lamp_get();
|
||||
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);
|
||||
stl->g_data->lamp_circle = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
stl->g_data->lamp_circle_shadow = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircleShadow);
|
||||
|
||||
geom = DRW_cache_lamp_sunrays_get();
|
||||
g_data.lamp_sunrays = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
stl->g_data->lamp_sunrays = shgroup_instance_screenspace(psl->non_meshes, geom, &ts.sizeLampCircle);
|
||||
|
||||
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);
|
||||
stl->g_data->lamp_groundline = shgroup_groundlines_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
stl->g_data->lamp_groundpoint = shgroup_groundpoints_uniform_color(psl->non_meshes, ts.colorLamp);
|
||||
|
||||
geom = DRW_cache_lamp_area_get();
|
||||
g_data.lamp_area = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_area = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_hemi_get();
|
||||
g_data.lamp_hemi = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_hemi = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_get();
|
||||
g_data.lamp_distance = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_distance = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_single_line_endpoints_get();
|
||||
g_data.lamp_buflimit_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_buflimit_points = shgroup_distance_lines_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_spot_get();
|
||||
g_data.lamp_spot_cone = shgroup_spot_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_spot_cone = shgroup_spot_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_circle_get();
|
||||
g_data.lamp_spot_blend = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_spot_blend = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_lamp_spot_square_get();
|
||||
g_data.lamp_spot_pyramid = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_spot_pyramid = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
geom = DRW_cache_square_get();
|
||||
g_data.lamp_spot_blend_rect = shgroup_instance(psl->non_meshes, geom);
|
||||
stl->g_data->lamp_spot_blend_rect = shgroup_instance(psl->non_meshes, geom);
|
||||
|
||||
/* Relationship Lines */
|
||||
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);
|
||||
stl->g_data->relationship_lines = shgroup_dynlines_uniform_color(psl->non_meshes, ts.colorWire);
|
||||
DRW_shgroup_state_set(stl->g_data->relationship_lines, DRW_STATE_STIPPLE_3);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -654,21 +661,21 @@ static void OBJECT_cache_init(void *vedata)
|
|||
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);
|
||||
g_data.center_active = grp;
|
||||
stl->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);
|
||||
g_data.center_selected = grp;
|
||||
stl->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);
|
||||
g_data.center_deselected = grp;
|
||||
stl->g_data->center_deselected = grp;
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_shgroup_lamp(Object *ob, SceneLayer *sl)
|
||||
static void DRW_shgroup_lamp(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
|
||||
{
|
||||
Lamp *la = ob->data;
|
||||
float *color;
|
||||
|
@ -677,29 +684,29 @@ static void DRW_shgroup_lamp(Object *ob, SceneLayer *sl)
|
|||
|
||||
/* Don't draw the center if it's selected or active */
|
||||
if (theme_id == TH_GROUP)
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_center_group, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_center_group, ob->obmat[3]);
|
||||
else if (theme_id == TH_LAMP)
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_center, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_center, ob->obmat[3]);
|
||||
|
||||
/* First circle */
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_circle, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_circle_shadow, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_distance, color, &zero, &la->dist, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_sunrays, ob->obmat[3], color);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_sunrays, ob->obmat[3], color);
|
||||
}
|
||||
else if (la->type == LA_SPOT) {
|
||||
float size[3], sizemat[4][4];
|
||||
|
@ -719,33 +726,33 @@ static void DRW_shgroup_lamp(Object *ob, SceneLayer *sl)
|
|||
mul_m4_m4m4(la->spotblendmat, la->spotconemat, sizemat);
|
||||
|
||||
if (la->mode & LA_SQUARE) {
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_pyramid, color, &one, la->spotconemat);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_spot_blend_rect, color, &one, la->spotblendmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_spot_blend_rect, color, &one, la->spotblendmat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_spot_cone, color, la->spotconemat);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_spot_blend, color, &one, la->spotblendmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_spot_blend, color, &one, la->spotblendmat);
|
||||
}
|
||||
}
|
||||
|
||||
normalize_m4(la->shapemat);
|
||||
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);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_buflimit, color, &la->clipsta, &la->clipend, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->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(g_data.lamp_hemi, color, &hemisize, la->shapemat);
|
||||
DRW_shgroup_dynamic_call_add(stl->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];
|
||||
|
@ -756,15 +763,15 @@ static void DRW_shgroup_lamp(Object *ob, SceneLayer *sl)
|
|||
mul_m4_m4m4(la->shapemat, la->shapemat, sizemat);
|
||||
}
|
||||
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_area, color, &la->area_size, la->shapemat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_area, color, &la->area_size, la->shapemat);
|
||||
}
|
||||
|
||||
/* Line and point going to the ground */
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_groundline, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(g_data.lamp_groundpoint, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_groundline, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->lamp_groundpoint, ob->obmat[3]);
|
||||
}
|
||||
|
||||
static void DRW_shgroup_camera(Object *ob, SceneLayer *sl)
|
||||
static void DRW_shgroup_camera(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
|
||||
{
|
||||
const struct bContext *C = DRW_get_context();
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
@ -799,11 +806,11 @@ static void DRW_shgroup_camera(Object *ob, SceneLayer *sl)
|
|||
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(g_data.camera, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
|
||||
/* Active cam */
|
||||
if (is_active) {
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_tria, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_tria, color, cam->drwcorners, &cam->drwdepth, cam->drwtria, ob->obmat);
|
||||
}
|
||||
|
||||
/* draw the rest in normalize object space */
|
||||
|
@ -820,10 +827,10 @@ static void DRW_shgroup_camera(Object *ob, SceneLayer *sl)
|
|||
size_to_mat4(sizemat, size);
|
||||
mul_m4_m4m4(cam->drwfocusmat, cam->drwfocusmat, sizemat);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(g_data.camera_focus, (is_active ? col_hi : col), &cam->drawsize, cam->drwfocusmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_focus, (is_active ? col_hi : col), &cam->drawsize, cam->drwfocusmat);
|
||||
|
||||
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);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_clip, color, &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_clip_points, (is_active ? col_hi : col), &cam->clipsta, &cam->clipend, cam->drwnormalmat);
|
||||
}
|
||||
|
||||
if (cam->flag & CAM_SHOWMIST) {
|
||||
|
@ -832,73 +839,74 @@ static void DRW_shgroup_camera(Object *ob, SceneLayer *sl)
|
|||
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(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);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_mist, color, &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->camera_mist_points, (is_active ? col_hi : col), &world->miststa, &world->mistend, cam->drwnormalmat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_shgroup_empty(Object *ob, SceneLayer *sl)
|
||||
static void DRW_shgroup_empty(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
|
||||
{
|
||||
float *color;
|
||||
DRW_object_wire_theme_get(ob, sl, &color);
|
||||
|
||||
switch (ob->empty_drawtype) {
|
||||
case OB_PLAINAXES:
|
||||
DRW_shgroup_dynamic_call_add(g_data.plain_axes, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->plain_axes, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_SINGLE_ARROW:
|
||||
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);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->single_arrow, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->single_arrow_line, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_CUBE:
|
||||
DRW_shgroup_dynamic_call_add(g_data.cube, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->cube, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_CIRCLE:
|
||||
DRW_shgroup_dynamic_call_add(g_data.circle, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->circle, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_EMPTY_SPHERE:
|
||||
DRW_shgroup_dynamic_call_add(g_data.sphere, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->sphere, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_EMPTY_CONE:
|
||||
DRW_shgroup_dynamic_call_add(g_data.cone, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->cone, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
case OB_ARROWS:
|
||||
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);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->arrows, color, &ob->empty_drawsize, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->axis_names, color, &ob->empty_drawsize, ob->obmat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_shgroup_speaker(Object *ob, SceneLayer *sl)
|
||||
static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
|
||||
{
|
||||
float *color;
|
||||
static float one = 1.0f;
|
||||
DRW_object_wire_theme_get(ob, sl, &color);
|
||||
|
||||
DRW_shgroup_dynamic_call_add(g_data.speaker, color, &one, ob->obmat);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->speaker, color, &one, ob->obmat);
|
||||
}
|
||||
|
||||
static void DRW_shgroup_relationship_lines(Object *ob)
|
||||
static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
|
||||
{
|
||||
if (ob->parent) {
|
||||
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]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->relationship_lines, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_shgroup_object_center(Object *ob)
|
||||
static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob)
|
||||
{
|
||||
if ((ob->base_flag & BASE_SELECTED) != 0) {
|
||||
DRW_shgroup_dynamic_call_add(g_data.center_selected, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->center_selected, ob->obmat[3]);
|
||||
}
|
||||
else if (0) {
|
||||
DRW_shgroup_dynamic_call_add(g_data.center_deselected, ob->obmat[3]);
|
||||
DRW_shgroup_dynamic_call_add(stl->g_data->center_deselected, ob->obmat[3]);
|
||||
}
|
||||
}
|
||||
|
||||
static void OBJECT_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
|
||||
const struct bContext *C = DRW_get_context();
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SceneLayer *sl = CTX_data_scene_layer(C);
|
||||
|
@ -918,16 +926,16 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
switch (theme_id) {
|
||||
case TH_ACTIVE:
|
||||
DRW_shgroup_call_add(g_data.outlines_active, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->outlines_active, geom, ob->obmat);
|
||||
break;
|
||||
case TH_SELECT:
|
||||
DRW_shgroup_call_add(g_data.outlines_select, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->outlines_select, geom, ob->obmat);
|
||||
break;
|
||||
case TH_GROUP_ACTIVE:
|
||||
DRW_shgroup_call_add(g_data.outlines_select_group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->outlines_select_group, geom, ob->obmat);
|
||||
break;
|
||||
case TH_TRANSFORM:
|
||||
DRW_shgroup_call_add(g_data.outlines_transform, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->outlines_transform, geom, ob->obmat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -935,16 +943,16 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
|||
}
|
||||
break;
|
||||
case OB_LAMP:
|
||||
DRW_shgroup_lamp(ob, sl);
|
||||
DRW_shgroup_lamp(stl, ob, sl);
|
||||
break;
|
||||
case OB_CAMERA:
|
||||
DRW_shgroup_camera(ob, sl);
|
||||
DRW_shgroup_camera(stl, ob, sl);
|
||||
break;
|
||||
case OB_EMPTY:
|
||||
DRW_shgroup_empty(ob, sl);
|
||||
DRW_shgroup_empty(stl, ob, sl);
|
||||
break;
|
||||
case OB_SPEAKER:
|
||||
DRW_shgroup_speaker(ob, sl);
|
||||
DRW_shgroup_speaker(stl, ob, sl);
|
||||
break;
|
||||
case OB_ARMATURE:
|
||||
{
|
||||
|
@ -952,7 +960,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
|||
if (arm->edbo == NULL) {
|
||||
DRW_shgroup_armature_object(ob, sl, ((OBJECT_Data *)vedata)->psl->bone_solid,
|
||||
((OBJECT_Data *)vedata)->psl->bone_wire,
|
||||
g_data.relationship_lines);
|
||||
stl->g_data->relationship_lines);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -960,8 +968,8 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
|||
break;
|
||||
}
|
||||
|
||||
DRW_shgroup_object_center(ob);
|
||||
DRW_shgroup_relationship_lines(ob);
|
||||
DRW_shgroup_object_center(stl, ob);
|
||||
DRW_shgroup_relationship_lines(stl, ob);
|
||||
}
|
||||
|
||||
static void OBJECT_draw_scene(void *vedata)
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct PAINT_TEXTURE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} PAINT_TEXTURE_StorageList;
|
||||
|
||||
typedef struct PAINT_TEXTURE_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_TEXTURE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void PAINT_TEXTURE_engine_init(void *vedata)
|
||||
{
|
||||
PAINT_TEXTURE_Data *ved = DRW_viewport_engine_data_get("PaintTextureMode");
|
||||
PAINT_TEXTURE_TextureList *txl = ved->txl;
|
||||
PAINT_TEXTURE_TextureList *txl = ((PAINT_TEXTURE_Data *)vedata)->txl;
|
||||
PAINT_TEXTURE_FramebufferList *fbl = ((PAINT_TEXTURE_Data *)vedata)->fbl;
|
||||
PAINT_TEXTURE_StorageList *stl = ved->stl;
|
||||
PAINT_TEXTURE_StorageList *stl = ((PAINT_TEXTURE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void PAINT_TEXTURE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_TEXTURE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
PAINT_TEXTURE_PassList *psl = ((PAINT_TEXTURE_Data *)vedata)->psl;
|
||||
PAINT_TEXTURE_StorageList *stl = ((PAINT_TEXTURE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct PAINT_VERTEX_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} PAINT_VERTEX_StorageList;
|
||||
|
||||
typedef struct PAINT_VERTEX_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_VERTEX_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void PAINT_VERTEX_engine_init(void *vedata)
|
||||
{
|
||||
PAINT_VERTEX_Data *ved = DRW_viewport_engine_data_get("PaintVertexMode");
|
||||
PAINT_VERTEX_TextureList *txl = ved->txl;
|
||||
PAINT_VERTEX_TextureList *txl = ((PAINT_VERTEX_Data *)vedata)->txl;
|
||||
PAINT_VERTEX_FramebufferList *fbl = ((PAINT_VERTEX_Data *)vedata)->fbl;
|
||||
PAINT_VERTEX_StorageList *stl = ved->stl;
|
||||
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void PAINT_VERTEX_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_VERTEX_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
|
||||
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void PAINT_VERTEX_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,7 +185,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct PAINT_WEIGHT_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} PAINT_WEIGHT_StorageList;
|
||||
|
||||
typedef struct PAINT_WEIGHT_Data {
|
||||
|
@ -99,16 +100,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PAINT_WEIGHT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data;
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -117,10 +113,9 @@ static struct {
|
|||
* (Optional) */
|
||||
static void PAINT_WEIGHT_engine_init(void *vedata)
|
||||
{
|
||||
PAINT_WEIGHT_Data *ved = DRW_viewport_engine_data_get("PaintWeightMode");
|
||||
PAINT_WEIGHT_TextureList *txl = ved->txl;
|
||||
PAINT_WEIGHT_TextureList *txl = ((PAINT_WEIGHT_Data *)vedata)->txl;
|
||||
PAINT_WEIGHT_FramebufferList *fbl = ((PAINT_WEIGHT_Data *)vedata)->fbl;
|
||||
PAINT_WEIGHT_StorageList *stl = ved->stl;
|
||||
PAINT_WEIGHT_StorageList *stl = ((PAINT_WEIGHT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(txl, fbl, stl);
|
||||
|
||||
|
@ -148,11 +143,13 @@ static void PAINT_WEIGHT_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PAINT_WEIGHT_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
PAINT_WEIGHT_PassList *psl = ((PAINT_WEIGHT_Data *)vedata)->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = ((PAINT_WEIGHT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -161,16 +158,16 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -178,17 +175,14 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
|
|||
/* Add geometry to shadingGroups. Execute for each objects */
|
||||
static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
PAINT_WEIGHT_PassList *psl = ((PAINT_WEIGHT_Data *)vedata)->psl;
|
||||
PAINT_WEIGHT_StorageList *stl = ((PAINT_WEIGHT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(psl, stl);
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
/* Get geometry cache */
|
||||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef struct PARTICLE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} PARTICLE_StorageList;
|
||||
|
||||
typedef struct PARTICLE_Data {
|
||||
|
@ -93,16 +94,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in PARTICLE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -111,7 +107,6 @@ static struct {
|
|||
* (Optional) */
|
||||
static void PARTICLE_engine_init(void *vedata)
|
||||
{
|
||||
|
||||
PARTICLE_TextureList *txl = ((PARTICLE_Data *)vedata)->txl;
|
||||
PARTICLE_FramebufferList *fbl = ((PARTICLE_Data *)vedata)->fbl;
|
||||
PARTICLE_StorageList *stl = ((PARTICLE_Data *)vedata)->stl;
|
||||
|
@ -142,11 +137,13 @@ static void PARTICLE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void PARTICLE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
PARTICLE_PassList *psl = ((PARTICLE_Data *)vedata)->psl;
|
||||
PARTICLE_StorageList *stl = ((PARTICLE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -155,16 +152,16 @@ static void PARTICLE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -182,7 +179,7 @@ static void PARTICLE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef struct POSE_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} POSE_StorageList;
|
||||
|
||||
typedef struct POSE_Data {
|
||||
|
@ -93,16 +94,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in POSE_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -111,7 +107,6 @@ static struct {
|
|||
* (Optional) */
|
||||
static void POSE_engine_init(void *vedata)
|
||||
{
|
||||
|
||||
POSE_TextureList *txl = ((POSE_Data *)vedata)->txl;
|
||||
POSE_FramebufferList *fbl = ((POSE_Data *)vedata)->fbl;
|
||||
POSE_StorageList *stl = ((POSE_Data *)vedata)->stl;
|
||||
|
@ -142,11 +137,13 @@ static void POSE_engine_init(void *vedata)
|
|||
* Assume that all Passes are NULL */
|
||||
static void POSE_cache_init(void *vedata)
|
||||
{
|
||||
|
||||
POSE_PassList *psl = ((POSE_Data *)vedata)->psl;
|
||||
POSE_StorageList *stl = ((POSE_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -155,16 +152,16 @@ static void POSE_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -182,7 +179,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef struct SCULPT_StorageList {
|
|||
* free with MEM_freeN() when viewport is freed.
|
||||
* (not per object) */
|
||||
struct CustomStruct *block;
|
||||
struct g_data *g_data;
|
||||
} SCULPT_StorageList;
|
||||
|
||||
typedef struct SCULPT_Data {
|
||||
|
@ -93,16 +94,11 @@ static struct {
|
|||
struct GPUShader *custom_shader;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
typedef struct g_data {
|
||||
/* This keeps the references of the shading groups for
|
||||
* easy access in SCULPT_cache_populate() */
|
||||
DRWShadingGroup *group;
|
||||
|
||||
/* 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 */
|
||||
} g_data; /* Transient data */
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
|
@ -144,7 +140,10 @@ static void SCULPT_cache_init(void *vedata)
|
|||
SCULPT_PassList *psl = ((SCULPT_Data *)vedata)->psl;
|
||||
SCULPT_StorageList *stl = ((SCULPT_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create a pass */
|
||||
|
@ -153,16 +152,16 @@ static void SCULPT_cache_init(void *vedata)
|
|||
|
||||
/* Create a shadingGroup using a function in draw_common.c or custom one */
|
||||
/*
|
||||
* g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
|
||||
* -- or --
|
||||
* g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
* stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
*/
|
||||
g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
|
||||
|
||||
/* 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(g_data.group, "color", color, 1);
|
||||
DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
|
|||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
/* Add geom to a shading group */
|
||||
DRW_shgroup_call_add(g_data.group, geom, ob->obmat);
|
||||
DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct GPUViewport GPUViewport;
|
|||
#define MAX_BUFFERS 8
|
||||
#define MAX_TEXTURES 16
|
||||
#define MAX_PASSES 16
|
||||
#define MAX_STORAGE 4 /* extend if needed */
|
||||
#define MAX_STORAGE 5 /* extend if needed */
|
||||
|
||||
/* All FramebufferLists are just the same pointers with different names */
|
||||
typedef struct FramebufferList {
|
||||
|
|
Loading…
Reference in New Issue