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:
authorCampbell Barton <ideasman42@gmail.com>2012-03-26 03:54:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-26 03:54:33 +0400
commit09144c3756f7b9b23461b522cf9711eb1c8db775 (patch)
tree3a037e82f54a35c09a67dcb236b8029d62dfd504 /source/blender/editors/space_view3d/view3d_draw.c
parent1ce2c73816be97f72484ffa40a3187b24968c6b3 (diff)
style cleanup: mostly whitespace around operators
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c1177
1 files changed, 590 insertions, 587 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 1f6ec45f908..b6ed8f65c68 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -65,7 +65,7 @@
#include "BKE_movieclip.h"
#include "RE_engine.h"
-#include "RE_pipeline.h" // make_stars
+#include "RE_pipeline.h" // make_stars
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -92,7 +92,7 @@
#include "GPU_material.h"
#include "GPU_extensions.h"
-#include "view3d_intern.h" // own include
+#include "view3d_intern.h" // own include
@@ -102,7 +102,7 @@ static void star_stuff_init_func(void)
glPointSize(1.0);
glBegin(GL_POINTS);
}
-static void star_stuff_vertex_func(float* i)
+static void star_stuff_vertex_func(float*i)
{
glVertex3fv(i);
}
@@ -121,7 +121,7 @@ void circf(float x, float y, float rad)
glTranslatef(x, y, 0.);
- gluDisk( qobj, 0.0, rad, 32, 1);
+ gluDisk(qobj, 0.0, rad, 32, 1);
glPopMatrix();
@@ -138,7 +138,7 @@ void circ(float x, float y, float rad)
glTranslatef(x, y, 0.);
- gluDisk( qobj, 0.0, rad, 32, 1);
+ gluDisk(qobj, 0.0, rad, 32, 1);
glPopMatrix();
@@ -150,21 +150,21 @@ void circ(float x, float y, float rad)
static void view3d_draw_clipping(RegionView3D *rv3d)
{
- BoundBox *bb= rv3d->clipbb;
+ BoundBox *bb = rv3d->clipbb;
if (bb) {
- static unsigned int clipping_index[6][4]= {{0, 1, 2, 3},
- {0, 4, 5, 1},
- {4, 7, 6, 5},
- {7, 3, 2, 6},
- {1, 5, 6, 2},
- {7, 4, 0, 3}};
+ static unsigned int clipping_index[6][4] = {{0, 1, 2, 3},
+ {0, 4, 5, 1},
+ {4, 7, 6, 5},
+ {7, 3, 2, 6},
+ {1, 5, 6, 2},
+ {7, 4, 0, 3}};
UI_ThemeColorShade(TH_BACK, -8);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, bb->vec);
- glDrawElements(GL_QUADS, sizeof(clipping_index)/sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
+ glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
glDisableClientState(GL_VERTEX_ARRAY);
}
@@ -229,15 +229,15 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y,
{
double verts[2][2];
- x+= (wx);
- y+= (wy);
+ x += (wx);
+ y += (wy);
/* set fixed 'Y' */
- verts[0][1]= 0.0f;
- verts[1][1]= (double)ar->winy;
+ verts[0][1] = 0.0f;
+ verts[1][1] = (double)ar->winy;
/* iter over 'X' */
- verts[0][0] = verts[1][0] = x-dx*floor(x/dx);
+ verts[0][0] = verts[1][0] = x - dx *floor(x / dx);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_DOUBLE, 0, verts);
@@ -247,11 +247,11 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y,
}
/* set fixed 'X' */
- verts[0][0]= 0.0f;
- verts[1][0]= (double)ar->winx;
+ verts[0][0] = 0.0f;
+ verts[1][0] = (double)ar->winx;
/* iter over 'Y' */
- verts[0][1]= verts[1][1]= y-dx*floor(y/dx);
+ verts[0][1] = verts[1][1] = y - dx *floor(y / dx);
while (verts[0][1] < ar->winy) {
glDrawArrays(GL_LINES, 0, 2);
verts[0][1] = verts[1][1] = verts[0][1] + dx;
@@ -265,34 +265,34 @@ static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y,
static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
{
/* extern short bgpicmode; */
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
double wx, wy, x, y, fw, fx, fy, dx;
double vec4[4];
unsigned char col[3], col2[3];
- fx= rv3d->persmat[3][0];
- fy= rv3d->persmat[3][1];
- fw= rv3d->persmat[3][3];
+ fx = rv3d->persmat[3][0];
+ fy = rv3d->persmat[3][1];
+ fw = rv3d->persmat[3][3];
- wx= (ar->winx/2.0); /* because of rounding errors, grid at wrong location */
- wy= (ar->winy/2.0);
+ wx = (ar->winx / 2.0); /* because of rounding errors, grid at wrong location */
+ wy = (ar->winy / 2.0);
- x= (wx)*fx/fw;
- y= (wy)*fy/fw;
+ x = (wx) * fx / fw;
+ y = (wy) * fy / fw;
- vec4[0]=vec4[1]= v3d->grid;
+ vec4[0] = vec4[1] = v3d->grid;
- vec4[2]= 0.0;
- vec4[3]= 1.0;
+ vec4[2] = 0.0;
+ vec4[3] = 1.0;
mul_m4_v4d(rv3d->persmat, vec4);
- fx= vec4[0];
- fy= vec4[1];
- fw= vec4[3];
+ fx = vec4[0];
+ fy = vec4[1];
+ fw = vec4[3];
- dx= fabs(x-(wx)*fx/fw);
- if (dx==0) dx= fabs(y-(wy)*fy/fw);
+ dx = fabs(x - (wx) * fx / fw);
+ if (dx == 0) dx = fabs(y - (wy) * fy / fw);
- glDepthMask(0); // disable write in zbuffer
+ glDepthMask(0); // disable write in zbuffer
/* check zoom out */
UI_ThemeColor(TH_GRID);
@@ -308,23 +308,23 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH);
if (usys) {
- i= len;
+ i = len;
while (i--) {
- double scalar= bUnit_GetScaler(usys, i);
+ double scalar = bUnit_GetScaler(usys, i);
dx_scalar = dx * scalar / unit->scale_length;
- if (dx_scalar < (GRID_MIN_PX*2))
+ if (dx_scalar < (GRID_MIN_PX * 2))
continue;
/* Store the smallest drawn grid size units name so users know how big each grid cell is */
- if (*grid_unit==NULL) {
- *grid_unit= bUnit_GetNameDisplay(usys, i);
- rv3d->gridview= (scalar * v3d->grid) / unit->scale_length;
+ if (*grid_unit == NULL) {
+ *grid_unit = bUnit_GetNameDisplay(usys, i);
+ rv3d->gridview = (scalar * v3d->grid) / unit->scale_length;
}
- blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar);
+ blend_fac = 1 - ((GRID_MIN_PX * 2) / dx_scalar);
/* tweak to have the fade a bit nicer */
- blend_fac= (blend_fac * blend_fac) * 2.0f;
+ blend_fac = (blend_fac * blend_fac) * 2.0f;
CLAMP(blend_fac, 0.3f, 1.0f);
@@ -337,83 +337,83 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
else {
short sublines = v3d->gridsubdiv;
- if (dx<GRID_MIN_PX) {
- rv3d->gridview*= sublines;
- dx*= sublines;
-
- if (dx<GRID_MIN_PX) {
- rv3d->gridview*= sublines;
- dx*= sublines;
-
- if (dx<GRID_MIN_PX) {
- rv3d->gridview*= sublines;
- dx*=sublines;
- if (dx<GRID_MIN_PX);
+ if (dx < GRID_MIN_PX) {
+ rv3d->gridview *= sublines;
+ dx *= sublines;
+
+ if (dx < GRID_MIN_PX) {
+ rv3d->gridview *= sublines;
+ dx *= sublines;
+
+ if (dx < GRID_MIN_PX) {
+ rv3d->gridview *= sublines;
+ dx *= sublines;
+ if (dx < GRID_MIN_PX) ;
else {
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx);
}
}
- else { // start blending out
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else { // start blending out
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6));
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
- drawgrid_draw(ar, wx, wy, x, y, sublines*dx);
+ drawgrid_draw(ar, wx, wy, x, y, sublines * dx);
}
}
- else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6));
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
- drawgrid_draw(ar, wx, wy, x, y, sublines*dx);
+ drawgrid_draw(ar, wx, wy, x, y, sublines * dx);
}
}
else {
- if (dx>(GRID_MIN_PX*10)) { // start blending in
- rv3d->gridview/= sublines;
- dx/= sublines;
- if (dx>(GRID_MIN_PX*10)) { // start blending in
- rv3d->gridview/= sublines;
- dx/= sublines;
- if (dx>(GRID_MIN_PX*10)) {
+ if (dx > (GRID_MIN_PX * 10)) { // start blending in
+ rv3d->gridview /= sublines;
+ dx /= sublines;
+ if (dx > (GRID_MIN_PX * 10)) { // start blending in
+ rv3d->gridview /= sublines;
+ dx /= sublines;
+ if (dx > (GRID_MIN_PX * 10)) {
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx);
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6));
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
- drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
+ drawgrid_draw(ar, wx, wy, x, y, dx * sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6));
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
- drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
+ drawgrid_draw(ar, wx, wy, x, y, dx * sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6));
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
- drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
+ drawgrid_draw(ar, wx, wy, x, y, dx * sublines);
}
}
}
- x+= (wx);
- y+= (wy);
+ x += (wx);
+ y += (wy);
UI_GetThemeColor3ubv(TH_GRID, col);
setlinestyle(0);
/* center cross */
/* horizontal line */
- if ( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
+ if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
UI_make_axis_color(col, col2, 'Y');
else UI_make_axis_color(col, col2, 'X');
glColor3ubv(col2);
@@ -421,14 +421,14 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
fdrawline(0.0, y, (float)ar->winx, y);
/* vertical line */
- if ( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
+ if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
UI_make_axis_color(col, col2, 'Y');
else UI_make_axis_color(col, col2, 'Z');
glColor3ubv(col2);
fdrawline(x, 0.0, x, (float)ar->winy);
- glDepthMask(1); // enable write in zbuffer
+ glDepthMask(1); // enable write in zbuffer
}
#undef GRID_MIN_PX
@@ -436,11 +436,11 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
{
float grid, grid_scale;
unsigned char col_grid[3];
- const int gridlines= v3d->gridlines/2;
+ const int gridlines = v3d->gridlines / 2;
- if (v3d->gridlines<3) return;
+ if (v3d->gridlines < 3) return;
- grid_scale= v3d->grid;
+ grid_scale = v3d->grid;
/* use 'grid_scale' instead of 'v3d->grid' from now on */
/* apply units */
@@ -451,53 +451,53 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
bUnit_GetSystem(&usys, &len, scene->unit.system, B_UNIT_LENGTH);
if (usys) {
- int i= bUnit_GetBaseUnit(usys);
- *grid_unit= bUnit_GetNameDisplay(usys, i);
+ int i = bUnit_GetBaseUnit(usys);
+ *grid_unit = bUnit_GetNameDisplay(usys, i);
grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length;
}
}
- grid= gridlines * grid_scale;
+ grid = gridlines * grid_scale;
- if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select
+ if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select
UI_GetThemeColor3ubv(TH_GRID, col_grid);
/* draw the Y axis and/or grid lines */
if (v3d->gridflag & V3D_SHOW_FLOOR) {
- float vert[4][3]= {{0.0f}};
+ float vert[4][3] = {{0.0f}};
unsigned char col_bg[3];
unsigned char col_grid_emphasise[3], col_grid_light[3];
int a;
- int prev_emphasise= -1;
+ int prev_emphasise = -1;
UI_GetThemeColor3ubv(TH_BACK, col_bg);
/* emphasise division lines lighter instead of darker, if background is darker than grid */
UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10);
UI_GetColorPtrShade3ubv(col_grid, col_grid_emphasise,
- (((col_grid[0]+col_grid[1]+col_grid[2])+30) >
- (col_bg[0]+col_bg[1]+col_bg[2])) ? 20 : -10);
+ (((col_grid[0] + col_grid[1] + col_grid[2]) + 30) >
+ (col_bg[0] + col_bg[1] + col_bg[2])) ? 20 : -10);
/* set fixed axis */
- vert[0][0]= vert[2][1]= grid;
- vert[1][0]= vert[3][1]= -grid;
+ vert[0][0] = vert[2][1] = grid;
+ vert[1][0] = vert[3][1] = -grid;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vert);
- for (a= -gridlines;a<=gridlines;a++) {
- const float line= a * grid_scale;
- const int is_emphasise= (a % 10) == 0;
+ for (a = -gridlines; a <= gridlines; a++) {
+ const float line = a * grid_scale;
+ const int is_emphasise = (a % 10) == 0;
if (is_emphasise != prev_emphasise) {
glColor3ubv(is_emphasise ? col_grid_emphasise : col_grid_light);
- prev_emphasise= is_emphasise;
+ prev_emphasise = is_emphasise;
}
/* 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);
}
@@ -511,21 +511,22 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit)
/* check for the 'show Z axis' preference */
if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
int axis;
- for (axis= 0; axis < 3; axis++)
- if (v3d->gridflag & (V3D_SHOW_X << axis)) {
- float vert[3];
- unsigned char tcol[3];
-
- UI_make_axis_color(col_grid, tcol, 'X' + axis);
- glColor3ubv(tcol);
-
- glBegin(GL_LINE_STRIP);
- zero_v3(vert);
- vert[axis]= grid;
- glVertex3fv(vert );
- vert[axis]= -grid;
- glVertex3fv(vert);
- glEnd();
+ for (axis = 0; axis < 3; axis++) {
+ if (v3d->gridflag & (V3D_SHOW_X << axis)) {
+ float vert[3];
+ unsigned char tcol[3];
+
+ UI_make_axis_color(col_grid, tcol, 'X' + axis);
+ glColor3ubv(tcol);
+
+ glBegin(GL_LINE_STRIP);
+ zero_v3(vert);
+ vert[axis] = grid;
+ glVertex3fv(vert);
+ vert[axis] = -grid;
+ glVertex3fv(vert);
+ glEnd();
+ }
}
}
@@ -542,15 +543,15 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
int flag;
/* we don't want the clipping for cursor */
- flag= v3d->flag;
- v3d->flag= 0;
+ flag = v3d->flag;
+ v3d->flag = 0;
project_int(ar, give_cursor(scene, v3d), co);
- v3d->flag= flag;
+ v3d->flag = flag;
mx = co[0];
my = co[1];
- if (mx!=IS_CLIPPED) {
+ if (mx != IS_CLIPPED) {
setlinestyle(0);
cpack(0xFF);
circ((float)mx, (float)my, 10.0);
@@ -560,10 +561,10 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
setlinestyle(0);
cpack(0x0);
- sdrawline(mx-20, my, mx-5, my);
- sdrawline(mx+5, my, mx+20, my);
- sdrawline(mx, my-20, mx, my-5);
- sdrawline(mx, my+5, mx, my+20);
+ sdrawline(mx - 20, my, mx - 5, my);
+ sdrawline(mx + 5, my, mx + 20, my);
+ sdrawline(mx, my - 20, mx, my - 5);
+ sdrawline(mx, my + 5, mx, my + 20);
}
}
@@ -573,9 +574,9 @@ static void draw_view_axis(RegionView3D *rv3d)
{
const float k = U.rvisize; /* axis size */
const float toll = 0.5; /* used to see when view is quasi-orthogonal */
- const float start = k + 1.0f;/* axis center in screen coordinates, x=y */
+ const float start = k + 1.0f; /* axis center in screen coordinates, x=y */
float ydisp = 0.0; /* vertical displacement to allow obj info text */
- int bright = 25*(float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */
+ int bright = 25 * (float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */
float vec[3];
float dx, dy;
@@ -654,7 +655,7 @@ static void draw_rotation_guide(RegionView3D *rv3d)
float o[3]; // center of rotation
float end[3]; // endpoints for drawing
- float color[4] = {0.f ,0.4235f, 1.f, 1.f}; // bright blue so it matches device LEDs
+ float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; // bright blue so it matches device LEDs
negate_v3_v3(o, rv3d->ofs);
@@ -693,7 +694,7 @@ static void draw_rotation_guide(RegionView3D *rv3d)
// -- draw ring around rotation center --
{
-#define ROT_AXIS_DETAIL 13
+#define ROT_AXIS_DETAIL 13
const float s = 0.05f * scale;
const float step = 2.f * (float)(M_PI / ROT_AXIS_DETAIL);
@@ -726,18 +727,18 @@ static void draw_rotation_guide(RegionView3D *rv3d)
}
glEnd();
-#undef ROT_AXIS_DETAIL
+#undef ROT_AXIS_DETAIL
}
color[3] = 1.f; // solid dot
}
else
- color[3] = 0.5f; // see-through dot
+ color[3] = 0.5f; // see-through dot
// -- draw rotation center --
glColor4fv(color);
glBegin(GL_POINTS);
- glVertex3fv(o);
+ glVertex3fv(o);
glEnd();
// find screen coordinates for rotation center, then draw pretty icon
@@ -754,12 +755,12 @@ static void draw_view_icon(RegionView3D *rv3d)
{
BIFIconID icon;
- if ( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
- icon= ICON_AXIS_TOP;
- else if ( ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
- icon= ICON_AXIS_FRONT;
- else if ( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
- icon= ICON_AXIS_SIDE;
+ if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
+ icon = ICON_AXIS_TOP;
+ else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
+ icon = ICON_AXIS_FRONT;
+ else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
+ icon = ICON_AXIS_SIDE;
else return;
glEnable(GL_BLEND);
@@ -801,7 +802,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
break;
default:
- if (rv3d->persp==RV3D_CAMOB) {
+ if (rv3d->persp == RV3D_CAMOB) {
if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
Camera *cam;
cam = v3d->camera->data;
@@ -822,18 +823,18 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
static void draw_viewport_name(ARegion *ar, View3D *v3d)
{
- RegionView3D *rv3d= ar->regiondata;
- const char *name= view3d_get_name(v3d, rv3d);
+ RegionView3D *rv3d = ar->regiondata;
+ const char *name = view3d_get_name(v3d, rv3d);
char tmpstr[24];
if (v3d->localvd) {
BLI_snprintf(tmpstr, sizeof(tmpstr), "%s (Local)", name);
- name= tmpstr;
+ name = tmpstr;
}
if (name) {
UI_ThemeColor(TH_TEXT_HI);
- BLF_draw_default_ascii(22, ar->winy-17, 0.0f, name, sizeof(tmpstr));
+ BLF_draw_default_ascii(22, ar->winy - 17, 0.0f, name, sizeof(tmpstr));
}
}
@@ -843,42 +844,42 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d)
static void draw_selected_name(Scene *scene, Object *ob)
{
char info[256], *markern;
- short offset=30;
+ short offset = 30;
/* get name of marker on current frame (if available) */
- markern= scene_find_marker_name(scene, CFRA);
+ markern = scene_find_marker_name(scene, CFRA);
/* check if there is an object */
if (ob) {
/* name(s) to display depends on type of object */
- if (ob->type==OB_ARMATURE) {
- bArmature *arm= ob->data;
- char *name= NULL;
+ if (ob->type == OB_ARMATURE) {
+ bArmature *arm = ob->data;
+ char *name = NULL;
/* show name of active bone too (if possible) */
if (arm->edbo) {
if (arm->act_edbone)
- name= ((EditBone *)arm->act_edbone)->name;
+ name = ((EditBone *)arm->act_edbone)->name;
}
else if (ob->mode & OB_MODE_POSE) {
if (arm->act_bone) {
if (arm->act_bone->layer & arm->layer)
- name= arm->act_bone->name;
+ name = arm->act_bone->name;
}
}
if (name && markern)
- BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name + 2, name, markern);
else if (name)
- BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, name);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name + 2, name);
else
- BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
+ BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name + 2);
}
else if (ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
- Key *key= NULL;
+ Key *key = NULL;
KeyBlock *kb = NULL;
char shapes[MAX_NAME + 10];
@@ -886,7 +887,7 @@ static void draw_selected_name(Scene *scene, Object *ob)
shapes[0] = '\0';
key = ob_get_key(ob);
if (key) {
- kb = BLI_findlink(&key->block, ob->shapenr-1);
+ kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb) {
BLI_snprintf(shapes, sizeof(shapes), ": %s ", kb->name);
if (ob->shapeflag == OB_SHAPE_LOCK) {
@@ -896,20 +897,20 @@ static void draw_selected_name(Scene *scene, Object *ob)
}
if (markern)
- BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name + 2, shapes, markern);
else
- BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, shapes);
+ BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name + 2, shapes);
}
else {
/* standard object */
if (markern)
- BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
+ BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name + 2, markern);
else
- BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
+ BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name + 2);
}
/* color depends on whether there is a keyframe */
- if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), ANIMFILTER_KEYS_LOCAL))
+ if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL))
UI_ThemeColor(TH_VERTEX_SELECT);
else
UI_ThemeColor(TH_TEXT_HI);
@@ -941,25 +942,25 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV
camera_params_init(&params);
camera_params_from_view3d(&params, v3d, rv3d);
if (no_zoom)
- params.zoom= 1.0f;
+ params.zoom = 1.0f;
camera_params_compute_viewplane(&params, ar->winx, ar->winy, 1.0f, 1.0f);
- rect_view= params.viewplane;
+ rect_view = params.viewplane;
/* get camera viewplane */
camera_params_init(&params);
camera_params_from_object(&params, v3d->camera);
if (no_shift) {
- params.shiftx= 0.0f;
- params.shifty= 0.0f;
+ params.shiftx = 0.0f;
+ params.shifty = 0.0f;
}
camera_params_compute_viewplane(&params, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp);
- rect_camera= params.viewplane;
+ rect_camera = params.viewplane;
/* get camera border within viewport */
- viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx;
- viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx;
- viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy;
- viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy;
+ viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
+ viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
+ viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
+ viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
}
void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2])
@@ -967,8 +968,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
rctf viewborder;
view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE);
- size_r[0]= viewborder.xmax - viewborder.xmin;
- size_r[1]= viewborder.ymax - viewborder.ymin;
+ size_r[0] = viewborder.xmax - viewborder.xmin;
+ size_r[1] = viewborder.ymax - viewborder.ymin;
}
void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@@ -981,10 +982,10 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f
{
float x3, y3, x4, y4;
- x3= x1 + fac * (x2-x1);
- y3= y1 + fac * (y2-y1);
- x4= x1 + (1.0f - fac) * (x2-x1);
- y4= y1 + (1.0f - fac) * (y2-y1);
+ x3 = x1 + fac * (x2 - x1);
+ y3 = y1 + fac * (y2 - y1);
+ x4 = x1 + (1.0f - fac) * (x2 - x1);
+ y4 = y1 + (1.0f - fac) * (y2 - y1);
glBegin(GL_LINES);
glVertex2f(x1, y3);
@@ -1005,13 +1006,13 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f
static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir)
{
float ofs;
- float w= x2 - x1;
- float h= y2 - y1;
+ float w = x2 - x1;
+ float h = y2 - y1;
glBegin(GL_LINES);
if (w > h) {
if (golden) {
- ofs = w * (1.0f-(1.0f/1.61803399f));
+ ofs = w * (1.0f - (1.0f / 1.61803399f));
}
else {
ofs = h * (h / w);
@@ -1029,7 +1030,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons
}
else {
if (golden) {
- ofs = h * (1.0f-(1.0f/1.61803399f));
+ ofs = h * (1.0f - (1.0f / 1.61803399f));
}
else {
ofs = w * (w / h);
@@ -1055,20 +1056,20 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
float x1i, x2i, y1i, y2i;
float x3, y3, x4, y4;
rctf viewborder;
- Camera *ca= NULL;
- RegionView3D *rv3d= (RegionView3D *)ar->regiondata;
+ Camera *ca = NULL;
+ RegionView3D *rv3d = (RegionView3D *)ar->regiondata;
- if (v3d->camera==NULL)
+ if (v3d->camera == NULL)
return;
- if (v3d->camera->type==OB_CAMERA)
+ if (v3d->camera->type == OB_CAMERA)
ca = v3d->camera->data;
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
/* the offsets */
- x1= viewborder.xmin;
- y1= viewborder.ymin;
- x2= viewborder.xmax;
- y2= viewborder.ymax;
+ x1 = viewborder.xmin;
+ y1 = viewborder.ymin;
+ x2 = viewborder.xmax;
+ y2 = viewborder.ymax;
/* apply offsets so the real 3D camera shows through */
@@ -1077,10 +1078,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
* obscures the 3D camera border */
/* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable
* but keep it here in case we need to remove the workaround */
- x1i= (int)(x1 - 1.0001f);
- y1i= (int)(y1 - 1.0001f);
- x2i= (int)(x2 + (1.0f-0.0001f));
- y2i= (int)(y2 + (1.0f-0.0001f));
+ x1i = (int)(x1 - 1.0001f);
+ y1i = (int)(y1 - 1.0001f);
+ x2i = (int)(x2 + (1.0f - 0.0001f));
+ y2i = (int)(y2 + (1.0f - 0.0001f));
/* passepartout, specified in camera edit buttons */
if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
@@ -1088,7 +1089,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
glColor3f(0, 0, 0);
}
else {
- glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(0, 0, 0, ca->passepartalpha);
}
@@ -1116,8 +1117,8 @@ 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);
- glRectf(x1i+1, y1i+1, x2i-1, y2i-1);
- view3d_camera_border_hack_test= FALSE;
+ glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1);
+ view3d_camera_border_hack_test = FALSE;
}
#endif
@@ -1136,10 +1137,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
if (scene->r.mode & R_BORDER) {
cpack(0);
- x3= x1+ scene->r.border.xmin*(x2-x1);
- y3= y1+ scene->r.border.ymin*(y2-y1);
- x4= x1+ scene->r.border.xmax*(x2-x1);
- y4= y1+ scene->r.border.ymax*(y2-y1);
+ x3 = x1 + scene->r.border.xmin * (x2 - x1);
+ y3 = y1 + scene->r.border.ymin * (y2 - y1);
+ x4 = x1 + scene->r.border.xmax * (x2 - x1);
+ y4 = y1 + scene->r.border.ymax * (y2 - y1);
cpack(0x4040FF);
glRectf(x3, y3, x4, y4);
@@ -1150,8 +1151,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
if (ca->dtx & CAM_DTX_CENTER) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
- x3= x1+ 0.5f*(x2-x1);
- y3= y1+ 0.5f*(y2-y1);
+ x3 = x1 + 0.5f * (x2 - x1);
+ y3 = y1 + 0.5f * (y2 - y1);
glBegin(GL_LINES);
glVertex2f(x1, y3);
@@ -1176,12 +1177,12 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
if (ca->dtx & CAM_DTX_THIRDS) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
- drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f);
+ drawviewborder_grid3(x1, x2, y1, y2, 1.0f / 3.0f);
}
if (ca->dtx & CAM_DTX_GOLDEN) {
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
- drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399f));
+ drawviewborder_grid3(x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
}
if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
@@ -1205,15 +1206,15 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
}
if (ca->flag & CAM_SHOWTITLESAFE) {
- fac= 0.1;
+ fac = 0.1;
- a= fac*(x2-x1);
- x1+= a;
- x2-= a;
+ a = fac * (x2 - x1);
+ x1 += a;
+ x2 -= a;
- a= fac*(y2-y1);
- y1+= a;
- y2-= a;
+ a = fac * (y2 - y1);
+ y1 += a;
+ y2 -= a;
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
@@ -1223,29 +1224,29 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
if (ca && (ca->flag & CAM_SHOWSENSOR)) {
/* determine sensor fit, and get sensor x/y, for auto fit we
* assume and square sensor and only use sensor_x */
- float sizex= scene->r.xsch*scene->r.xasp;
- float sizey= scene->r.ysch*scene->r.yasp;
+ float sizex = scene->r.xsch * scene->r.xasp;
+ float sizey = scene->r.ysch * scene->r.yasp;
int sensor_fit = camera_sensor_fit(ca->sensor_fit, sizex, sizey);
- float sensor_x= ca->sensor_x;
- float sensor_y= (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO)? ca->sensor_x: ca->sensor_y;
+ float sensor_x = ca->sensor_x;
+ float sensor_y = (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO) ? ca->sensor_x : ca->sensor_y;
/* determine sensor plane */
rctf rect;
if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
- float sensor_scale = (x2i-x1i) / sensor_x;
+ float sensor_scale = (x2i - x1i) / sensor_x;
float sensor_height = sensor_scale * sensor_y;
rect.xmin = x1i;
rect.xmax = x2i;
- rect.ymin = (y1i + y2i)*0.5f - sensor_height*0.5f;
+ rect.ymin = (y1i + y2i) * 0.5f - sensor_height * 0.5f;
rect.ymax = rect.ymin + sensor_height;
}
else {
- float sensor_scale = (y2i-y1i) / sensor_y;
+ float sensor_scale = (y2i - y1i) / sensor_y;
float sensor_width = sensor_scale * sensor_x;
- rect.xmin = (x1i + x2i)*0.5f - sensor_width*0.5f;
+ rect.xmin = (x1i + x2i) * 0.5f - sensor_width * 0.5f;
rect.xmax = rect.xmin + sensor_width;
rect.ymin = y1i;
rect.ymax = y2i;
@@ -1263,7 +1264,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* camera name - draw in highlighted text color */
if (ca && (ca->flag & CAM_SHOWNAME)) {
UI_ThemeColor(TH_TEXT_HI);
- BLF_draw_default(x1i, y1i-15, 0.0f, v3d->camera->id.name+2, sizeof(v3d->camera->id.name)-2);
+ BLF_draw_default(x1i, y1i - 15, 0.0f, v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2);
UI_ThemeColor(TH_WIRE);
}
}
@@ -1272,30 +1273,30 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
struct Base *base = scene->basact;
int multisample_enabled;
rcti winrct;
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
- if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) ||
- paint_facesel_test(base->object)))
+ if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
+ paint_facesel_test(base->object)))
{
/* do nothing */
}
else if ((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) &&
- scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE))
+ scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE))
{
/* do nothing */
}
else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) &&
- v3d->drawtype > OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT))
+ v3d->drawtype > OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT))
{
/* do nothing */
}
- else if (scene->obedit && v3d->drawtype>OB_WIRE &&
- (v3d->flag & V3D_ZBUF_SELECT)) {
+ else if (scene->obedit && v3d->drawtype > OB_WIRE &&
+ (v3d->flag & V3D_ZBUF_SELECT)) {
/* do nothing */
}
else {
@@ -1303,7 +1304,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
return;
}
- if ( !(v3d->flag & V3D_INVALID_BACKBUF) ) return;
+ if (!(v3d->flag & V3D_INVALID_BACKBUF) ) return;
// if (test) {
// if (qtest()) {
@@ -1312,12 +1313,12 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
// }
// }
- if (v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE;
+ if (v3d->drawtype > OB_WIRE) v3d->zbuf = TRUE;
/* dithering and AA break color coding, so disable */
glDisable(GL_DITHER);
- multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB);
+ multisample_enabled = glIsEnabled(GL_MULTISAMPLE_ARB);
if (multisample_enabled)
glDisable(GL_MULTISAMPLE_ARB);
@@ -1343,10 +1344,10 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
draw_object_backbufsel(scene, v3d, rv3d, base->object);
v3d->flag &= ~V3D_INVALID_BACKBUF;
- ar->swap= 0; /* mark invalid backbuf for wm draw */
+ ar->swap = 0; /* mark invalid backbuf for wm draw */
G.f &= ~G_BACKBUFSEL;
- v3d->zbuf= FALSE;
+ v3d->zbuf = FALSE;
glDisable(GL_DEPTH_TEST);
glEnable(GL_DITHER);
if (multisample_enabled)
@@ -1372,15 +1373,15 @@ unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y)
unsigned int col;
if (x >= vc->ar->winx || y >= vc->ar->winy) return 0;
- x+= vc->ar->winrct.xmin;
- y+= vc->ar->winrct.ymin;
+ x += vc->ar->winrct.xmin;
+ y += vc->ar->winrct.ymin;
view3d_validate_backbuf(vc);
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
glReadBuffer(GL_BACK);
- if (ENDIAN_ORDER==B_ENDIAN) SWITCH_INT(col);
+ if (ENDIAN_ORDER == B_ENDIAN) SWITCH_INT(col);
return WM_framebuffer_to_index(col);
}
@@ -1394,47 +1395,47 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
short xminc, yminc, xmaxc, ymaxc, xs, ys;
/* clip */
- if (xmin<0) xminc= 0; else xminc= xmin;
- if (xmax >= vc->ar->winx) xmaxc= vc->ar->winx-1; else xmaxc= xmax;
+ if (xmin < 0) xminc = 0; else xminc = xmin;
+ if (xmax >= vc->ar->winx) xmaxc = vc->ar->winx - 1; else xmaxc = xmax;
if (xminc > xmaxc) return NULL;
- if (ymin<0) yminc= 0; else yminc= ymin;
- if (ymax >= vc->ar->winy) ymaxc= vc->ar->winy-1; else ymaxc= ymax;
+ if (ymin < 0) yminc = 0; else yminc = ymin;
+ if (ymax >= vc->ar->winy) ymaxc = vc->ar->winy - 1; else ymaxc = ymax;
if (yminc > ymaxc) return NULL;
- ibuf= IMB_allocImBuf((xmaxc-xminc+1), (ymaxc-yminc+1), 32, IB_rect);
+ ibuf = IMB_allocImBuf((xmaxc - xminc + 1), (ymaxc - yminc + 1), 32, IB_rect);
view3d_validate_backbuf(vc);
glReadPixels(vc->ar->winrct.xmin + xminc,
vc->ar->winrct.ymin + yminc,
- (xmaxc-xminc + 1),
- (ymaxc-yminc + 1),
+ (xmaxc - xminc + 1),
+ (ymaxc - yminc + 1),
GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glReadBuffer(GL_BACK);
- if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
+ if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
- a= (xmaxc-xminc+1)*(ymaxc-yminc+1);
- dr= ibuf->rect;
+ a = (xmaxc - xminc + 1) * (ymaxc - yminc + 1);
+ dr = ibuf->rect;
while (a--) {
- if (*dr) *dr= WM_framebuffer_to_index(*dr);
+ if (*dr) *dr = WM_framebuffer_to_index(*dr);
dr++;
}
/* put clipped result back, if needed */
- if (xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax)
+ if (xminc == xmin && xmaxc == xmax && yminc == ymin && ymaxc == ymax)
return ibuf;
- ibuf1= IMB_allocImBuf( (xmax-xmin+1),(ymax-ymin+1),32,IB_rect);
- rd= ibuf->rect;
- dr= ibuf1->rect;
-
- for (ys= ymin; ys<=ymax; ys++) {
- for (xs= xmin; xs<=xmax; xs++, dr++) {
- if ( xs>=xminc && xs<=xmaxc && ys>=yminc && ys<=ymaxc) {
- *dr= *rd;
+ ibuf1 = IMB_allocImBuf( (xmax - xmin + 1), (ymax - ymin + 1), 32, IB_rect);
+ rd = ibuf->rect;
+ dr = ibuf1->rect;
+
+ for (ys = ymin; ys <= ymax; ys++) {
+ for (xs = xmin; xs <= xmax; xs++, dr++) {
+ if (xs >= xminc && xs <= xmaxc && ys >= yminc && ys <= ymaxc) {
+ *dr = *rd;
rd++;
}
}
@@ -1445,59 +1446,59 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size,
- unsigned int min, unsigned int max, int *dist, short strict,
- void *handle, unsigned int (*indextest)(void *handle, unsigned int index))
+ unsigned int min, unsigned int max, int *dist, short strict,
+ void *handle, unsigned int (*indextest)(void *handle, unsigned int index))
{
struct ImBuf *buf;
unsigned int *bufmin, *bufmax, *tbuf;
int minx, miny;
int a, b, rc, nr, amount, dirvec[4][2];
- int distance=0;
+ int distance = 0;
unsigned int index = 0;
short indexok = 0;
- amount= (size-1)/2;
+ amount = (size - 1) / 2;
- minx = mval[0]-(amount+1);
- miny = mval[1]-(amount+1);
- buf = view3d_read_backbuf(vc, minx, miny, minx+size-1, miny+size-1);
+ minx = mval[0] - (amount + 1);
+ miny = mval[1] - (amount + 1);
+ buf = view3d_read_backbuf(vc, minx, miny, minx + size - 1, miny + size - 1);
if (!buf) return 0;
- rc= 0;
+ rc = 0;
- dirvec[0][0]= 1; dirvec[0][1]= 0;
- dirvec[1][0]= 0; dirvec[1][1]= -size;
- dirvec[2][0]= -1; dirvec[2][1]= 0;
- dirvec[3][0]= 0; dirvec[3][1]= size;
+ dirvec[0][0] = 1; dirvec[0][1] = 0;
+ dirvec[1][0] = 0; dirvec[1][1] = -size;
+ dirvec[2][0] = -1; dirvec[2][1] = 0;
+ dirvec[3][0] = 0; dirvec[3][1] = size;
bufmin = buf->rect;
tbuf = buf->rect;
- bufmax = buf->rect + size*size;
- tbuf+= amount*size+ amount;
+ bufmax = buf->rect + size * size;
+ tbuf += amount * size + amount;
- for (nr=1; nr<=size; nr++) {
+ for (nr = 1; nr <= size; nr++) {
- for (a=0; a<2; a++) {
- for (b=0; b<nr; b++, distance++) {
- if (*tbuf && *tbuf>=min && *tbuf<max) { //we got a hit
+ for (a = 0; a < 2; a++) {
+ for (b = 0; b < nr; b++, distance++) {
+ if (*tbuf && *tbuf >= min && *tbuf < max) { //we got a hit
if (strict) {
- indexok = indextest(handle, *tbuf - min+1);
+ indexok = indextest(handle, *tbuf - min + 1);
if (indexok) {
- *dist= (short) sqrt( (float)distance );
- index = *tbuf - min+1;
+ *dist = (short) sqrt( (float)distance);
+ index = *tbuf - min + 1;
goto exit;
}
}
else {
- *dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong -
- index = *tbuf - min+1; // messy yah, but indices start at 1
+ *dist = (short) sqrt( (float)distance); // XXX, this distance is wrong -
+ index = *tbuf - min + 1; // messy yah, but indices start at 1
goto exit;
}
}
- tbuf+= (dirvec[rc][0]+dirvec[rc][1]);
+ tbuf += (dirvec[rc][0] + dirvec[rc][1]);
- if (tbuf<bufmin || tbuf>=bufmax) {
+ if (tbuf < bufmin || tbuf >= bufmax) {
goto exit;
}
}
@@ -1516,98 +1517,98 @@ exit:
static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
BGpic *bgpic;
Image *ima;
MovieClip *clip;
- ImBuf *ibuf= NULL, *freeibuf;
+ ImBuf *ibuf = NULL, *freeibuf;
float vec[4], fac, asp, zoomx, zoomy;
float x1, y1, x2, y2, cx, cy;
- for ( bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next ) {
+ for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
- if ( (bgpic->view == 0) || /* zero for any */
- (bgpic->view & (1<<rv3d->view)) || /* check agaist flags */
- (rv3d->persp==RV3D_CAMOB && bgpic->view == (1<<RV3D_VIEW_CAMERA))
- ) {
+ if ((bgpic->view == 0) || /* zero for any */
+ (bgpic->view & (1 << rv3d->view)) || /* check agaist flags */
+ (rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA)))
+ {
/* disable individual images */
- if ((bgpic->flag&V3D_BGPIC_DISABLED))
+ if ((bgpic->flag & V3D_BGPIC_DISABLED))
continue;
- freeibuf= NULL;
- if (bgpic->source==V3D_BGPIC_IMAGE) {
- ima= bgpic->ima;
- if (ima==NULL)
+ freeibuf = NULL;
+ if (bgpic->source == V3D_BGPIC_IMAGE) {
+ ima = bgpic->ima;
+ if (ima == NULL)
continue;
BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0);
- ibuf= BKE_image_get_ibuf(ima, &bgpic->iuser);
+ ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
}
else {
- clip= NULL;
+ clip = NULL;
- if (bgpic->flag&V3D_BGPIC_CAMERACLIP) {
+ if (bgpic->flag & V3D_BGPIC_CAMERACLIP) {
if (scene->camera)
- clip= object_get_movieclip(scene, scene->camera, 1);
+ clip = object_get_movieclip(scene, scene->camera, 1);
}
- else clip= bgpic->clip;
+ else clip = bgpic->clip;
- if (clip==NULL)
+ if (clip == NULL)
continue;
BKE_movieclip_user_set_frame(&bgpic->cuser, CFRA);
- ibuf= BKE_movieclip_get_ibuf(clip, &bgpic->cuser);
+ ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser);
/* working with ibuf from image and clip has got different workflow now.
* ibuf acquired from clip is referenced by cache system and should
* be dereferenced after usage. */
- freeibuf= ibuf;
+ freeibuf = ibuf;
}
- if (ibuf==NULL)
+ if (ibuf == NULL)
continue;
- if ((ibuf->rect==NULL && ibuf->rect_float==NULL) || ibuf->channels!=4) { /* invalid image format */
+ if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) { /* invalid image format */
if (freeibuf)
IMB_freeImBuf(freeibuf);
continue;
}
- if (ibuf->rect==NULL)
+ if (ibuf->rect == NULL)
IMB_rect_from_float(ibuf);
- if (rv3d->persp==RV3D_CAMOB) {
+ 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;
+ x1 = vb.xmin;
+ y1 = vb.ymin;
+ x2 = vb.xmax;
+ y2 = vb.ymax;
}
else {
float sco[2];
- const float mval_f[2]= {1.0f, 0.0f};
+ const float mval_f[2] = {1.0f, 0.0f};
/* calc window coord */
initgrabz(rv3d, 0.0, 0.0, 0.0);
ED_view3d_win_to_delta(ar, mval_f, vec);
- fac= maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */
- fac= 1.0f/fac;
+ fac = maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */
+ fac = 1.0f / fac;
- asp= ( (float)ibuf->y)/(float)ibuf->x;
+ asp = ( (float)ibuf->y) / (float)ibuf->x;
zero_v3(vec);
ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat);
cx = sco[0];
cy = sco[1];
- x1= cx+ fac*(bgpic->xof-bgpic->size);
- y1= cy+ asp*fac*(bgpic->yof-bgpic->size);
- x2= cx+ fac*(bgpic->xof+bgpic->size);
- y2= cy+ asp*fac*(bgpic->yof+bgpic->size);
+ x1 = cx + fac * (bgpic->xof - bgpic->size);
+ y1 = cy + asp * fac * (bgpic->yof - bgpic->size);
+ x2 = cx + fac * (bgpic->xof + bgpic->size);
+ y2 = cy + asp * fac * (bgpic->yof + bgpic->size);
}
/* complete clip? */
@@ -1619,29 +1620,29 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
continue;
}
- zoomx= (x2-x1)/ibuf->x;
- zoomy= (y2-y1)/ibuf->y;
+ zoomx = (x2 - x1) / ibuf->x;
+ zoomy = (y2 - y1) / ibuf->y;
/* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */
if (zoomx < 1.0f || zoomy < 1.0f) {
- float tzoom= MIN2(zoomx, zoomy);
- int mip= 0;
+ float tzoom = MIN2(zoomx, zoomy);
+ int mip = 0;
- if ((ibuf->userflags&IB_MIPMAP_INVALID) != 0) {
+ if ((ibuf->userflags & IB_MIPMAP_INVALID) != 0) {
IMB_remakemipmap(ibuf, 0);
- ibuf->userflags&= ~IB_MIPMAP_INVALID;
+ ibuf->userflags &= ~IB_MIPMAP_INVALID;
}
- else if (ibuf->mipmap[0]==NULL)
+ else if (ibuf->mipmap[0] == NULL)
IMB_makemipmap(ibuf, 0);
- while (tzoom < 1.0f && mip<8 && ibuf->mipmap[mip]) {
- tzoom*= 2.0f;
- zoomx*= 2.0f;
- zoomy*= 2.0f;
+ while (tzoom < 1.0f && mip < 8 && ibuf->mipmap[mip]) {
+ tzoom *= 2.0f;
+ zoomx *= 2.0f;
+ zoomy *= 2.0f;
mip++;
}
- if (mip>0)
- ibuf= ibuf->mipmap[mip-1];
+ if (mip > 0)
+ ibuf = ibuf->mipmap[mip - 1];
}
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
@@ -1657,7 +1658,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
ED_region_pixelspace(ar);
glPixelZoom(zoomx, zoomy);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f-bgpic->blend);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend);
glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
glPixelZoom(1.0, 1.0);
@@ -1690,10 +1691,10 @@ typedef struct View3DAfter {
/* temp storage of Objects that need to be drawn as last */
void add_view3d_after(ListBase *lb, Base *base, int flag)
{
- View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after");
+ View3DAfter *v3da = MEM_callocN(sizeof(View3DAfter), "View 3d after");
BLI_addtail(lb, v3da);
- v3da->base= base;
- v3da->flag= flag;
+ v3da->base = base;
+ v3da->flag = flag;
}
/* disables write in zbuffer and draws it over */
@@ -1702,15 +1703,15 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
View3DAfter *v3da, *next;
glDepthMask(0);
- v3d->transp= TRUE;
+ v3d->transp = TRUE;
- for (v3da= v3d->afterdraw_transp.first; v3da; v3da= next) {
- next= v3da->next;
+ for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
BLI_remlink(&v3d->afterdraw_transp, v3da);
MEM_freeN(v3da);
}
- v3d->transp= FALSE;
+ v3d->transp = FALSE;
glDepthMask(1);
@@ -1724,14 +1725,14 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
if (clear && v3d->zbuf)
glClear(GL_DEPTH_BUFFER_BIT);
- v3d->xray= TRUE;
- for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
- next= v3da->next;
+ v3d->xray = TRUE;
+ for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
BLI_remlink(&v3d->afterdraw_xray, v3da);
MEM_freeN(v3da);
}
- v3d->xray= FALSE;
+ v3d->xray = FALSE;
}
@@ -1743,18 +1744,18 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c
if (clear && v3d->zbuf)
glClear(GL_DEPTH_BUFFER_BIT);
- v3d->xray= TRUE;
- v3d->transp= TRUE;
+ v3d->xray = TRUE;
+ v3d->transp = TRUE;
- for (v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) {
- next= v3da->next;
+ for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
BLI_remlink(&v3d->afterdraw_xraytransp, v3da);
MEM_freeN(v3da);
}
- v3d->transp= FALSE;
- v3d->xray= FALSE;
+ v3d->transp = FALSE;
+ v3d->xray = FALSE;
}
@@ -1769,11 +1770,11 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int c
#if 0
int dupli_ob_sort(void *arg1, void *arg2)
{
- void *p1= ((DupliObject *)arg1)->ob;
- void *p2= ((DupliObject *)arg2)->ob;
+ void *p1 = ((DupliObject *)arg1)->ob;
+ void *p2 = ((DupliObject *)arg2)->ob;
int val = 0;
- if (p1 < p2) val = -1;
- else if (p1 > p2) val = 1;
+ if (p1 < p2) val = -1;
+ else if (p1 > p2) val = 1;
return val;
}
#endif
@@ -1782,40 +1783,40 @@ int dupli_ob_sort(void *arg1, void *arg2)
static DupliObject *dupli_step(DupliObject *dob)
{
while (dob && dob->no_draw)
- dob= dob->next;
+ dob = dob->next;
return dob;
}
static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int color)
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
ListBase *lb;
- DupliObject *dob_prev= NULL, *dob, *dob_next= NULL;
+ DupliObject *dob_prev = NULL, *dob, *dob_next = NULL;
Base tbase;
BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */
- GLuint displist=0;
- short transflag, use_displist= -1; /* -1 is initialize */
+ GLuint displist = 0;
+ short transflag, use_displist = -1; /* -1 is initialize */
char dt, dtx;
if (base->object->restrictflag & OB_RESTRICT_VIEW) return;
- tbase.flag= OB_FROMDUPLI|base->flag;
- lb= object_duplilist(scene, base->object);
+ tbase.flag = OB_FROMDUPLI | base->flag;
+ lb = object_duplilist(scene, base->object);
// BLI_sortlist(lb, dupli_ob_sort); // might be nice to have if we have a dupli list with mixed objects.
- dob=dupli_step(lb->first);
- if (dob) dob_next= dupli_step(dob->next);
+ dob = dupli_step(lb->first);
+ if (dob) dob_next = dupli_step(dob->next);
- for ( ; dob ; dob_prev= dob, dob= dob_next, dob_next= dob_next ? dupli_step(dob_next->next) : NULL) {
- tbase.object= dob->ob;
+ for (; dob; dob_prev = dob, dob = dob_next, dob_next = dob_next ? dupli_step(dob_next->next) : NULL) {
+ tbase.object = dob->ob;
/* extra service: draw the duplicator in drawtype of parent */
/* MIN2 for the drawtype to allow bounding box objects in groups for lods */
- dt= tbase.object->dt; tbase.object->dt= MIN2(tbase.object->dt, base->object->dt);
- dtx= tbase.object->dtx; tbase.object->dtx= base->object->dtx;
+ dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
+ dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx;
/* negative scale flag has to propagate */
- transflag= tbase.object->transflag;
+ transflag = tbase.object->transflag;
if (base->object->transflag & OB_NEG_SCALE)
tbase.object->transflag ^= OB_NEG_SCALE;
@@ -1823,10 +1824,10 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
/* generate displist, test for new object */
if (dob_prev && dob_prev->ob != dob->ob) {
- if (use_displist==1)
+ if (use_displist == 1)
glDeleteLists(displist, 1);
- use_displist= -1;
+ use_displist = -1;
}
/* generate displist */
@@ -1837,31 +1838,31 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
* offset feature (used in group-duplicate.blend but no longer works in 2.5)
* so for now it should be ok to - campbell */
- if ( /* if this is the last no need to make a displist */
- (dob_next==NULL || dob_next->ob != dob->ob) ||
- /* lamp drawing messes with matrices, could be handled smarter... but this works */
- (dob->ob->type == OB_LAMP) ||
- (dob->type == OB_DUPLIGROUP && dob->animated) ||
- !(bb_tmp= object_get_boundbox(dob->ob)))
+ if (/* if this is the last no need to make a displist */
+ (dob_next == NULL || dob_next->ob != dob->ob) ||
+ /* lamp drawing messes with matrices, could be handled smarter... but this works */
+ (dob->ob->type == OB_LAMP) ||
+ (dob->type == OB_DUPLIGROUP && dob->animated) ||
+ !(bb_tmp = object_get_boundbox(dob->ob)))
{
// printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2);
- use_displist= 0;
+ use_displist = 0;
}
else {
// printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name+2);
- bb= *bb_tmp; /* must make a copy */
+ bb = *bb_tmp; /* must make a copy */
/* disable boundbox check for list creation */
object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1);
/* need this for next part of code */
- unit_m4(dob->ob->obmat); /* obmat gets restored */
+ unit_m4(dob->ob->obmat); /* obmat gets restored */
- displist= glGenLists(1);
+ displist = glGenLists(1);
glNewList(displist, GL_COMPILE);
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
glEndList();
- use_displist= 1;
+ use_displist = 1;
object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0);
}
}
@@ -1876,14 +1877,14 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
}
- tbase.object->dt= dt;
- tbase.object->dtx= dtx;
- tbase.object->transflag= transflag;
+ tbase.object->dt = dt;
+ tbase.object->dtx = dtx;
+ tbase.object->transflag = transflag;
}
/* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */
- free_object_duplilist(lb); /* does restore */
+ free_object_duplilist(lb); /* does restore */
if (use_displist)
glDeleteLists(displist, 1);
@@ -1894,10 +1895,10 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas
/* 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;
+ 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;
+ if (base->object->dup_group && base->object->dup_group->id.us < 1)
+ color = TH_REDALERT;
draw_dupli_objects_color(scene, ar, v3d, base, color);
}
@@ -1909,80 +1910,82 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
/* clamp rect by area */
r.xmin = 0;
- r.xmax = ar->winx-1;
+ r.xmax = ar->winx - 1;
r.ymin = 0;
- r.ymax = ar->winy-1;
+ r.ymax = ar->winy - 1;
/* Constrain rect to depth bounds */
BLI_isect_rcti(&r, rect, rect);
/* assign values to compare with the ViewDepths */
- x= rect->xmin;
- y= rect->ymin;
+ x = rect->xmin;
+ y = rect->ymin;
- w= rect->xmax - rect->xmin;
- h= rect->ymax - rect->ymin;
+ w = rect->xmax - rect->xmin;
+ h = rect->ymax - rect->ymin;
if (w <= 0 || h <= 0) {
if (d->depths)
MEM_freeN(d->depths);
- d->depths= NULL;
+ d->depths = NULL;
- d->damaged= FALSE;
+ d->damaged = FALSE;
}
- else if ( d->w != w ||
- d->h != h ||
- d->x != x ||
- d->y != y ||
- d->depths==NULL
- ) {
- d->x= x;
- d->y= y;
- d->w= w;
- d->h= h;
+ else if (d->w != w ||
+ d->h != h ||
+ d->x != x ||
+ d->y != y ||
+ d->depths == NULL
+ )
+ {
+ d->x = x;
+ d->y = y;
+ d->w = w;
+ d->h = h;
if (d->depths)
MEM_freeN(d->depths);
- d->depths= MEM_mallocN(sizeof(float)*d->w*d->h,"View depths Subset");
+ d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset");
- d->damaged= TRUE;
+ d->damaged = TRUE;
}
if (d->damaged) {
- glReadPixels(ar->winrct.xmin+d->x,ar->winrct.ymin+d->y, d->w,d->h, GL_DEPTH_COMPONENT,GL_FLOAT, d->depths);
- glGetDoublev(GL_DEPTH_RANGE,d->depth_range);
- d->damaged= FALSE;
+ glReadPixels(ar->winrct.xmin + d->x, ar->winrct.ymin + d->y, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths);
+ glGetDoublev(GL_DEPTH_RANGE, d->depth_range);
+ d->damaged = FALSE;
}
}
/* note, with nouveau drivers the glReadPixels() is very slow. [#24339] */
void ED_view3d_depth_update(ARegion *ar)
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
/* Create storage for, and, if necessary, copy depth buffer */
- if (!rv3d->depths) rv3d->depths= MEM_callocN(sizeof(ViewDepths),"ViewDepths");
+ if (!rv3d->depths) rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths");
if (rv3d->depths) {
- ViewDepths *d= rv3d->depths;
+ ViewDepths *d = rv3d->depths;
if (d->w != ar->winx ||
- d->h != ar->winy ||
- !d->depths) {
- d->w= ar->winx;
- d->h= ar->winy;
+ d->h != ar->winy ||
+ !d->depths)
+ {
+ d->w = ar->winx;
+ d->h = ar->winy;
if (d->depths)
MEM_freeN(d->depths);
- d->depths= MEM_mallocN(sizeof(float)*d->w*d->h,"View depths");
- d->damaged= 1;
+ d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths");
+ d->damaged = 1;
}
if (d->damaged) {
- glReadPixels(ar->winrct.xmin,ar->winrct.ymin,d->w,d->h,
- GL_DEPTH_COMPONENT,GL_FLOAT, d->depths);
+ glReadPixels(ar->winrct.xmin, ar->winrct.ymin, d->w, d->h,
+ GL_DEPTH_COMPONENT, GL_FLOAT, d->depths);
- glGetDoublev(GL_DEPTH_RANGE,d->depth_range);
+ glGetDoublev(GL_DEPTH_RANGE, d->depth_range);
- d->damaged= 0;
+ d->damaged = 0;
}
}
}
@@ -1991,20 +1994,20 @@ void ED_view3d_depth_update(ARegion *ar)
float view3d_depth_near(ViewDepths *d)
{
/* convert to float for comparisons */
- const float near= (float)d->depth_range[0];
- const float far_real= (float)d->depth_range[1];
- float far= far_real;
+ const float near = (float)d->depth_range[0];
+ const float far_real = (float)d->depth_range[1];
+ float far = far_real;
- const float *depths= d->depths;
- float depth= FLT_MAX;
- int i= (int)d->w * (int)d->h; /* cast to avoid short overflow */
+ const float *depths = d->depths;
+ float depth = FLT_MAX;
+ int i = (int)d->w * (int)d->h; /* cast to avoid short overflow */
/* far is both the starting 'far' value
* and the closest value found. */
while (i--) {
- depth= *depths++;
+ depth = *depths++;
if ((depth < far) && (depth > near)) {
- far= depth;
+ far = depth;
}
}
@@ -2013,11 +2016,11 @@ float view3d_depth_near(ViewDepths *d)
void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
{
- short zbuf= v3d->zbuf;
- RegionView3D *rv3d= ar->regiondata;
+ short zbuf = v3d->zbuf;
+ RegionView3D *rv3d = ar->regiondata;
- setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
+ setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
+ setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
@@ -2027,32 +2030,32 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
glLoadMatrixf(rv3d->viewmat);
- v3d->zbuf= TRUE;
+ v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, 1);
- v3d->zbuf= zbuf;
+ v3d->zbuf = zbuf;
}
-void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
+void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *))
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
Base *base;
- short zbuf= v3d->zbuf;
- short flag= v3d->flag;
- float glalphaclip= U.glalphaclip;
- int obcenter_dia= U.obcenter_dia;
+ short zbuf = v3d->zbuf;
+ short flag = v3d->flag;
+ float glalphaclip = U.glalphaclip;
+ int obcenter_dia = U.obcenter_dia;
/* temp set drawtype to solid */
/* Setting these temporarily is not nice */
v3d->flag &= ~V3D_SELECT_OUTLINE;
U.glalphaclip = 0.5; /* not that nice but means we wont zoom into billboards */
- U.obcenter_dia= 0;
+ U.obcenter_dia = 0;
- setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
+ setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
+ setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
invert_m4_m4(rv3d->persinv, rv3d->persmat);
@@ -2067,7 +2070,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
ED_view3d_clipping_set(rv3d);
}
- v3d->zbuf= TRUE;
+ v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
/* draw set first */
@@ -2085,7 +2088,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
}
}
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (v3d->lay & base->lay) {
if (func == NULL || func(base)) {
/* dupli drawing */
@@ -2098,14 +2101,14 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
}
/* this isn't that nice, draw xray objects as if they are normal */
- if ( v3d->afterdraw_transp.first ||
- v3d->afterdraw_xray.first ||
- v3d->afterdraw_xraytransp.first
- ) {
+ if (v3d->afterdraw_transp.first ||
+ v3d->afterdraw_xray.first ||
+ v3d->afterdraw_xraytransp.first)
+ {
View3DAfter *v3da, *next;
int mask_orig;
- v3d->xray= TRUE;
+ v3d->xray = TRUE;
/* transp materials can change the depth mask, see #21388 */
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
@@ -2113,44 +2116,44 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) {
glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */
- for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
- next= v3da->next;
+ for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, 0);
}
glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */
}
/* draw 3 passes, transp/xray/xraytransp */
- v3d->xray= FALSE;
- v3d->transp= TRUE;
- for (v3da= v3d->afterdraw_transp.first; v3da; v3da= next) {
- next= v3da->next;
+ v3d->xray = FALSE;
+ v3d->transp = TRUE;
+ for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, 0);
BLI_remlink(&v3d->afterdraw_transp, v3da);
MEM_freeN(v3da);
}
- v3d->xray= TRUE;
- v3d->transp= FALSE;
- for (v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
- next= v3da->next;
+ v3d->xray = TRUE;
+ v3d->transp = FALSE;
+ for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, 0);
BLI_remlink(&v3d->afterdraw_xray, v3da);
MEM_freeN(v3da);
}
- v3d->xray= TRUE;
- v3d->transp= TRUE;
- for (v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) {
- next= v3da->next;
+ v3d->xray = TRUE;
+ v3d->transp = TRUE;
+ for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) {
+ next = v3da->next;
draw_object(scene, ar, v3d, v3da->base, 0);
BLI_remlink(&v3d->afterdraw_xraytransp, v3da);
MEM_freeN(v3da);
}
- v3d->xray= FALSE;
- v3d->transp= FALSE;
+ v3d->xray = FALSE;
+ v3d->transp = FALSE;
glDepthMask(mask_orig);
}
@@ -2163,7 +2166,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
U.glalphaclip = glalphaclip;
v3d->flag = flag;
- U.obcenter_dia= obcenter_dia;
+ U.obcenter_dia = obcenter_dia;
}
typedef struct View3DShadow {
@@ -2175,7 +2178,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object
float obmat[][4], ListBase *shadows)
{
GPULamp *lamp;
- Lamp *la = (Lamp*)ob->data;
+ Lamp *la = (Lamp *)ob->data;
View3DShadow *shadow;
lamp = GPU_lamp_from_blender(scene, ob, par);
@@ -2185,7 +2188,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object
GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
if ((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) {
- shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow");
+ shadow = MEM_callocN(sizeof(View3DShadow), "View3DShadow");
shadow->lamp = lamp;
BLI_addtail(shadows, shadow);
}
@@ -2200,11 +2203,11 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
Base *base;
Object *ob;
- shadows.first= shadows.last= NULL;
+ shadows.first = shadows.last = NULL;
/* update lamp transform and gather shadow lamps */
for (SETLOOPER(scene, sce_iter, base)) {
- ob= base->object;
+ ob = base->object;
if (ob->type == OB_LAMP)
gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows);
@@ -2213,8 +2216,8 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
DupliObject *dob;
ListBase *lb = object_duplilist(scene, ob);
- for (dob=lb->first; dob; dob=dob->next)
- if (dob->ob->type==OB_LAMP)
+ for (dob = lb->first; dob; dob = dob->next)
+ if (dob->ob->type == OB_LAMP)
gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows);
free_object_duplilist(lb);
@@ -2223,15 +2226,15 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
/* render shadows after updating all lamps, nested object_duplilist
* don't work correct since it's replacing object matrices */
- for (shadow=shadows.first; shadow; shadow=shadow->next) {
+ for (shadow = shadows.first; shadow; shadow = shadow->next) {
/* this needs to be done better .. */
float viewmat[4][4], winmat[4][4];
- int drawtype, lay, winsize, flag2=v3d->flag2;
- ARegion ar= {NULL};
- RegionView3D rv3d= {{{0}}};
+ int drawtype, lay, winsize, flag2 = v3d->flag2;
+ ARegion ar = {NULL};
+ RegionView3D rv3d = {{{0}}};
- drawtype= v3d->drawtype;
- lay= v3d->lay;
+ drawtype = v3d->drawtype;
+ lay = v3d->lay;
v3d->drawtype = OB_SOLID;
v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp);
@@ -2240,9 +2243,9 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat);
- ar.regiondata= &rv3d;
- ar.regiontype= RGN_TYPE_WINDOW;
- rv3d.persp= RV3D_CAMOB;
+ ar.regiondata = &rv3d;
+ ar.regiontype = RGN_TYPE_WINDOW;
+ rv3d.persp = RV3D_CAMOB;
copy_m4_m4(rv3d.winmat, winmat);
copy_m4_m4(rv3d.viewmat, viewmat);
invert_m4_m4(rv3d.viewinv, rv3d.viewmat);
@@ -2252,8 +2255,8 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
- v3d->drawtype= drawtype;
- v3d->lay= lay;
+ v3d->drawtype = drawtype;
+ v3d->lay = lay;
v3d->flag2 = flag2;
}
@@ -2264,10 +2267,10 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d)
{
- CustomDataMask mask= 0;
+ CustomDataMask mask = 0;
- if ( ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) ||
- ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX)))
+ if (ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) ||
+ ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX)))
{
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
@@ -2286,8 +2289,8 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d)
CustomDataMask ED_view3d_object_datamask(Scene *scene)
{
- Object *ob= scene->basact ? scene->basact->object : NULL;
- CustomDataMask mask= 0;
+ Object *ob = scene->basact ? scene->basact->object : NULL;
+ CustomDataMask mask = 0;
if (ob) {
/* check if we need tfaces & mcols due to face select or texture paint */
@@ -2311,7 +2314,7 @@ CustomDataMask ED_view3d_object_datamask(Scene *scene)
/* goes over all modes and view3d settings */
CustomDataMask ED_view3d_screen_datamask(bScreen *screen)
{
- Scene *scene= screen->scene;
+ Scene *scene = screen->scene;
CustomDataMask mask = CD_MASK_BAREMESH;
ScrArea *sa;
@@ -2335,13 +2338,13 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
if (winmat)
copy_m4_m4(rv3d->winmat, winmat);
else
- setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */
+ setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */
/* setup view matrix */
if (viewmat)
copy_m4_m4(rv3d->viewmat, viewmat);
else
- setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
+ setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
/* update utilitity matrices */
mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
@@ -2355,16 +2358,16 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view
float v1[3], v2[3];
float len1, len2;
- v1[0]= rv3d->persmat[0][0];
- v1[1]= rv3d->persmat[1][0];
- v1[2]= rv3d->persmat[2][0];
+ v1[0] = rv3d->persmat[0][0];
+ v1[1] = rv3d->persmat[1][0];
+ v1[2] = rv3d->persmat[2][0];
- v2[0]= rv3d->persmat[0][1];
- v2[1]= rv3d->persmat[1][1];
- v2[2]= rv3d->persmat[2][1];
+ v2[0] = rv3d->persmat[0][1];
+ v2[1] = rv3d->persmat[1][1];
+ v2[2] = rv3d->persmat[2][1];
- len1= 1.0f / len_v3(v1);
- len2= 1.0f / len_v3(v2);
+ len1 = 1.0f / len_v3(v1);
+ len2 = 1.0f / len_v3(v2);
rv3d->pixsize = (2.0f * MAX2(len1, len2)) / (float)MAX2(ar->winx, ar->winy);
}
@@ -2387,7 +2390,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
int winx, int winy, float viewmat[][4], float winmat[][4],
int draw_background)
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
Base *base;
float backcol[3];
int bwinx, bwiny;
@@ -2397,12 +2400,12 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
glPushMatrix();
/* set temporary new size */
- bwinx= ar->winx;
- bwiny= ar->winy;
- brect= ar->winrct;
+ bwinx = ar->winx;
+ bwiny = ar->winy;
+ brect = ar->winrct;
- ar->winx= winx;
- ar->winy= winy;
+ ar->winx = winx;
+ ar->winy = winy;
ar->winrct.xmin = 0;
ar->winrct.ymin = 0;
ar->winrct.xmax = winx;
@@ -2421,7 +2424,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
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) {
+ if (draw_background && scene->clip && rv3d->persp == RV3D_CAMOB && v3d->camera) {
MovieClipUser user = {0};
BKE_movieclip_user_set_frame(&user, CFRA);
@@ -2443,7 +2446,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
}
}
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (bg_ibuf) {
unsigned char *pixels, *cp, *dst_cp;
@@ -2452,9 +2455,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
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");
+ 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) {
+ 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];
@@ -2489,11 +2492,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* set zbuffer */
if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf= TRUE;
+ v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
}
else
- v3d->zbuf= FALSE;
+ v3d->zbuf = FALSE;
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_set(rv3d);
@@ -2504,7 +2507,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
for (SETLOOPER(scene->set, sce_iter, base)) {
if (v3d->lay & base->lay) {
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET);
+ draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET);
if (base->object->transflag & OB_DUPLI)
draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
@@ -2513,7 +2516,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
}
/* then draw not selected and the duplis, but skip editmode object */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (v3d->lay & base->lay) {
/* dupli drawing */
if (base->object->transflag & OB_DUPLI)
@@ -2529,16 +2532,16 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
/* transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
- if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
+ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
+ if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
+ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_disable();
/* cleanup */
if (v3d->zbuf) {
- v3d->zbuf= FALSE;
+ v3d->zbuf = FALSE;
glDisable(GL_DEPTH_TEST);
}
@@ -2552,8 +2555,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
GPU_free_images_anim();
/* restore size */
- ar->winx= bwinx;
- ar->winy= bwiny;
+ ar->winx = bwinx;
+ ar->winy = bwiny;
ar->winrct = brect;
glPopMatrix();
@@ -2568,7 +2571,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256])
{
- RegionView3D *rv3d= ar->regiondata;
+ RegionView3D *rv3d = ar->regiondata;
ImBuf *ibuf;
GPUOffScreen *ofs;
@@ -2576,14 +2579,14 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
glPushAttrib(GL_LIGHTING_BIT);
/* bind */
- ofs= GPU_offscreen_create(sizex, sizey, err_out);
+ ofs = GPU_offscreen_create(sizex, sizey, err_out);
if (ofs == NULL)
return NULL;
GPU_offscreen_bind(ofs);
/* render 3d view */
- if (rv3d->persp==RV3D_CAMOB && v3d->camera) {
+ if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
CameraParams params;
camera_params_init(&params);
@@ -2598,7 +2601,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
}
/* read in pixels & stamp */
- ibuf= IMB_allocImBuf(sizex, sizey, 32, flag);
+ ibuf = IMB_allocImBuf(sizex, sizey, 32, flag);
if (ibuf->rect_float)
GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float);
@@ -2624,21 +2627,21 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height,
unsigned int flag, int drawtype, int draw_background, char err_out[256])
{
- View3D v3d= {NULL};
- ARegion ar= {NULL};
- RegionView3D rv3d= {{{0}}};
+ View3D v3d = {NULL};
+ ARegion ar = {NULL};
+ RegionView3D rv3d = {{{0}}};
/* connect data */
- v3d.regionbase.first= v3d.regionbase.last= &ar;
- ar.regiondata= &rv3d;
- ar.regiontype= RGN_TYPE_WINDOW;
+ v3d.regionbase.first = v3d.regionbase.last = &ar;
+ ar.regiondata = &rv3d;
+ ar.regiontype = RGN_TYPE_WINDOW;
- v3d.camera= camera;
- v3d.lay= scene->lay;
+ v3d.camera = camera;
+ v3d.lay = scene->lay;
v3d.drawtype = drawtype;
v3d.flag2 = V3D_RENDER_OVERRIDE;
- rv3d.persp= RV3D_CAMOB;
+ rv3d.persp = RV3D_CAMOB;
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
normalize_m4(rv3d.viewinv);
@@ -2653,9 +2656,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
camera_params_compute_matrix(&params);
copy_m4_m4(rv3d.winmat, params.winmat);
- v3d.near= params.clipsta;
- v3d.far= params.clipend;
- v3d.lens= params.lens;
+ v3d.near = params.clipsta;
+ v3d.far = params.clipend;
+ v3d.lens = params.lens;
}
mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
@@ -2672,7 +2675,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
*/
static void draw_viewport_fps(Scene *scene, ARegion *ar)
{
- ScreenFrameRateInfo *fpsi= scene->fps_info;
+ ScreenFrameRateInfo *fpsi = scene->fps_info;
float fps;
char printable[16];
int i, tot;
@@ -2684,11 +2687,11 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
#if 0
/* this is too simple, better do an average */
- fps = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime))
+ fps = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime))
#else
- fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime));
+ fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime));
- for (i=0, tot=0, fps=0.0f ; i < REDRAW_FRAME_AVERAGE ; i++) {
+ for (i = 0, tot = 0, fps = 0.0f; i < REDRAW_FRAME_AVERAGE; i++) {
if (fpsi->redrawtimes_fps[i]) {
fps += fpsi->redrawtimes_fps[i];
tot++;
@@ -2705,44 +2708,44 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
}
#endif
- /* is this more then half a frame behind? */
- if (fps+0.5f < (float)(FPS)) {
+ /* is this more then half a frame behind? */
+ if (fps + 0.5f < (float)(FPS)) {
UI_ThemeColor(TH_REDALERT);
BLI_snprintf(printable, sizeof(printable), "fps: %.2f", fps);
}
else {
UI_ThemeColor(TH_TEXT_HI);
- BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f));
+ BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps + 0.5f));
}
- BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable));
+ 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)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
RenderEngineType *type;
if (!rv3d->render_engine) {
- type= RE_engines_find(scene->r.engine);
+ type = RE_engines_find(scene->r.engine);
if (!(type->view_update && type->view_draw))
return 0;
- rv3d->render_engine= RE_engine_create(type);
+ rv3d->render_engine = RE_engine_create(type);
type->view_update(rv3d->render_engine, C);
}
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ED_region_pixelspace(ar);
- type= rv3d->render_engine->type;
+ type = rv3d->render_engine->type;
type->view_draw(rv3d->render_engine, C);
return 1;
@@ -2759,9 +2762,9 @@ static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar)
/* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */
static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
Base *base;
float backcol[3];
unsigned int lay_used;
@@ -2787,7 +2790,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
else
UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
@@ -2799,11 +2802,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
/* set zbuffer after we draw clipping region */
if (v3d->drawtype > OB_WIRE) {
- v3d->zbuf= TRUE;
+ v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
}
else
- v3d->zbuf= FALSE;
+ v3d->zbuf = FALSE;
/* enables anti-aliasing for 3D view drawing */
#if 0
@@ -2812,26 +2815,26 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
#endif
// needs to be done always, gridview is adjusted in drawgrid() now
- rv3d->gridview= v3d->grid;
+ rv3d->gridview = v3d->grid;
if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
drawfloor(scene, v3d, grid_unit);
}
- if (rv3d->persp==RV3D_CAMOB) {
+ if (rv3d->persp == RV3D_CAMOB) {
if (scene->world) {
if (scene->world->mode & WO_STARS) {
RE_make_stars(NULL, scene, star_stuff_init_func, star_stuff_vertex_func,
- star_stuff_term_func);
+ star_stuff_term_func);
}
}
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
if (v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d);
}
}
}
else {
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
ED_region_pixelspace(ar);
drawgrid(&scene->unit, ar, v3d, grid_unit);
/* XXX make function? replaces persp(1) */
@@ -2857,7 +2860,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
if (v3d->lay & base->lay) {
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
- draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET);
+ draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET);
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
@@ -2868,11 +2871,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
/* Transp and X-ray afterdraw stuff for sets is done later */
}
- lay_used= 0;
+ lay_used = 0;
/* then draw not selected and the duplis, but skip editmode object */
- for (base= scene->base.first; base; base= base->next) {
- lay_used |= base->lay & ((1<<20)-1);
+ for (base = scene->base.first; base; base = base->next) {
+ lay_used |= base->lay & ((1 << 20) - 1);
if (v3d->lay & base->lay) {
@@ -2880,8 +2883,8 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects(scene, ar, v3d, base);
}
- if ((base->flag & SELECT)==0) {
- if (base->object!=scene->obedit)
+ if ((base->flag & SELECT) == 0) {
+ if (base->object != scene->obedit)
draw_object(scene, ar, v3d, base, 0);
}
}
@@ -2889,23 +2892,23 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
/* find header and force tag redraw */
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar_header= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
ED_region_tag_redraw(ar_header); /* can be NULL */
- v3d->lay_used= lay_used;
+ v3d->lay_used = lay_used;
}
/* draw selected and editmode */
- for (base= scene->base.first; base; base= base->next) {
+ for (base = scene->base.first; base; base = base->next) {
if (v3d->lay & base->lay) {
- if (base->object==scene->obedit || ( base->flag & SELECT) )
+ if (base->object == scene->obedit || (base->flag & SELECT) )
draw_object(scene, ar, v3d, base, 0);
}
}
// REEB_draw();
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
/* must be before xray draw which clears the depth buffer */
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, 1);
@@ -2913,9 +2916,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
}
/* Transp and X-ray afterdraw stuff */
- if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
- if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
- if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
+ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
+ if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
+ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
@@ -2931,11 +2934,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
#endif
if (v3d->zbuf) {
- v3d->zbuf= FALSE;
+ v3d->zbuf = FALSE;
glDisable(GL_DEPTH_TEST);
}
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
BDR_drawSketch(C);
}
@@ -2947,20 +2950,20 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const char *grid_unit)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
- bScreen *screen= CTX_wm_screen(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ bScreen *screen = CTX_wm_screen(C);
Object *ob;
- if (rv3d->persp==RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB)
drawviewborder(scene, ar, v3d);
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
- // if (v3d->flag2 & V3D_DISPGP)
- draw_gpencil_view3d(scene, v3d, ar, 0);
+ // if (v3d->flag2 & V3D_DISPGP)
+ draw_gpencil_view3d(scene, v3d, ar, 0);
drawcursor(scene, ar, v3d);
}
@@ -2970,7 +2973,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
else
draw_view_icon(rv3d);
- ob= OBACT;
+ ob = OBACT;
if (U.uiflag & USER_DRAWVIEWINFO)
draw_selected_name(scene, ob);
@@ -2987,14 +2990,14 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
}
if (grid_unit) { /* draw below the viewport name */
- char numstr[32]= "";
+ char numstr[32] = "";
UI_ThemeColor(TH_TEXT_HI);
if (v3d->grid != 1.0f) {
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
}
- BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f,
+ BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f,
numstr[0] ? numstr : grid_unit, sizeof(numstr));
}
}
@@ -3002,7 +3005,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
void view3d_main_area_draw(const bContext *C, ARegion *ar)
{
View3D *v3d = CTX_wm_view3d(C);
- const char *grid_unit= NULL;
+ const char *grid_unit = NULL;
/* draw viewport using external renderer? */
if (!(v3d->drawtype == OB_RENDER && view3d_main_area_draw_engine(C, ar))) {