Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-02-24 06:45:13 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-02-25 19:55:49 +0300
commitd6df23d9d96bfefb6a0a0f3979d3440d0fef05cc (patch)
treefdd62cd27688e2124fde8100a8024c754eb3cd19 /source/blender/draw/modes/object_mode.c
parentb795f5eb7a913f2fb86667098c36e8f654a9ef6a (diff)
Object Mode: Display meshes without faces and edges in object mode.
Diffstat (limited to 'source/blender/draw/modes/object_mode.c')
-rw-r--r--source/blender/draw/modes/object_mode.c86
1 files changed, 76 insertions, 10 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index d6c0369b0a5..ad943767da4 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -214,6 +214,14 @@ typedef struct OBJECT_PrivateData {
DRWShadingGroup *wire_select;
DRWShadingGroup *wire_select_group;
DRWShadingGroup *wire_transform;
+
+ /* Points */
+ DRWShadingGroup *points;
+ DRWShadingGroup *points_active;
+ DRWShadingGroup *points_active_group;
+ DRWShadingGroup *points_select;
+ DRWShadingGroup *points_select_group;
+ DRWShadingGroup *points_transform;
} OBJECT_PrivateData; /* Transient data */
static struct {
@@ -571,6 +579,15 @@ static DRWShadingGroup *shgroup_wire(DRWPass *pass, const float col[4], GPUShade
return grp;
}
+/* currently same as 'shgroup_outline', new function to avoid confustion */
+static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUShader *sh)
+{
+ DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
+ DRW_shgroup_uniform_vec4(grp, "color", col, 1);
+
+ return grp;
+}
+
static DRWShadingGroup *shgroup_theme_id_to_outline_or(
OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback)
{
@@ -605,6 +622,23 @@ static DRWShadingGroup *shgroup_theme_id_to_wire_or(
}
}
+static DRWShadingGroup *shgroup_theme_id_to_point_or(
+ OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback)
+{
+ switch (theme_id) {
+ case TH_ACTIVE:
+ return stl->g_data->points_active;
+ case TH_SELECT:
+ return stl->g_data->points_select;
+ case TH_GROUP_ACTIVE:
+ return stl->g_data->points_select_group;
+ case TH_TRANSFORM:
+ return stl->g_data->points_transform;
+ default:
+ return fallback;
+ }
+}
+
static void image_calc_aspect(Image *ima, ImageUser *iuser, float r_image_aspect[2])
{
float ima_x, ima_y;
@@ -981,6 +1015,25 @@ static void OBJECT_cache_init(void *vedata)
stl->g_data->wire_active_group = shgroup_wire(psl->non_meshes, ts.colorGroupActive, sh);
}
+
+ {
+ GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
+
+ /* Unselected */
+ stl->g_data->points = shgroup_points(psl->non_meshes, ts.colorWire, sh);
+
+ /* Select */
+ stl->g_data->points_select = shgroup_points(psl->non_meshes, ts.colorSelect, sh);
+ stl->g_data->points_select_group = shgroup_points(psl->non_meshes, ts.colorGroupActive, sh);
+
+ /* Transform */
+ stl->g_data->points_transform = shgroup_points(psl->non_meshes, ts.colorTransform, sh);
+
+ /* Active */
+ stl->g_data->points_active = shgroup_points(psl->non_meshes, ts.colorActive, sh);
+ stl->g_data->points_active_group = shgroup_points(psl->non_meshes, ts.colorGroupActive, sh);
+ }
+
{
/* Metaballs Handles */
struct Gwn_Batch *geom;
@@ -1845,17 +1898,30 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
switch (ob->type) {
case OB_MESH:
{
- Mesh *me = ob->data;
- if (me->totpoly == 0) {
- if (ob != draw_ctx->object_edit) {
- struct Gwn_Batch *geom = DRW_cache_mesh_edges_get(ob);
- if (geom) {
- if (theme_id == TH_UNDEFINED) {
- theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
+ if (ob != draw_ctx->object_edit) {
+ Mesh *me = ob->data;
+ if (me->totpoly == 0) {
+ if (me->totedge == 0) {
+ struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob);
+ if (geom) {
+ if (theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
+ }
+
+ DRWShadingGroup *shgroup = shgroup_theme_id_to_point_or(stl, theme_id, stl->g_data->points);
+ DRW_shgroup_call_add(shgroup, geom, ob->obmat);
+ }
+ }
+ else {
+ struct Gwn_Batch *geom = DRW_cache_mesh_edges_get(ob);
+ if (geom) {
+ if (theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
+ }
+
+ DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire);
+ DRW_shgroup_call_add(shgroup, geom, ob->obmat);
}
-
- DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(stl, theme_id, stl->g_data->wire);
- DRW_shgroup_call_add(shgroup, geom, ob->obmat);
}
}
}