[Bf-blender-cvs] [20ae92b] gooseberry: Experimental color wire-frame (for testing in the studio)
Campbell Barton
noreply at git.blender.org
Thu Oct 30 16:27:06 CET 2014
Commit: 20ae92b352bbfa73314640a268033914ac2dd3b7
Author: Campbell Barton
Date: Thu Oct 30 16:26:39 2014 +0100
Branches: gooseberry
https://developer.blender.org/rB20ae92b352bbfa73314640a268033914ac2dd3b7
Experimental color wire-frame (for testing in the studio)
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/editors/space_view3d/view3d_intern.h
M source/blender/makesdna/DNA_object_types.h
M source/blender/makesdna/DNA_view3d_types.h
M source/blender/makesrna/intern/rna_object.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 25367a5..095db89 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -253,10 +253,12 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
col.prop(obj, "draw_type", text="")
col = split.column()
- if is_geometry or is_empty_image:
+ if 1:
# Only useful with object having faces/materials...
col.label(text="Object Color:")
- col.prop(obj, "color", text="")
+ row = col.row(align=True)
+ row.prop(obj, "color", text="")
+ row.prop(obj, "show_wire_color", text="", toggle=True, icon='WIRE')
class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 0ea552e..db902bd 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2766,7 +2766,8 @@ class VIEW3D_PT_view3d_cursor(Panel):
layout = self.layout
view = context.space_data
- layout.column().prop(view, "cursor_location", text="Location")
+ col = layout.column()
+ col.prop(view, "cursor_location", text="Location")
class VIEW3D_PT_view3d_name(Panel):
@@ -2781,6 +2782,7 @@ class VIEW3D_PT_view3d_name(Panel):
def draw(self, context):
layout = self.layout
+ view = context.space_data
ob = context.active_object
row = layout.row()
row.label(text="", icon='OBJECT_DATA')
@@ -2793,6 +2795,10 @@ class VIEW3D_PT_view3d_name(Panel):
row.label(text="", icon='BONE_DATA')
row.prop(bone, "name", text="")
+ row = layout.row(align=True)
+ row.prop(ob, "color", text="")
+ row.prop(ob, "show_wire_color", text="", toggle=True, icon='WIRE')
+
class VIEW3D_PT_view3d_display(Panel):
bl_space_type = 'VIEW_3D'
@@ -2879,6 +2885,9 @@ class VIEW3D_PT_view3d_shading(Panel):
if not scene.render.use_shading_nodes:
col.prop(gs, "material_mode", text="")
+ if view.viewport_shade in {'BOUNDBOX', 'WIREFRAME', 'SOLID'}:
+ col.prop(view, "use_wire_color")
+
if view.viewport_shade == 'SOLID':
col.prop(view, "show_textured_solid")
col.prop(view, "use_matcap")
@@ -3277,3 +3286,4 @@ def unregister():
if __name__ == "__main__":
register()
+
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 37115bc..3ddbc9a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7093,6 +7093,52 @@ static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_
r_ob_wire_col[3] = 255;
}
+static float draw_object_wire_grey = -1.0f;
+void draw_object_bg_wire_color_set(const float color[3])
+{
+ float hsv[3];
+ rgb_to_hsv_v(color, hsv);
+ draw_object_wire_grey = hsv[2];
+}
+
+static void draw_object_wire_color_adjust_contrast(
+ unsigned char ob_wire_col[3],
+ /* 0 == normal, 1 == select, 2 == obact */
+ const int select_state,
+ const short draw_type)
+{
+ const float tint[3] = {0.0, 0.65f, 1.0f};
+ const float fac[3] = {0.666f, 0.75f, 1.0f};
+ const float contrast = 0.075f;
+
+ float hsv[3];
+
+ BLI_assert(draw_object_wire_grey != -1.0);
+
+ rgb_uchar_to_float(hsv, ob_wire_col);
+ rgb_to_hsv_v(hsv, hsv);
+
+ hsv[2] = interpf(tint[select_state], hsv[2], fac[select_state]);
+
+ /* when no solid --- ensure contrast */
+ if (draw_type <= OB_WIRE) {
+ const float fill_bw = draw_object_wire_grey;
+
+ if (fabsf(fill_bw - hsv[2]) < contrast) {
+ if (fill_bw < hsv[2]) {
+ hsv[2] = fill_bw + contrast;
+ }
+ else {
+ hsv[2] = fill_bw - contrast;
+ }
+ }
+
+ }
+
+ hsv_to_rgb_v(hsv, hsv);
+ rgb_float_to_uchar(ob_wire_col, hsv);
+}
+
static void draw_object_matcap_check(View3D *v3d, Object *ob)
{
/* fixed rule, active object draws as matcap */
@@ -7178,6 +7224,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
const bool is_picking = (G.f & G_PICKSEL) != 0;
const bool has_particles = (ob->particlesystem.first != NULL);
+ const bool is_wire_color = V3D_IS_WIRECOLOR_OBJECT(scene, v3d, ob);
bool particle_skip_object = false; /* Draw particles but not their emitter object. */
if (ob != scene->obedit) {
@@ -7256,21 +7303,32 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
draw_motion_paths_cleanup(v3d);
}
- /* multiply view with object matrix.
- * local viewmat and persmat, to calculate projections */
- ED_view3d_init_mats_rv3d_gl(ob, rv3d);
-
/* which wire color */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
ED_view3d_project_base(ar, base);
- draw_object_wire_color(scene, base, _ob_wire_col);
+ if (is_wire_color) {
+ rgb_float_to_uchar(_ob_wire_col, ob->col);
+ _ob_wire_col[3] = 255;
+
+ draw_object_wire_color_adjust_contrast(
+ _ob_wire_col,
+ (ob->flag & SELECT) ? (is_obact ? 2 : 1) : 0,
+ v3d->drawtype);
+ }
+ else {
+ draw_object_wire_color(scene, base, _ob_wire_col);
+ }
ob_wire_col = _ob_wire_col;
glColor3ubv(ob_wire_col);
}
+ /* multiply view with object matrix.
+ * local viewmat and persmat, to calculate projections */
+ ED_view3d_init_mats_rv3d_gl(ob, rv3d);
+
/* maximum drawtype */
dt = v3d->drawtype;
if (dt == OB_RENDER) dt = OB_SOLID;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 2da5f8d..6637a89 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2130,17 +2130,27 @@ static void draw_dupli_objects_color(
glDeleteLists(displist, 1);
}
-static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base)
+static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const bool is_wire_color)
{
/* define the color here so draw_dupli_objects_color can be called
* from the set loop */
-
- int color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE;
- /* debug */
- if (base->object->dup_group && base->object->dup_group->id.us < 1)
- color = TH_REDALERT;
-
- draw_dupli_objects_color(scene, ar, v3d, base, 0, color);
+ short dflag;
+ int color;
+
+ if (is_wire_color) {
+ glColor3fv(base->object->col);
+ color = TH_UNDEFINED;
+ dflag = DRAW_CONSTCOLOR;
+ }
+ else {
+ color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE;
+ /* debug */
+ if (base->object->dup_group && base->object->dup_group->id.us < 1)
+ color = TH_REDALERT;
+ dflag = 0;
+ }
+
+ draw_dupli_objects_color(scene, ar, v3d, base, dflag, color);
}
/* XXX warning, not using gpu offscreen here */
@@ -2614,6 +2624,7 @@ static void view3d_draw_objects(
RegionView3D *rv3d = ar->regiondata;
Base *base;
const bool do_camera_frame = !draw_offscreen;
+ const bool is_wire_color = V3D_IS_WIRECOLOR(scene, v3d);
if (!draw_offscreen) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -2702,7 +2713,7 @@ static void view3d_draw_objects(
if (v3d->lay & base->lay) {
/* dupli drawing */
if (base->object->transflag & OB_DUPLI)
- draw_dupli_objects(scene, ar, v3d, base);
+ draw_dupli_objects(scene, ar, v3d, base, is_wire_color && (base->object->dtx & OB_DRAW_WIRECOLOR));
draw_object(scene, ar, v3d, base, 0);
}
@@ -2719,7 +2730,7 @@ static void view3d_draw_objects(
/* dupli drawing */
if (base->object->transflag & OB_DUPLI) {
- draw_dupli_objects(scene, ar, v3d, base);
+ draw_dupli_objects(scene, ar, v3d, base, is_wire_color && (base->object->dtx & OB_DRAW_WIRECOLOR));
}
if ((base->flag & SELECT) == 0) {
if (base->object != scene->obedit)
@@ -2731,6 +2742,10 @@ static void view3d_draw_objects(
/* mask out localview */
v3d->lay_used = lay_used & ((1 << 20) - 1);
+ if (is_wire_color && (v3d->drawtype <= OB_WIRE)) {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ }
+
/* draw selected and editmode */
for (base = scene->base.first; base; base = base->next) {
if (v3d->lay & base->lay) {
@@ -3210,6 +3225,8 @@ static void view3d_main_area_draw_engine_info(View3D *v3d, RegionView3D *rv3d, A
*/
static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
{
+ const bool is_wire_color = V3D_IS_WIRECOLOR(scene, v3d);
+
/* clear background */
if (scene->world && (v3d->flag2 & V3D_RENDER_OVERRIDE)) { /* clear with solid color */
if (scene->world->skytype & WO_SKYBLEND) { /* blend sky */
@@ -3328,6 +3345,12 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
#undef VIEWGRAD_RES_X
#undef VIEWGRAD_RES_Y
+
+ if (is_wire_color) {
+ float col_mid[3];
+ mid_v3_v3v3(col_mid, col_hor, col_zen);
+ draw_object_bg_wire_color_set(col_mid);
+ }
}
else { /* solid sky */
float col_hor[3];
@@ -3336,10 +3359,19 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
glClearColor(col_hor[0], col_hor[1], col_hor[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (is_wire_color) {
+ draw_object_bg_wire_color_set(col_hor);
+ }
}
}
else {
if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+ float col_low[3], col_high[3];
+
+ UI_GetThemeColor3fv(TH_HIGH_GRAD, col_high);
+ UI_GetThemeColor3fv(TH_LOW_GRAD, col_low);
+
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
@@ -3351,10 +3383,10 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
glDepthFunc(GL_ALWAYS);
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
- UI_ThemeColor(TH_LOW_GRAD);
+ glColor3fv(col_low);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
- UI_ThemeColor(TH_HIGH_GRAD);
+ glColor3fv(col_high);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glE
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list