Cleanup: explicit names for return arguments and position last

This commit is contained in:
Campbell Barton
2017-04-15 14:07:57 +10:00
parent 49fc9cff3b
commit 608b711beb
7 changed files with 45 additions and 40 deletions

View File

@@ -244,7 +244,7 @@ DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]);
void DRW_shgroup_dynamic_call_add_array(DRWShadingGroup *shgroup, const void **attr, unsigned int attr_len);
void DRW_shgroup_dynamic_call_add_array(DRWShadingGroup *shgroup, const void *attr[], unsigned int attr_len);
#define DRW_shgroup_dynamic_call_add(shgroup, ...) do { \
const void *array[] = {__VA_ARGS__}; \
DRW_shgroup_dynamic_call_add_array(shgroup, array, (sizeof(array) / sizeof(*array))); \

View File

@@ -1464,15 +1464,17 @@ Batch *DRW_cache_single_vert_get(void)
}
/* Meshes */
void DRW_cache_mesh_wire_overlay_get(Object *ob, Batch **tris, Batch **ledges, Batch **lverts)
void DRW_cache_mesh_wire_overlay_get(
Object *ob,
Batch **r_tris, Batch **r_ledges, Batch **r_lverts)
{
BLI_assert(ob->type == OB_MESH);
Mesh *me = ob->data;
*tris = BKE_mesh_batch_cache_get_overlay_triangles(me);
*ledges = BKE_mesh_batch_cache_get_overlay_loose_edges(me);
*lverts = BKE_mesh_batch_cache_get_overlay_loose_verts(me);
*r_tris = BKE_mesh_batch_cache_get_overlay_triangles(me);
*r_ledges = BKE_mesh_batch_cache_get_overlay_loose_edges(me);
*r_lverts = BKE_mesh_batch_cache_get_overlay_loose_verts(me);
}
Batch *DRW_cache_face_centers_get(Object *ob)

View File

@@ -80,7 +80,8 @@ struct Batch *DRW_cache_bone_arrows_get(void);
/* Meshes */
void DRW_cache_mesh_wire_overlay_get(
struct Object *ob, struct Batch **tris, struct Batch **ledges, struct Batch **lverts);
struct Object *ob,
struct Batch **r_tris, struct Batch **r_ledges, struct Batch **r_lverts);
struct Batch *DRW_cache_face_centers_get(struct Object *ob);
struct Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
struct Batch *DRW_cache_mesh_surface_get(struct Object *ob);

View File

@@ -296,9 +296,11 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Batch *geom)
/* ******************************************** COLOR UTILS *********************************************** */
/* TODO FINISH */
/* Get the wire color theme_id of an object based on it's state
* **color is a way to get a pointer to the static color var associated */
int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
/**
* Get the wire color theme_id of an object based on it's state
* \a r_color is a way to get a pointer to the static color var associated
*/
int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **r_color)
{
const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
const bool active = (sl->basact && sl->basact->object == ob);
@@ -338,24 +340,24 @@ int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
}
}
if (color != NULL) {
if (r_color != NULL) {
switch (theme_id) {
case TH_WIRE_EDIT: *color = ts.colorTransform; break;
case TH_ACTIVE: *color = ts.colorActive; break;
case TH_SELECT: *color = ts.colorSelect; break;
case TH_GROUP: *color = ts.colorGroup; break;
case TH_GROUP_ACTIVE: *color = ts.colorGroupActive; break;
case TH_TRANSFORM: *color = ts.colorTransform; break;
case OB_SPEAKER: *color = ts.colorSpeaker; break;
case OB_CAMERA: *color = ts.colorCamera; break;
case OB_EMPTY: *color = ts.colorEmpty; break;
case OB_LAMP: *color = ts.colorLamp; break;
default: *color = ts.colorWire; break;
case TH_WIRE_EDIT: *r_color = ts.colorTransform; break;
case TH_ACTIVE: *r_color = ts.colorActive; break;
case TH_SELECT: *r_color = ts.colorSelect; break;
case TH_GROUP: *r_color = ts.colorGroup; break;
case TH_GROUP_ACTIVE: *r_color = ts.colorGroupActive; break;
case TH_TRANSFORM: *r_color = ts.colorTransform; break;
case OB_SPEAKER: *r_color = ts.colorSpeaker; break;
case OB_CAMERA: *r_color = ts.colorCamera; break;
case OB_EMPTY: *r_color = ts.colorEmpty; break;
case OB_LAMP: *r_color = ts.colorLamp; break;
default: *r_color = ts.colorWire; break;
}
/* uses darker active color for non-active + selected */
if ((theme_id == TH_GROUP_ACTIVE) && !active) {
*color = ts.colorGroupSelect;
*r_color = ts.colorGroupSelect;
}
}

View File

@@ -102,7 +102,7 @@ struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Bat
struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Batch *geom);
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Batch *geom);
int DRW_object_wire_theme_get(struct Object *ob, struct SceneLayer *sl, float **color);
int DRW_object_wire_theme_get(struct Object *ob, struct SceneLayer *sl, float **r_color);
float *DRW_color_background_blend_get(int theme_id);
/* draw_armature.c */

