Browse Source

- Exposed the flag that controls whether a SceneObject is allowed to be picked or not.
- Removed the redundant "ignorePick" dynamic field in the Sandbox manipulation script.
- Removed the obsolete SceneObject "attached to path" functionality.

MelvMay-GG 12 years ago
parent
commit
69946be

+ 5 - 5
engine/source/2d/scene/WorldQuery.cc

@@ -422,7 +422,7 @@ bool WorldQuery::ReportFixture( b2Fixture* fixture )
         return true;
         return true;
 
 
     // Picking allowed filter.
     // Picking allowed filter.
-    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getIsPickingAllowed() )
+    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getPickingAllowed() )
         return true;
         return true;
 
 
     // Check fixture point.
     // Check fixture point.
@@ -475,7 +475,7 @@ F32 WorldQuery::ReportFixture( b2Fixture* fixture, const b2Vec2& point, const b2
         return 1.0f;
         return 1.0f;
 
 
     // Picking allowed filter.
     // Picking allowed filter.
-    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getIsPickingAllowed() )
+    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getPickingAllowed() )
         return 1.0f;
         return 1.0f;
 
 
     // Tag with world query key.
     // Tag with world query key.
@@ -530,7 +530,7 @@ bool WorldQuery::QueryCallback( S32 proxyId )
         return true;
         return true;
 
 
     // Picking allowed filter.
     // Picking allowed filter.
-    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getIsPickingAllowed() )
+    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getPickingAllowed() )
         return true;
         return true;
 
 
     // Tag with world query key.
     // Tag with world query key.
@@ -579,7 +579,7 @@ F32 WorldQuery::RayCastCallback( const b2RayCastInput& input, S32 proxyId )
         return 1.0f;
         return 1.0f;
 
 
     // Picking allowed filter.
     // Picking allowed filter.
-    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getIsPickingAllowed() )
+    if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getPickingAllowed() )
         return 1.0f;
         return 1.0f;
 
 
     // Tag with world query key.
     // Tag with world query key.
@@ -633,7 +633,7 @@ void WorldQuery::injectAlwaysInScope( void )
             continue;
             continue;
 
 
         // Picking allowed filter.
         // Picking allowed filter.
-        if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getIsPickingAllowed() )
+        if ( mQueryFilter.mPickingAllowedFilter && !pSceneObject->getPickingAllowed() )
             continue;
             continue;
 
 
         // Fetch layer and group masks.
         // Fetch layer and group masks.

+ 2 - 3
engine/source/2d/sceneobject/SceneObject.cc

@@ -179,9 +179,6 @@ SceneObject::SceneObject() :
     mpAttachedGui(NULL),
     mpAttachedGui(NULL),
     mpAttachedGuiSceneWindow(NULL),
     mpAttachedGuiSceneWindow(NULL),
 
 
-    /// Pathing.
-    mAttachedToPath(NULL),
-
     /// Safe deletion.
     /// Safe deletion.
     mBeingSafeDeleted(false),
     mBeingSafeDeleted(false),
     mSafeDeleteReady(true),
     mSafeDeleteReady(true),
@@ -349,6 +346,8 @@ void SceneObject::initPersistFields()
     /// Input events.
     /// Input events.
     addField("UseInputEvents", TypeBool, Offset(mUseInputEvents, SceneObject), &writeUseInputEvents, "");
     addField("UseInputEvents", TypeBool, Offset(mUseInputEvents, SceneObject), &writeUseInputEvents, "");
 
 
+    addField("PickingAllowed", TypeBool, Offset(mPickingAllowed, SceneObject), &writePickingAllowed, "");
+
     // Script callbacks.
     // Script callbacks.
     addField("UpdateCallback", TypeBool, Offset(mUpdateCallback, SceneObject), &writeUpdateCallback, "");
     addField("UpdateCallback", TypeBool, Offset(mUpdateCallback, SceneObject), &writeUpdateCallback, "");
     addField("CollisionCallback", TypeBool, Offset(mCollisionCallback, SceneObject), &writeCollisionCallback, "");
     addField("CollisionCallback", TypeBool, Offset(mCollisionCallback, SceneObject), &writeCollisionCallback, "");

+ 6 - 7
engine/source/2d/sceneobject/SceneObject.h

@@ -204,9 +204,6 @@ protected:
     GuiControl*             mpAttachedGui;
     GuiControl*             mpAttachedGui;
     SceneWindow*            mpAttachedGuiSceneWindow;
     SceneWindow*            mpAttachedGuiSceneWindow;
 
 
-    /// Pathing.
-    SimObjectPtr<SceneObject> mAttachedToPath;
-
     /// Safe deletion.
     /// Safe deletion.
     bool                    mBeingSafeDeleted;
     bool                    mBeingSafeDeleted;
     bool                    mSafeDeleteReady;
     bool                    mSafeDeleteReady;
@@ -533,9 +530,9 @@ public:
     void                    detachGui( void );
     void                    detachGui( void );
     inline void             updateAttachedGui( void );
     inline void             updateAttachedGui( void );
 
 
-    /// Pathing.
-    inline                  void setAttachedToPath(SceneObject* path){ mAttachedToPath = path; }
-    inline SceneObject*     getAttachedToPath() const                   { return mAttachedToPath; }
+    // Picking.
+    inline void             setPickingAllowed( const bool pickingAllowed ) { mPickingAllowed = pickingAllowed; }
+    inline bool             getPickingAllowed(void) const               { return mPickingAllowed; }
 
 
     /// Cloning.
     /// Cloning.
     virtual void            copyFrom( SceneObject* pSceneObject, const bool copyDynamicFields );
     virtual void            copyFrom( SceneObject* pSceneObject, const bool copyDynamicFields );
