Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/drawobject.c')
-rw-r--r--source/blender/editors/space_view3d/drawobject.c324
1 files changed, 150 insertions, 174 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 11a1658b30d..48923cc9593 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -25,6 +25,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/editors/space_view3d/drawobject.c
+ * \ingroup spview3d
+ */
+
+
#include <string.h>
#include <math.h>
@@ -150,16 +155,16 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l
mul_m4_v4(rv3d->persmatob, vec4);
/* clipplanes in window space */
- if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
+ if( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
if( fx>0 && fx<ar->winx) {
fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
- if(fy>0.0 && fy< (float)ar->winy) {
- adr[0]= (short)floor(fx);
- adr[1]= (short)floor(fy);
+ if(fy > 0.0f && fy < (float)ar->winy) {
+ adr[0]= (short)floorf(fx);
+ adr[1]= (short)floorf(fy);
}
}
}
@@ -178,16 +183,16 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr)
mul_m4_v4(rv3d->persmatob, vec4);
- if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
+ if( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
if( fx>-32700 && fx<32700) {
fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
- if(fy>-32700.0 && fy<32700.0) {
- adr[0]= (short)floor(fx);
- adr[1]= (short)floor(fy);
+ if(fy > -32700.0f && fy < 32700.0f) {
+ adr[0]= (short)floorf(fx);
+ adr[1]= (short)floorf(fy);
}
}
}
@@ -322,7 +327,7 @@ static float cosval[32] ={
static void draw_xyz_wire(const float c[3], float size, int axis)
{
float v1[3]= {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f};
- float dim = size * 0.1;
+ float dim = size * 0.1f;
float dx[3], dy[3], dz[3];
dx[0]=dim; dx[1]=0.f; dx[2]=0.f;
@@ -441,9 +446,9 @@ void drawaxes(float size, char drawtype)
/* square pyramid */
glBegin(GL_TRIANGLES);
- v2[0]= size*0.035; v2[1] = size*0.035;
- v3[0]= size*-0.035; v3[1] = size*0.035;
- v2[2]= v3[2]= size*0.75;
+ v2[0]= size * 0.035f; v2[1] = size * 0.035f;
+ v3[0]= size * -0.035f; v3[1] = size * 0.035f;
+ v2[2]= v3[2]= size * 0.75f;
for (axis=0; axis<4; axis++) {
if (axis % 2 == 1) {
@@ -489,18 +494,18 @@ void drawaxes(float size, char drawtype)
glVertex3fv(v1);
glVertex3fv(v2);
- v1[axis]= size*0.85;
- v1[arrow_axis]= -size*0.08;
+ v1[axis]= size*0.85f;
+ v1[arrow_axis]= -size*0.08f;
glVertex3fv(v1);
glVertex3fv(v2);
- v1[arrow_axis]= size*0.08;
+ v1[arrow_axis]= size*0.08f;
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
- v2[axis]+= size*0.125;
+ v2[axis]+= size*0.125f;
draw_xyz_wire(v2, size, axis);
@@ -572,6 +577,7 @@ typedef struct ViewCachedString {
short mval[2];
short xoffs;
short flag;
+ int str_len, pad;
/* str is allocated past the end */
} ViewCachedString;
@@ -593,6 +599,7 @@ void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs
vos->col.pack= *((int *)col);
vos->xoffs= xoffs;
vos->flag= flag;
+ vos->str_len= alloc_len-1;
/* allocate past the end */
memcpy(++vos, str, alloc_len);
@@ -658,10 +665,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
col_pack_prev= vos->col.pack;
}
if(vos->flag & V3D_CACHE_TEXT_ASCII) {
- BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, 65535); /* XXX, use real length */
+ BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len);
}
else {
- BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, 65535); /* XXX, use real length */
+ BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len);
}
}
}
@@ -819,7 +826,7 @@ static void spotvolume(float *lvec, float *vvec, float inp)
q[3] = 0 ;
normalize_v3(&q[1]);
- angle = saacos(plane[2])/2.0;
+ angle = saacos(plane[2])/2.0f;
co = cos(angle);
si = sqrt(1-co*co);
@@ -876,7 +883,7 @@ static void draw_spot_cone(Lamp *la, float x, float z)
for(a=0; a<33; a++) {
angle= a*M_PI*2/(33-1);
- glVertex3f(z*cos(angle), z*sin(angle), 0);
+ glVertex3f(z*cosf(angle), z*sinf(angle), 0);
}
}
@@ -996,7 +1003,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
short axis;
/* setup a 45 degree rotation matrix */
- vec_rot_to_mat3( mat,imat[2], M_PI/4.0f);
+ vec_rot_to_mat3(mat, imat[2], (float)M_PI/4.0f);
/* vectors */
mul_v3_v3fl(v1, imat[0], circrad * 1.2f);
@@ -1043,7 +1050,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
vvec[1]= x*ob->obmat[1][0] + y*ob->obmat[1][1] + z*ob->obmat[1][2];
vvec[2]= x*ob->obmat[2][0] + y*ob->obmat[2][1] + z*ob->obmat[2][2];
- y = cos( M_PI*la->spotsize/360.0 );
+ y = cosf(la->spotsize*(float)(M_PI/360.0));
spotvolume(lvec, vvec, y);
x = -la->dist;
mul_v3_fl(lvec, x);
@@ -1056,7 +1063,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
glVertex3fv(lvec);
glEnd();
- z = x*sqrt(1.0 - y*y);
+ z = x*sqrtf(1.0f - y*y);
x *= y;
/* draw the circle/square at the end of the cone */
@@ -1078,7 +1085,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
glVertex3fv(tvec);
glEnd();
}
- else circ(0.0, 0.0, fabs(z));
+ else circ(0.0, 0.0, fabsf(z));
/* draw the circle/square representing spotbl */
if(la->type==LA_SPOT) {
@@ -1086,7 +1093,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* hide line if it is zero size or overlaps with outer border,
previously it adjusted to always to show it but that seems
confusing because it doesn't show the actual blend size */
- if (spotblcirc != 0 && spotblcirc != fabs(z))
+ if (spotblcirc != 0 && spotblcirc != fabsf(z))
circ(0.0, 0.0, spotblcirc);
}
@@ -1160,9 +1167,9 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
} else if(la->type==LA_AREA) {
setlinestyle(3);
if(la->area_shape==LA_AREA_SQUARE)
- fdrawbox(-la->area_size*0.5, -la->area_size*0.5, la->area_size*0.5, la->area_size*0.5);
+ fdrawbox(-la->area_size*0.5f, -la->area_size*0.5f, la->area_size*0.5f, la->area_size*0.5f);
else if(la->area_shape==LA_AREA_RECT)
- fdrawbox(-la->area_size*0.5, -la->area_sizey*0.5, la->area_size*0.5, la->area_sizey*0.5);
+ fdrawbox(-la->area_size*0.5f, -la->area_sizey*0.5f, la->area_size*0.5f, la->area_sizey*0.5f);
glBegin(GL_LINE_STRIP);
glVertex3f(0.0,0.0,-circrad);
@@ -1282,7 +1289,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
if(is_view) {
/* fixed depth, variable size (avoids exceeding clipping range) */
- depth = -(cam->clipsta + 0.1);
+ depth = -(cam->clipsta + 0.1f);
fac = depth / (cam->lens/-16.0f * scaz);
}
else {
@@ -1337,15 +1344,15 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
else if (i==1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES);
else break;
- vec[0][0]= shx + ((-0.7 * drawsize) * scax);
- vec[0][1]= shy + ((drawsize * (caspy + 0.1)) * scay);
+ vec[0][0]= shx + ((-0.7f * drawsize) * scax);
+ vec[0][1]= shy + ((drawsize * (caspy + 0.1f)) * scay);
glVertex3fv(vec[0]); /* left */
- vec[0][0]= shx + ((0.7 * drawsize) * scax);
+ vec[0][0]= shx + ((0.7f * drawsize) * scax);
glVertex3fv(vec[0]); /* right */
vec[0][0]= shx;
- vec[0][1]= shy + ((1.1 * drawsize * (caspy + 0.7)) * scay);
+ vec[0][1]= shy + ((1.1f * drawsize * (caspy + 0.7f)) * scay);
glVertex3fv(vec[0]); /* top */
glEnd();
@@ -2102,7 +2109,7 @@ static int draw_dm_creases__setDrawOptions(void *userData, int index)
if (!crease)
return 0;
- if (!BM_TestHFlag(eed, BM_HIDDEN) && *crease!=0.0) {
+ if (!BM_TestHFlag(eed, BM_HIDDEN) && *crease!=0.0f) {
UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease);
return 1;
} else {
@@ -2125,7 +2132,7 @@ static int draw_dm_bweights__setDrawOptions(void *userData, int index)
if (!bweight)
return 0;
- if (!BM_TestHFlag(eed, BM_HIDDEN) && *bweight!=0.0) {
+ if (!BM_TestHFlag(eed, BM_HIDDEN) && *bweight!=0.0f) {
UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight);
return 1;
} else {
@@ -2141,7 +2148,7 @@ static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, floa
if (!bweight)
return;
- if (!BM_TestHFlag(eve, BM_HIDDEN) && *bweight!=0.0) {
+ if (!BM_TestHFlag(eve, BM_HIDDEN) && *bweight!=0.0f) {
UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight);
bglVertex3fv(co);
}
@@ -2200,8 +2207,8 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
continue;
}
- size = (size>2.1?size/2.0:size);
- fsize = (fsize>2.1?fsize/2.0:fsize);
+ size = (size > 2.1f ? size/2.0f:size);
+ fsize = (fsize > 2.1f ? fsize/2.0f:fsize);
col[3] = fcol[3] = 100;
} else {
col[3] = fcol[3] = 255;
@@ -2301,7 +2308,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d,
float fvec[3];
char val[32]; /* Stores the measurement display text here */
const char *conv_float; /* Use a float conversion matching the grid size */
- unsigned char col[3]; /* color of the text to draw */
+ unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */
float area; /* area of the face */
float grid= unit->system ? unit->scale_length : v3d->grid;
const int do_split= unit->flag & USER_UNIT_OPT_SPLIT;
@@ -2340,7 +2347,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d,
bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE);
else
sprintf(val, conv_float, len_v3v3(v1, v2));
-
+
view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col);
}
}
@@ -2409,29 +2416,29 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d,
if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) {
/* Vec 1 */
- sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v4, v1, v2)));
+ sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v4, v1, v2)));
interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f);
view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
}
if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) {
/* Vec 2 */
- sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v1, v2, v3)));
+ sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f);
view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
}
if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) {
/* Vec 3 */
if(efa->v4)
- sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v2, v3, v4)));
+ sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v4)));
else
- sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v2, v3, v1)));
+ sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v1)));
interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f);
view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
}
/* Vec 4 */
if(efa->v4) {
if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) {
- sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v3, v4, v1)));
+ sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v3, v4, v1)));
interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f);
view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
}
@@ -2649,7 +2656,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
{
if(v3d->transp==0) { // not when we draw the transparent pass
- glLineWidth(2.0);
+ glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(0);
/* if transparent, we cannot draw the edges for solid select... edges have no material info.
@@ -3332,12 +3339,12 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B
static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt)
{
Object *ob= base->object;
- ListBase *lb=0;
+ ListBase *lb=NULL;
DispList *dl;
Curve *cu;
- int solid, retval= 0;
-
- solid= (dt > OB_WIRE);
+ const short render_only= (v3d->flag2 & V3D_RENDER_OVERRIDE);
+ const short solid= (dt > OB_WIRE);
+ int retval= 0;
if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) {
return 0;
@@ -3354,13 +3361,15 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
dl= lb->first;
if(dl==NULL) return 1;
- if(dl->nors==0) addnormalsDispList(lb);
+ if(dl->nors==NULL) addnormalsDispList(lb);
index3_nors_incr= 0;
if( displist_has_faces(lb)==0) {
- draw_index_wire= 0;
- drawDispListwire(lb);
- draw_index_wire= 1;
+ if(!render_only) {
+ draw_index_wire= 0;
+ drawDispListwire(lb);
+ draw_index_wire= 1;
+ }
}
else {
if(draw_glsl_material(scene, ob, v3d, dt)) {
@@ -3369,7 +3378,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
GPU_end_object_materials();
}
else if(dt == OB_SHADED) {
- if(ob->disp.first==0) shadeDispList(scene, base);
+ if(ob->disp.first==NULL) shadeDispList(scene, base);
drawDispListshaded(lb, ob);
}
else {
@@ -3378,7 +3387,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
drawDispListsolid(lb, ob, 0);
GPU_end_object_materials();
}
- if(cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0 && cu->ext2 == 0.0) {
+ if(cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
cpack(0);
draw_index_wire= 0;
drawDispListwire(lb);
@@ -3388,9 +3397,11 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
index3_nors_incr= 1;
}
else {
- draw_index_wire= 0;
- retval= drawDispListwire(lb);
- draw_index_wire= 1;
+ if(!render_only || (render_only && displist_has_faces(lb))) {
+ draw_index_wire= 0;
+ retval= drawDispListwire(lb);
+ draw_index_wire= 1;
+ }
}
break;
case OB_SURF:
@@ -3439,7 +3450,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
else if(dt == OB_SHADED) {
dl= lb->first;
- if(dl && dl->col1==0) shadeDispList(scene, base);
+ if(dl && dl->col1==NULL) shadeDispList(scene, base);
drawDispListshaded(lb, ob);
}
else {
@@ -3652,14 +3663,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
ParticleEditSettings *pset = PE_settings(scene);
ParticleSettings *part;
ParticleData *pars, *pa;
- ParticleKey state, *states=0;
+ ParticleKey state, *states=NULL;
ParticleBillboardData bb;
- ParticleSimulationData sim= {0};
+ ParticleSimulationData sim= {NULL};
ParticleDrawData *pdd = psys->pdd;
Material *ma;
float vel[3], imat[4][4];
float timestep, pixsize=1.0, pa_size, r_tilt, r_length;
- float pa_time, pa_birthtime, pa_dietime, pa_health;
+ float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
float cfra;
float ma_r=0.0f, ma_g=0.0f, ma_b=0.0f;
int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0;
@@ -3669,16 +3680,16 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
unsigned char tcol[4]= {0, 0, 0, 255};
/* 1. */
- if(psys==0)
+ if(psys==NULL)
return;
part=psys->part;
pars=psys->particles;
- if(part==0 || !psys_check_enabled(ob, psys))
+ if(part==NULL || !psys_check_enabled(ob, psys))
return;
- if(pars==0) return;
+ if(pars==NULL) return;
/* don't draw normal paths in edit mode */
if(psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART)==0)
@@ -3723,7 +3734,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(v3d->zbuf) glDepthMask(1);
- if((ma) && (part->draw&PART_DRAW_MAT_COL)) {
+ if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
rgb_float_to_byte(&(ma->r), tcol);
ma_r = ma->r;
@@ -3746,7 +3757,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
totpart=psys->totpart;
- cfra=bsystem_time(scene, 0, (float)CFRA, 0.0f);
+ cfra= bsystem_time(scene, NULL, (float)CFRA, 0.0f);
if(draw_as==PART_DRAW_PATH && psys->pathcache==NULL && psys->childcache==NULL)
draw_as=PART_DRAW_DOT;
@@ -3771,7 +3782,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
pixsize= view3d_pixel_size(rv3d, ob->obmat[3]);
if(part->draw_size==0.0)
- pixsize*=2.0;
+ pixsize *= 2.0f;
else
pixsize*=part->draw_size;
@@ -3779,19 +3790,19 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
create_cdata = 1;
break;
case PART_DRAW_OB:
- if(part->dup_ob==0)
+ if(part->dup_ob==NULL)
draw_as=PART_DRAW_DOT;
else
draw_as=0;
break;
case PART_DRAW_GR:
- if(part->dup_group==0)
+ if(part->dup_group==NULL)
draw_as=PART_DRAW_DOT;
else
draw_as=0;
break;
case PART_DRAW_BB:
- if(v3d->camera==0 && part->bb_ob==0){
+ if(v3d->camera==NULL && part->bb_ob==NULL){
printf("Billboards need an active camera or a target object!\n");
draw_as=part->draw_as=PART_DRAW_DOT;
@@ -3824,6 +3835,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
normalize_v3(imat[1]);
}
+ if(ELEM3(draw_as, PART_DRAW_DOT, PART_DRAW_CROSS, PART_DRAW_LINE)
+ && part->draw_col > PART_DRAW_COL_MAT)
+ create_cdata = 1;
+
if(!create_cdata && pdd && pdd->cdata) {
MEM_freeN(pdd->cdata);
pdd->cdata = pdd->cd = NULL;
@@ -3866,7 +3881,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(create_cdata && !pdd->cdata)
pdd->cdata = MEM_callocN(tot_vec_size, "particle_cdata");
if(create_ndata && !pdd->ndata)
- pdd->ndata = MEM_callocN(tot_vec_size, "particle_vdata");
+ pdd->ndata = MEM_callocN(tot_vec_size, "particle_ndata");
if(part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) {
if(!pdd->vedata)
@@ -3921,66 +3936,27 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
else
pa_health = -1.0;
-#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0){
- if(ma && ma->ipo){
- IpoCurve *icu;
-
- /* correction for lifetime */
- calc_ipo(ma->ipo, 100.0f*pa_time);
-
- for(icu = ma->ipo->curve.first; icu; icu=icu->next) {
- if(icu->adrcode == MA_COL_R)
- ma_r = icu->curval;
- else if(icu->adrcode == MA_COL_G)
- ma_g = icu->curval;
- else if(icu->adrcode == MA_COL_B)
- ma_b = icu->curval;
- }
- }
- if(part->ipo) {
- IpoCurve *icu;
-
- /* correction for lifetime */
- calc_ipo(part->ipo, 100*pa_time);
+ r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
+ r_length = PSYS_FRAND(a + 22);
- for(icu = part->ipo->curve.first; icu; icu=icu->next) {
- if(icu->adrcode == PART_SIZE)
- pa_size = icu->curval;
- }
+ if(part->draw_col > PART_DRAW_COL_MAT) {
+ switch(part->draw_col) {
+ case PART_DRAW_COL_VEL:
+ intensity = len_v3(pa->state.vel)/part->color_vec_max;
+ break;
+ case PART_DRAW_COL_ACC:
+ intensity = len_v3v3(pa->state.vel, pa->prev_state.vel)/((pa->state.time-pa->prev_state.time)*part->color_vec_max);
+ break;
}
+ CLAMP(intensity, 0.f, 1.f);
+ weight_to_rgb(intensity, &ma_r, &ma_g, &ma_b);
}
-#endif // XXX old animation system
-
- r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
- r_length = PSYS_FRAND(a + 22);
}
else{
ChildParticle *cpa= &psys->child[a-totpart];
pa_time=psys_get_child_time(psys,cpa,cfra,&pa_birthtime,&pa_dietime);
-
-#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0) {
- if(ma && ma->ipo){
- IpoCurve *icu;
-
- /* correction for lifetime */
- calc_ipo(ma->ipo, 100.0f*pa_time);
-
- for(icu = ma->ipo->curve.first; icu; icu=icu->next) {
- if(icu->adrcode == MA_COL_R)
- ma_r = icu->curval;
- else if(icu->adrcode == MA_COL_G)
- ma_g = icu->curval;
- else if(icu->adrcode == MA_COL_B)
- ma_b = icu->curval;
- }
- }
- }
-#endif // XXX old animation system
-
- pa_size=psys_get_child_size(psys,cpa,cfra,0);
+ pa_size=psys_get_child_size(psys,cpa,cfra,NULL);
pa_health = -1.0;
@@ -3990,8 +3966,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
drawn = 0;
if(part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
- float length = part->path_end * (1.0 - part->randlength * r_length);
- int trail_count = part->trail_count * (1.0 - part->randlength * r_length);
+ float length = part->path_end * (1.0f - part->randlength * r_length);
+ int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
float dt = length / (trail_count ? (float)trail_count : 1.0f);
int i=0;
@@ -4099,13 +4075,13 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(draw_as==PART_DRAW_PATH){
ParticleCacheKey **cache, *path;
- float *cd2=0,*cdata2=0;
+ float *cd2=NULL,*cdata2=NULL;
/* setup gl flags */
if (1) { //ob_dt > OB_WIRE) {
glEnableClientState(GL_NORMAL_ARRAY);
- if(part->draw&PART_DRAW_MAT_COL)
+ if(part->draw_col == PART_DRAW_COL_MAT)
glEnableClientState(GL_COLOR_ARRAY);
glEnable(GL_LIGHTING);
@@ -4134,7 +4110,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(1) { //ob_dt > OB_WIRE) {
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if(part->draw&PART_DRAW_MAT_COL)
+ if(part->draw_col == PART_DRAW_COL_MAT)
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
}
@@ -4150,7 +4126,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(1) { //ob_dt > OB_WIRE) {
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if(part->draw&PART_DRAW_MAT_COL)
+ if(part->draw_col == PART_DRAW_COL_MAT)
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
}
@@ -4160,14 +4136,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* restore & clean up */
if(1) { //ob_dt > OB_WIRE) {
- if(part->draw&PART_DRAW_MAT_COL)
+ if(part->draw_col == PART_DRAW_COL_MAT)
glDisable(GL_COLOR_ARRAY);
glDisable(GL_COLOR_MATERIAL);
}
if(cdata2)
MEM_freeN(cdata2);
- cd2=cdata2=0;
+ cd2=cdata2=NULL;
glLineWidth(1.0f);
@@ -4287,7 +4263,7 @@ static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit
PE_update_object(scene, ob, 0);
/* create path and child path cache if it doesn't exist already */
- if(edit->pathcache==0)
+ if(edit->pathcache == NULL)
psys_cache_edit_paths(scene, ob, edit, CFRA);
}
@@ -4303,7 +4279,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
float nosel_col[3];
float *pathcol = NULL, *pcol;
- if(edit->pathcache==0)
+ if(edit->pathcache == NULL)
return;
PE_hide_keys_time(scene, edit, CFRA);
@@ -4343,7 +4319,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
if(timed) {
for(k=0, pcol=pathcol, pkey=path; k<steps; k++, pkey++, pcol+=4){
copy_v3_v3(pcol, pkey->col);
- pcol[3] = 1.0f - fabs((float)CFRA - pkey->time)/(float)pset->fade_frames;
+ pcol[3] = 1.0f - fabsf((float)(CFRA) - pkey->time)/(float)pset->fade_frames;
}
glColorPointer(4, GL_FLOAT, 4*sizeof(float), pathcol);
@@ -4362,8 +4338,8 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
if(pset->selectmode==SCE_SELECT_POINT){
- float *pd=0,*pdata=0;
- float *cd=0,*cdata=0;
+ float *pd=NULL,*pdata=NULL;
+ float *cd=NULL,*cdata=NULL;
int totkeys = 0;
for (i=0, point=edit->points; i<totpoint; i++, point++)
@@ -4392,7 +4368,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
}
if(timed)
- *(cd+3) = 1.0f - fabs((float)CFRA - *key->time)/(float)pset->fade_frames;
+ *(cd+3) = 1.0f - fabsf((float)CFRA - *key->time)/(float)pset->fade_frames;
cd += (timed?4:3);
}
@@ -4415,8 +4391,8 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
pd += pd ? 3 * point->totkey : 0;
cd += (timed?4:3) * point->totkey;
}
- if(pdata) { MEM_freeN(pdata); pd=pdata=0; }
- if(cdata) { MEM_freeN(cdata); cd=cdata=0; }
+ if(pdata) { MEM_freeN(pdata); pd=pdata=NULL; }
+ if(cdata) { MEM_freeN(cdata); cd=cdata=NULL; }
}
else if(pset->selectmode == SCE_SELECT_END){
for(i=0, point=edit->points; i<totpoint; i++, point++){
@@ -4986,7 +4962,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
/* direction vectors for 3d curve paths
when at its lowest, dont render normals */
- if(cu->flag & CU_3D && ts->normalsize > 0.0015 && (cu->drawflag & CU_HIDE_NORMALS)==0) {
+ if(cu->flag & CU_3D && ts->normalsize > 0.0015f && (cu->drawflag & CU_HIDE_NORMALS)==0) {
UI_ThemeColor(TH_WIRE);
for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) {
@@ -5083,7 +5059,7 @@ static void draw_empty_cone (float size)
radius = size;
glTranslatef(cent,cent, cent);
- glScalef(radius, 2.0*size, radius);
+ glScalef(radius, size * 2.0f, radius);
glRotatef(-90., 1.0, 0.0, 0.0);
gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
@@ -5312,7 +5288,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
ml->selcol2= code;
glLoadName(code++);
}
- drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad*atan(ml->s)/M_PI_2, imat);
+ drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad*atanf(ml->s)/(float)M_PI_2, imat);
}
ml= ml->next;
@@ -5354,15 +5330,15 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
// force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
//else
force_val = pd->f_strength;
- force_val*= 0.1;
+ force_val *= 0.1f;
drawcircball(GL_LINE_LOOP, vec, size, tmat);
- vec[2]= 0.5*force_val;
+ vec[2]= 0.5f * force_val;
drawcircball(GL_LINE_LOOP, vec, size, tmat);
- vec[2]= 1.0*force_val;
+ vec[2]= 1.0f * force_val;
drawcircball(GL_LINE_LOOP, vec, size, tmat);
- vec[2]= 1.5*force_val;
+ vec[2]= 1.5f * force_val;
drawcircball(GL_LINE_LOOP, vec, size, tmat);
- vec[2] = 0; /* reset vec for max dist circle */
+ vec[2] = 0.0f; /* reset vec for max dist circle */
}
else if (pd->forcefield == PFIELD_FORCE) {
@@ -5375,33 +5351,33 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
drawcircball(GL_LINE_LOOP, vec, size, imat);
- UI_ThemeColorBlend(curcol, TH_BACK, 0.9 - 0.4 / pow(1.5, (double)ffall_val));
- drawcircball(GL_LINE_LOOP, vec, size*1.5, imat);
- UI_ThemeColorBlend(curcol, TH_BACK, 0.9 - 0.4 / pow(2.0, (double)ffall_val));
- drawcircball(GL_LINE_LOOP, vec, size*2.0, imat);
+ UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val));
+ drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat);
+ UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val));
+ drawcircball(GL_LINE_LOOP, vec, size*2.0f, imat);
}
else if (pd->forcefield == PFIELD_VORTEX) {
- float ffall_val, force_val;
+ float /*ffall_val,*/ force_val;
unit_m4(tmat);
//if (has_ipo_code(ob->ipo, OB_PD_FFALL))
// ffall_val = IPO_GetFloatValue(ob->ipo, OB_PD_FFALL, scene->r.cfra);
//else
- ffall_val = pd->f_power;
+ // ffall_val = pd->f_power;
//if (has_ipo_code(ob->ipo, OB_PD_FSTR))
// force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra);
//else
force_val = pd->f_strength;
- UI_ThemeColorBlend(curcol, TH_BACK, 0.7);
+ UI_ThemeColorBlend(curcol, TH_BACK, 0.7f);
if (force_val < 0) {
- drawspiral(vec, size*1.0, tmat, 1);
- drawspiral(vec, size*1.0, tmat, 16);
+ drawspiral(vec, size, tmat, 1);
+ drawspiral(vec, size, tmat, 16);
}
else {
- drawspiral(vec, size*1.0, tmat, -1);
- drawspiral(vec, size*1.0, tmat, -16);
+ drawspiral(vec, size, tmat, -1);
+ drawspiral(vec, size, tmat, -16);
}
}
else if (pd->forcefield == PFIELD_GUIDE && ob->type==OB_CURVE) {
@@ -5473,9 +5449,9 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f;
if(pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)){
- drawcone(vec,distance*sin(radius),distance*cos(radius),tmat);
+ drawcone(vec, distance * sinf(radius),distance * cosf(radius), tmat);
if((pd->flag & PFIELD_POSZ)==0)
- drawcone(vec,distance*sin(radius),-distance*cos(radius),tmat);
+ drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat);
}
radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f;
@@ -5483,9 +5459,9 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f;
if(pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)){
- drawcone(vec,distance*sin(radius),distance*cos(radius),tmat);
+ drawcone(vec,distance*sinf(radius),distance*cosf(radius),tmat);
if((pd->flag & PFIELD_POSZ)==0)
- drawcone(vec,distance*sin(radius),-distance*cos(radius),tmat);
+ drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat);
}
}
setlinestyle(0);
@@ -5535,13 +5511,13 @@ static void draw_bb_quadric(BoundBox *bb, short type)
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
- size[0]= 0.5*fabs(bb->vec[0][0] - bb->vec[4][0]);
- size[1]= 0.5*fabs(bb->vec[0][1] - bb->vec[2][1]);
- size[2]= 0.5*fabs(bb->vec[0][2] - bb->vec[1][2]);
+ size[0]= 0.5f*fabsf(bb->vec[0][0] - bb->vec[4][0]);
+ size[1]= 0.5f*fabsf(bb->vec[0][1] - bb->vec[2][1]);
+ size[2]= 0.5f*fabsf(bb->vec[0][2] - bb->vec[1][2]);
- cent[0]= (bb->vec[0][0] + bb->vec[4][0])/2.0;
- cent[1]= (bb->vec[0][1] + bb->vec[2][1])/2.0;
- cent[2]= (bb->vec[0][2] + bb->vec[1][2])/2.0;
+ cent[0]= 0.5f*(bb->vec[0][0] + bb->vec[4][0]);
+ cent[1]= 0.5f*(bb->vec[0][1] + bb->vec[2][1]);
+ cent[2]= 0.5f*(bb->vec[0][2] + bb->vec[1][2]);
glPushMatrix();
if(type==OB_BOUND_SPHERE) {
@@ -5552,13 +5528,13 @@ static void draw_bb_quadric(BoundBox *bb, short type)
else if(type==OB_BOUND_CYLINDER) {
float radius = size[0] > size[1] ? size[0] : size[1];
glTranslatef(cent[0], cent[1], cent[2]-size[2]);
- glScalef(radius, radius, 2.0*size[2]);
+ glScalef(radius, radius, 2.0f * size[2]);
gluCylinder(qobj, 1.0, 1.0, 1.0, 8, 1);
}
else if(type==OB_BOUND_CONE) {
float radius = size[0] > size[1] ? size[0] : size[1];
glTranslatef(cent[0], cent[2]-size[2], cent[1]);
- glScalef(radius, 2.0*size[2], radius);
+ glScalef(radius, 2.0f * size[2], radius);
glRotatef(-90., 1.0, 0.0, 0.0);
gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
}
@@ -6067,7 +6043,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
drawDispList(scene, v3d, rv3d, base, dt);
}
- if (cu->linewidth != 0.0) {
+ if (cu->linewidth != 0.0f) {
cpack(0xff44ff);
UI_ThemeColor(TH_WIRE);
copy_v3_v3(vec1, ob->orig);
@@ -6086,7 +6062,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
setlinestyle(3);
for (i=0; i<cu->totbox; i++) {
- if (cu->tb[i].w != 0.0) {
+ if (cu->tb[i].w != 0.0f) {
if (i == (cu->actbox-1))
UI_ThemeColor(TH_ACTIVE);
else
@@ -6214,7 +6190,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if(ob->soft /*&& flag & OB_SBMOTION*/){
float mrt[3][3],msc[3][3],mtr[3][3];
- SoftBody *sb = 0;
+ SoftBody *sb= NULL;
float tipw = 0.5f, tiph = 0.5f,drawsize = 4.0f;
if ((sb= ob->soft)){
if(sb->solverflags & SBSO_ESTIMATEIPO){