[Bf-blender-cvs] [d1258f92f82] hair_guides: Use edit submode for groom overlay rendering.

Lukas Tönne noreply at git.blender.org
Sat Dec 23 12:10:26 CET 2017


Commit: d1258f92f82627eaffc0597b00fa979e4756c86c
Author: Lukas Tönne
Date:   Sat Dec 23 11:09:50 2017 +0000
Branches: hair_guides
https://developer.blender.org/rBd1258f92f82627eaffc0597b00fa979e4756c86c

Use edit submode for groom overlay rendering.

===================================================================

M	source/blender/draw/intern/draw_cache.c
M	source/blender/draw/intern/draw_cache.h
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_groom.c
M	source/blender/draw/modes/edit_groom_mode.c

===================================================================

diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 2eb5f1dd1be..442f30bfcbb 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -2498,12 +2498,12 @@ Gwn_Batch *DRW_cache_groom_wire_get(Object *ob)
 	return DRW_groom_batch_cache_get_all_edges(groom);
 }
 
-Gwn_Batch *DRW_cache_groom_vert_overlay_get(Object *ob)
+Gwn_Batch *DRW_cache_groom_vert_overlay_get(Object *ob, int mode)
 {
 	BLI_assert(ob->type == OB_GROOM);
 
 	struct Groom *groom = ob->data;
-	return DRW_groom_batch_cache_get_overlay_verts(groom);
+	return DRW_groom_batch_cache_get_overlay_verts(groom, mode);
 }
 
 /** \} */
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 9604001f6cf..3bef2940175 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -165,7 +165,7 @@ struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob);
 /* Groom */
 struct Gwn_Batch *DRW_cache_groom_verts_get(struct Object *ob);
 struct Gwn_Batch *DRW_cache_groom_wire_get(struct Object *ob);
-struct Gwn_Batch *DRW_cache_groom_vert_overlay_get(struct Object *ob);
+struct Gwn_Batch *DRW_cache_groom_vert_overlay_get(struct Object *ob, int mode);
 
 /* Particles */
 struct Gwn_Batch *DRW_cache_particles_get_hair(struct ParticleSystem *psys, struct ModifierData *md);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 67599b51c96..56386ddde1a 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -98,7 +98,7 @@ struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt);
 /* Groom */
 struct Gwn_Batch *DRW_groom_batch_cache_get_all_edges(struct Groom *groom);
 struct Gwn_Batch *DRW_groom_batch_cache_get_all_verts(struct Groom *groom);
-struct Gwn_Batch *DRW_groom_batch_cache_get_overlay_verts(struct Groom *groom);
+struct Gwn_Batch *DRW_groom_batch_cache_get_overlay_verts(struct Groom *groom, int mode);
 
 /* Mesh */
 
diff --git a/source/blender/draw/intern/draw_cache_impl_groom.c b/source/blender/draw/intern/draw_cache_impl_groom.c
index 5a811b8a488..b296c1ec4eb 100644
--- a/source/blender/draw/intern/draw_cache_impl_groom.c
+++ b/source/blender/draw/intern/draw_cache_impl_groom.c
@@ -39,6 +39,7 @@
 #include "BLI_listbase.h"
 
 #include "DNA_groom_types.h"
+#include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 
 #include "BKE_groom.h"
@@ -179,45 +180,107 @@ BLI_INLINE char make_vertex_flag(bool active, bool selected)
 	return vflag;
 }
 
-#define GM_ATTR_ID_UNUSED 0xFFFFFFFF
+/* Parts of the groom object to render */
+typedef enum GroomRenderPart
+{
+	GM_RENDER_REGIONS   = (1 << 0),   /* Draw scalp regions */
+	GM_RENDER_CURVES    = (1 << 1),   /* Draw center curves of bundles */
+	GM_RENDER_SECTIONS  = (1 << 2),   /* Draw section curves */
+	
+	GM_RENDER_ALL       = GM_RENDER_REGIONS | GM_RENDER_CURVES | GM_RENDER_SECTIONS,
+} GroomRenderPart;
 
