[Bf-blender-cvs] [af20ca5] blender2.8: Viewport: Bring camera, speaker, rigid body shape and bounding box
Dalai Felinto
noreply at git.blender.org
Fri Oct 21 22:51:33 CEST 2016
Commit: af20ca51a1d6d132d69d913ff8376e6333c00787
Author: Dalai Felinto
Date: Fri Oct 21 17:26:42 2016 +0000
Branches: blender2.8
https://developer.blender.org/rBaf20ca51a1d6d132d69d913ff8376e6333c00787
Viewport: Bring camera, speaker, rigid body shape and bounding box
===================================================================
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
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index c32ca31..4adfea1 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -211,8 +211,6 @@ typedef struct drawBMSelect_userData {
bool select;
} drawBMSelect_userData;
-static void draw_bounding_volume(Object *ob, char type);
-
static void drawcube_size(float size, unsigned pos);
static void drawcircle_size(float size, unsigned pos);
static void draw_empty_sphere(float size, unsigned pos);
@@ -2113,8 +2111,8 @@ static void drawcamera_stereo3d(
}
/* flag similar to draw_object() */
-static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
- const short dflag, const unsigned char ob_wire_col[4])
+void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dflag, const unsigned char ob_wire_col[4])
{
/* a standing up pyramid with (0,0,0) as top */
Camera *cam;
@@ -2287,7 +2285,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
}
/* flag similar to draw_object() */
-static void drawspeaker(const unsigned char ob_wire_col[3])
+void drawspeaker(const unsigned char ob_wire_col[3])
{
VertexFormat *format = immVertexFormat();
unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
@@ -6158,7 +6156,7 @@ static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin)
gluDeleteQuadric(qobj);
}
-static void draw_bounding_volume(Object *ob, char type)
+void draw_bounding_volume(Object *ob, char type)
{
BoundBox bb_local;
BoundBox *bb = NULL;
@@ -6406,7 +6404,7 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
setlinestyle(0);
}
-static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4])
+void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4])
{
Object *ob = base->object;
int colindex = 0;
@@ -6500,7 +6498,7 @@ static void draw_object_matcap_check(View3D *v3d, Object *ob)
v3d->flag2 |= V3D_SHOW_SOLID_MATCAP;
}
-static void draw_rigidbody_shape(Object *ob)
+void draw_rigidbody_shape(Object *ob)
{
BoundBox *bb = NULL;
float size[3], vec[8][3];
@@ -6712,7 +6710,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* TODO Viewport: draw only depth here, for selection */
if (!IS_VIEWPORT_LEGACY(v3d)) {
- if (ELEM(ob->type, OB_EMPTY, OB_LAMP)) {
+ if ((dt == OB_BOUNDBOX) || ELEM(ob->type, OB_EMPTY, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index bc0bc52..4a2a043 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1304,8 +1304,8 @@ static void view3d_draw_grid(const bContext *C, ARegion *ar)
/* ******************** non-meshes ***************** */
static void view3d_draw_non_mesh(
-Object *ob, Base *base, View3D *v3d,
-RegionView3D *rv3d, const unsigned char color[4])
+Scene *scene, Object *ob, Base *base, View3D *v3d,
+RegionView3D *rv3d, const bool is_boundingbox, const unsigned char color[4])
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -1317,17 +1317,42 @@ RegionView3D *rv3d, const unsigned char color[4])
ED_view3d_init_mats_rv3d_gl(ob, rv3d);
switch (ob->type) {
+ case OB_MESH:
+ case OB_FONT:
+ case OB_CURVE:
+ case OB_SURF:
+ case OB_MBALL:
+ if (is_boundingbox) {
+ draw_bounding_volume(ob, ob->boundtype);
+ }
+ break;
case OB_EMPTY:
drawaxes(rv3d->viewmatob, ob->empty_drawsize, ob->empty_drawtype, color);
break;
case OB_LAMP:
- drawlamp(v3d, rv3d, base, OB_SOLID, DRAW_CONSTCOLOR, color, false);
+ drawlamp(v3d, rv3d, base, OB_SOLID, DRAW_CONSTCOLOR, color, ob == OBACT);
+ break;
+ case OB_CAMERA:
+ drawcamera(scene, v3d, rv3d, base, DRAW_CONSTCOLOR, color);
+ break;
+ case OB_SPEAKER:
+ drawspeaker(color);
+ break;
+ case OB_LATTICE:
+ /* TODO */
+ break;
+ case OB_ARMATURE:
+ /* TODO */
break;
default:
/* TODO Viewport: handle the other cases*/
break;
}
+ if (ob->rigidbody_object) {
+ draw_rigidbody_shape(ob);
+ }
+
ED_view3d_clear_mats_rv3d(rv3d);
glMatrixMode(GL_PROJECTION);
@@ -1480,12 +1505,10 @@ static void view3d_draw_non_meshes(const bContext *C, ARegion *ar)
Object *ob_act = CTX_data_active_object(C);
Base *base;
- unsigned char *color, *color_prev = NULL;
- unsigned char color_active[4], color_select[4], color_normal[4];
+ bool is_boundingbox = ((v3d->drawtype == OB_BOUNDBOX) ||
+ ((v3d->drawtype == OB_RENDER) && (v3d->prev_drawtype == OB_BOUNDBOX)));
- UI_GetThemeColor4ubv(TH_ACTIVE, color_active);
- UI_GetThemeColor4ubv(TH_SELECT, color_select);
- UI_GetThemeColor4ubv(TH_WIRE, color_normal);
+ unsigned char ob_wire_col[4]; /* dont initialize this */
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE); /* disable write in zbuffer */
@@ -1498,19 +1521,8 @@ static void view3d_draw_non_meshes(const bContext *C, ARegion *ar)
if (v3d->lay & base->lay) {
Object *ob = base->object;
- if (ob == ob_act)
- color = color_active;
- else if (ob->flag & SELECT)
- color = color_select;
- else
- color = color_normal;
-
- if (color != color_prev) {
- glColor4ubv(color);
- color_prev = color;
- }
-
- view3d_draw_non_mesh(ob, base, v3d, rv3d, color);
+ draw_object_wire_color(scene, base, ob_wire_col);
+ view3d_draw_non_mesh(scene, ob, base, v3d, rv3d, is_boundingbox, ob_wire_col);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 777e4e0..fd85527 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -148,10 +148,17 @@ void draw_mesh_object_outline(View3D *v3d, Object *ob, struct DerivedMesh *dm);
bool draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const char dt);
void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline);
void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
+
+void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4]);
void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]);
void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4],
const bool is_obact);
+void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dflag, const unsigned char ob_wire_col[4]);
+void drawspeaker(const unsigned char ob_wire_col[3]);
+void draw_bounding_volume(struct Object *ob, char type);
+void draw_rigidbody_shape(struct Object *ob);
void view3d_cached_text_draw_begin(void);
void view3d_cached_text_draw_add(const float co[3],
More information about the Bf-blender-cvs
mailing list