View File

@@ -580,7 +580,7 @@ void DRW_shgroup_dynamic_call_add_array(DRWShadingGroup *shgroup, const void *at
BLI_assert(attr_len == interface->attribs_count);
memcpy((void *) call->data, attr, data_size);
memcpy((void *)call->data, attr, data_size);
interface->instance_count += 1;

View File

@@ -227,9 +227,9 @@ static void EDIT_MESH_engine_init(void *vedata)
}
static DRWPass *edit_mesh_create_overlay_pass(
DRWShadingGroup **face_shgrp, DRWShadingGroup **ledges_shgrp,
DRWShadingGroup **lverts_shgrp, DRWShadingGroup **facedot_shgrp,
float *faceAlpha, DRWState statemod)
float *faceAlpha, DRWState statemod,
DRWShadingGroup **r_face_shgrp, DRWShadingGroup **r_ledges_shgrp,
DRWShadingGroup **r_lverts_shgrp, DRWShadingGroup **r_facedot_shgrp)
{
static struct GPUShader *tri_sh, *ledge_sh;
const struct bContext *C = DRW_get_context();
@@ -258,21 +258,21 @@ static DRWPass *edit_mesh_create_overlay_pass(
"Edit Mesh Face Overlay Pass",
DRW_STATE_WRITE_COLOR | DRW_STATE_POINT | statemod);
*face_shgrp = DRW_shgroup_create(tri_sh, pass);
DRW_shgroup_uniform_block(*face_shgrp, "globalsBlock", globals_ubo, 0);
DRW_shgroup_uniform_vec2(*face_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_float(*face_shgrp, "faceAlphaMod", faceAlpha, 1);
*r_face_shgrp = DRW_shgroup_create(tri_sh, pass);
DRW_shgroup_uniform_block(*r_face_shgrp, "globalsBlock", globals_ubo, 0);
DRW_shgroup_uniform_vec2(*r_face_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_float(*r_face_shgrp, "faceAlphaMod", faceAlpha, 1);
*ledges_shgrp = DRW_shgroup_create(ledge_sh, pass);
DRW_shgroup_uniform_vec2(*ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
*r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass);
DRW_shgroup_uniform_vec2(*r_ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
if ((tsettings->selectmode & (SCE_SELECT_VERTEX)) != 0) {
*lverts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass);
DRW_shgroup_uniform_vec2(*lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
*r_lverts_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, pass);
DRW_shgroup_uniform_vec2(*r_lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
}
if ((tsettings->selectmode & (SCE_SELECT_FACE)) != 0) {
*facedot_shgrp = DRW_shgroup_create(e_data.overlay_facedot_sh, pass);
*r_facedot_shgrp = DRW_shgroup_create(e_data.overlay_facedot_sh, pass);
}
return pass;
@@ -330,16 +330,16 @@ static void EDIT_MESH_cache_init(void *vedata)
if (!do_zbufclip) {
psl->edit_face_overlay = edit_mesh_create_overlay_pass(
&face_mod, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND,
&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);
&stl->g_data->lverts_overlay_shgrp, &stl->g_data->facedot_overlay_shgrp);
}
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(
&zero, DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH,
&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);
&stl->g_data->lverts_occluded_shgrp, &stl->g_data->facedot_occluded_shgrp);
/* 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. */