[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35514] trunk/blender/source/blender/ editors/armature/poseSlide.c: Replaced RNA code in previous commit with a version which should be a

Joshua Leung aligorith at gmail.com
Sun Mar 13 13:26:54 CET 2011


Revision: 35514
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35514
Author:   aligorith
Date:     2011-03-13 12:26:53 +0000 (Sun, 13 Mar 2011)
Log Message:
-----------
Replaced RNA code in previous commit with a version which should be a
bit safer (less likelyhood of float <-> int corruption)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/poseSlide.c

Modified: trunk/blender/source/blender/editors/armature/poseSlide.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseSlide.c	2011-03-13 12:22:57 UTC (rev 35513)
+++ trunk/blender/source/blender/editors/armature/poseSlide.c	2011-03-13 12:26:53 UTC (rev 35514)
@@ -193,7 +193,7 @@
 }
 
 /* helper for apply() - perform sliding for some value */
-static void pose_slider_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
+static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
 {
 	float cframe = (float)pso->cframe;
 	float sVal, eVal;
@@ -283,7 +283,7 @@
 		FCurve *fcu= (FCurve *)ld->data;
 		
 		/* just work on these channels one by one... there's no interaction between values */
-		pose_slider_apply_val(pso, fcu, &vec[fcu->array_index]);
+		pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]);
 	}
 	
 	/* free the temp path we got */
@@ -324,11 +324,28 @@
 			PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr);
 			
 			if (prop) {
-				float tval = RNA_property_float_get(&ptr, prop);
-				
-				pose_slider_apply_val(pso, fcu, &tval);
-				
-				RNA_property_float_set(&ptr, prop, tval);
+				switch (RNA_property_type(prop)) {
+					case PROP_FLOAT:
+					{
+						float tval = RNA_property_float_get(&ptr, prop);
+						pose_slide_apply_val(pso, fcu, &tval);
+						RNA_property_float_set(&ptr, prop, tval);
+					}
+						break;
+					case PROP_BOOLEAN:
+					case PROP_ENUM:
+					case PROP_INT:
+					{
+						float tval = (float)RNA_property_int_get(&ptr, prop);
+						pose_slide_apply_val(pso, fcu, &tval);
+						RNA_property_int_set(&ptr, prop, (int)tval);
+					}
+						break;
+					default:
+						/* cannot handle */
+						//printf("Cannot Pose Slide non-numerical property\n");
+						break;
+				}
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list