[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14846] trunk/blender/source/gameengine: Fix BGE bug #7532: TrackTo Actuator does not work correctly if it has a Vertex Parent.

Benoit Bolsee benoit.bolsee at online.be
Wed May 14 22:22:57 CEST 2008


Revision: 14846
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14846
Author:   ben2610
Date:     2008-05-14 22:22:57 +0200 (Wed, 14 May 2008)

Log Message:
-----------
Fix BGE bug #7532: TrackTo Actuator does not work correctly if it has a Vertex Parent.  This is only a partial fix: the user must put the parent vertex at the center of the parent object and disable the physics on the tracking object (use empty or collision free object).

Modified Paths:
--------------
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
    trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
    trunk/blender/source/gameengine/Ketsji/KX_TrackToActuator.cpp
    trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp
    trunk/blender/source/gameengine/SceneGraph/SG_Node.h
    trunk/blender/source/gameengine/SceneGraph/SG_ParentRelation.h

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2008-05-14 20:22:57 UTC (rev 14846)
@@ -368,7 +368,15 @@
 	{ 
 		return m_bDyna; 
 	}
-	
+
+	/**
+	 * Check if this object has a vertex parent relationship
+	 */
+	bool IsVertexParent( )
+	{
+		return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
+	}
+
 	bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
 
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h	2008-05-14 20:22:57 UTC (rev 14846)
@@ -129,6 +129,12 @@
 	~KX_VertexParentRelation(
 	);
 
+		bool
+	IsVertexRelation(
+	) { 
+		return true;
+	}
+
 private :
 
 	KX_VertexParentRelation(

Modified: trunk/blender/source/gameengine/Ketsji/KX_TrackToActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_TrackToActuator.cpp	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/Ketsji/KX_TrackToActuator.cpp	2008-05-14 20:22:57 UTC (rev 14846)
@@ -69,13 +69,19 @@
 	m_upflag = upflag;
 	m_parentobj = 0;
 	
-	if (m_object){
+	if (m_object)
 		m_object->RegisterActuator(this);
-		KX_GameObject* curobj = (KX_GameObject*) GetParent();
 
-		m_parentobj = curobj->GetParent(); // check if the object is parented 
-		if (m_parentobj) {  // if so, store the initial local rotation
-			m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+	if (gameobj->isA(&KX_GameObject::Type))
+	{
+		// if the object is vertex parented, don't check parent orientation as the link is broken
+		if (!((KX_GameObject*)gameobj)->IsVertexParent()){
+			m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented 
+			if (m_parentobj) {  
+				// if so, store the initial local rotation
+				// this is needed to revert the effect of the parent inverse node (TBC)
+				m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+			}
 		}
 	}
 
@@ -180,6 +186,8 @@
 {
 	if (m_object)
 		m_object->UnregisterActuator(this);
+	if (m_parentobj)
+		m_parentobj->Release();
 } /* end of destructor */
 
 void KX_TrackToActuator::ProcessReplica()

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp	2008-05-14 20:22:57 UTC (rev 14846)
@@ -148,6 +148,16 @@
 	return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this);
 }
 
+	bool
+SG_Node::
+IsVertexParent()
+{
+	if (m_parent_relation)
+	{
+		return m_parent_relation->IsVertexRelation();
+	}
+	return false;
+}
 
 	void 
 SG_Node::

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Node.h
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Node.h	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Node.h	2008-05-14 20:22:57 UTC (rev 14846)
@@ -152,6 +152,14 @@
 	) ;
 
 
+	/**
+	 * Return vertex parent status.
+	 */
+
+		bool	
+	IsVertexParent(
+	) ;
+
 	/**		
 	 * Update the spatial data of this node. Iterate through
 	 * the children of this node and update their world data.

Modified: trunk/blender/source/gameengine/SceneGraph/SG_ParentRelation.h
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_ParentRelation.h	2008-05-14 20:01:22 UTC (rev 14845)
+++ trunk/blender/source/gameengine/SceneGraph/SG_ParentRelation.h	2008-05-14 20:22:57 UTC (rev 14846)
@@ -90,6 +90,15 @@
 	NewCopy(
 	) = 0;
 
+	/**
+	 * Vertex Parent Relation are special: they don't propagate rotation
+	 */
+	virtual
+		bool
+	IsVertexRelation(
+	) { 
+		return false;
+	}
 protected :
 
 	/** 





More information about the Bf-blender-cvs mailing list