[Bf-blender-cvs] [a79e17f] hair_system: Added an operator for resetting hairs to their rest positions.

Lukas Tönne noreply at git.blender.org
Mon Jul 28 14:25:01 CEST 2014


Commit: a79e17f70349de47946aab431b4760b9a7911764
Author: Lukas Tönne
Date:   Mon Jul 28 14:13:14 2014 +0200
Branches: hair_system
https://developer.blender.org/rBa79e17f70349de47946aab431b4760b9a7911764

Added an operator for resetting hairs to their rest positions.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/physics/hair_ops.c
M	source/blender/editors/physics/physics_intern.h
M	source/blender/editors/physics/physics_ops.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index a5cc30c..9d6ebae 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1240,6 +1240,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         
         col.separator()
         
+        col.operator("hair.reset to rest location")
         col.operator("hair.copy_from_particles")
 
 
diff --git a/source/blender/editors/physics/hair_ops.c b/source/blender/editors/physics/hair_ops.c
index 09569a7..0fe0b95 100644
--- a/source/blender/editors/physics/hair_ops.c
+++ b/source/blender/editors/physics/hair_ops.c
@@ -82,6 +82,44 @@ static int ED_hair_active_poll(bContext *C)
 	return ED_hair_get(C, NULL, NULL);
 }
 
+/************************ reset hair to rest position *********************/
+
+static int hair_reset_to_rest_location_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Object *ob;
+	HairSystem *hsys;
+	int i, k;
+	ED_hair_get(C, &ob, &hsys);
+	
+	for (i = 0; i < hsys->totcurves; ++i) {
+		HairCurve *hair = &hsys->curves[i];
+		for (k = 0; k < hair->totpoints; ++k) {
+			HairPoint *point = &hair->points[k];
+			
+			copy_v3_v3(point->co, point->rest_co);
+			zero_v3(point->vel);
+		}
+	}
+	
+	WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+	return OPERATOR_FINISHED;
+}
+
+void HAIR_OT_reset_to_rest_location(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->idname = "HAIR_OT_reset to rest location";
+	ot->name = "Reset to Rest Location";
+	ot->description = "Reset hair data to the rest location";
+
+	/* callbacks */
+	ot->exec = hair_reset_to_rest_location_exec;
+	ot->poll = ED_hair_active_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /************************ copy hair data from old particles *********************/
 
 static void hair_copy_from_particles_psys(Object *ob, HairSystem *hsys, Object *UNUSED(pob), ParticleSystem *psys)
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 4b69c56..be0a2db 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -126,5 +126,6 @@ void RIGIDBODY_OT_world_export(struct wmOperatorType *ot);
 
 /* hair_ops.c */
 void HAIR_OT_copy_from_particles(struct wmOperatorType *ot);
+void HAIR_OT_reset_to_rest_location(struct wmOperatorType *ot);
 
 #endif /* __PHYSICS_INTERN_H__ */
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 32d27a2..068838f 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -104,6 +104,7 @@ static void operatortypes_particle(void)
 //	WM_operatortype_append(RIGIDBODY_OT_world_export);
 
 	WM_operatortype_append(HAIR_OT_copy_from_particles);
+	WM_operatortype_append(HAIR_OT_reset_to_rest_location);
 }
 
 static void keymap_particle(wmKeyConfig *keyconf)




More information about the Bf-blender-cvs mailing list