@@ -560,7 +557,6 @@ public:
 
 
     /// Miscellaneous.
     /// Miscellaneous.
     inline const char*      scriptThis(void) const                      { return Con::getIntArg(getId()); }
     inline const char*      scriptThis(void) const                      { return Con::getIntArg(getId()); }
-    inline bool             getIsPickingAllowed(void) const             { return mPickingAllowed; }
     inline bool             getIsAlwaysInScope(void) const              { return mAlwaysInScope; }
     inline bool             getIsAlwaysInScope(void) const              { return mAlwaysInScope; }
     inline void             setWorldQueryKey( const U32 key )           { mWorldQueryKey = key; }
     inline void             setWorldQueryKey( const U32 key )           { mWorldQueryKey = key; }
     inline U32              getWorldQueryKey( void ) const              { return mWorldQueryKey; }
     inline U32              getWorldQueryKey( void ) const              { return mWorldQueryKey; }
@@ -708,6 +704,9 @@ protected:
     /// Input events.
     /// Input events.
     static bool             writeUseInputEvents( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUseInputEvents() == true; }
     static bool             writeUseInputEvents( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUseInputEvents() == true; }
 
 
+    /// Picking.
+    static bool             writePickingAllowed( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getPickingAllowed() == true; }    
+
     /// Script callbacks.
     /// Script callbacks.
     static bool             writeUpdateCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUpdateCallback() == true; }
     static bool             writeUpdateCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUpdateCallback() == true; }
     static bool             writeCollisionCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionCallback() == true; }
     static bool             writeCollisionCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionCallback() == true; }

+ 20 - 12
engine/source/2d/sceneobject/SceneObject_ScriptBinding.h

@@ -3671,18 +3671,6 @@ ConsoleMethod(SceneObject, detachGui, void, 2, 2, "() - Detach any GUI Control.\
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
-ConsoleMethod(SceneObject, getAttachedToPath, S32, 2, 2, "() - Gets the Path that this object is attached to.\n"
-                                                            "@return (Path path) The path that this object is attached to, or 0 if it is not attached to a path.")
-{
-   SceneObject* path = object->getAttachedToPath();
-   if (path)
-      return path->getId();
-   
-   return NULL;
-}
-
-//-----------------------------------------------------------------------------
-
 ConsoleMethod(SceneObject, copyFrom, bool, 3, 4, "(SceneObject object, [copyDynamicFields? = false]) - Copies one scene object from another scene object.\n"
 ConsoleMethod(SceneObject, copyFrom, bool, 3, 4, "(SceneObject object, [copyDynamicFields? = false]) - Copies one scene object from another scene object.\n"
                                                     "The object being copied to needs to be of the same class as the object being copied from.\n"
                                                     "The object being copied to needs to be of the same class as the object being copied from.\n"
                                                     "@param object The SceneObject to copy this object to.\n"
                                                     "@param object The SceneObject to copy this object to.\n"
@@ -3711,6 +3699,26 @@ ConsoleMethod(SceneObject, copyFrom, bool, 3, 4, "(SceneObject object, [copyDyna
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
+ConsoleMethod(SceneObject, setPickingAllowed, void, 3, 3,   "(bool pickingAllowed) - Sets whether picking is allowed or not.\n"
+                                                            "@param pickingAllowed Whether picking is allowed or not.\n"
+                                                            "@return No return Value.")
+{
+    // Fetch flag.
+    const bool pickingAllowed = dAtob(argv[2]);
+
+    object->setPickingAllowed( pickingAllowed )
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(SceneObject, getPickingAllowed, bool, 2, 2,   "() - Gets whether picking is allowed or not.\n"
+                                                            "@return Whether picking is allowed or not.")
+{
+    return object->getPickingAllowed();
+}
+
+//-----------------------------------------------------------------------------
+
 ConsoleMethod(SceneObject, safeDelete, void, 2, 2, "() - Safely deletes object.\n"
 ConsoleMethod(SceneObject, safeDelete, void, 2, 2, "() - Safely deletes object.\n"
                                                                  "@return No return Value.")
                                                                  "@return No return Value.")
 {
 {

+ 0 - 4
modules/Sandbox/1/scripts/manipulation.cs

@@ -365,10 +365,6 @@ function SandboxWindow::onTouchDown(%this, %touchID, %worldPosition)
             if ( %pickedObject.getBodyType() $= "static" )
             if ( %pickedObject.getBodyType() $= "static" )
                 continue;
                 continue;
                 
                 
-            // Skipp if the object is ignoring being picked.
-            if ( %pickedObject.ignorePick )
-                continue;
-                
             // Set the pull object.
             // Set the pull object.
             Sandbox.ManipulationPullObject[%touchID] = %pickedObject;
             Sandbox.ManipulationPullObject[%touchID] = %pickedObject;
             Sandbox.ManipulationPullJointId[%touchID] = SandboxScene.createTargetJoint( %pickedObject, %worldPosition, Sandbox.ManipulationPullMaxForce );            
             Sandbox.ManipulationPullJointId[%touchID] = SandboxScene.createTargetJoint( %pickedObject, %worldPosition, Sandbox.ManipulationPullMaxForce );