if (font->flags & BLF_ROTATION)
glRotatef(font->angle, 0.0f, 0.0f, 1.0f);
+
+ if(font->shadow || font->blur)
+ glGetFloatv(GL_CURRENT_COLOR, font->orig_col);
+
+ /* always bind the texture for the first glyph */
+ font->tex_bind_state= -1;
+
}
static void blf_draw__end(void)
memset((void *)buf, 0, tot_mem);
glGenTextures(1, &gc->textures[gc->cur_tex]);
- glBindTexture(GL_TEXTURE_2D, gc->textures[gc->cur_tex]);
+ glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= gc->textures[gc->cur_tex]));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
-static void blf_texture5_draw(float uv[2][2], float x1, float y1, float x2, float y2)
+static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
- float soft[25]= {
- 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f,
- 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
- 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f,
- 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
- 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f};
+ float soft[25]= {1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f,
+ 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
+ 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f,
+ 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
+ 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f};
float color[4], *fp= soft;
int dx, dy;
-
- glGetFloatv(GL_CURRENT_COLOR, color);
+
+ color[0]= shadow_col[0];
+ color[1]= shadow_col[1];
+ color[2]= shadow_col[2];
for(dx=-2; dx<3; dx++) {
for(dy=-2; dy<3; dy++, fp++) {
- glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
+ color[3]= *(fp) * shadow_col[3];
+ glColor4fv(color);
blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
}
}
glColor4fv(color);
}
-static void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2, float y2)
+static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
- float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
+ float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f,
+ 2/16.0f,4/16.0f, 2/16.0f,
+ 1/16.0f, 2/16.0f, 1/16.0f};
+
float color[4], *fp= soft;
int dx, dy;
-
- glGetFloatv(GL_CURRENT_COLOR, color);
-
+
+ color[0]= shadow_col[0];
+ color[1]= shadow_col[1];
+ color[2]= shadow_col[2];
+
for(dx=-1; dx<2; dx++) {
for(dy=-1; dy<2; dy++, fp++) {
- glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
+ color[3]= *(fp) * shadow_col[3];
+ glColor4fv(color);
blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
}
}
int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
{
- GlyphCacheBLF *gc;
- GLint cur_tex;
float dx, dx1;
float y1, y2;
float xo, yo;
- float color[4];
if ((!g->width) || (!g->height))
return(1);
if (g->build_tex == 0) {
- gc= font->glyph_cache;
+ GlyphCacheBLF *gc= font->glyph_cache;
if (font->max_tex_size == -1)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
return(0);
}
- glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex);
- if (cur_tex != g->tex)
- glBindTexture(GL_TEXTURE_2D, g->tex);
+ if (font->tex_bind_state != g->tex) {
+ glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= g->tex));
+ }
if (font->flags & BLF_SHADOW) {
- glGetFloatv(GL_CURRENT_COLOR, color);
- glColor4fv(font->shadow_col);
-
- if (font->shadow == 3)
- blf_texture3_draw(g->uv, dx, y1, dx1, y2);
- else if (font->shadow == 5)
- blf_texture5_draw(g->uv, dx, y1, dx1, y2);
- else
- blf_texture_draw(g->uv, dx, y1, dx1, y2);
- glColor4fv(color);
+ switch(font->shadow) {
+ case 3:
+ blf_texture3_draw(font->shadow_col, g->uv, dx, y1, dx1, y2);
+ break;
+ case 5:
+ blf_texture5_draw(font->shadow_col, g->uv, dx, y1, dx1, y2);
+ break;
+ default:
+ glColor4fv(font->shadow_col);
+ blf_texture_draw(g->uv, dx, y1, dx1, y2);
+ break;
+ }
+
+ glColor4fv(font->orig_col);
+
x= xo;
y= yo;
y2= y + g->pos_y - g->height;
}
- if (font->blur==3)
- blf_texture3_draw(g->uv, dx, y1, dx1, y2);
- else if (font->blur==5)
- blf_texture5_draw(g->uv, dx, y1, dx1, y2);
- else
- blf_texture_draw(g->uv, dx, y1, dx1, y2);
+ switch(font->blur) {
+ case 3:
+ blf_texture3_draw(font->orig_col, g->uv, dx, y1, dx1, y2);
+ break;
+ case 5:
+ blf_texture5_draw(font->orig_col, g->uv, dx, y1, dx1, y2);
+ break;
+ default:
+ blf_texture_draw(g->uv, dx, y1, dx1, y2);
+ break;
+ }
return(1);
}
/* shadow color. */
float shadow_col[4];
-
+
+ /* store color here when drawing shadow or blur. */
+ float orig_col[4];
+
/* Multiplied this matrix with the current one before
* draw the text! see blf_draw__start.
*/
/* max texture size. */
int max_tex_size;
+ /* current opengl texture bind, avoids calling glGet */
+ int tex_bind_state;
+
/* font options. */
int flags;
if (data->type < 10) {
/* extract rotation (is in whatever space target should be in) */
mat4_to_eul(vec, tempmat);
- mul_v3_fl(vec, (float)(180.0/M_PI)); /* rad -> deg */
+ mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */
axis= data->type;
}
else if (data->type < 20) {
break;
case 1: /* rotation (convert to degrees first) */
mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
- mul_v3_fl(dvec, (float)(180.0/M_PI)); /* rad -> deg */
+ mul_v3_fl(dvec, RAD2DEGF(1.0f)); /* rad -> deg */
break;
default: /* location */
copy_v3_v3(dvec, ct->matrix[3]);
/* flip rotation if needs be */
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
- if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90.0f/(float)(180.0/M_PI))
+ if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f))
angle = -angle;
bevp2= (BevPoint *)(bl+1);
if(falloff == 0.0f)
break;
- r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI;
+ r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point)));
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
normalize_v3(v1);
normalize_v3(v2);
- d = saacos(dot_v3v3(v1, v2)) * 180.0f/(float)M_PI;
+ d = RAD2DEGF(saacos(dot_v3v3(v1, v2)));
}
if(p_max > p_min)
ar->v2d.tab_offset= NULL;
}
- if(ar)
- BLI_freelistN(&ar->panels);
+ BLI_freelistN(&ar->panels);
}
/* not area itself */
}
// Rotate
- rotate_radians = ((float)M_PI*transform->rotIni)/180.0f;
+ rotate_radians = DEG2RADF(transform->rotIni);
transform_image(x,y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation);
}
#define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) )
/* all input coordinates must be in bounding box 0.0 - 1.0 */
-float voxel_sample_nearest(float *data, int *res, float *co);
-float voxel_sample_trilinear(float *data, int *res, float *co);
-float voxel_sample_triquadratic(float *data, int *res, float *co);
-float voxel_sample_tricubic(float *data, int *res, float *co, int bspline);
+float voxel_sample_nearest(float *data, const int res[3], const float co[3]);
+float voxel_sample_trilinear(float *data, const int res[3], const float co[3]);
+float voxel_sample_triquadratic(float *data, const int res[3], const float co[3]);
+float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline);
#endif /* BLI_VOXEL_H */
-BM_INLINE float D(float *data, int *res, int x, int y, int z)
+BM_INLINE float D(float *data, const int res[3], int x, int y, int z)
{
CLAMP(x, 0, res[0]-1);
CLAMP(y, 0, res[1]-1);
/* *** nearest neighbour *** */
/* input coordinates must be in bounding box 0.0 - 1.0 */
-float voxel_sample_nearest(float *data, int *res, float *co)
+float voxel_sample_nearest(float *data, const int res[3], const float co[3])
{
int xi, yi, zi;
return (a < b) ? b : ((a > c) ? c : a);
}
-float voxel_sample_trilinear(float *data, int *res, float *co)
+float voxel_sample_trilinear(float *data, const int res[3], const float co[3])
{
if (data) {
}
-float voxel_sample_triquadratic(float *data, int *res, float *co)
+float voxel_sample_triquadratic(float *data, const int res[3], const float co[3])
{
if (data) {
return 0.f;
}
-float voxel_sample_tricubic(float *data, int *res, float *co, int bspline)
+float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline)
{
if (data) {
ntreetype->foreach_nodetree(main, NULL, lib_nodetree_init_types_cb);
}
for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
- ntreeInitTypes(ntree);
+ lib_nodetree_init_types_cb(NULL, NULL, ntree);
{
int has_old_groups=0;
case COLLADASW::InputSemantic::OUTPUT:
*length = 1;
if (rotation) {
- values[0] = (bezt->vec[1][1]) * 180.0f/M_PI;
+ values[0] = RAD2DEGF(bezt->vec[1][1]);
}
else {
values[0] = bezt->vec[1][1];
values[1] = 0;
}
else if (rotation) {
- values[1] = (bezt->vec[0][1]) * 180.0f/M_PI;
+ values[1] = RAD2DEGF(bezt->vec[0][1]);
} else {
values[1] = bezt->vec[0][1];
}
values[1] = 0;
}
else if (rotation) {
- values[1] = (bezt->vec[2][1]) * 180.0f/M_PI;
+ values[1] = RAD2DEGF(bezt->vec[2][1]);
} else {
values[1] = bezt->vec[2][1];
}
// val = convert_time(val);
//else
if (is_rot)
- val *= 180.0f / M_PI;
+ val = RAD2DEGF(val);
source.appendValues(val);
}
{
for (unsigned int i = 0; i < cu->totvert; i++) {
// TODO convert handles too
- cu->bezt[i].vec[1][1] *= M_PI / 180.0f;
- cu->bezt[i].vec[0][1] *= M_PI / 180.0f;
- cu->bezt[i].vec[2][1] *= M_PI / 180.0f;
+ cu->bezt[i].vec[1][1] *= DEG2RADF(1.0f);
+ cu->bezt[i].vec[0][1] *= DEG2RADF(1.0f);
+ cu->bezt[i].vec[2][1] *= DEG2RADF(1.0f);
}
}
mat4_to_quat(rot, mat);
/*for ( int i = 0 ; i < 4 ; i ++ )
{
- rot[i] = rot[i] * (180 / M_PI);
+ rot[i] = RAD2DEGF(rot[i]);
}*/
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
if (cam->type == CAM_PERSP) {
COLLADASW::PerspectiveOptic persp(mSW);
- persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI),"xfov");
+ persp.setXFov(RAD2DEGF(lens_to_angle(cam->lens)), "xfov");
persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,"aspect_ratio");
persp.setZFar(cam->clipend, false , "zfar");
persp.setZNear(cam->clipsta,false , "znear");
double aspect = camera->getAspectRatio().getValue();
double xfov = aspect*yfov;
// xfov is in degrees, cam->lens is in millimiters
- cam->lens = angle_to_lens((float)xfov*(M_PI/180.0f));
+ cam->lens = angle_to_lens(DEG2RADF(xfov));;
}
break;
}
{
double x = camera->getXFov().getValue();
// x is in degrees, cam->lens is in millimiters
- cam->lens = angle_to_lens((float)x*(M_PI/180.0f));
+ cam->lens = angle_to_lens(DEG2RADF(x));
}
break;
}
{
double yfov = camera->getYFov().getValue();
// yfov is in degrees, cam->lens is in millimiters
- cam->lens = angle_to_lens((float)yfov*(M_PI/180.0f));
+ cam->lens = angle_to_lens(DEG2RADF(yfov));
}
break;
}
{
COLLADAFW::Rotate *ro = (COLLADAFW::Rotate*)tm;
COLLADABU::Math::Vector3& axis = ro->getRotationAxis();
- float angle = (float)(ro->getRotationAngle() * M_PI / 180.0f);
- float ax[] = {axis[0], axis[1], axis[2]};
+ const float angle = (float)DEG2RAD(ro->getRotationAngle());
+ const float ax[] = {axis[0], axis[1], axis[2]};
// float quat[4];
// axis_angle_to_quat(quat, axis, angle);
// quat_to_mat4(m, quat);
/*node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2]));
node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1]));
node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));*/
- node.addRotateZ("rotationZ", rot[2] * 180.0f/M_PI);
- node.addRotateY("rotationY", (rot[1]* 180.0f/M_PI));
- node.addRotateX("rotationX", (rot[0]* 180.0f/M_PI));
+ node.addRotateZ("rotationZ", RAD2DEGF(rot[2]));
+ node.addRotateY("rotationY", RAD2DEGF(rot[1]));
+ node.addRotateX("rotationX", RAD2DEGF(rot[0]));
node.addScale("scale", scale[0], scale[1], scale[2]);
}
/* if the radians flag is not set, default to using degrees which need conversions */
if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) {
if (restore)
- return M_PI / 180.0; /* degrees to radians */
+ return DEG2RADF(1.0f); /* degrees to radians */
else
- return 180.0 / M_PI; /* radians to degrees */
+ return RAD2DEGF(1.0f); /* radians to degrees */
}
}
print_m4("premat", premat);
print_m4("postmat", postmat);
print_m4("difmat", difmat);
- printf ("Roll = %f\n", (-atan2(difmat[2][0], difmat[2][2]) * (180.0/M_PI)));
+ printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
#endif
curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]);
return center + diam * ampli * sinf(angle);
}
-static void vectorscope_draw_target(float centerx, float centery, float diam, float r, float g, float b)
+static void vectorscope_draw_target(float centerx, float centery, float diam, const float colf[3])
{
float y,u,v;
float tangle=0.f, tampli;
float dangle, dampli, dangle2, dampli2;
- rgb_to_yuv(r,g,b, &y, &u, &v);
+ rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v);
if (u>0 && v>=0) tangle=atanf(v/u);
else if (u>0 && v<0) tangle= atanf(v/u) + 2.0f * (float)M_PI;
else if (u<0) tangle=atanf(v/u) + (float)M_PI;
/* small target vary by 2.5 degree and 2.5 IRE unit */
glColor4f(1.0f, 1.0f, 1.0, 0.12f);
- dangle= 2.5f*(float)M_PI/180.0f;
+ dangle= DEG2RADF(2.5f);
dampli= 2.5f/200.0f;
glBegin(GL_LINE_STRIP);
glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
glEnd();
/* big target vary by 10 degree and 20% amplitude */
glColor4f(1.0f, 1.0f, 1.0, 0.12f);
- dangle= 10.0f*(float)M_PI/180.0f;
+ dangle= DEG2RADF(10.0f);
dampli= 0.2f*tampli;
- dangle2= 5.0f*(float)M_PI/180.0f;
+ dangle2= DEG2RADF(5.0f);
dampli2= 0.5f*dampli;
glBegin(GL_LINE_STRIP);
glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle));
void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
+ const float skin_rad= DEG2RADF(123.0f); /* angle in radians of the skin tone line */
Scopes *scopes = (Scopes *)but->poin;
rctf rect;
int i, j;
- int skina= 123; /* angle in degree of the skin tone line */
float w, h, centerx, centery, diam;
float alpha;
- float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}};
+ const float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}};
GLint scissor[4];
rect.xmin = (float)recti->xmin+1;
for(j=0; j<5; j++) {
glBegin(GL_LINE_STRIP);
for(i=0; i<=360; i=i+15) {
- float a= i*M_PI/180.0;
- float r= (j+1)/10.0f;
- glVertex2f( polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a));
+ const float a= DEG2RADF((float)i);
+ const float r= (j+1)/10.0f;
+ glVertex2f(polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a));
}
glEnd();
}
/* skin tone line */
glColor4f(1.f, 0.4f, 0.f, 0.2f);
- fdrawline( polar_to_x(centerx, diam, 0.5f, skina*M_PI/180.0), polar_to_y(centery,diam,0.5,skina*M_PI/180.0),
- polar_to_x(centerx, diam, 0.1f, skina*M_PI/180.0), polar_to_y(centery,diam,0.1,skina*M_PI/180.0));
+ fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery,diam,0.5,skin_rad),
+ polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery,diam,0.1,skin_rad));
/* saturation points */
for(i=0; i<6; i++)
- vectorscope_draw_target(centerx, centery, diam, colors[i][0], colors[i][1], colors[i][2]);
+ vectorscope_draw_target(centerx, centery, diam, colors[i]);
if (scopes->ok && scopes->vecscope != NULL) {
/* pixel point cloud */
* 1 : occluded
2 : occluded with w[3] weights set (need to know in some cases) */
-static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], float v3[3], float w[3], int is_ortho)
+static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho)
{
/* if all are behind us, return false */
if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])
if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
/* brush rotation */
glTranslatef(0.5, 0.5, 0);
- glRotatef((double)((brush->flag & BRUSH_RAKE) ?
- sd->last_angle : sd->special_rotation) * (180.0/M_PI),
- 0.0, 0.0, 1.0);
+ glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
+ sd->last_angle : sd->special_rotation),
+ 0.0, 0.0, 1.0);
glTranslatef(-0.5f, -0.5f, 0);
/* scale based on tablet pressure */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
- RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merking pasted keys and existing");
+ RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
}
/* ******************** Insert Keyframes Operator ************************* */
/* identifiers */
ot->name = "Select Linked";
ot->idname= "ACTION_OT_select_linked";
- ot->description = "Select keyframes occurring the same F-Curves as selected ones";
+ ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
/* api callbacks */
ot->exec= actkeys_select_linked_exec;
ot->poll= ED_operator_console_active;
/* properties */
- RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "reverse cycle history");
+ RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history");
}
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
- RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merking pasted keys and existing");
+ RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
}
/* ******************** Duplicate Keyframes Operator ************************* */
/* identifiers */
ot->name = "Select Linked";
ot->idname= "GRAPH_OT_select_linked";
- ot->description = "Select keyframes occurring the same F-Curves as selected ones";
+ ot->description = "Select keyframes occurring in the same F-Curves as selected ones";
/* api callbacks */
ot->exec= graphkeys_select_linked_exec;
/* ----------------- OpenGL Circle Drawing - Tables for Optimised Drawing Speed ------------------ */
/* 32 values of sin function (still same result!) */
-static float sinval[32] = {
+#define CIRCLE_RESOL 32
+
+static const float sinval[CIRCLE_RESOL] = {
0.00000000,
0.20129852,
0.39435585,
};
/* 32 values of cos function (still same result!) */
-static float cosval[32] ={
+static const float cosval[CIRCLE_RESOL] = {
1.00000000,
0.97952994,
0.91895781,
glPopMatrix();
}
-void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
+static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4])
{
- float vec[3], vx[3], vy[3];
- int a, tot=32;
+ float vx[3], vy[3];
+ float *viter= (float *)verts;
+ unsigned int a;
mul_v3_v3fl(vx, tmat[0], rad);
mul_v3_v3fl(vy, tmat[1], rad);
- glBegin(mode);
- for(a=0; a<tot; a++) {
- vec[0]= cent[0] + *(sinval+a) * vx[0] + *(cosval+a) * vy[0];
- vec[1]= cent[1] + *(sinval+a) * vx[1] + *(cosval+a) * vy[1];
- vec[2]= cent[2] + *(sinval+a) * vx[2] + *(cosval+a) * vy[2];
- glVertex3fv(vec);
+ for (a=0; a < CIRCLE_RESOL; a++, viter += 3) {
+ viter[0]= cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
+ viter[1]= cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
+ viter[2]= cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
}
- glEnd();
+}
+
+void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
+{
+ float verts[CIRCLE_RESOL][3];
+
+ circball_array_fill(verts, cent, rad, tmat);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, verts);
+ glDrawArrays(mode, 0, CIRCLE_RESOL);
+ glDisableClientState(GL_VERTEX_ARRAY);
}
/* circle for object centers, special_color is for library or ob users */
static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, int special_color)
{
const float size= ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f;
+ float verts[CIRCLE_RESOL][3];
/* using gldepthfunc guarantees that it does write z values, but not checks for it, so centers remain visible independt order of drawing */
if(v3d->zbuf) glDepthFunc(GL_ALWAYS);
else if (selstate == SELECT) UI_ThemeColorShadeAlpha(TH_SELECT, 0, -80);
else if (selstate == DESELECT) UI_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
}
- drawcircball(GL_POLYGON, co, size, rv3d->viewinv);
-
+
+ circball_array_fill(verts, co, size, rv3d->viewinv);
+
+ /* enable vertex array */
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, verts);
+
+ /* 1. draw filled, blended polygon */
+ glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL);
+
+ /* 2. draw outline */
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
- drawcircball(GL_LINE_LOOP, co, size, rv3d->viewinv);
-
+ glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL);
+
+ /* finishe up */
+ glDisableClientState(GL_VERTEX_ARRAY);
+
glDisable(GL_BLEND);
+
if(v3d->zbuf) glDepthFunc(GL_LEQUAL);
}
{
BezTriple *bezt;
float *fp;
- int basecol;
int a;
-
+
if(nu->hide || hide_handles) return;
glBegin(GL_LINES);
-
+
if(nu->type == CU_BEZIER) {
- if(sel) basecol= TH_HANDLE_SEL_FREE;
- else basecol= TH_HANDLE_FREE;
+
+#define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1)
+ /* use MIN2 when indexing to ensure newer files dont read outside the array */
+ unsigned char handle_cols[TH_HANDLE_COL_TOT][3];
+ const int basecol= sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
+
+ for (a=0; a < TH_HANDLE_COL_TOT; a++) {
+ UI_GetThemeColor3ubv(basecol + a, handle_cols[a]);
+ }
bezt= nu->bezt;
a= nu->pntsu;
if( (bezt->f2 & SELECT)==sel) {
fp= bezt->vec[0];
- UI_ThemeColor(basecol + bezt->h1);
+ glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
glVertex3fv(fp);
glVertex3fv(fp+3);
- UI_ThemeColor(basecol + bezt->h2);
+ glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
glVertex3fv(fp+3);
glVertex3fv(fp+6);
}
else if( (bezt->f1 & SELECT)==sel) {
fp= bezt->vec[0];
- UI_ThemeColor(basecol + bezt->h1);
+ glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]);
glVertex3fv(fp);
glVertex3fv(fp+3);
}
else if( (bezt->f3 & SELECT)==sel) {
fp= bezt->vec[1];
- UI_ThemeColor(basecol + bezt->h2);
+ glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]);
glVertex3fv(fp);
glVertex3fv(fp+3);
}
}
bezt++;
}
+
+#undef TH_HANDLE_COL_TOT
+
}
glEnd();
}
static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
{
float vec[3], vx[3], vy[3];
- const int tot=32;
- const float tot_inv= (1.0f / 32.0f);
+ const float tot_inv= (1.0f / (float)CIRCLE_RESOL);
int a;
char inverse= FALSE;
copy_v3_v3(vec, cent);
if (inverse==0) {
- for(a=0; a<tot; a++) {
+ for(a=0; a<CIRCLE_RESOL; a++) {
if (a+start>31)
start=-a + 1;
glBegin(GL_LINES);
glVertex3fv(vec);
- vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a * tot_inv) + *(cosval+a+start) * (vy[0] * (float)a * tot_inv);
- vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a * tot_inv) + *(cosval+a+start) * (vy[1] * (float)a * tot_inv);
- vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a * tot_inv) + *(cosval+a+start) * (vy[2] * (float)a * tot_inv);
+ vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)a * tot_inv) + cosval[a+start] * (vy[0] * (float)a * tot_inv);
+ vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)a * tot_inv) + cosval[a+start] * (vy[1] * (float)a * tot_inv);
+ vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)a * tot_inv) + cosval[a+start] * (vy[2] * (float)a * tot_inv);
glVertex3fv(vec);
glEnd();
}
}
else {
a=0;
- vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
- vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
- vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
- for(a=0; a<tot; a++) {
+ vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+ vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+ vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
+ for(a=0; a<CIRCLE_RESOL; a++) {
if (a+start>31)
start=-a + 1;
glBegin(GL_LINES);
glVertex3fv(vec);
- vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
- vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
- vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
+ vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+ vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+ vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
glVertex3fv(vec);
glEnd();
}
glBegin(GL_LINE_LOOP);
/* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */
- for (degrees=0; degrees<32; degrees++) {
- x= *(cosval + degrees);
- y= *(sinval + degrees);
+ for (degrees=0; degrees<CIRCLE_RESOL; degrees++) {
+ x= cosval[degrees];
+ y= sinval[degrees];
glVertex3f(x*size, 0.0f, y*size);
}
unit_m4(tmat);
- radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f;
- radius*=(float)M_PI/180.0f;
+ radius= DEG2RADF((pd->flag&PFIELD_USEMAXR) ? pd->maxrad : 1.0f);
distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f;
if(pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)){
drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat);
}
- radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f;
- radius*=(float)M_PI/180.0f;
+ radius= DEG2RADF((pd->flag&PFIELD_USEMINR) ? pd->minrad : 1.0f);
distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f;
if(pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)){
quat_to_eul( tfp->ob_eul,pchan->quat);
else
copy_v3_v3(tfp->ob_eul, pchan->eul);
- tfp->ob_eul[0]*= 180.0/M_PI;
- tfp->ob_eul[1]*= 180.0/M_PI;
- tfp->ob_eul[2]*= 180.0/M_PI;
+ tfp->ob_eul[0]*= RAD2DEGF(1.0f);
+ tfp->ob_eul[1]*= RAD2DEGF(1.0f);
+ tfp->ob_eul[2]*= RAD2DEGF(1.0f);
uiDefBut(block, LABEL, 0, "Location:", 0, 240, 100, 20, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
if (!pchan) return;
/* make a copy to eul[3], to allow TAB on buttons to work */
- eul[0]= (float)M_PI*tfp->ob_eul[0]/180.0f;
- eul[1]= (float)M_PI*tfp->ob_eul[1]/180.0f;
- eul[2]= (float)M_PI*tfp->ob_eul[2]/180.0f;
+ eul[0]= DEG2RADF(tfp->ob_eul[0]);
+ eul[1]= DEG2RADF(tfp->ob_eul[1]);
+ eul[2]= DEG2RADF(tfp->ob_eul[2]);
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float quat[4];
VECSUB2D(av4, tf_uv[2], tf_uv[3]); normalize_v2(av4);
/* This is the correct angle however we are only comparing angles
- * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90);*/
+ * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * RAD2DEGF(1.0f))-90);*/
uvang1 = angle_normalized_v2v2(av1, av2);
uvang2 = angle_normalized_v2v2(av2, av3);
uvang3 = angle_normalized_v2v2(av3, av4);
VECSUB(av4, efa->v3->co, efa->v4->co); normalize_v3(av4);
/* This is the correct angle however we are only comparing angles
- * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90);*/
+ * ang1 = 90-((angle_normalized_v3v3(av1, av2) * RAD2DEGF(1.0f))-90);*/
ang1 = angle_normalized_v3v3(av1, av2);
ang2 = angle_normalized_v3v3(av2, av3);
ang3 = angle_normalized_v3v3(av3, av4);
#define SOCK_FLOAT 0
#define SOCK_VECTOR 1
#define SOCK_RGBA 2
-#define SOCK_INT 3
+#define SOCK_SHADER 3
#define SOCK_BOOLEAN 4
#define SOCK_MESH 5
-#define NUM_SOCKET_TYPES 6 /* must be last! */
+#define SOCK_INT 6
+#define NUM_SOCKET_TYPES 7 /* must be last! */
/* socket side (input/output) */
#define SOCK_IN 1
#define SOCK_DYNAMIC 16
/* group socket should not be exposed */
#define SOCK_INTERNAL 32
+ /* socket collapsed in UI */
+#define SOCK_COLLAPSED 64
+ /* hide socket value, if it gets auto default */
+#define SOCK_HIDE_VALUE 128
typedef struct bNodePreview {
unsigned char *rect;
void make_voxeldata(struct Render *re);
void free_voxeldata(struct Render *re);
-int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres);
+int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres);
#endif /* VOXELDATA_H */
if(obr->totvert==0) return;
asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts");
- thresh= cosf((float)M_PI*(0.5f+(float)degr)/180.0f );
+ thresh= cosf(DEG2RADF((0.5f + (float)degr)));
/* step zero: give faces normals of original mesh, if this is provided */
if(part->draw & PART_DRAW_REN_ADAPT) {
sd.adapt = 1;
sd.adapt_pix = (float)part->adapt_pix;
- sd.adapt_angle = cos((float)part->adapt_angle * (float)(M_PI / 180.0));
+ sd.adapt_angle = cosf(DEG2RADF((float)part->adapt_angle));
}
if(re->r.renderer==R_INTERN && part->draw&PART_DRAW_REN_STRAND) {
strandbuf->winx= re->winx;
strandbuf->winy= re->winy;
strandbuf->maxdepth= 2;
- strandbuf->adaptcos= cos((float)part->adapt_angle*(float)(M_PI/180.0));
+ strandbuf->adaptcos= cosf(DEG2RADF((float)part->adapt_angle));
strandbuf->overrideuv= sd.override_uv;
strandbuf->minwidth= ma->strand_min;
col_r[3] = shr_new.alpha;
}
-static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], float col[3])
+static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], float col_r[4])
{
Isect isect;
/* check to see if there's anything behind the volume, otherwise shade the sky */
if(RE_rayobject_raycast(R.raytree, &isect)) {
- shade_intersection(shi, col, &isect);
+ shade_intersection(shi, col_r, &isect);
} else {
- shadeSkyView(col, co, shi->view, NULL, shi->thread);
- shadeSunView(col, shi->view);
+ shadeSkyView(col_r, co, shi->view, NULL, shi->thread);
+ shadeSunView(col_r, shi->view);
}
}
} else {
/* we're tracing through the volume between the camera
* and a solid surface, so use that pre-shaded radiance */
- QUATCOPY(col, shr->combined);
+ copy_v4_v4(col, shr->combined);
}
/* shade volume from 'camera' to 1st hit point */
}
-int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres)
+int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres)
{
int retval = TEX_INT;
VoxelData *vd = tex->vd;
int i,j;
float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
- m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening
+ m_radangle = DEG2RADF(m_angle); //calculates the radians angle, used for flattening
//creating faces for the env mapcube 180deg Dome
// Top Face - just a triangle