[Bf-blender-cvs] [3db28f3] hair_system: Simple draw method for hair systems.

Lukas Tönne noreply at git.blender.org
Sat Jul 26 09:51:32 CEST 2014


Commit: 3db28f3525d454d34dfe35f76d6e6de1218efea3
Author: Lukas Tönne
Date:   Sat Jul 26 09:25:25 2014 +0200
Branches: hair_system
https://developer.blender.org/rB3db28f3525d454d34dfe35f76d6e6de1218efea3

Simple draw method for hair systems.

This is totally unoptimized and has only the bare minimum of key hair
display as lines. More sophisticated drawing will follow once the
requirements are clear.

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

M	source/blender/editors/space_view3d/CMakeLists.txt
A	source/blender/editors/space_view3d/drawhair.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/view3d_intern.h

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

diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 97c328d..5856060 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -41,6 +41,7 @@ set(INC_SYS
 set(SRC
 	drawanimviz.c
 	drawarmature.c
+	drawhair.c
 	drawmesh.c
 	drawobject.c
 	drawvolume.c
diff --git a/source/blender/editors/space_view3d/drawhair.c b/source/blender/editors/space_view3d/drawhair.c
new file mode 100644
index 0000000..3e746ff
--- /dev/null
+++ b/source/blender/editors/space_view3d/drawhair.c
@@ -0,0 +1,84 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 by the Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/drawarmature.c
+ *  \ingroup spview3d
+ */
+
+#include "DNA_hair_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_global.h"
+#include "BKE_hair.h"
+#include "BKE_modifier.h"
+
+#include "view3d_intern.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+/* ******** Hair Drawing ******** */
+
+/* TODO vertex/index buffers, etc. etc., avoid direct mode ... */
+
+static void draw_hair_curve(HairSystem *UNUSED(hsys), HairCurve *hair)
+{
+	HairPoint *point;
+	int k;
+	
+	glBegin(GL_LINE_STRIP);
+	for (point = hair->points, k = 0; k < hair->totpoints; ++point, ++k) {
+		glVertex3fv(point->co);
+	}
+	glEnd();
+}
+
+/* called from drawobject.c, return true if nothing was drawn */
+bool draw_hair_system(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar, Base *base, HairSystem *hsys)
+{
+	RegionView3D *rv3d = ar->regiondata;
+	Object *ob = base->object;
+	HairCurve *hair;
+	int i;
+	bool retval = true;
+	
+	glLoadMatrixf(rv3d->viewmat);
+	glMultMatrixf(ob->obmat);
+	
+	for (hair = hsys->curves, i = 0; i < hsys->totcurves; ++hair, ++i) {
+		draw_hair_curve(hsys, hair);
+	}
+	
+	return retval;
+}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8d39632..13fc59d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7644,6 +7644,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
 		}
 	}
 
+	/* draw hair */
+	{
+		HairModifierData *hmd = (HairModifierData *)modifiers_findByType(ob, eModifierType_Hair);
+		if (hmd) {
+			draw_hair_system(scene, v3d, ar, base, hmd->hairsys);
+		}
+	}
+
 	if (!render_override) {
 		bConstraint *con;
 
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 169bc49..e26ffc3 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -39,6 +39,7 @@ struct ARegion;
 struct ARegionType;
 struct BoundBox;
 struct DerivedMesh;
+struct HairSystem;
 struct Object;
 struct SmokeDomainSettings;
 struct ViewContext;
@@ -130,7 +131,9 @@ void draw_motion_path_instance(Scene *scene,
                                struct bAnimVizSettings *avs, struct bMotionPath *mpath);
 void draw_motion_paths_cleanup(View3D *v3d);
 
-
+/* drawhair.c */
+bool draw_hair_system(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+               struct HairSystem *hsys);
 
 /* drawobject.c */
 void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, const short dflag);




More information about the Bf-blender-cvs mailing list