[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23567] branches/blender2.4/source/ gameengine/GameLogic/SCA_PropertySensor.cpp: comparing float values with the property sensor didnt work

Campbell Barton ideasman42 at gmail.com
Wed Sep 30 15:19:43 CEST 2009


Revision: 23567
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23567
Author:   campbellbarton
Date:     2009-09-30 15:19:42 +0200 (Wed, 30 Sep 2009)

Log Message:
-----------
comparing float values with the property sensor didnt work

Modified Paths:
--------------
    branches/blender2.4/source/gameengine/GameLogic/SCA_PropertySensor.cpp

Modified: branches/blender2.4/source/gameengine/GameLogic/SCA_PropertySensor.cpp
===================================================================
--- branches/blender2.4/source/gameengine/GameLogic/SCA_PropertySensor.cpp	2009-09-30 08:47:39 UTC (rev 23566)
+++ branches/blender2.4/source/gameengine/GameLogic/SCA_PropertySensor.cpp	2009-09-30 13:19:42 UTC (rev 23567)
@@ -38,6 +38,7 @@
 #include "SCA_EventManager.h"
 #include "SCA_LogicManager.h"
 #include "BoolValue.h"
+#include "FloatValue.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -191,6 +192,22 @@
 					m_checkpropval.Upper();
 				}
 				result = (testprop == m_checkpropval);
+				
+				/* Patch: floating point values cant use strings usefully since you can have "0.0" == "0.0000"
+				 * this could be made into a generic Value class function for comparing values with a string.
+				 */
+				if(result==false && dynamic_cast<CFloatValue *>(orgprop) != NULL) {
+					float f;
+					
+					if(EOF == sscanf(m_checkpropval.ReadPtr(), "%f", &f))
+					{
+						//error
+					} 
+					else {
+						result = (f == ((CFloatValue *)orgprop)->GetFloat());
+					}
+				}
+				/* end patch */
 			}
 			orgprop->Release();
 





More information about the Bf-blender-cvs mailing list