[Bf-blender-cvs] [1a43510] temp_hair_flow: Simple operator for solving and integrating the hair flow grid.

Lukas Tönne noreply at git.blender.org
Wed Jan 7 19:37:38 CET 2015


Commit: 1a435106e6523a06dcffc59df92709e0ded569d9
Author: Lukas Tönne
Date:   Tue Jan 6 15:34:06 2015 +0100
Branches: temp_hair_flow
https://developer.blender.org/rB1a435106e6523a06dcffc59df92709e0ded569d9

Simple operator for solving and integrating the hair flow grid.

This would probably become an automatic update running in a job
eventually, but for testing this is the easiest implementation.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/hair/CMakeLists.txt
A	source/blender/editors/hair/hair_flow.c
M	source/blender/editors/hair/hair_intern.h
M	source/blender/editors/hair/hair_ops.c
M	source/blender/physics/BPH_strands.h
M	source/blender/physics/intern/hair_flow.cpp

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index c9f4c69..ebbe0bf 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -899,6 +899,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
 
             col.prop(brush, "hair_tool", text="Tool")
 
+            col.separator()
+
+            col.operator("hair.solve_flow")
+
         # Sculpt Mode #
 
         elif context.sculpt_object and brush:
diff --git a/source/blender/editors/hair/CMakeLists.txt b/source/blender/editors/hair/CMakeLists.txt
index 570f46c..18754b0 100644
--- a/source/blender/editors/hair/CMakeLists.txt
+++ b/source/blender/editors/hair/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
 	../../gpu
 	../../makesdna
 	../../makesrna
+	../../physics
 	../../windowmanager
 	../../../../intern/guardedalloc
 	../../../../intern/glew-mx
@@ -40,6 +41,7 @@ set(INC_SYS
 set(SRC
 	hair_cursor.c
 	hair_edit.c
+	hair_flow.c
 	hair_ops.c
 	hair_select.c
 	hair_stroke.c
diff --git a/source/blender/editors/hair/hair_flow.c b/source/blender/editors/hair/hair_flow.c
new file mode 100644
index 0000000..1c34b1c
--- /dev/null
+++ b/source/blender/editors/hair/hair_flow.c
@@ -0,0 +1,91 @@
+/*
+ * ***** 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) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/hair/hair_flow.c
+ *  \ingroup edhair
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+
+#include "BPH_strands.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_physics.h"
+
+#include "hair_intern.h"
+
+static int hair_solve_flow_exec(bContext *C, wmOperator *op)
+{
+	Scene *scene = CTX_data_scene(C);
+	Object *ob = CTX_data_active_object(C);
+	BMEditStrands *edit = BKE_editstrands_from_object(ob);
+//	HairEditSettings *settings = &scene->toolsettings->hair_edit;
+	
+	struct HairFlowData *data = BPH_strands_solve_hair_flow(scene, ob);
+	
+	BPH_strands_sample_hair_flow(ob, edit, data);
+	
+	BPH_strands_free_hair_flow(data);
+	
+	WM_event_add_notifier(C, NC_OBJECT | ND_DRAW | NA_SELECTED, ob);
+	
+	return OPERATOR_FINISHED;
+}
+
+void HAIR_OT_solve_flow(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Solve Hair Flow";
+	ot->idname = "HAIR_OT_solve_flow";
+	ot->description = "Generate hair strands based on flow editing";
+
+	/* api callbacks */
+	ot->exec = hair_solve_flow_exec;
+	ot->poll = hair_edit_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/hair/hair_intern.h b/source/blender/editors/hair/hair_intern.h
index 4854104..42abe6f 100644
--- a/source/blender/editors/hair/hair_intern.h
+++ b/source/blender/editors/hair/hair_intern.h
@@ -47,6 +47,9 @@ int hair_edit_poll(struct bContext *C);
 
 void HAIR_OT_hair_edit_toggle(struct wmOperatorType *ot);
 
+/* hair_flow.c */
+void HAIR_OT_solve_flow(struct wmOperatorType *ot);
+
 /* hair_select.c */
 void HAIR_OT_select_all(struct wmOperatorType *ot);
 void HAIR_OT_select_linked(struct wmOperatorType *ot);
diff --git a/source/blender/editors/hair/hair_ops.c b/source/blender/editors/hair/hair_ops.c
index bb3b027..762d5aa 100644
--- a/source/blender/editors/hair/hair_ops.c
+++ b/source/blender/editors/hair/hair_ops.c
@@ -49,6 +49,8 @@ void ED_operatortypes_hair(void)
 {
 	WM_operatortype_append(HAIR_OT_hair_edit_toggle);
 	
+	WM_operatortype_append(HAIR_OT_solve_flow);
+	
 	WM_operatortype_append(HAIR_OT_select_all);
 	WM_operatortype_append(HAIR_OT_select_linked);
 	
diff --git a/source/blender/physics/BPH_strands.h b/source/blender/physics/BPH_strands.h
index 46b0ab4..160df95 100644
--- a/source/blender/physics/BPH_strands.h
+++ b/source/blender/physics/BPH_strands.h
@@ -33,6 +33,7 @@ extern "C" {
 #endif
 
 struct Object;
+struct Scene;
 struct BMEditStrands;
 
 void BPH_strands_solve_constraints(struct Object *ob, struct BMEditStrands *es, float (*orig)[3]);
@@ -41,10 +42,10 @@ void BPH_strands_solve_constraints(struct Object *ob, struct BMEditStrands *es,
 
 struct HairFlowData;
 
-struct HairFlowData *BPH_strands_solve_hair_flow(struct Object *ob);
+struct HairFlowData *BPH_strands_solve_hair_flow(struct Scene *scene, struct Object *ob);
 void BPH_strands_free_hair_flow(struct HairFlowData *data);
 
-void BPH_strands_sample_hair_flow(struct Object *ob, struct BMEditStrands *es, struct HairFlowData *data);
+void BPH_strands_sample_hair_flow(struct Object *ob, struct BMEditStrands *edit, struct HairFlowData *data);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/physics/intern/hair_flow.cpp b/source/blender/physics/intern/hair_flow.cpp
index 570b2b3..f39b104 100644
--- a/source/blender/physics/intern/hair_flow.cpp
+++ b/source/blender/physics/intern/hair_flow.cpp
@@ -35,7 +35,8 @@ extern "C" {
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
-#include "DNA_texture_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_effect.h"
 }
@@ -48,7 +49,7 @@ extern "C" {
 struct HairFlowData {
 };
 
-HairFlowData *BPH_strands_solve_hair_flow(Object *ob)
+HairFlowData *BPH_strands_solve_hair_flow(Scene *scene, Object *ob)
 {
 	return NULL;
 }
@@ -57,7 +58,7 @@ void BPH_strands_free_hair_flow(HairFlowData *data)
 {
 }
 
-void BPH_strands_sample_hair_flow(Object *ob, BMEditStrands *es, HairFlowData *data)
+void BPH_strands_sample_hair_flow(Object *ob, BMEditStrands *edit, HairFlowData *data)
 {
 	
 }




More information about the Bf-blender-cvs mailing list