[Bf-blender-cvs] [8c16f4c] master: BGE: New Property sensor evaluation types

Jorge Bernal noreply at git.blender.org
Tue Jun 17 00:16:25 CEST 2014


Commit: 8c16f4c7d0b334b70ec3b01ac1d81d280e9759b1
Author: Jorge Bernal
Date:   Tue Jun 3 13:20:59 2014 -0700
https://developer.blender.org/rB8c16f4c7d0b334b70ec3b01ac1d81d280e9759b1

BGE: New Property sensor evaluation types

This patch adds "Less Than" and "Greater Than" evaluation types to the property sensor.
The Wiki Docs modifications http://wiki.blender.org/index.php/User:Lordloki/Doc:2.6/Manual/Game_Engine/Logic/Sensors/Property
Also, I have attached a screenshot and a blend to check.

Reviewers: dfelinto, moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D476

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

M	doc/python_api/rst/bge.logic.rst
M	source/blender/editors/space_logic/logic_window.c
M	source/blender/makesdna/DNA_sensor_types.h
M	source/blender/makesrna/intern/rna_sensor.c
M	source/gameengine/Converter/KX_ConvertSensors.cpp
M	source/gameengine/Expressions/BoolValue.cpp
M	source/gameengine/Expressions/BoolValue.h
M	source/gameengine/Expressions/EmptyValue.cpp
M	source/gameengine/Expressions/EmptyValue.h
M	source/gameengine/Expressions/ErrorValue.cpp
M	source/gameengine/Expressions/ErrorValue.h
M	source/gameengine/Expressions/FloatValue.cpp
M	source/gameengine/Expressions/FloatValue.h
M	source/gameengine/Expressions/IntValue.cpp
M	source/gameengine/Expressions/IntValue.h
M	source/gameengine/Expressions/ListValue.cpp
M	source/gameengine/Expressions/ListValue.h
M	source/gameengine/Expressions/StringValue.cpp
M	source/gameengine/Expressions/StringValue.h
M	source/gameengine/Expressions/Value.cpp
M	source/gameengine/Expressions/Value.h
M	source/gameengine/Expressions/VectorValue.cpp
M	source/gameengine/Expressions/VectorValue.h
M	source/gameengine/Expressions/VoidValue.h
M	source/gameengine/GameLogic/SCA_PropertySensor.cpp
M	source/gameengine/GameLogic/SCA_PropertySensor.h
M	source/gameengine/Ketsji/KX_PythonInit.cpp

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

diff --git a/doc/python_api/rst/bge.logic.rst b/doc/python_api/rst/bge.logic.rst
index 0ddae47..b378064 100644
--- a/doc/python_api/rst/bge.logic.rst
+++ b/doc/python_api/rst/bge.logic.rst
@@ -507,6 +507,18 @@ Property Sensor
    
    :value: 5
 
+.. data:: KX_PROPSENSOR_LESSTHAN
+
+   Activate when the property is less than the sensor value
+
+   :value: 6
+
+.. data:: KX_PROPSENSOR_GREATERTHAN
+
+   Activate when the property is greater than the sensor value
+
+   :value: 7
+
 ------------
 Radar Sensor
 ------------
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 4b53329..7f0fadc 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -1182,9 +1182,9 @@ static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr)
 			uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE);
 			break;
 		case SENS_PROP_EQUAL:
-			uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
-			break;
 		case SENS_PROP_NEQUAL:
+		case SENS_PROP_LESSTHAN:
+		case SENS_PROP_GREATERTHAN:
 			uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
 			break;
 		case SENS_PROP_CHANGED:
diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h
index fcdbbe3..cd1977c 100644
--- a/source/blender/makesdna/DNA_sensor_types.h
+++ b/source/blender/makesdna/DNA_sensor_types.h
@@ -202,6 +202,8 @@ typedef struct bJoystickSensor {
 #define SENS_PROP_INTERVAL	2
 #define SENS_PROP_CHANGED	3
 #define SENS_PROP_EXPRESSION	4
+#define SENS_PROP_LESSTHAN	5
+#define SENS_PROP_GREATERTHAN	6
 
 /* raysensor->axisflag */
 /* flip x and y to make y default!!! */
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index f5e5911..aeef04f 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -478,6 +478,8 @@ static void rna_def_property_sensor(BlenderRNA *brna)
 		{SENS_PROP_INTERVAL, "PROPINTERVAL", 0, "Interval", ""},
 		{SENS_PROP_CHANGED, "PROPCHANGED", 0, "Changed", ""},
 		/* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""},  NOT_USED_IN_UI */
+		{SENS_PROP_LESSTHAN, "PROPLESSTHAN", 0, "Less Than", ""},
+		{SENS_PROP_GREATERTHAN, "PROPGREATERTHAN", 0, "Greater Than", ""},
 		{0, NULL, 0, NULL, NULL}
 	};
 
