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:
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c107
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c6
-rw-r--r--source/blender/editors/space_view3d/drawobject.c417
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c198
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h41
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c21
8 files changed, 435 insertions, 359 deletions
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 0de7e2569c0..e51f7a312eb 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -557,7 +557,7 @@ static void draw_bone_solid_octahedral(void)
/* *************** Armature drawing, bones ******************* */
-static void draw_bone_points(int dt, int armflag, unsigned int boneflag, int id)
+static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, int id)
{
/* Draw root point if we are not connected */
if ((boneflag & BONE_CONNECTED) == 0) {
@@ -862,7 +862,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4],
}
/* does wire only for outline selecting */
-static void draw_sphere_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+static void draw_sphere_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
GLUquadricObj *qobj;
@@ -1100,7 +1100,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
glPopMatrix();
}
-static void draw_b_bone_boxes(int dt, bPoseChannel *pchan, float xwidth, float length, float zwidth)
+static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, float xwidth, float length, float zwidth)
{
int segments = 0;
@@ -1128,7 +1128,7 @@ static void draw_b_bone_boxes(int dt, bPoseChannel *pchan, float xwidth, float l
}
}
-static void draw_b_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+static void draw_b_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
float xwidth, length, zwidth;
@@ -1242,7 +1242,7 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len
}
}
-static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id,
+static void draw_wire_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
Mat4 *bbones = NULL;
@@ -1293,7 +1293,7 @@ static void draw_wire_bone(int dt, int armflag, int boneflag, short constflag, u
draw_wire_bone_segments(pchan, bbones, length, segments);
}
-static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsigned int id, float length)
+static void draw_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id, float length)
{
/* Draw a 3d octahedral bone, we use normalized space based on length,
@@ -1364,7 +1364,7 @@ static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsign
}
static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob,
- int dt, int armflag, int boneflag, unsigned int id, float length)
+ const short dt, int armflag, int boneflag, unsigned int id, float length)
{
if (ob == NULL) return;
@@ -1656,8 +1656,9 @@ static void bone_matrix_translate_y(float mat[][4], float y)
}
/* assumes object is Armature with pose */
-static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt,
- const short is_ghost, const short is_outline)
+static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const unsigned char ob_wire_col[4],
+ const short do_const_color, const short is_outline)
{
RegionView3D *rv3d = ar->regiondata;
Object *ob = base->object;
@@ -1752,8 +1753,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
if (bone == arm->act_bone)
flag |= BONE_DRAW_ACTIVE;
- /* set color-set to use */
- set_pchan_colorset(ob, pchan);
+ if (do_const_color) {
+ /* keep color */
+ }
+ else {
+ /* set color-set to use */
+ set_pchan_colorset(ob, pchan);
+ }
if (use_custom) {
/* if drawwire, don't try to draw in solid */
@@ -1827,20 +1833,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
}
/* prepare colors */
- if (is_ghost) {
+ if (do_const_color) {
/* 13 October 2009, Disabled this to make ghosting show the right colors (Aligorith) */
}
- else if (arm->flag & ARM_POSEMODE)
+ else if (arm->flag & ARM_POSEMODE)
set_pchan_colorset(ob, pchan);
else {
- if ((scene->basact) == base) {
- if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_ACTIVE);
- else UI_ThemeColor(TH_WIRE);
- }
- else {
- if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_SELECT);
- else UI_ThemeColor(TH_WIRE);
- }
+ glColor3ubv(ob_wire_col);
}
/* catch exception for bone with hidden parent */
@@ -1956,7 +1955,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
/* extra draw service for pose mode */
/* set color-set to use */
- set_pchan_colorset(ob, pchan);
+ if (do_const_color) {
+ /* keep color */
+ }
+ else {
+ set_pchan_colorset(ob, pchan);
+ }
if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
/* custom bone shapes should not be drawn here! */
@@ -1991,20 +1995,35 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
glDisable(GL_CULL_FACE);
/* draw DoFs */
- if (arm->flag & ARM_POSEMODE)
- draw_pose_dofs(ob);
+ if (arm->flag & ARM_POSEMODE) {
+ if (((base->flag & OB_FROMDUPLI) == 0)) {
+ draw_pose_dofs(ob);
+ }
+ }
/* finally names and axes */
- if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) && (is_outline == 0)) {
+ if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) &&
+ (is_outline == 0) &&
+ ((base->flag & OB_FROMDUPLI) == 0))
+ {
/* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
if ((G.f & G_PICKSEL) == 0) {
float vec[3];
-
+
unsigned char col[4];
- float col_f[4];
- glGetFloatv(GL_CURRENT_COLOR, col_f); /* in case this is not set below */
- rgb_float_to_uchar(col, col_f);
- col[3] = 255;
+ if (do_const_color) {
+ /* so we can draw bone names in current const color */
+ float tcol[4];
+ glGetFloatv(GL_CURRENT_COLOR, tcol);
+ rgb_float_to_uchar(col, tcol);
+ col[3] = 255;
+ }
+ else {
+ col[0] = ob_wire_col[0];
+ col[1] = ob_wire_col[1];
+ col[2] = ob_wire_col[2];
+ col[3] = 255;
+ }
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
@@ -2063,7 +2082,7 @@ static void get_matrix_editbone(EditBone *eBone, float bmat[][4])
add_v3_v3(bmat[3], eBone->head);
}
-static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
+static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
{
RegionView3D *rv3d = ar->regiondata;
EditBone *eBone;
@@ -2353,7 +2372,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2432,7 +2451,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base *
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2502,7 +2521,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
}
@@ -2517,7 +2536,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
}
}
@@ -2537,8 +2556,11 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
/* ********************************** Armature Drawing - Main ************************* */
-/* called from drawobject.c, return 1 if nothing was drawn */
-int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline)
+/* called from drawobject.c, return 1 if nothing was drawn
+ * (ob_wire_col == NULL) when drawing ghost */
+int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const short dflag, const unsigned char ob_wire_col[4],
+ const short is_outline)
{
Object *ob = base->object;
bArmature *arm = ob->data;
@@ -2549,11 +2571,8 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in
if (dt > OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) {
/* we use color for solid lighting */
- glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
- glEnable(GL_COLOR_MATERIAL);
- glColor3ub(255, 255, 255); // clear spec
- glDisable(GL_COLOR_MATERIAL);
-
+ const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); // only for lighting...
}
@@ -2594,7 +2613,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in
if (arm->ghostep)
draw_ghost_poses(scene, v3d, ar, base);
}
- if ((flag & DRAW_SCENESET) == 0) {
+ if ((dflag & DRAW_SCENESET) == 0) {
if (ob == OBACT)
arm->flag |= ARM_POSEMODE;
else if (OBACT && (OBACT->mode & OB_MODE_WEIGHT_PAINT)) {
@@ -2605,7 +2624,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in
}
}
}
- draw_pose_bones(scene, v3d, ar, base, dt, FALSE, is_outline);
+ draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline);
arm->flag &= ~ARM_POSEMODE;
if (ob->mode & OB_MODE_POSE)
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index de1d9f22667..19696b2b0e0 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -1015,14 +1015,14 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *d
if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
if (do_light) {
+ const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
+
/* enforce default material settings */
GPU_enable_material(0, NULL);
/* but set default spec */
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
- glEnable(GL_COLOR_MATERIAL); /* according manpages needed */
- glColor3ub(120, 120, 120);
- glDisable(GL_COLOR_MATERIAL);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
/* diffuse */
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 498189321be..7e84ab062ca 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -333,7 +333,7 @@ static void view3d_project_short_clip_persmat(ARegion *ar, const float vec[3], s
/* check for glsl drawing */
-int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
+int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const short dt)
{
if (!GPU_glsl_support())
return 0;
@@ -1189,14 +1189,17 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z)
glCullFace(GL_BACK);
}
-static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
+static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
Lamp *la = ob->data;
float vec[3], lvec[3], vvec[3], circrad, x, y, z;
float lampsize;
- float imat[4][4], curcol[4];
+ float imat[4][4];
+
+ unsigned char curcol[4];
unsigned char col[4];
/* cone can't be drawn for duplicated lamps, because duplilist would be freed to */
/* the moment of view3d_draw_transp() call */
@@ -1210,7 +1213,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
if (drawcone && !v3d->transp) {
/* in this case we need to draw delayed */
- add_view3d_after(&v3d->afterdraw_transp, base, flag);
+ ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
return;
}
@@ -1228,17 +1231,23 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* lamp center */
copy_v3_v3(vec, ob->obmat[3]);
-
- /* for AA effects */
- glGetFloatv(GL_CURRENT_COLOR, curcol);
- curcol[3] = 0.6;
- glColor4fv(curcol);
-
+
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ /* for AA effects */
+ curcol[0] = ob_wire_col[0];
+ curcol[1] = ob_wire_col[1];
+ curcol[2] = ob_wire_col[2];
+ curcol[3] = 154;
+ glColor4ubv(curcol);
+ }
+
if (lampsize > 0.0f) {
- if (ob->id.us > 1) {
- if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155);
- else glColor4ub(0x77, 0xCC, 0xCC, 155);
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ if (ob->id.us > 1) {
+ if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155);
+ else glColor4ub(0x77, 0xCC, 0xCC, 155);
+ }
}
/* Inner Circle */
@@ -1248,8 +1257,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
drawcircball(GL_POLYGON, vec, lampsize, imat);
/* restore */
- if (ob->id.us > 1)
- glColor4fv(curcol);
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ if (ob->id.us > 1)
+ glColor4ubv(curcol);
+ }
/* Outer circle */
circrad = 3.0f * lampsize;
@@ -1481,9 +1492,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
glDisable(GL_BLEND);
- /* restore for drawing extra stuff */
- glColor3fv(curcol);
-
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ /* restore for drawing extra stuff */
+ glColor3ubv(ob_wire_col);
+ }
}
static void draw_limit_line(float sta, float end, unsigned int col)
@@ -1516,7 +1528,7 @@ static void draw_focus_cross(float dist, float size)
}
#ifdef VIEW3D_CAMERA_BORDER_HACK
-float view3d_camera_border_hack_col[4];
+unsigned char view3d_camera_border_hack_col[3];
short view3d_camera_border_hack_test = FALSE;
#endif
@@ -1546,8 +1558,8 @@ static void draw_bundle_sphere(void)
}
static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d,
- MovieClip *clip, MovieTrackingObject *tracking_object, int flag,
- int *global_track_index, int draw_selected)
+ MovieClip *clip, MovieTrackingObject *tracking_object,
+ const short dflag, int *global_track_index, int draw_selected)
{
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
@@ -1590,7 +1602,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
if ((track->flag & TRACK_HAS_BUNDLE) == 0)
continue;
- if (flag & DRAW_PICKING)
+ if (dflag & DRAW_PICKING)
glLoadName(base->selcol + (tracknr << 16));
glPushMatrix();
@@ -1656,7 +1668,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
glPopMatrix();
- if ((flag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) {
+ if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) {
float pos[3];
unsigned char tcol[4];
@@ -1670,7 +1682,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
tracknr++;
}
- if ((flag & DRAW_PICKING) == 0) {
+ if ((dflag & DRAW_PICKING) == 0) {
if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA)) {
MovieTrackingReconstruction *reconstruction;
reconstruction = BKE_tracking_object_reconstruction(tracking, tracking_object);
@@ -1701,11 +1713,11 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
}
static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip,
- int flag, int draw_selected)
+ const short dflag, const unsigned char ob_wire_col[4],
+ int draw_selected)
{
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object;
- float curcol[4];
int global_track_index = 1;
if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0)
@@ -1714,8 +1726,6 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
if (v3d->flag2 & V3D_RENDER_OVERRIDE)
return;
- glGetFloatv(GL_CURRENT_COLOR, curcol);
-
glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
@@ -1724,7 +1734,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
tracking_object = tracking->objects.first;
while (tracking_object) {
draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object,
- flag, &global_track_index, draw_selected);
+ dflag, &global_track_index, draw_selected);
tracking_object = tracking_object->next;
}
@@ -1734,14 +1744,17 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d,
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
- glColor4fv(curcol);
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ glColor3ubv(ob_wire_col);
+ }
- if (flag & DRAW_PICKING)
+ if (dflag & DRAW_PICKING)
glLoadName(base->selcol);
}
/* flag similar to draw_object() */
-static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int flag)
+static 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;
@@ -1755,13 +1768,22 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
/* draw data for movie clip set as active for scene */
if (clip) {
- draw_viewport_reconstruction(scene, base, v3d, clip, flag, FALSE);
- draw_viewport_reconstruction(scene, base, v3d, clip, flag, TRUE);
+ draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, FALSE);
+ draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, TRUE);
}
#ifdef VIEW3D_CAMERA_BORDER_HACK
if (is_view && !(G.f & G_PICKSEL)) {
- glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col);
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ view3d_camera_border_hack_col[0] = ob_wire_col[0];
+ view3d_camera_border_hack_col[1] = ob_wire_col[1];
+ view3d_camera_border_hack_col[2] = ob_wire_col[2];
+ }
+ else {
+ float col[4];
+ glGetFloatv(GL_CURRENT_COLOR, col);
+ rgb_float_to_uchar(view3d_camera_border_hack_col, col);
+ }
view3d_camera_border_hack_test = TRUE;
return;
}
@@ -1829,7 +1851,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
glEnd();
}
- if (flag == 0) {
+ if (dflag == 0) {
if (cam->flag & (CAM_SHOWLIMITS + CAM_SHOWMIST)) {
float nobmat[4][4];
World *wrld;
@@ -2451,7 +2473,7 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3],
}
static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, int sel, BMVert *eve_act,
- RegionView3D *rv3d)
+ RegionView3D *rv3d)
{
drawDMVerts_userData data;
data.sel = sel;
@@ -3140,7 +3162,7 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
}
static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
+ Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const short dt)
{
Mesh *me = ob->data;
@@ -3361,7 +3383,8 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
}
}
-static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
+static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dt, const short dflag)
{
Object *ob = base->object;
Mesh *me = ob->data;
@@ -3447,10 +3470,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
else if (dt == OB_SOLID) {
if (draw_flags & DRAW_MODIFIERS_PREVIEW) {
/* for object selection draws no shade */
- if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
+ if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
}
else {
+ const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
+
/* draw outline */
if ( (v3d->flag & V3D_SELECT_OUTLINE) &&
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
@@ -3468,9 +3493,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* set default spec */
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
- glEnable(GL_COLOR_MATERIAL); /* according manpages needed */
- glColor3ub(120, 120, 120);
- glDisable(GL_COLOR_MATERIAL);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
/* diffuse */
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_LIGHTING);
@@ -3549,7 +3572,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
UI_ThemeColor(TH_GROUP_ACTIVE);
else if (ob->flag & OB_FROMGROUP)
UI_ThemeColorShade(TH_GROUP_ACTIVE, -16);
- else if (flag != DRAW_CONSTCOLOR)
+ else if (dflag != DRAW_CONSTCOLOR)
UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT);
else
glColor3ub(80, 80, 80);
@@ -3558,7 +3581,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if (ob->flag & OB_FROMGROUP)
UI_ThemeColor(TH_GROUP);
else {
- if (ob->dtx & OB_DRAWWIRE && flag == DRAW_CONSTCOLOR)
+ if (ob->dtx & OB_DRAWWIRE && dflag == DRAW_CONSTCOLOR)
glColor3ub(80, 80, 80);
else
UI_ThemeColor(TH_WIRE);
@@ -3615,7 +3638,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
/* returns 1 if nothing was drawn, for detecting to draw an object center */
-static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
+static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dt, const short dflag)
{
Object *ob = base->object;
Object *obedit = scene->obedit;
@@ -3679,7 +3703,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
(check_alpha) ? &do_alpha_after : NULL);
}
- draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, flag);
+ draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, dflag);
GPU_end_object_materials();
@@ -3687,20 +3711,20 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
}
- if ((flag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0) {
+ if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0) {
/* GPU_begin_object_materials checked if this is needed */
if (do_alpha_after) {
if (ob->dtx & OB_DRAWXRAY) {
- add_view3d_after(&v3d->afterdraw_xraytransp, base, flag);
+ ED_view3d_after_add(&v3d->afterdraw_xraytransp, base, dflag);
}
else {
- add_view3d_after(&v3d->afterdraw_transp, base, flag);
+ ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
}
}
else if (ob->dtx & OB_DRAWXRAY && ob->dtx & OB_DRAWTRANSP) {
/* special case xray+transp when alpha is 1.0, without this the object vanishes */
if (v3d->xray == 0 && v3d->transp == 0) {
- add_view3d_after(&v3d->afterdraw_xray, base, flag);
+ ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
}
}
}
@@ -3808,17 +3832,15 @@ static int drawDispListwire(ListBase *dlbase)
return 0;
}
-static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
+static void drawDispListsolid(ListBase *lb, Object *ob,
+ const unsigned char ob_wire_col[4], int use_glsl)
{
DispList *dl;
GPUVertexAttribs gattribs;
- float *data, curcol[4];
+ float *data;
float *ndata;
if (lb == NULL) return;
-
- /* for drawing wire */
- glGetFloatv(GL_CURRENT_COLOR, curcol);
glEnable(GL_LIGHTING);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -3841,7 +3863,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
int nr;
glDisable(GL_LIGHTING);
- glColor3fv(curcol);
+ glColor3ubv(ob_wire_col);
// glVertexPointer(3, GL_FLOAT, 0, dl->verts);
// glDrawArrays(GL_LINE_STRIP, 0, dl->nr);
@@ -3875,7 +3897,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
case DL_SURF:
if (dl->index) {
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH);
else glShadeModel(GL_FLAT);
@@ -3889,7 +3911,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
break;
case DL_INDEX3:
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
@@ -3909,7 +3931,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
break;
case DL_INDEX4:
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
@@ -3935,7 +3957,7 @@ static void drawCurveDMWired(Object *ob)
}
/* return 1 when nothing was drawn */
-static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt)
+static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const short dt)
{
Object *ob = base->object;
DerivedMesh *dm = ob->derivedFinal;
@@ -3967,7 +3989,8 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B
}
/* returns 1 when nothing was drawn */
-static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt)
+static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dt, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
ListBase *lb = NULL;
@@ -4015,12 +4038,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
else {
if (draw_glsl_material(scene, ob, v3d, dt)) {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
- drawDispListsolid(lb, ob, 1);
+ drawDispListsolid(lb, ob, ob_wire_col, TRUE);
GPU_end_object_materials();
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
- drawDispListsolid(lb, ob, 0);
+ drawDispListsolid(lb, ob, ob_wire_col, FALSE);
GPU_end_object_materials();
}
if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
@@ -4052,12 +4075,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
if (draw_glsl_material(scene, ob, v3d, dt)) {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
- drawDispListsolid(lb, ob, 1);
+ drawDispListsolid(lb, ob, ob_wire_col, TRUE);
GPU_end_object_materials();
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
- drawDispListsolid(lb, ob, 0);
+ drawDispListsolid(lb, ob, ob_wire_col, FALSE);
GPU_end_object_materials();
}
}
@@ -4076,12 +4099,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
if (draw_glsl_material(scene, ob, v3d, dt)) {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
- drawDispListsolid(lb, ob, 1);
+ drawDispListsolid(lb, ob, ob_wire_col, TRUE);
GPU_end_object_materials();
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
- drawDispListsolid(lb, ob, 0);
+ drawDispListsolid(lb, ob, ob_wire_col, FALSE);
GPU_end_object_materials();
}
}
@@ -5593,7 +5616,8 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
}
}
-static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, int dt)
+static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
+ const short dt, const unsigned char ob_wire_col[4])
{
ToolSettings *ts = scene->toolsettings;
Object *ob = base->object;
@@ -5602,10 +5626,13 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
BevList *bl;
short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
int index;
+ unsigned char wire_col[3];
/* DispList */
- UI_ThemeColor(TH_WIRE);
- drawDispList(scene, v3d, rv3d, base, dt);
+ UI_GetThemeColor3ubv(TH_WIRE, wire_col);
+ glColor3ubv(wire_col);
+
+ drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col);
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
@@ -5917,7 +5944,8 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[
glEnd();
}
/* return 1 if nothing was drawn */
-static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt)
+static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ const short dt, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
MetaBall *mb;
@@ -5928,13 +5956,19 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
mb = ob->data;
if (mb->editelems) {
- UI_ThemeColor(TH_WIRE);
- if ((G.f & G_PICKSEL) == 0) drawDispList(scene, v3d, rv3d, base, dt);
+ if ((G.f & G_PICKSEL) == 0) {
+ unsigned char wire_col[3];
+ UI_GetThemeColor3ubv(TH_WIRE, wire_col);
+ glColor3ubv(wire_col);
+
+ drawDispList(scene, v3d, rv3d, base, dt, wire_col);
+ }
ml = mb->editelems->first;
}
else {
- if ((base->flag & OB_FROMDUPLI) == 0)
- drawDispList(scene, v3d, rv3d, base, dt);
+ if ((base->flag & OB_FROMDUPLI) == 0) {
+ drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col);
+ }
ml = mb->elems.first;
}
@@ -6306,7 +6340,8 @@ static void drawtexspace(Object *ob)
}
/* draws wire outline */
-static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
+static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ const unsigned char ob_wire_col[4])
{
RegionView3D *rv3d = ar->regiondata;
Object *ob = base->object;
@@ -6345,7 +6380,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
}
else if (ob->type == OB_ARMATURE) {
if (!(ob->mode & OB_MODE_POSE && base == scene->basact))
- draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, TRUE);
+ draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, ob_wire_col, TRUE);
}
glLineWidth(1.0);
@@ -6437,19 +6472,13 @@ static void draw_hooks(Object *ob)
}
}
-static void drawRBpivot(bRigidBodyJointConstraint *data)
+static void drawRBpivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4])
{
const char *axis_str[3] = {"px", "py", "pz"};
int axis;
float mat[4][4];
/* color */
- float curcol[4];
- unsigned char tcol[4];
-
- glGetFloatv(GL_CURRENT_COLOR, curcol);
- rgb_float_to_uchar(tcol, curcol);
- tcol[3] = 255;
eul_to_mat4(mat, &data->axX);
glLineWidth(4.0f);
@@ -6468,14 +6497,89 @@ static void drawRBpivot(bRigidBodyJointConstraint *data)
glVertex3fv(v);
glEnd();
- view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, tcol);
+ view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
}
glLineWidth(1.0f);
setlinestyle(0);
}
+static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4],
+ const int warning_recursive)
+{
+ Object *ob = base->object;
+ int colindex = 0;
+
+ /* confusing logic here, there are 2 methods of setting the color
+ * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
+ *
+ * note: no theme yet for 'colindex' */
+ int theme_id = TH_WIRE;
+ int theme_shade = 0;
+
+ if ((scene->obedit == NULL) &&
+ (G.moving & G_TRANSFORM_OBJ) &&
+ (base->flag & (SELECT + BA_WAS_SEL)))
+ {
+ theme_id = TH_TRANSFORM;
+ }
+ else {
+ /* Sets the 'colindex' */
+ if (ob->id.lib) {
+ colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 4 : 3;
+ }
+ else if (warning_recursive == 1) {
+ if (base->flag & (SELECT + BA_WAS_SEL)) {
+ colindex = (scene->basact == base) ? 8 : 7;
+ }
+ else {
+ colindex = 6;
+ }
+ }
+ /* Sets the 'theme_id' or fallback to wire */
+ else {
+ if (ob->flag & OB_FROMGROUP) {
+ if (base->flag & (SELECT + BA_WAS_SEL)) {
+ /* uses darker active color for non-active + selected*/
+ theme_id = TH_GROUP_ACTIVE;
+
+ if (scene->basact != base) {
+ theme_shade = -16;
+ }
+ }
+ else {
+ theme_id = TH_GROUP;
+ }
+ }
+ else {
+ if (base->flag & (SELECT + BA_WAS_SEL)) {
+ theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT;
+ }
+ else {
+ if (ob->type == OB_LAMP) theme_id = TH_LAMP;
+ else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
+ else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
+ else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
+ /* fallback to TH_WIRE */
+ }
+ }
+ }
+ }
+
+ /* finally set the color */
+ if (colindex == 0) {
+ if (theme_shade == 0) UI_GetThemeColor3ubv(theme_id, r_ob_wire_col);
+ else UI_GetThemeColorShade3ubv(theme_id, theme_shade, r_ob_wire_col);
+ }
+ else {
+ cpack_cpy_3ub(r_ob_wire_col, colortab[colindex]);
+ }
+
+ /* no reason to use this but some functions take col[4] */
+ r_ob_wire_col[3] = 255;
+}
+
/* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET */
-void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
+void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
{
static int warning_recursive = 0;
ModifierData *md = NULL;
@@ -6484,7 +6588,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
RegionView3D *rv3d = ar->regiondata;
float vec1[3], vec2[3];
unsigned int col = 0;
- int /*sel, drawtype,*/ colindex = 0;
+ unsigned char _ob_wire_col[4]; /* dont initialize this */
+ unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
int i, selstart, selend, empty_object = 0;
short dt, dtx, zbufoff = 0;
const short is_obact = (ob == OBACT);
@@ -6508,12 +6613,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
return;
/* xray delay? */
- if ((flag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0) {
+ if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0) {
/* don't do xray in particle mode, need the z-buffer */
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
/* xray and transp are set when it is drawing the 2nd/3rd pass */
if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) {
- add_view3d_after(&v3d->afterdraw_xray, base, flag);
+ ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
return;
}
}
@@ -6522,9 +6627,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* no return after this point, otherwise leaks */
view3d_cached_text_draw_begin();
- /* patch? children objects with a timeoffs change the parents. How to solve! */
- /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */
-
/* draw motion paths (in view space) */
if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
bAnimVizSettings *avs = &ob->avs;
@@ -6544,74 +6646,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
ED_view3d_init_mats_rv3d_gl(ob, rv3d);
/* which wire color */
- if ((flag & DRAW_CONSTCOLOR) == 0) {
- /* confusing logic here, there are 2 methods of setting the color
- * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
- *
- * note: no theme yet for 'colindex' */
- int theme_id = TH_WIRE;
- int theme_shade = 0;
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
project_short(ar, ob->obmat[3], &base->sx);
- if ((scene->obedit == NULL) &&
- (G.moving & G_TRANSFORM_OBJ) &&
- (base->flag & (SELECT + BA_WAS_SEL)))
- {
- theme_id = TH_TRANSFORM;
- }
- else {
- /* Sets the 'colindex' */
- if (ob->id.lib) {
- colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 4 : 3;
- }
- else if (warning_recursive == 1) {
- if (base->flag & (SELECT + BA_WAS_SEL)) {
- colindex = (scene->basact == base) ? 8 : 7;
- }
- else {
- colindex = 6;
- }
- }
- /* Sets the 'theme_id' or fallback to wire */
- else {
- if (ob->flag & OB_FROMGROUP) {
- if (base->flag & (SELECT + BA_WAS_SEL)) {
- /* uses darker active color for non-active + selected*/
- theme_id = TH_GROUP_ACTIVE;
-
- if (scene->basact != base) {
- theme_shade = -16;
- }
- }
- else {
- theme_id = TH_GROUP;
- }
- }
- else {
- if (base->flag & (SELECT + BA_WAS_SEL)) {
- theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT;
- }
- else {
- if (ob->type == OB_LAMP) theme_id = TH_LAMP;
- else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
- else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
- else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
- /* fallback to TH_WIRE */
- }
- }
- }
- }
+ draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive);
+ ob_wire_col = _ob_wire_col;
- /* finally set the color */
- if (colindex == 0) {
- if (theme_shade == 0) UI_ThemeColor(theme_id);
- else UI_ThemeColorShade(theme_id, theme_shade);
- }
- else {
- col = colortab[colindex];
- cpack(col);
- }
+ glColor3ubv(ob_wire_col);
}
/* maximum drawtype */
@@ -6669,18 +6711,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* draw outline for selected objects, mesh does itself */
if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && ob->type != OB_MESH) {
- if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (flag & DRAW_SCENESET) == 0) {
- if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(flag & DRAW_PICKING)) {
+ if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
+ if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & DRAW_PICKING)) {
- drawObjectSelect(scene, v3d, ar, base);
+ drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
}
}
}
switch (ob->type) {
case OB_MESH:
- empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, flag);
- if (flag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
+ empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, dflag);
+ if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
break;
case OB_FONT:
@@ -6691,11 +6733,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if (cu->flag & CU_FAST) {
cpack(0xFFFFFF);
set_inverted_drawing(1);
- drawDispList(scene, v3d, rv3d, base, OB_WIRE);
+ drawDispList(scene, v3d, rv3d, base, OB_WIRE, ob_wire_col);
set_inverted_drawing(0);
}
else {
- drawDispList(scene, v3d, rv3d, base, dt);
+ drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col);
}
if (cu->linewidth != 0.0f) {
@@ -6770,7 +6812,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
- empty_object = drawDispList(scene, v3d, rv3d, base, dt);
+ empty_object = drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col);
}
break;
@@ -6780,7 +6822,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if (cu->editnurb) {
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- drawnurb(scene, v3d, rv3d, base, nurbs->first, dt);
+ drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, ob_wire_col);
}
else if (dt == OB_BOUNDBOX) {
if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) {
@@ -6788,7 +6830,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
- empty_object = drawDispList(scene, v3d, rv3d, base, dt);
+ empty_object = drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col);
//XXX old animsys if (cu->path)
// curve_draw_speed(scene, ob);
@@ -6799,14 +6841,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
MetaBall *mb = ob->data;
if (mb->editelems)
- drawmball(scene, v3d, rv3d, base, dt);
+ drawmball(scene, v3d, rv3d, base, dt, ob_wire_col);
else if (dt == OB_BOUNDBOX) {
if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) {
draw_bounding_volume(scene, ob, ob->boundtype);
}
}
else
- empty_object = drawmball(scene, v3d, rv3d, base, dt);
+ empty_object = drawmball(scene, v3d, rv3d, base, dt, ob_wire_col);
break;
}
case OB_EMPTY:
@@ -6821,7 +6863,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
break;
case OB_LAMP:
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- drawlamp(scene, v3d, rv3d, base, dt, flag);
+ drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat);
}
break;
@@ -6829,12 +6871,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 ||
(rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */
{
- drawcamera(scene, v3d, rv3d, base, flag);
+ drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col);
break;
}
case OB_SPEAKER:
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
- drawspeaker(scene, v3d, rv3d, ob, flag);
+ drawspeaker(scene, v3d, rv3d, ob, dflag);
break;
case OB_LATTICE:
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
@@ -6852,7 +6894,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
else {
if (dt > OB_WIRE)
GPU_enable_material(0, NULL); /* we use default material */
- empty_object = draw_armature(scene, v3d, ar, base, dt, flag, FALSE);
+ empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, FALSE);
if (dt > OB_WIRE)
GPU_disable_material();
}
@@ -6866,7 +6908,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
- if (ob->soft /*&& flag & OB_SBMOTION*/) {
+ if (ob->soft /*&& dflag & OB_SBMOTION*/) {
float mrt[3][3], msc[3][3], mtr[3][3];
SoftBody *sb = NULL;
float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f;
@@ -6891,7 +6933,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* code for new particle system */
if ((warning_recursive == 0) &&
(ob->particlesystem.first) &&
- (flag & DRAW_PICKING) == 0 &&
+ (dflag & DRAW_PICKING) == 0 &&
(ob != scene->obedit)
)
{
@@ -6925,7 +6967,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* draw edit particles last so that they can draw over child particles */
if ( (warning_recursive == 0) &&
- (flag & DRAW_PICKING) == 0 &&
+ (dflag & DRAW_PICKING) == 0 &&
(!scene->obedit))
{
@@ -7056,7 +7098,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data;
if (data->flag & CONSTRAINT_DRAW_PIVOT)
- drawRBpivot(data);
+ drawRBpivot(data, ob_wire_col);
}
}
@@ -7083,14 +7125,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if (dtx & OB_DRAWNAME) {
/* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
/* but, we also don't draw names for sets or duplicators */
- if (flag == 0) {
- float zero[3] = {0, 0, 0};
- float curcol[4];
- unsigned char tcol[4];
- glGetFloatv(GL_CURRENT_COLOR, curcol);
- rgb_float_to_uchar(tcol, curcol);
- tcol[3] = 255;
- view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, tcol);
+ if (dflag == 0) {
+ const float zero[3] = {0, 0, 0};
+ view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, ob_wire_col);
}
}
/*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/
@@ -7146,13 +7183,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
do_draw_center = DESELECT;
if (do_draw_center != -1) {
- if (flag & DRAW_PICKING) {
+ if (dflag & DRAW_PICKING) {
/* draw a single point for opengl selection */
glBegin(GL_POINTS);
glVertex3fv(ob->obmat[3]);
glEnd();
}
- else if ((flag & DRAW_CONSTCOLOR) == 0) {
+ else if ((dflag & DRAW_CONSTCOLOR) == 0) {
/* we don't draw centers for duplicators and sets */
if (U.obcenter_dia > 0) {
/* check > 0 otherwise grease pencil can draw into the circle select which is annoying. */
@@ -7163,7 +7200,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
/* not for sets, duplicators or picking */
- if (flag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+ if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
ListBase *list;
/* draw hook center and offset line */
@@ -7505,7 +7542,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
/* helper function for drawing object instances - meshes */
static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Object *ob, int dt, int outline)
+ Object *ob, const short dt, int outline)
{
Mesh *me = ob->data;
DerivedMesh *dm = NULL, *edm = NULL;
@@ -7553,7 +7590,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
if (dm) dm->release(dm);
}
-void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int outline)
+void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const short dt, int outline)
{
if (ob == NULL)
return;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 28fd2c8bc74..a6948222d93 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn)
break;
}
- // removed since BKE_image_user_frame_calc is now called in draw_bgpic because screen_ops doesnt call the notifier.
+ // removed since BKE_image_user_frame_calc is now called in view3d_draw_bgpic because screen_ops doesnt call the notifier.
#if 0
if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) {
View3D *v3d = area->spacedata.first;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 14afcaa855f..6d9507ebff1 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -508,8 +508,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
}
/* set variable axis */
- vert[0][1] = vert[1][1] =
- vert[2][0] = vert[3][0] = line;
+ vert[0][1] = vert[1][1] = vert[2][0] = vert[3][0] = line;
glDrawArrays(GL_LINES, 0, 4);
}
@@ -1128,7 +1127,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
#ifdef VIEW3D_CAMERA_BORDER_HACK
if (view3d_camera_border_hack_test == TRUE) {
- glColor4fv(view3d_camera_border_hack_col);
+ glColor3ubv(view3d_camera_border_hack_col);
glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1);
view3d_camera_border_hack_test = FALSE;
}
@@ -1147,7 +1146,6 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* border */
if (scene->r.mode & R_BORDER) {
-
cpack(0);
x3 = x1 + scene->r.border.xmin * (x2 - x1);
y3 = y1 + scene->r.border.ymin * (y2 - y1);
@@ -1528,7 +1526,8 @@ exit:
/* ************************************************************* */
-static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
+static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
+ const short do_forground, const short do_camera_frame)
{
RegionView3D *rv3d = ar->regiondata;
BGpic *bgpic;
@@ -1537,7 +1536,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
ImBuf *ibuf = NULL, *freeibuf;
float vec[4], fac, asp, zoomx, zoomy;
float x1, y1, x2, y2, cx, cy;
- int fg_flag = foreground ? V3D_BGPIC_FOREGROUND : 0;
+ int fg_flag = do_forground ? V3D_BGPIC_FOREGROUND : 0;
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
@@ -1560,7 +1559,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0);
ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
}
- else {
+ else if (bgpic->source == V3D_BGPIC_MOVIE) {
clip = NULL;
if (bgpic->flag & V3D_BGPIC_CAMERACLIP) {
@@ -1595,14 +1594,21 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
IMB_rect_from_float(ibuf);
if (rv3d->persp == RV3D_CAMOB) {
- rctf vb;
- ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
-
- x1 = vb.xmin;
- y1 = vb.ymin;
- x2 = vb.xmax;
- y2 = vb.ymax;
+ if (do_camera_frame) {
+ rctf vb;
+ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
+ x1 = vb.xmin;
+ y1 = vb.ymin;
+ x2 = vb.xmax;
+ y2 = vb.ymax;
+ }
+ else {
+ x1 = ar->winrct.xmin;
+ y1 = ar->winrct.ymin;
+ x2 = ar->winrct.xmax;
+ y2 = ar->winrct.ymax;
+ }
}
else {
float sco[2];
@@ -1696,7 +1702,8 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
}
}
-static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
+static void view3d_draw_bgpic_test(Scene *scene, ARegion *ar, View3D *v3d,
+ const short do_forground, const short do_camera_frame)
{
RegionView3D *rv3d = ar->regiondata;
@@ -1708,11 +1715,11 @@ static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) {
if (rv3d->persp == RV3D_CAMOB) {
- draw_bgpic(scene, ar, v3d, foreground);
+ view3d_draw_bgpic(scene, ar, v3d, do_forground, do_camera_frame);
}
}
else {
- draw_bgpic(scene, ar, v3d, foreground);
+ view3d_draw_bgpic(scene, ar, v3d, do_forground, do_camera_frame);
}
}
@@ -1721,17 +1728,17 @@ static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground)
typedef struct View3DAfter {
struct View3DAfter *next, *prev;
struct Base *base;
- int flag;
+ short dflag;
} View3DAfter;
/* temp storage of Objects that need to be drawn as last */
-void add_view3d_after(ListBase *lb, Base *base, int flag)
+void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag)
{
View3DAfter *v3da = MEM_callocN(sizeof(View3DAfter), "View 3d after");
BLI_assert((base->flag & OB_FROMDUPLI) == 0);
BLI_addtail(lb, v3da);
v3da->base = base;
- v3da->flag = flag;
+ v3da->dflag = dflag;
}
/* disables write in zbuffer and draws it over */
@@ -1744,7 +1751,7 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) {
next = v3da->next;
- draw_object(scene, ar, v3d, v3da->base, v3da->flag);
+ draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
BLI_remlink(&v3d->afterdraw_transp, v3da);
MEM_freeN(v3da);
}
@@ -1765,7 +1772,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
v3d->xray = TRUE;
for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) {
next = v3da->next;
- draw_object(scene, ar, v3d, v3da->base, v3da->flag);
+ draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
BLI_remlink(&v3d->afterdraw_xray, v3da);
MEM_freeN(v3da);
}
@@ -1786,7 +1793,7 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c
for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) {
next = v3da->next;
- draw_object(scene, ar, v3d, v3da->base, v3da->flag);
+ draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
BLI_remlink(&v3d->afterdraw_xraytransp, v3da);
MEM_freeN(v3da);
}
@@ -2428,14 +2435,13 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
int winx, int winy, float viewmat[][4], float winmat[][4],
- int draw_background)
+ int do_bgpic)
{
RegionView3D *rv3d = ar->regiondata;
Base *base;
float backcol[3];
int bwinx, bwiny;
rcti brect;
- ImBuf *bg_ibuf = NULL;
glPushMatrix();
@@ -2465,66 +2471,21 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows(scene, v3d);
- /* if scene has got active clip, use it for render backdrop */
- if (draw_background && scene->clip && rv3d->persp == RV3D_CAMOB && v3d->camera) {
- MovieClipUser user = {0};
-
- BKE_movieclip_user_set_frame(&user, CFRA);
- bg_ibuf = BKE_movieclip_get_ibuf(scene->clip, &user);
+ /* set background color, fallback on the view background color
+ * (if active clip is set but frame is failed to load fallback to horizon color as background) */
+ if (scene->world) {
+ if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
+ else
+ copy_v3_v3(backcol, &scene->world->horr);
+ glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
}
-
- if (!bg_ibuf) {
- /* set background color, fallback on the view background color
- * (if active clip is set but frame is failed to load fallback to horizon color as background) */
- if (scene->world) {
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
- else
- copy_v3_v3(backcol, &scene->world->horr);
- glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
- }
- else {
- UI_ThemeClearColor(TH_BACK);
- }
+ else {
+ UI_ThemeClearColor(TH_BACK);
}
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- if (bg_ibuf) {
- unsigned char *pixels, *cp, *dst_cp;
- int i;
-
- if (bg_ibuf->rect_float && !bg_ibuf->rect)
- IMB_rect_from_float(bg_ibuf);
-
- dst_cp = pixels = MEM_callocN(4 * sizeof(unsigned char) * bg_ibuf->x * bg_ibuf->y, "draw offscreen clip pixels");
- cp = (unsigned char *)bg_ibuf->rect;
- for (i = 0; i < bg_ibuf->x * bg_ibuf->y; i++, cp += 4, dst_cp += 4) {
- dst_cp[0] = cp[0];
- dst_cp[1] = cp[1];
- dst_cp[2] = cp[2];
- dst_cp[3] = 255;
- }
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- ED_region_pixelspace(ar);
-
- glPixelZoom((float)winx / bg_ibuf->x, (float)winy / bg_ibuf->y);
- glaDrawPixelsTex(0, 0, bg_ibuf->x, bg_ibuf->y, GL_UNSIGNED_BYTE, pixels);
-
- glPixelZoom(1.0, 1.0);
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- IMB_freeImBuf(bg_ibuf);
- MEM_freeN(pixels);
- }
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat);
@@ -2540,6 +2501,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
else
v3d->zbuf = FALSE;
+ /* important to do before clipping */
+ if (do_bgpic) {
+ view3d_draw_bgpic_test(scene, ar, v3d, FALSE, FALSE);
+ }
+
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(rv3d);
@@ -2581,6 +2547,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_disable();
+ /* important to do after clipping */
+ if (do_bgpic) {
+ view3d_draw_bgpic_test(scene, ar, v3d, TRUE, FALSE);
+ }
+
/* cleanup */
if (v3d->zbuf) {
v3d->zbuf = FALSE;
@@ -2763,12 +2734,15 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, printable, sizeof(printable));
}
-static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
+static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit);
+
+static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
RenderEngineType *type;
+ GLint scissor[4];
/* create render engine */
if (!rv3d->render_engine) {
@@ -2785,22 +2759,53 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
/* background draw */
+ ED_region_pixelspace(ar);
+
+ if (draw_border) {
+ /* for border draw, we only need to clear a subset of the 3d view */
+ rctf viewborder;
+ rcti cliprct;
+
+ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
+
+ cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin);
+ cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin);
+ cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin);
+ cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin);
+
+ cliprct.xmin += ar->winrct.xmin;
+ cliprct.xmax += ar->winrct.xmin;
+ cliprct.ymin += ar->winrct.ymin;
+ cliprct.ymax += ar->winrct.ymin;
+
+ cliprct.xmin = MAX2(cliprct.xmin, ar->winrct.xmin);
+ cliprct.ymin = MAX2(cliprct.ymin, ar->winrct.ymin);
+ cliprct.xmax = MIN2(cliprct.xmax, ar->winrct.xmax);
+ cliprct.ymax = MIN2(cliprct.ymax, ar->winrct.ymax);
+
+ glGetIntegerv(GL_SCISSOR_BOX, scissor);
+ glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin);
+ }
+
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- ED_region_pixelspace(ar);
-
- /* render result draw */
if (v3d->flag & V3D_DISPBGPICS)
- draw_bgpic(scene, ar, v3d, FALSE);
+ view3d_draw_bgpic(scene, ar, v3d, FALSE, TRUE);
else
fdrawcheckerboard(0, 0, ar->winx, ar->winy);
+ if (draw_border) {
+ /* restore scissor as it was before */
+ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+ }
+
+ /* render result draw */
type = rv3d->render_engine->type;
type->view_draw(rv3d->render_engine, C);
if (v3d->flag & V3D_DISPBGPICS)
- draw_bgpic(scene, ar, v3d, TRUE);
+ view3d_draw_bgpic(scene, ar, v3d, TRUE, TRUE);
return 1;
}
@@ -2896,7 +2901,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
}
}
- draw_bgpics(scene, ar, v3d, FALSE);
+ view3d_draw_bgpic_test(scene, ar, v3d, FALSE, TRUE);
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(rv3d);
@@ -2955,8 +2960,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
}
}
- draw_bgpics(scene, ar, v3d, TRUE);
-
// REEB_draw();
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
@@ -2976,6 +2979,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_disable();
+ /* important to do after clipping */
+ view3d_draw_bgpic_test(scene, ar, v3d, TRUE, TRUE);
+
BIF_draw_manipulator(C);
#if 0
@@ -3055,15 +3061,21 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
void view3d_main_area_draw(const bContext *C, ARegion *ar)
{
+ Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
const char *grid_unit = NULL;
+ int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER));
- /* draw viewport using external renderer? */
- if (!(v3d->drawtype == OB_RENDER && view3d_main_area_draw_engine(C, ar))) {
- /* draw viewport using opengl */
+ /* draw viewport using opengl */
+ if (v3d->drawtype != OB_RENDER || draw_border) {
view3d_main_area_draw_objects(C, ar, &grid_unit);
ED_region_pixelspace(ar);
}
+
+ /* draw viewport using external renderer */
+ if (v3d->drawtype == OB_RENDER)
+ view3d_main_area_draw_engine(C, ar, draw_border);
view3d_main_area_draw_info(C, ar, grid_unit);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 8ba0d75c786..d632314f3ca 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -498,7 +498,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
static void viewops_data_free(bContext *C, wmOperator *op)
{
ARegion *ar;
- Paint *p = paint_get_active(CTX_data_scene(C));
+ Paint *p = paint_get_active_from_context(C);
if (op->customdata) {
ViewOpsData *vod = op->customdata;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 29edc0158d6..3c6a0dd4b9f 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -53,13 +53,17 @@ struct wmWindowManager;
#define BL_NEAR_CLIP 0.001
/* drawing flags: */
-#define DRAW_PICKING 1
-#define DRAW_CONSTCOLOR 2
-#define DRAW_SCENESET 4
+enum {
+ DRAW_PICKING = (1 << 0),
+ DRAW_CONSTCOLOR = (1 << 1),
+ DRAW_SCENESET = (1 << 2)
+};
/* draw_mesh_fancy/draw_mesh_textured draw_flags */
-#define DRAW_MODIFIERS_PREVIEW 1
-#define DRAW_FACE_SELECT 2
+enum {
+ DRAW_MODIFIERS_PREVIEW = (1 << 0),
+ DRAW_FACE_SELECT = (1 << 1)
+};
/* view3d_header.c */
void VIEW3D_OT_layers(struct wmOperatorType *ot);
@@ -112,23 +116,28 @@ void draw_motion_paths_cleanup(View3D *v3d);
/* drawobject.c */
-void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, int flag);
-int draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, int dt);
-void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, int dt, int outline);
+void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, const short dflag);
+int draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const short dt);
+void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const short dt, int outline);
void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
void drawaxes(float size, char drawtype);
void view3d_cached_text_draw_begin(void);
void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]);
void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, float mat[][4]);
-#define V3D_CACHE_TEXT_ZBUF (1 << 0)
-#define V3D_CACHE_TEXT_WORLDSPACE (1 << 1)
-#define V3D_CACHE_TEXT_ASCII (1 << 2)
-#define V3D_CACHE_TEXT_GLOBALSPACE (1 << 3)
-#define V3D_CACHE_TEXT_LOCALCLIP (1 << 4)
+
+enum {
+ V3D_CACHE_TEXT_ZBUF = (1 << 0),
+ V3D_CACHE_TEXT_WORLDSPACE = (1 << 1),
+ V3D_CACHE_TEXT_ASCII = (1 << 2),
+ V3D_CACHE_TEXT_GLOBALSPACE = (1 << 3),
+ V3D_CACHE_TEXT_LOCALCLIP = (1 << 4)
+};
/* drawarmature.c */
-int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline);
+int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ const short dt, const short dflag, const unsigned char ob_wire_col[4],
+ const short is_outline);
/* drawmesh.c */
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
@@ -140,7 +149,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar);
void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (*func)(void *));
void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d);
-void add_view3d_after(ListBase *lb, Base *base, int flag);
+void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag);
void circf(float x, float y, float rad);
void circ(float x, float y, float rad);
@@ -211,7 +220,7 @@ void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float min[3], float
* any direction it starts to fail */
#define VIEW3D_CAMERA_BORDER_HACK
#ifdef VIEW3D_CAMERA_BORDER_HACK
-extern float view3d_camera_border_hack_col[4];
+extern unsigned char view3d_camera_border_hack_col[3];
extern short view3d_camera_border_hack_test;
#endif
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 602f790c8df..d2f2fdcaa81 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1870,7 +1870,6 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
for (base = vc->scene->base.first; base && hits; base = base->next) {
if (BASE_SELECTABLE(vc->v3d, base)) {
while (base->selcol == (*col & 0xFFFF)) { /* we got an object */
-
if (*col & 0xFFFF0000) { /* we got a bone */
bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
if (bone) {
@@ -1878,16 +1877,13 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
if ((bone->flag & BONE_UNSELECTABLE) == 0) {
bone->flag |= BONE_SELECTED;
bone_selected = 1;
-// XXX select_actionchannel_by_name(base->object->action, bone->name, 1);
}
}
else {
bArmature *arm = base->object->data;
bone->flag &= ~BONE_SELECTED;
-// XXX select_actionchannel_by_name(base->object->action, bone->name, 0);
if (arm->act_bone == bone)
arm->act_bone = NULL;
-
}
}
}
@@ -1897,7 +1893,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
else
ED_base_object_select(base, BA_DESELECT);
}
-
+
col += 4; /* next color */
hits--;
if (hits == 0) break;
@@ -1906,13 +1902,16 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
if (bone_selected) {
Object *ob = base->object;
- bArmature *arm = ob->data;
-
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
- if (arm->flag & ARM_HAS_VIZ_DEPS) {
- /* mask modifier ('armature' mode), etc. */
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ if (ob && (ob->type == OB_ARMATURE)) {
+ bArmature *arm = ob->data;
+
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+
+ if (arm && (arm->flag & ARM_HAS_VIZ_DEPS)) {
+ /* mask modifier ('armature' mode), etc. */
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ }
}
}
}