Revision: 15221
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15221
Author:   campbellbarton
Date:     2008-06-14 19:12:49 +0200 (Sat, 14 Jun 2008)

Log Message:
-----------
Added access for adjusting timeOffset value at runtime, used for apricot 
(Franky climbing walls)

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

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp    2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp    2008-06-14 
17:12:49 UTC (rev 15221)
@@ -911,7 +911,15 @@
                
        if (attr == "name")
                return PyString_FromString(m_name.ReadPtr());
+       if (attr == "timeOffset") {
+               if (m_pSGNode->GetSGParent()->IsSlowParent()) {
+                       return 
PyFloat_FromDouble(static_cast<KX_SlowParentRelation 
*>(m_pSGNode->GetSGParent()->GetParentRelation())->GetTimeOffset());
+               } else {
+                       return PyFloat_FromDouble(0.0);
+               }
+       }
        
+       
        _getattr_up(SCA_IObject);
 }
 
@@ -932,6 +940,19 @@
                        return 0;
                }
        }
+
+       if (PyFloat_Check(value))
+       {
+               MT_Scalar val = PyFloat_AsDouble(value);
+               if (attr == "timeOffset") {
+                       if (m_pSGNode->GetSGParent()->IsSlowParent()) {
+                               static_cast<KX_SlowParentRelation 
*>(m_pSGNode->GetSGParent()->GetParentRelation())->SetTimeOffset(val);
+                               return 0;
+                       } else {
+                               return 0;
+                       }               
+               }
+       }
        
        if (PySequence_Check(value))
        {

Modified: trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h    
2008-06-14 16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/Ketsji/KX_SG_NodeRelationships.h    
2008-06-14 17:12:49 UTC (rev 15221)
@@ -177,8 +177,23 @@
        NewCopy(
        );
 
+               MT_Scalar
+       GetTimeOffset(
+       ) { return m_relax; }
+       
+               void
+       SetTimeOffset(
+               MT_Scalar relaxation
+       ) { m_relax = relaxation; }
+
        ~KX_SlowParentRelation(
        );
+       
+               bool
+       IsSlowRelation(
+       ) { 
+               return true;
+       }
 
 private :
 

Modified: trunk/blender/source/gameengine/PyDoc/KX_GameObject.py
===================================================================
--- trunk/blender/source/gameengine/PyDoc/KX_GameObject.py      2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/PyDoc/KX_GameObject.py      2008-06-14 
17:12:49 UTC (rev 15221)
@@ -22,6 +22,8 @@
        @type orientation: 3x3 Matrix [[float]]
        @ivar scaling: The object's scaling factor. list [sx, sy, sz]
        @type scaling: list [sx, sy, sz]
+       @ivar timeOffset: adjust the slowparent delay at runtime.
+       @type timeOffset: float
        """
        
        def setVisible(visible):

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp      2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Node.cpp      2008-06-14 
17:12:49 UTC (rev 15221)
@@ -159,6 +159,17 @@
        return false;
 }
 
+       bool
+SG_Node::
+IsSlowParent()
+{
+       if (m_parent_relation)
+       {
+               return m_parent_relation->IsSlowRelation();
+       }
+       return false;
+}
+
        void 
 SG_Node::
 DisconnectFromParent(

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Node.h
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Node.h        2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Node.h        2008-06-14 
17:12:49 UTC (rev 15221)
@@ -159,7 +159,15 @@
                bool    
        IsVertexParent(
        ) ;
+       
+       /**
+        * Return slow parent status.
+        */
 
+               bool    
+       IsSlowParent(
+       ) ;
+
        /**             
         * 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-06-14 16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/SceneGraph/SG_ParentRelation.h      
2008-06-14 17:12:49 UTC (rev 15221)
@@ -99,6 +99,16 @@
        ) { 
                return false;
        }
+       
+       /**
+        * Need this to see if we are able to adjust time-offset from the 
python api
+        */
+       virtual
+               bool
+       IsSlowRelation(
+       ) { 
+               return false;
+       }
 protected :
 
        /** 

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Spatial.cpp
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Spatial.cpp   2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Spatial.cpp   2008-06-14 
17:12:49 UTC (rev 15221)
@@ -87,6 +87,13 @@
        delete (m_parent_relation);
 }
 
+       SG_ParentRelation *
+SG_Spatial::
+GetParentRelation(
+){
+       return m_parent_relation;
+}
+
        void
 SG_Spatial::
 SetParentRelation(

Modified: trunk/blender/source/gameengine/SceneGraph/SG_Spatial.h
===================================================================
--- trunk/blender/source/gameengine/SceneGraph/SG_Spatial.h     2008-06-14 
16:54:46 UTC (rev 15220)
+++ trunk/blender/source/gameengine/SceneGraph/SG_Spatial.h     2008-06-14 
17:12:49 UTC (rev 15221)
@@ -83,6 +83,10 @@
        SetParentRelation(
                SG_ParentRelation *relation
        );
+       
+               SG_ParentRelation *
+       GetParentRelation(
+       );
 
 
        /**


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to