@@ -498,7 +500,7 @@ static void rna_def_property_sensor(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "value");
-	RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal or Not Equal types");
+	RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal, Not Equal, Less Than and Greater Than types");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
 	prop = RNA_def_property(srna, "value_min", PROP_STRING, PROP_NONE);
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index b3c6f6d..93a5ee1 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -377,6 +377,12 @@ void BL_ConvertSensors(struct Object* blenderobject,
 						propchecktype = SCA_PropertySensor::KX_PROPSENSOR_EXPRESSION;
 						/* error */
 						break;
+					case SENS_PROP_LESSTHAN:
+						propchecktype = SCA_PropertySensor::KX_PROPSENSOR_LESSTHAN;
+						break;
+					case SENS_PROP_GREATERTHAN:
+						propchecktype = SCA_PropertySensor::KX_PROPSENSOR_GREATERTHAN;
+						break;
 					default:
 						; /* error */
 					}
diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp
index ee91387..9ff5339 100644
--- a/source/gameengine/Expressions/BoolValue.cpp
+++ b/source/gameengine/Expressions/BoolValue.cpp
@@ -186,6 +186,13 @@ double CBoolValue::GetNumber()
 
 
 
+int CBoolValue::GetValueType()
+{
+	return VALUE_BOOL_TYPE;
+}
+
+
+
 const STR_String& CBoolValue::GetText()
 {
 	return m_bool ? sTrueString : sFalseString;
diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h
index b88c839..161d611 100644
--- a/source/gameengine/Expressions/BoolValue.h
+++ b/source/gameengine/Expressions/BoolValue.h
@@ -41,6 +41,7 @@ public:
 
 	virtual const STR_String& GetText();
 	virtual double		GetNumber();
+	virtual int			GetValueType();
 	bool				GetBool();
 	virtual void		SetValue(CValue* newval);
 	
diff --git a/source/gameengine/Expressions/EmptyValue.cpp b/source/gameengine/Expressions/EmptyValue.cpp
index 7f3af9f..f8e7218 100644
--- a/source/gameengine/Expressions/EmptyValue.cpp
+++ b/source/gameengine/Expressions/EmptyValue.cpp
@@ -82,6 +82,13 @@ double CEmptyValue::GetNumber()
 
 
 
+int CEmptyValue::GetValueType()
+{
+	return VALUE_EMPTY_TYPE;
+}
+
+
+
 CListValue* CEmptyValue::GetPolySoup()
 {
 	CListValue* soup = new CListValue();
diff --git a/source/gameengine/Expressions/EmptyValue.h b/source/gameengine/Expressions/EmptyValue.h
index 8eccb97..88ef206 100644
--- a/source/gameengine/Expressions/EmptyValue.h
+++ b/source/gameengine/Expressions/EmptyValue.h
@@ -32,6 +32,7 @@ public:
 
 	virtual const STR_String &	GetText();
 	virtual double			GetNumber();
+	virtual int				GetValueType();
 	CListValue*				GetPolySoup();
 	virtual double*			GetVector3(bool bGetTransformedVec=false);
 	bool					IsInside(CValue* testpoint,bool bBorderInclude=true);
diff --git a/source/gameengine/Expressions/ErrorValue.cpp b/source/gameengine/Expressions/ErrorValue.cpp
index ba9c52b..46e09b9 100644
--- a/source/gameengine/Expressions/ErrorValue.cpp
+++ b/source/gameengine/Expressions/ErrorValue.cpp
@@ -107,6 +107,13 @@ double CErrorValue::GetNumber()
 
 
 
+int CErrorValue::GetValueType()
+{
+	return VALUE_ERROR_TYPE;
+}
+
+
+
 const STR_String & CErrorValue::GetText()
 {
 	return m_strErrorText;
diff --git a/source/gameengine/Expressions/ErrorValue.h b/source/gameengine/Expressions/ErrorValue.h
index 0095528..61c7215 100644
--- a/source/gameengine/Expressions/ErrorValue.h
+++ b/source/gameengine/Expressions/ErrorValue.h
@@ -27,6 +27,7 @@ class CErrorValue : public CPropValue
 public:
 	virtual const STR_String & GetText();
 	virtual double GetNumber();
+	virtual int GetValueType();
 	CErrorValue();
 	CErrorValue(const char *errmsg);
 	virtual ~CErrorValue();
diff --git a/source/gameengine/Expressions/FloatValue.cpp b/source/gameengine/Expressions/FloatValue.cpp
index 0f468e3..4d6f3f4 100644
--- a/source/gameengine/Expressions/FloatValue.cpp
+++ b/source/gameengine/Expressions/FloatValue.cpp
@@ -285,6 +285,13 @@ double CFloatValue::GetNumber()
 
 
 
+int CFloatValue::GetValueType()
+{
+	return VALUE_FLOAT_TYPE;
+}
+
+
+
 void CFloatValue::SetValue(CValue* newval)
 { 	
 	m_float = (float)newval->GetNumber(); 
diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h
index bc6a2d0..379c3e9 100644
--- a/source/gameengine/Expressions/FloatValue.h
+++ b/source/gameengine/Expressions/FloatValue.h
@@ -33,6 +33,7 @@ public:
 
 	void Configure(CValue* menuvalue);
 	virtual double GetNumber();
+	virtual int GetValueType();
 	virtual void SetValue(CValue* newval);
 	float GetFloat();
 	void SetFloat(float fl);
diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp
index fa4c9ad..5cb8a1c 100644
--- a/source/gameengine/Expressions/IntValue.cpp
+++ b/source/gameengine/Expressions/IntValue.cpp
@@ -298,6 +298,13 @@ double CIntValue::GetNumber()
 
 
 
+int CIntValue::GetValueType()
+{
+	return VALUE_INT_TYPE;
+}
+
+
+
 const STR_String & CIntValue::GetText()
 {
 	if (!m_pstrRep)
diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h
index 8411b09..6da975f 100644
--- a/source/gameengine/Expressions/IntValue.h
+++ b/source/gameengine/Expressions/IntValue.h
@@ -31,6 +31,7 @@ class CIntValue : public CPropValue
 public:
 	virtual const STR_String& GetText();
 	virtual double			GetNumber();
+	virtual int				GetValueType();
 	
 	cInt GetInt();
 	CIntValue();
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp
index 1f12a9b..75e3b49 100644
--- a/source/gameengine/Expressions/ListValue.cpp
+++ b/source/gameengine/Expressions/ListValue.cpp
@@ -250,6 +250,13 @@ double CListValue::GetNumber()
 
 
 
+int CListValue::GetValueType()
+{
+	return VALUE_LIST_TYPE;
+}
+
+
+
 void CListValue::SetModified(bool bModified)
 {
 	CValue::SetModified(bModified);
diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h
index 5240c54..bb18817 100644
--- a/source/gameengine/Expressions/ListValue.h
+++ b/source/gameengine/Expressions/ListValue.h
@@ -40,6 +40,7 @@ public:
 							  VALUE_OPERATOR op,
 							  CValue* val);
 	virtual double GetNumber();
+	virtual int GetValueType();
 	virtual CValue* GetReplica();
 
 public:
diff --git a/source/gameengine/Expressions/StringValue.cpp b/source/gameengine/Expressions/StringValue.cpp
index 166125b..098949c 100644
--- a/source/gameengine/Expressions/StringValue.cpp
+++ b/source/gameengine/Expressions/StringValue.cpp
@@ -120,6 +120,13 @@ double CStringValue::GetNumber()
 
 
 
+int CStringValue::GetValueType()
+{
+	return VALUE_STRING_TYPE;
+}
+
+
+
 const STR_String & CStringValue::GetText()
 {
 	return m_strString;
diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h
index 22d4334..cb60600 100644
--- a/source/gameengine/Expressions/StringValue.h
+++ b/source/gameengine/Expressions/StringValue.h
@@ -36,6 +36,7 @@ public:
 	virtual bool		IsEqual(const STR_String & other);
 	virtual const STR_String &	GetText();
 	virtual double		GetNumber();
+	virtual int			GetValueType();
 	
 	virtual	CValue*		Calc(VALUE_OPERATOR op, CValue *val);
 	virtual	CValue*		CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index e5c4001..1ced71e 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -494,6 +494,15 @@ void CVa

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list