[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23174] branches/blender2.4/source/ gameengine/Ketsji: Patch [#19293] NearSensor: Changing distance and resetDistance from Python did not take effect immediately

Campbell Barton ideasman42 at gmail.com
Sun Sep 13 10:17:22 CEST 2009


Revision: 23174
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23174
Author:   campbellbarton
Date:     2009-09-13 10:17:22 +0200 (Sun, 13 Sep 2009)

Log Message:
-----------
Patch [#19293] NearSensor: Changing distance and resetDistance from Python did not take effect immediately
from Frank Papenmeier (hodka)
 --- from the submission
Changing the distance and resetDistance Properties of a NearSensor from Python did only take effect, once there was
a collision within the old radius.

Reason:
The radius of the PHY_IPhysicsController was not set to the new values.

Solution:
It is set at the end of the CheckResetDistance function. I moved the relevant code snippet from the Evaluate function
into a new function called SetPhysCtrlRadius in order to avoid duplicating code doing the same thing.
 

Modified Paths:
--------------
    branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.cpp
    branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.h

Modified: branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.cpp
===================================================================
--- branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.cpp	2009-09-13 08:08:50 UTC (rev 23173)
+++ branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.cpp	2009-09-13 08:17:22 UTC (rev 23174)
@@ -144,6 +144,22 @@
 		delete m_client_info;
 }
 
+void KX_NearSensor::SetPhysCtrlRadius()
+{
+	if (m_bTriggered)
+	{
+		if (m_physCtrl)
+		{
+			m_physCtrl->SetRadius(m_ResetMargin);
+		}
+	} else
+	{
+		if (m_physCtrl)
+		{
+			m_physCtrl->SetRadius(m_Margin);
+		}
+	}
+}
 
 bool KX_NearSensor::Evaluate()
 {
@@ -153,20 +169,9 @@
 	if (m_bTriggered != m_bLastTriggered)
 	{
 		m_bLastTriggered = m_bTriggered;
-		if (m_bTriggered)
-		{
-			if (m_physCtrl)
-			{
-				m_physCtrl->SetRadius(m_ResetMargin);
-			}
-		} else
-		{
-			if (m_physCtrl)
-			{
-				m_physCtrl->SetRadius(m_Margin);
-			}
-
-		}
+		
+		SetPhysCtrlRadius();
+		
 		result = true;
 	}
 

Modified: branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.h
===================================================================
--- branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.h	2009-09-13 08:08:50 UTC (rev 23173)
+++ branches/blender2.4/source/gameengine/Ketsji/KX_NearSensor.h	2009-09-13 08:17:22 UTC (rev 23174)
@@ -70,6 +70,7 @@
 	virtual void SynchronizeTransform();
 	virtual CValue* GetReplica();
 	virtual void ProcessReplica();
+	virtual void SetPhysCtrlRadius();
 	virtual bool Evaluate();
 
 	virtual void ReParent(SCA_IObject* parent);
@@ -96,6 +97,8 @@
 		if (sensor->m_Margin > sensor->m_ResetMargin)
 			sensor->m_ResetMargin = sensor->m_Margin;
 
+		sensor->SetPhysCtrlRadius();
+			
 		return 0;
 	}
 





More information about the Bf-blender-cvs mailing list