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.c526
1 files changed, 286 insertions, 240 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 0f2a57d881c..1bad1b3215c 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1552,6 +1552,12 @@ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *
}
}
}
+
+/* disabled because it crashes combined with e.g. subsurf modifier,
+ * the derivedmesh can't be assumed to be an EditMeshDerivedMesh,
+ * nor should this struct be copied around, it should be defined in
+ * a single place only to avoid them getting out of sync */
+#if 0
/* originally defined in DerivedMesh.c */
typedef struct {
DerivedMesh dm;
@@ -1561,15 +1567,17 @@ typedef struct {
float (*vertexNos)[3];
float (*faceNos)[3];
} EditMeshDerivedMesh;
+#endif
static void draw_dm_verts(DerivedMesh *dm, int sel, EditVert *eve_act)
{
struct { int sel; EditVert *eve_act; } data;
- GPUBuffer *buffer;
- float *varray;
+ //GPUBuffer *buffer;
+ //float *varray;
data.sel = sel;
data.eve_act = eve_act;
+#if 0
/* first come the unselected vertices, then the selected */
buffer = GPU_buffer_legacy(dm)?0:GPU_buffer_alloc( sizeof(float)*3*dm->getNumVerts(dm)*2, 0 );
@@ -1612,12 +1620,15 @@ static void draw_dm_verts(DerivedMesh *dm, int sel, EditVert *eve_act)
UI_ThemeColor4(data.sel?TH_VERTEX_SELECT:TH_VERTEX);
GPU_buffer_unbind();
}
- else {
+ {
+#endif
bglBegin(GL_POINTS);
dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
bglEnd();
+#if 0
}
GPU_buffer_free( buffer, 0 );
+#endif
}
/* Draw edges with color set based on selection */
@@ -1688,15 +1699,14 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i
static void draw_dm_edges_sel_interp(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
{
- unsigned char *cols[2];
+ unsigned char *cols[2] = {baseCol, selCol};
+#if 0
int elemsize = sizeof(float)*3+sizeof(unsigned char)*4;
EditMeshDerivedMesh *emdm = (EditMeshDerivedMesh *)dm;
EditMesh *em= emdm->em;
unsigned char *varray;
int i;
GPUBuffer *buffer;
- cols[0] = baseCol;
- cols[1] = selCol;
buffer = GPU_buffer_legacy(dm)?0:GPU_buffer_alloc( elemsize*em->totedge*2, 0 );
if( (varray = GPU_buffer_lock_stream( buffer )) ) {
@@ -1733,9 +1743,12 @@ static void draw_dm_edges_sel_interp(DerivedMesh *dm, unsigned char *baseCol, un
GPU_buffer_unbind();
}
else {
+#endif
dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols);
+#if 0
}
GPU_buffer_free( buffer, 0 );
+#endif
}
/* Draw only seam edges */
@@ -1792,11 +1805,10 @@ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned
//EditMeshDerivedMesh *emdm = (EditMeshDerivedMesh *)dm;
EditFace *efa;
unsigned char *col;
- unsigned char *colors;
GPUBuffer *buffer;
unsigned char *varray;
unsigned char black[] = { 0, 0, 0, 0 };
- int i,j,draw=0;
+ int i, draw=0;
int elemsize = (sizeof(float)*6+sizeof(unsigned char)*4);
data.cols[0] = baseCol;
data.cols[1] = selCol;
@@ -3358,7 +3370,30 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
/* *********** drawing for particles ************* */
+static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
+{
+ /* draw created data arrays */
+ switch(draw_as){
+ case PART_DRAW_AXIS:
+ case PART_DRAW_CROSS:
+ glDrawArrays(GL_LINES, 0, 6*totpoint);
+ break;
+ case PART_DRAW_LINE:
+ glDrawArrays(GL_LINES, 0, 2*totpoint);
+ break;
+ case PART_DRAW_BB:
+ if(ob_dt<=OB_WIRE || select)
+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
+ else
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glDrawArrays(GL_QUADS, 0, 4*totpoint);
+ break;
+ default:
+ glDrawArrays(GL_POINTS, 0, totpoint);
+ break;
+ }
+}
static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize, float imat[4][4], float *draw_line, ParticleBillboardData *bb, ParticleDrawData *pdd)
{
float vec[3], vec2[3];
@@ -3401,7 +3436,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
cd[7]=cd[10]=1.0;
cd[13]=cd[12]=cd[15]=cd[16]=0.0;
cd[14]=cd[17]=1.0;
- cd+=18;
+ pdd->cd+=18;
VECCOPY(vec2,state->co);
}
@@ -3552,7 +3587,13 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART)==0)
return;
- if(part->draw_as==PART_DRAW_NOT) return;
+ if(part->draw_as == PART_DRAW_REND)
+ draw_as = part->ren_as;
+ else
+ draw_as = part->draw_as;
+
+ if(draw_as == PART_DRAW_NOT)
+ return;
/* 2. */
sim.psmd = psmd = psys_get_modifier(ob,psys);
@@ -3582,26 +3623,22 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(v3d->zbuf) glDepthMask(1);
- if(select)
- cpack(0xFFFFFF);
- else if((ma) && (part->draw&PART_DRAW_MAT_COL)) {
+ if((ma) && (part->draw&PART_DRAW_MAT_COL)) {
glColor3f(ma->r,ma->g,ma->b);
ma_r = ma->r;
ma_g = ma->g;
ma_b = ma->b;
-
- if(pdd) {
- pdd->ma_r = &ma_r;
- pdd->ma_g = &ma_g;
- pdd->ma_b = &ma_b;
- }
-
- create_cdata = 1;
}
else
cpack(0);
+ if(pdd) {
+ pdd->ma_r = &ma_r;
+ pdd->ma_g = &ma_g;
+ pdd->ma_b = &ma_b;
+ }
+
timestep= psys_get_timestep(&sim);
if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {
@@ -3612,11 +3649,6 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
totpart=psys->totpart;
- if(part->draw_as==PART_DRAW_REND)
- draw_as = part->ren_as;
- else
- draw_as = part->draw_as;
-
//if(part->flag&PART_GLOB_TIME)
cfra=bsystem_time(scene, 0, (float)CFRA, 0.0f);
@@ -3646,6 +3678,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
pixsize*=2.0;
else
pixsize*=part->draw_size;
+
+ if(draw_as==PART_DRAW_AXIS)
+ create_cdata = 1;
break;
case PART_DRAW_OB:
if(part->dup_ob==0)
@@ -3693,9 +3728,15 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
Normalize(imat[1]);
}
+ if(!create_cdata && pdd && pdd->cdata) {
+ MEM_freeN(pdd->cdata);
+ pdd->cdata = pdd->cd = NULL;
+ }
+
/* 4. */
- if(draw_as && draw_as!=PART_DRAW_PATH) {
+ if(draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC)==0) {
int tot_vec_size = (totpart + totchild) * 3 * sizeof(float);
+ int create_ndata = 0;
if(!pdd)
pdd = psys->pdd = MEM_callocN(sizeof(ParticleDrawData), "ParticlDrawData");
@@ -3705,37 +3746,36 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
psys_make_temp_pointcache(ob, psys);
}
+ switch(draw_as) {
+ case PART_DRAW_AXIS:
+ case PART_DRAW_CROSS:
+ tot_vec_size *= 6;
+ if(draw_as != PART_DRAW_CROSS)
+ create_cdata = 1;
+ break;
+ case PART_DRAW_LINE:
+ tot_vec_size *= 2;
+ break;
+ case PART_DRAW_BB:
+ tot_vec_size *= 4;
+ create_ndata = 1;
+ break;
+ }
+
if(pdd->tot_vec_size != tot_vec_size)
psys_free_pdd(psys);
- if(draw_as!=PART_DRAW_CIRC) {
- switch(draw_as) {
- case PART_DRAW_AXIS:
- case PART_DRAW_CROSS:
- if(draw_as != PART_DRAW_CROSS || create_cdata)
- if(!pdd->cdata) pdd->cdata = MEM_callocN(tot_vec_size * 6, "particle_cdata");
- if(!pdd->vdata) pdd->vdata = MEM_callocN(tot_vec_size * 6, "particle_vdata");
- break;
- case PART_DRAW_LINE:
- if(create_cdata)
- if(!pdd->cdata) pdd->cdata = MEM_callocN(tot_vec_size * 2, "particle_cdata");
- if(!pdd->vdata) pdd->vdata = MEM_callocN(tot_vec_size * 2, "particle_vdata");
- break;
- case PART_DRAW_BB:
- if(create_cdata)
- if(!pdd->cdata) pdd->cdata = MEM_callocN(tot_vec_size * 4, "particle_cdata");
- if(!pdd->vdata) pdd->vdata = MEM_callocN(tot_vec_size * 4, "particle_vdata");
- if(!pdd->ndata) pdd->ndata = MEM_callocN(tot_vec_size * 4, "particle_vdata");
- break;
- default:
- if(create_cdata)
- if(!pdd->cdata) pdd->cdata=MEM_callocN(tot_vec_size, "particle_cdata");
- if(!pdd->vdata) pdd->vdata=MEM_callocN(tot_vec_size, "particle_vdata");
- }
- }
+ if(!pdd->vdata)
+ pdd->vdata = MEM_callocN(tot_vec_size, "particle_vdata");
+ 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");
if(part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) {
- if(!pdd->vedata) pdd->vedata = MEM_callocN(tot_vec_size * 2, "particle_vedata");
+ if(!pdd->vedata)
+ pdd->vedata = MEM_callocN(2 * (totpart + totchild) * 3 * sizeof(float), "particle_vedata");
+
need_v = 1;
}
@@ -3744,11 +3784,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
pdd->cd= pdd->cdata;
pdd->nd= pdd->ndata;
pdd->tot_vec_size= tot_vec_size;
-
- psys->lattice= psys_get_lattice(&sim);
}
- if(draw_as){
+ psys->lattice= psys_get_lattice(&sim);
+
+ if(pdd && draw_as!=PART_DRAW_PATH){
/* 5. */
if((pdd->flag & PARTICLE_DRAW_DATA_UPDATED)
&& (pdd->vedata || part->draw & (PART_DRAW_SIZE|PART_DRAW_NUM|PART_DRAW_HEALTH))==0) {
@@ -3836,156 +3876,139 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
r_length = PSYS_FRAND(a + 22);
}
- if(draw_as!=PART_DRAW_PATH){
- 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 ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
- float dt = length / (trail_count ? (float)trail_count : 1.0f);
- int i=0;
-
- ct+=dt;
- for(i=0; i < trail_count; i++, ct += dt) {
- if(part->draw & PART_ABS_PATH_TIME) {
- if(ct < pa_birthtime || ct > pa_dietime)
- continue;
- }
- else if(ct < 0.0f || ct > 1.0f)
+ 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 ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
+ float dt = length / (trail_count ? (float)trail_count : 1.0f);
+ int i=0;
+
+ ct+=dt;
+ for(i=0; i < trail_count; i++, ct += dt) {
+ if(part->draw & PART_ABS_PATH_TIME) {
+ if(ct < pa_birthtime || ct > pa_dietime)
continue;
+ }
+ else if(ct < 0.0f || ct > 1.0f)
+ continue;
- state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
- psys_get_particle_on_path(&sim,a,&state,need_v);
-
- if(psys->parent)
- Mat4MulVecfl(psys->parent->obmat, state.co);
-
- /* create actiual particle data */
- if(draw_as == PART_DRAW_BB) {
- bb.size = pa_size;
- bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
- bb.time = ct;
- }
+ state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
+ psys_get_particle_on_path(&sim,a,&state,need_v);
+
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
+ /* create actiual particle data */
+ if(draw_as == PART_DRAW_BB) {
+ bb.size = pa_size;
+ bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
+ bb.time = ct;
+ }
- draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, psys->pdd);
+ draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, psys->pdd);
- totpoint++;
- drawn = 1;
- }
+ totpoint++;
+ drawn = 1;
}
- else
- {
- state.time=cfra;
- if(psys_get_particle_state(&sim,a,&state,0)){
- if(psys->parent)
- Mat4MulVecfl(psys->parent->obmat, state.co);
-
- /* create actiual particle data */
- if(draw_as == PART_DRAW_BB) {
- bb.size = pa_size;
- bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
- bb.time = pa_time;
- }
+ }
+ else
+ {
+ state.time=cfra;
+ if(psys_get_particle_state(&sim,a,&state,0)){
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
+ /* create actiual particle data */
+ if(draw_as == PART_DRAW_BB) {
+ bb.size = pa_size;
+ bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
+ bb.time = pa_time;
+ }
- draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, pdd);
+ draw_particle(&state, draw_as, part->draw, pixsize, imat, part->draw_line, &bb, pdd);
- totpoint++;
- drawn = 1;
- }
+ totpoint++;
+ drawn = 1;
}
+ }
- if(drawn) {
- /* additional things to draw for each particle */
- /* (velocity, size and number) */
- if(pdd->vedata){
- VECCOPY(pdd->ved,state.co);
- pdd->ved+=3;
- VECCOPY(vel,state.vel);
- VecMulf(vel,timestep);
- VECADD(pdd->ved,state.co,vel);
- pdd->ved+=3;
-
- totve++;
- }
+ if(drawn) {
+ /* additional things to draw for each particle */
+ /* (velocity, size and number) */
+ if(pdd->vedata){
+ VECCOPY(pdd->ved,state.co);
+ pdd->ved+=3;
+ VECCOPY(vel,state.vel);
+ VecMulf(vel,timestep);
+ VECADD(pdd->ved,state.co,vel);
+ pdd->ved+=3;
+
+ totve++;
+ }
- if(part->draw & PART_DRAW_SIZE){
- setlinestyle(3);
- drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
- setlinestyle(0);
- }
+ if(part->draw & PART_DRAW_SIZE){
+ setlinestyle(3);
+ drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
+ setlinestyle(0);
+ }
- if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){
- val[0]= '\0';
-
- if(part->draw&PART_DRAW_NUM)
- sprintf(val, " %i", a);
+ if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){
+ val[0]= '\0';
+
+ if(part->draw&PART_DRAW_NUM)
+ sprintf(val, " %i", a);
- if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH)
- sprintf(val, "%s:", val);
+ if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH)
+ sprintf(val, "%s:", val);
- if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS)
- sprintf(val, "%s %.2f", val, pa_health);
+ if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS)
+ sprintf(val, "%s %.2f", val, pa_health);
- /* in path drawing state.co is the end point */
- view3d_cached_text_draw_add(state.co[0], state.co[1], state.co[2], val, 0);
- }
+ /* in path drawing state.co is the end point */
+ view3d_cached_text_draw_add(state.co[0], state.co[1], state.co[2], val, 0);
}
}
}
+ }
/* 6. */
- glGetIntegerv(GL_POLYGON_MODE, polygonmode);
- glDisableClientState(GL_NORMAL_ARRAY);
-
- if(draw_as==PART_DRAW_PATH){
- ParticleCacheKey **cache, *path;
- float *cd2=0,*cdata2=0;
-
- glEnableClientState(GL_VERTEX_ARRAY);
+ glGetIntegerv(GL_POLYGON_MODE, polygonmode);
+ glDisableClientState(GL_NORMAL_ARRAY);
- /* setup gl flags */
- if(ob_dt > OB_WIRE) {
- glEnableClientState(GL_NORMAL_ARRAY);
+ if(draw_as==PART_DRAW_PATH){
+ ParticleCacheKey **cache, *path;
+ float *cd2=0,*cdata2=0;
- if(part->draw&PART_DRAW_MAT_COL)
- glEnableClientState(GL_COLOR_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
- glEnable(GL_LIGHTING);
- glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
- glEnable(GL_COLOR_MATERIAL);
- }
- else {
- glDisableClientState(GL_NORMAL_ARRAY);
+ /* setup gl flags */
+ if(ob_dt > OB_WIRE) {
+ glEnableClientState(GL_NORMAL_ARRAY);
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
- UI_ThemeColor(TH_WIRE);
- }
+ if(part->draw&PART_DRAW_MAT_COL)
+ glEnableClientState(GL_COLOR_ARRAY);
- if(totchild && (part->draw&PART_DRAW_PARENT)==0)
- totpart=0;
+ glEnable(GL_LIGHTING);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+ }
+ else {
+ glDisableClientState(GL_NORMAL_ARRAY);
- /* draw actual/parent particles */
- cache=psys->pathcache;
- for(a=0, pa=psys->particles; a<totpart; a++, pa++){
- path=cache[a];
- if(path->steps > 0) {
- glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_LIGHTING);
+ UI_ThemeColor(TH_WIRE);
+ }
- if(ob_dt > OB_WIRE) {
- glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
- if(part->draw&PART_DRAW_MAT_COL)
- glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
- }
+ if(totchild && (part->draw&PART_DRAW_PARENT)==0)
+ totpart=0;
- glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
- }
- }
-
- /* draw child particles */
- cache=psys->childcache;
- for(a=0; a<totchild; a++){
- path=cache[a];
+ /* draw actual/parent particles */
+ cache=psys->pathcache;
+ for(a=0, pa=psys->particles; a<totpart; a++, pa++){
+ path=cache[a];
+ if(path->steps > 0) {
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
if(ob_dt > OB_WIRE) {
@@ -3996,86 +4019,103 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
}
+ }
+
+ /* draw child particles */
+ cache=psys->childcache;
+ for(a=0; a<totchild; a++){
+ path=cache[a];
+ glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
-
- /* restore & clean up */
if(ob_dt > OB_WIRE) {
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
if(part->draw&PART_DRAW_MAT_COL)
- glDisable(GL_COLOR_ARRAY);
- glDisable(GL_COLOR_MATERIAL);
+ glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
}
- if(cdata2)
- MEM_freeN(cdata2);
- cd2=cdata2=0;
+ glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
+ }
+
- glLineWidth(1.0f);
+ /* restore & clean up */
+ if(ob_dt > OB_WIRE) {
+ if(part->draw&PART_DRAW_MAT_COL)
+ glDisable(GL_COLOR_ARRAY);
+ glDisable(GL_COLOR_MATERIAL);
}
- else if(draw_as!=PART_DRAW_CIRC){
- glDisableClientState(GL_COLOR_ARRAY);
- /* setup created data arrays */
- if(pdd->vdata){
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, pdd->vdata);
- }
+ if(cdata2)
+ MEM_freeN(cdata2);
+ cd2=cdata2=0;
+
+ glLineWidth(1.0f);
+ }
+ else if(pdd && ELEM(draw_as, 0, PART_DRAW_CIRC)==0){
+ glDisableClientState(GL_COLOR_ARRAY);
+
+ /* enable point data array */
+ if(pdd->vdata){
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, pdd->vdata);
+ }
+ else
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ if(select) {
+ UI_ThemeColor(TH_ACTIVE);
+
+ if(part->draw_size)
+ glPointSize(part->draw_size + 2);
else
- glDisableClientState(GL_VERTEX_ARRAY);
+ glPointSize(4.0);
- /* billboards are drawn this way */
- if(pdd->ndata && ob_dt>OB_WIRE){
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(GL_FLOAT, 0, pdd->ndata);
- glEnable(GL_LIGHTING);
- }
- else{
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisable(GL_LIGHTING);
- }
+ glLineWidth(3.0);
- if(pdd->cdata){
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
- }
+ draw_particle_arrays(draw_as, totpoint, ob_dt, 1);
+ }
- /* draw created data arrays */
- switch(draw_as){
- case PART_DRAW_AXIS:
- case PART_DRAW_CROSS:
- glDrawArrays(GL_LINES, 0, 6*totpoint);
- break;
- case PART_DRAW_LINE:
- glDrawArrays(GL_LINES, 0, 2*totpoint);
- break;
- case PART_DRAW_BB:
- if(ob_dt<=OB_WIRE)
- glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
-
- glDrawArrays(GL_QUADS, 0, 4*totpoint);
- break;
- default:
- glDrawArrays(GL_POINTS, 0, totpoint);
- break;
- }
+ /* restore from select */
+ glColor3f(ma_r,ma_g,ma_b);
+ glPointSize(part->draw_size ? part->draw_size : 2.0);
+ glLineWidth(1.0);
+
+ /* enable other data arrays */
- pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
- pdd->totpoint = totpoint;
+ /* billboards are drawn this way */
+ if(pdd->ndata && ob_dt>OB_WIRE){
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(GL_FLOAT, 0, pdd->ndata);
+ glEnable(GL_LIGHTING);
+ }
+ else{
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisable(GL_LIGHTING);
}
- if(pdd->vedata){
- glDisableClientState(GL_COLOR_ARRAY);
- cpack(0xC0C0C0);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
-
- glDrawArrays(GL_LINES, 0, 2*totve);
+ if(pdd->cdata){
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
}
- glPolygonMode(GL_FRONT, polygonmode[0]);
- glPolygonMode(GL_BACK, polygonmode[1]);
+ draw_particle_arrays(draw_as, totpoint, ob_dt, 0);
+
+ pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
+ pdd->totpoint = totpoint;
}
+ if(pdd && pdd->vedata){
+ glDisableClientState(GL_COLOR_ARRAY);
+ cpack(0xC0C0C0);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
+
+ glDrawArrays(GL_LINES, 0, 2*totve);
+ }
+
+ glPolygonMode(GL_FRONT, polygonmode[0]);
+ glPolygonMode(GL_BACK, polygonmode[1]);
+
/* 7. */
glDisable(GL_LIGHTING);
@@ -4087,6 +4127,12 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
psys->flag &= ~PSYS_DRAWING;
+ /* draw data can't be saved for billboards as they must update to target changes */
+ if(draw_as == PART_DRAW_BB) {
+ psys_free_pdd(psys);
+ pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
+ }
+
if(psys->lattice){
end_latt_deform(psys->lattice);
psys->lattice= NULL;