-static void groom_create_center_curves(
-        Groom *groom,
-        int tessellation,
-        Gwn_VertBuf *vbo,
-        Gwn_IndexBuf **ibo,
-        uint id_pos,
-        uint id_flag)
+static int groom_count_verts(Groom *groom, int parts, int tessellation)
 {
 	UNUSED_VARS(tessellation);
 	
-	Gwn_IndexBufBuilder elb;
-	
 	int vert_len = 0;
-	int edge_len = 0;
-	for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+	
+	if (parts & GM_RENDER_REGIONS)
+	{
+		// TODO
+	}
+	if (parts & GM_RENDER_CURVES)
+	{
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			int numsections = BLI_listbase_count(&bundle->sections);
+			vert_len += numsections;
+		}
+	}
+	if (parts & GM_RENDER_SECTIONS)
 	{
-		int numsections = BLI_listbase_count(&bundle->sections);
-		vert_len += numsections;
-		edge_len += numsections - 1;
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+			{
+				// TODO
+				//vert_len += ...;
+			}
+		}
 	}
 	
-	if (vbo)
+	return vert_len;
+}
+
+static int groom_count_edges(Groom *groom, int parts, int tessellation)
+{
+	UNUSED_VARS(tessellation);
+	
+	int edge_len = 0;
+	
+	if (parts & GM_RENDER_REGIONS)
 	{
-		GWN_vertbuf_data_alloc(vbo, vert_len);
+		// TODO
 	}
-	if (ibo)
+	if (parts & GM_RENDER_CURVES)
 	{
-		GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			int numsections = BLI_listbase_count(&bundle->sections);
+			edge_len += numsections - 1;
+		}
 	}
+	if (parts & GM_RENDER_SECTIONS)
+	{
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+			{
+				// TODO
+				//edge_len += ...;
+			}
+		}
+	}
+	
+	return edge_len;
+}
+
+#define GM_ATTR_ID_UNUSED 0xFFFFFFFF
+
+static void groom_get_verts(
+        Groom *groom,
+        int parts,
+        int tessellation,
+        Gwn_VertBuf *vbo,
+        uint id_pos,
+        uint id_flag)
+{
+	int vert_len = groom_count_verts(groom, parts, tessellation);
+	
+	GWN_vertbuf_data_alloc(vbo, vert_len);
 	
-	uint idx = 0;
-	for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+	if (parts & GM_RENDER_REGIONS)
 	{
-		const bool active = bundle->flag & GM_BUNDLE_SELECT;
-		for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+		// TODO
+	}
+	if (parts & GM_RENDER_CURVES)
+	{
+		uint idx = 0;
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
 		{
-			if (vbo)
+			const bool active = bundle->flag & GM_BUNDLE_SELECT;
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
 			{
 				if (id_pos != GM_ATTR_ID_UNUSED)
 				{
@@ -228,83 +291,76 @@ static void groom_create_center_curves(
 					char vflag = make_vertex_flag(active, section->flag & GM_SECTION_SELECT);
 					GWN_vertbuf_attr_set(vbo, id_flag, idx, &vflag);
 				}
+				
+				++idx;
 			}
-			if (ibo)
-			{
-				if (section->prev)
-				{
-					GWN_indexbuf_add_line_verts(&elb, idx-1, idx);
-				}
-			}
-			
-			++idx;
 		}
 	}
-	
-	if (ibo)
+	if (parts & GM_RENDER_SECTIONS)
 	{
-		*ibo = GWN_indexbuf_build(&elb);
+		uint idx = 0;
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+			{
+				// TODO
+				UNUSED_VARS(idx);
+			}
+		}
 	}
 }
 
