Metalball drawing: rename mball helpers to handles

and also rename some related functions
This commit is contained in:
Germano Cavalcante 2018-02-16 02:01:09 -02:00
parent 3ba6ff6750
commit fa0e89b9e8
11 changed files with 30 additions and 30 deletions

View File

@ -77,9 +77,9 @@ void BKE_mball_eval_geometry(const struct EvaluationContext *eval_ctx,
struct MetaBall *mball);
/* Draw Cache */
void BKE_mball_element_calc_display_m3x4(float r_scale_xform[3][4],
const float obmat[4][4],
const float local_pos[3]);
void BKE_mball_element_calc_scale_xform(float r_scale_xform[3][4],
const float obmat[4][4],
const float local_pos[3]);
enum {
BKE_MBALL_BATCH_DIRTY_ALL = 0,

View File

@ -549,9 +549,9 @@ void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
/* Draw Engine */
/* use for draw-manager only. */
void BKE_mball_element_calc_display_m3x4(float r_scale_xform[3][4],
const float obmat[4][4],
const float local_pos[3])
void BKE_mball_element_calc_scale_xform(float r_scale_xform[3][4],
const float obmat[4][4],
const float local_pos[3])
{
float world_pos[3], scamat[3][3];
mul_v3_m4v3(world_pos, obmat, local_pos);

View File

@ -168,7 +168,7 @@ static struct {
struct Gwn_VertFormat *instance_spot;
struct Gwn_VertFormat *instance_bone_envelope_wire;
struct Gwn_VertFormat *instance_bone_envelope_solid;
struct Gwn_VertFormat *instance_mball_helpers;
struct Gwn_VertFormat *instance_mball_handles;
} g_formats = {NULL};
void DRW_globals_free(void)
@ -421,17 +421,17 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Gwn_
return grp;
}
DRWShadingGroup *shgroup_instance_mball_helpers(DRWPass *pass, struct Gwn_Batch *geom)
DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass, struct Gwn_Batch *geom)
{
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_MBALL_HELPERS);
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_MBALL_HANDLES);
DRW_shgroup_instance_format(g_formats.instance_mball_helpers, {
DRW_shgroup_instance_format(g_formats.instance_mball_handles, {
{"ScaleTranslationMatrix" , DRW_ATTRIB_FLOAT, 16},
{"radius" , DRW_ATTRIB_FLOAT, 1},
{"color" , DRW_ATTRIB_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_mball_helpers);
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_mball_handles);
DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
return grp;

View File

@ -119,7 +119,7 @@ struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, st
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance_bone_envelope_wire(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance_mball_helpers(struct DRWPass *pass, struct Gwn_Batch *geom);
struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass, struct Gwn_Batch *geom);
int DRW_object_wire_theme_get(
struct Object *ob, struct ViewLayer *view_layer, float **r_color);

View File

@ -119,11 +119,11 @@ static void EDIT_METABALL_cache_init(void *vedata)
psl->pass = DRW_pass_create("My Pass", state);
/* Create a shadingGroup using a function in draw_common.c or custom one */
stl->g_data->group = shgroup_instance_mball_helpers(psl->pass, DRW_cache_screenspace_circle_get());
stl->g_data->group = shgroup_instance_mball_handles(psl->pass, DRW_cache_screenspace_circle_get());
}
}
static void EDIT_METABALL_cache_populate_radius_visualization(
static void EDIT_METABALL_cache_populate_radius(
DRWShadingGroup *group, MetaElem *ml, const float scale_xform[3][4],
const float *radius, const int selection_id)
{
@ -142,7 +142,7 @@ static void EDIT_METABALL_cache_populate_radius_visualization(
DRW_shgroup_call_dynamic_add(group, scale_xform, radius, color);
}
static void EDIT_METABALL_cache_populate_stiffness_visualization(
static void EDIT_METABALL_cache_populate_stiffness(
DRWShadingGroup *group, MetaElem *ml, const float scale_xform[3][4],
const float *radius, const int selection_id)
{
@ -179,13 +179,13 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
int selection_id = 0;
for (MetaElem *ml = mb->editelems->first; ml != NULL; ml = ml->next) {
BKE_mball_element_calc_display_m3x4(ml->draw_scale_xform, ob->obmat, &ml->x);
BKE_mball_element_calc_scale_xform(ml->draw_scale_xform, ob->obmat, &ml->x);
ml->draw_stiffness_radius = ml->rad * atanf(ml->s) / (float)M_PI_2;
EDIT_METABALL_cache_populate_radius_visualization(
EDIT_METABALL_cache_populate_radius(
group, ml, ml->draw_scale_xform, &ml->rad, is_select ? ++selection_id : -1);
EDIT_METABALL_cache_populate_stiffness_visualization(
EDIT_METABALL_cache_populate_stiffness(
group, ml, ml->draw_scale_xform, &ml->draw_stiffness_radius, is_select ? ++selection_id : -1);
}
}

View File

@ -156,7 +156,7 @@ typedef struct OBJECT_PrivateData {
DRWShadingGroup *probe_grid;
/* MetaBalls */
DRWShadingGroup *mball_circle;
DRWShadingGroup *mball_handle;
/* Lamps */
DRWShadingGroup *lamp_center;
@ -980,10 +980,10 @@ static void OBJECT_cache_init(void *vedata)
}
{
/* Metaballs Helpers */
/* Metaballs Handles */
struct Gwn_Batch *geom;
geom = DRW_cache_screenspace_circle_get();
stl->g_data->mball_circle = shgroup_instance_mball_helpers(psl->non_meshes, geom);
stl->g_data->mball_handle = shgroup_instance_mball_handles(psl->non_meshes, geom);
}
{
@ -1115,7 +1115,7 @@ static void OBJECT_cache_init(void *vedata)
}
}
static void DRW_shgroup_mball_helpers(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer)
static void DRW_shgroup_mball_handles(OBJECT_StorageList *stl, Object *ob, ViewLayer *view_layer)
{
MetaBall *mb = ob->data;
@ -1124,8 +1124,8 @@ static void DRW_shgroup_mball_helpers(OBJECT_StorageList *stl, Object *ob, ViewL
for (MetaElem *ml = mb->elems.first; ml != NULL; ml = ml->next) {
/* draw radius */
BKE_mball_element_calc_display_m3x4(ml->draw_scale_xform, ob->obmat, &ml->x);
DRW_shgroup_call_dynamic_add(stl->g_data->mball_circle, ml->draw_scale_xform, &ml->rad, color);
BKE_mball_element_calc_scale_xform(ml->draw_scale_xform, ob->obmat, &ml->x);
DRW_shgroup_call_dynamic_add(stl->g_data->mball_handle, ml->draw_scale_xform, &ml->rad, color);
}
}
@ -1884,7 +1884,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
case OB_MBALL:
{
if (ob != draw_ctx->object_edit) {
DRW_shgroup_mball_helpers(stl, ob, view_layer);
DRW_shgroup_mball_handles(stl, ob, view_layer);
}
break;
}

View File

@ -174,7 +174,7 @@ data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_solid_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_wire_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_mball_helpers_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_mball_handles_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC)

View File

@ -174,7 +174,7 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID,
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE,
GPU_SHADER_3D_INSTANCE_MBALL_HELPERS,
GPU_SHADER_3D_INSTANCE_MBALL_HANDLES,
GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */
} GPUBuiltinShader;

View File

@ -98,7 +98,7 @@ extern char datatoc_gpu_shader_instance_edges_variying_color_geom_glsl[];
extern char datatoc_gpu_shader_instance_edges_variying_color_vert_glsl[];
extern char datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl[];
extern char datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl[];
extern char datatoc_gpu_shader_instance_mball_helpers_vert_glsl[];
extern char datatoc_gpu_shader_instance_mball_handles_vert_glsl[];
extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[];
extern char datatoc_gpu_shader_3D_groundline_geom_glsl[];
@ -823,7 +823,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
[GPU_SHADER_3D_INSTANCE_MBALL_HELPERS] = { datatoc_gpu_shader_instance_mball_helpers_vert_glsl,
[GPU_SHADER_3D_INSTANCE_MBALL_HANDLES] = { datatoc_gpu_shader_instance_mball_handles_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
};

View File

@ -62,7 +62,7 @@ typedef struct MetaElem {
/* Draw_Data: stores pointers used for shader attributes */
float draw_scale_xform[3][4]; /* Matrix of Scale and Translation */
float draw_stiffness_radius; /* stiffness circle radius (only in edit mode) */
float draw_stiffness_radius; /* radius of the stiffness circle (only in edit mode) */
float pad;
} MetaElem;