[Bf-blender-cvs] [68d8047] gooseberry: New draw mode 'HULL' for hair drawing.
Lukas Tönne
noreply at git.blender.org
Thu Jan 22 19:51:16 CET 2015
Commit: 68d80478af236e6fd7f20dbff10c56d1ab20abb0
Author: Lukas Tönne
Date: Wed Jan 21 17:20:47 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB68d80478af236e6fd7f20dbff10c56d1ab20abb0
New draw mode 'HULL' for hair drawing.
Not implemented yet, currently uses just the child path drawing.
===================================================================
M source/blender/editors/space_view3d/drawobject.c
M source/blender/makesdna/DNA_particle_types.h
M source/blender/makesrna/intern/rna_particle.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index bab19e4..80ac864 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4480,6 +4480,77 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
}
/* *********** drawing for particles ************* */
+
+static void draw_particle_hair_hull(Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ Base *base, ParticleSystem *psys,
+ const char ob_dt, const short dflag)
+{
+ Object *ob = base->object;
+ ParticleSettings *part = psys->part;
+ /*Material *ma = give_current_material(ob, part->omat);*/
+ GLint polygonmode[2];
+ int totchild;
+
+ ParticleData *pa;
+ ParticleCacheKey **cache, *path;
+ int p;
+
+ if (part->type == PART_HAIR && !psys->childcache)
+ totchild = 0;
+ else
+ totchild = psys->totchild * part->disp / 100;
+
+ if (v3d->zbuf)
+ glDepthMask(true);
+
+ glGetIntegerv(GL_POLYGON_MODE, polygonmode);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+
+
+#if 0
+ /* draw actual/parent particles */
+ cache = psys->pathcache;
+ for (p = 0, pa = psys->particles; p < totpart; ++p, ++pa) {
+ path = cache[p];
+ if (path->segments > 0) {
+ glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+
+ glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
+ }
+ }
+#endif
+
+ /* draw child particles */
+ cache = psys->childcache;
+ for (p = 0; p < totchild; ++p) {
+ path = cache[p];
+
+ glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
+ glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
+
+ glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
+ }
+
+
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_LIGHTING);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glPolygonMode(GL_FRONT, polygonmode[0]);
+ glPolygonMode(GL_BACK, polygonmode[1]);
+
+ if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
+ glLoadMatrixf(rv3d->viewmat);
+ }
+}
+
static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
{
/* draw created data arrays */
@@ -4504,6 +4575,7 @@ static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int selec
break;
}
}
+
static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd)
{
@@ -4654,6 +4726,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
}
}
}
+
static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
ParticleKey *state, int draw_as,
float imat[4][4], ParticleBillboardData *bb, ParticleDrawData *pdd,
@@ -4735,14 +4808,15 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* don't draw normal paths in edit mode */
if (psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART) == 0)
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)
+
+ draw_as = part->draw_as == PART_DRAW_REND ? part->ren_as : part->draw_as;
+ if (draw_as == PART_DRAW_NOT) {
return;
+ }
+ else if (draw_as == PART_DRAW_HULL) {
+ draw_particle_hair_hull(scene, v3d, rv3d, base, psys, ob_dt, dflag);
+ return;
+ }
/* 2. */
sim.scene = scene;
@@ -4943,7 +5017,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
else if (psys->pdd) {
psys_free_pdd(psys);
MEM_freeN(psys->pdd);
- pdd = psys->pdd = NULL;
+ psys->pdd = NULL;
}
if (pdd) {
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 71ca02a..033cbb3 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -477,18 +477,21 @@ typedef enum eParticleChildFlag {
/* part->draw_as */
/* part->ren_as*/
-#define PART_DRAW_NOT 0
-#define PART_DRAW_DOT 1
-#define PART_DRAW_HALO 1
-#define PART_DRAW_CIRC 2
-#define PART_DRAW_CROSS 3
-#define PART_DRAW_AXIS 4
-#define PART_DRAW_LINE 5
-#define PART_DRAW_PATH 6
-#define PART_DRAW_OB 7
-#define PART_DRAW_GR 8
-#define PART_DRAW_BB 9
-#define PART_DRAW_REND 10
+typedef enum eParticleDrawMethod {
+ PART_DRAW_NOT = 0,
+ PART_DRAW_DOT = 1,
+ PART_DRAW_HALO = 1,
+ PART_DRAW_CIRC = 2,
+ PART_DRAW_CROSS = 3,
+ PART_DRAW_AXIS = 4,
+ PART_DRAW_LINE = 5,
+ PART_DRAW_PATH = 6,
+ PART_DRAW_OB = 7,
+ PART_DRAW_GR = 8,
+ PART_DRAW_BB = 9,
+ PART_DRAW_REND = 10,
+ PART_DRAW_HULL = 11,
+} eParticleDrawMethod;
/* part->integrator */
#define PART_INT_EULER 0
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index a5ed3ff..0af22df 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -98,9 +98,10 @@ static EnumPropertyItem part_draw_as_items[] = {
#ifdef RNA_RUNTIME
static EnumPropertyItem part_hair_draw_as_items[] = {
- {PART_DRAW_NOT, "NONE", 0, "None", ""},
- {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
- {PART_DRAW_PATH, "PATH", 0, "Path", ""},
+ {PART_DRAW_NOT, "NONE", 0, "None", "No hair drawing"},
+ {PART_DRAW_REND, "RENDER", 0, "Rendered", "Approximate render result in the viewport"},
+ {PART_DRAW_PATH, "PATH", 0, "Path", "Show path of hair particles"},
+ {PART_DRAW_HULL, "HULL", 0, "Hull", "Show convex hull of child particle paths"},
{0, NULL, 0, NULL, NULL}
};
#endif
More information about the Bf-blender-cvs
mailing list