-static void groom_create_section_curves(
+static void groom_get_edges(
         Groom *groom,
+        int parts,
         int tessellation,
-        Gwn_VertBuf *vbo,
-        Gwn_IndexBuf **ibo,
-        uint id_pos,
-        uint id_flag)
+        Gwn_IndexBuf **ibo)
 {
-	UNUSED_VARS(tessellation, id_pos, id_flag);
-	
 	Gwn_IndexBufBuilder elb;
 	
-	const int vert_len = 0;
-	const int edge_len = 0;
-	for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
-	{
-		for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
-		{
-			// TODO
-			//vert_len += ...;
-			//edge_len += ...;
-		}
-	}
-	if (vbo)
+	int vert_len = groom_count_verts(groom, parts, tessellation);
+	int edge_len = groom_count_edges(groom, parts, tessellation);
+	
+	GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+	
+	if (parts & GM_RENDER_REGIONS)
 	{
-		GWN_vertbuf_data_alloc(vbo, vert_len);
+		// TODO
 	}
-	if (ibo)
+	if (parts & GM_RENDER_CURVES)
 	{
-		GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len);
+		uint idx = 0;
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+		{
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+			{
+				if (section->prev)
+				{
+					GWN_indexbuf_add_line_verts(&elb, idx-1, idx);
+				}
+				
+				++idx;
+			}
+		}
 	}
-	
-	uint idx = 0;
-	for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
+	if (parts & GM_RENDER_SECTIONS)
 	{
-		for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+		uint idx = 0;
+		for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
 		{
-			// TODO
-			UNUSED_VARS(idx);
+			for (GroomBundleSection *section = bundle->sections.first; section; section = section->next)
+			{
+				// TODO
+				UNUSED_VARS(idx);
+			}
 		}
 	}
 	
-	if (ibo)
-	{
-		*ibo = GWN_indexbuf_build(&elb);
-	}
+	*ibo = GWN_indexbuf_build(&elb);
 }
 
-/* Parts of the groom object to render */
-typedef enum GroomRenderPart
-{
-	GM_RENDER_REGIONS   = (1 << 0),   /* Draw scalp regions */
-	GM_RENDER_CURVES    = (1 << 1),   /* Draw center curves of bundles */
-	GM_RENDER_SECTIONS  = (1 << 2),   /* Draw section curves */
-} GroomRenderPart;
-
 /* Gwn_Batch cache usage. */
-static Gwn_VertBuf *groom_batch_cache_get_pos(Groom *groom, GroomBatchCache *cache, GroomRenderPart part)
+static Gwn_VertBuf *groom_batch_cache_get_pos(Groom *groom, GroomBatchCache *cache, int parts)
 {
 	if (cache->pos == NULL) {
 		static Gwn_VertFormat format = { 0 };
@@ -317,42 +373,22 @@ static Gwn_VertBuf *groom_batch_cache_get_pos(Groom *groom, GroomBatchCache *cac
 		
 		cache->pos = GWN_vertbuf_create_with_format(&format);
 		
-		switch (part)
-		{
-			case GM_RENDER_REGIONS:
-				break;
-			case GM_RENDER_CURVES:
-				groom_create_center_curves(groom, 0, cache->pos, NULL, attr_id.pos, GM_ATTR_ID_UNUSED);
-				break;
-			case GM_RENDER_SECTIONS:
-				groom_create_section_curves(groom, 0, cache->pos, NULL, attr_id.pos, GM_ATTR_ID_UNUSED);
-				break;
-		}
+		groom_get_verts(groom, parts, 0, cache->pos, attr_id.pos, GM_ATTR_ID_UNUSED);
 	}
 
 	return cache->pos;
 }
 
-static Gwn_IndexBuf *groom_batch_cache_get_edges(Groom *groom, GroomBatchCache *cache, GroomRenderPart part)
+static Gwn_IndexBuf *groom_batch_cache_get_edges(Groom *groom, GroomBatchCache *cache, int p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list