Ver código fonte

Merge branch 'method_Unmangle' into PBR_PR

Azaezel 6 anos atrás
pai
commit
1eed979a9c
100 arquivos alterados com 2245 adições e 2477 exclusões
  1. 2 2
      Engine/lib/nativeFileDialogs/nfd_win.cpp
  2. 13 13
      Engine/source/T3D/aiClient.cpp
  3. 8 8
      Engine/source/T3D/aiConnection.cpp
  4. 1 1
      Engine/source/T3D/aiPlayer.cpp
  5. 1 1
      Engine/source/T3D/assets/MaterialAsset.cpp
  6. 7 6
      Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h
  7. 7 7
      Engine/source/T3D/components/collision/collisionComponent_ScriptBinding.h
  8. 26 19
      Engine/source/T3D/components/component.cpp
  9. 2 0
      Engine/source/T3D/convexShape.h
  10. 22 29
      Engine/source/T3D/entity.cpp
  11. 24 30
      Engine/source/T3D/gameBase/gameConnection.cpp
  12. 1 1
      Engine/source/T3D/gameBase/gameProcess.cpp
  13. 2 2
      Engine/source/T3D/gameFunctions.cpp
  14. 2 2
      Engine/source/T3D/lightBase.cpp
  15. 1 1
      Engine/source/T3D/missionMarker.cpp
  16. 1 1
      Engine/source/T3D/physics/physicsDebris.cpp
  17. 18 15
      Engine/source/T3D/physics/physicsPlugin.cpp
  18. 4 0
      Engine/source/T3D/physics/physicsPlugin.h
  19. 2 0
      Engine/source/T3D/physics/physicsWorld.cpp
  20. 6 0
      Engine/source/T3D/physics/physicsWorld.h
  21. 34 10
      Engine/source/T3D/physics/physx3/px3.h
  22. 20 47
      Engine/source/T3D/physics/physx3/px3Body.cpp
  23. 2 1
      Engine/source/T3D/physics/physx3/px3Body.h
  24. 107 119
      Engine/source/T3D/physics/physx3/px3Collision.cpp
  25. 3 0
      Engine/source/T3D/physics/physx3/px3Collision.h
  26. 3 10
      Engine/source/T3D/physics/physx3/px3Player.cpp
  27. 3 6
      Engine/source/T3D/physics/physx3/px3Stream.cpp
  28. 2 2
      Engine/source/T3D/physics/physx3/px3Stream.h
  29. 110 121
      Engine/source/T3D/physics/physx3/px3World.cpp
  30. 15 13
      Engine/source/T3D/physics/physx3/px3World.h
  31. 9 11
      Engine/source/T3D/player.cpp
  32. 2 2
      Engine/source/T3D/staticShape.cpp
  33. 49 66
      Engine/source/afx/afxCamera.cpp
  34. 22 22
      Engine/source/afx/afxMagicSpell.cpp
  35. 24 60
      Engine/source/afx/arcaneFX.cpp
  36. 15 13
      Engine/source/app/game.cpp
  37. 9 0
      Engine/source/app/mainLoop.cpp
  38. 3 3
      Engine/source/app/net/net.cpp
  39. 10 10
      Engine/source/app/net/serverQuery.cpp
  40. 7 7
      Engine/source/app/version.cpp
  41. 4 4
      Engine/source/assets/assetQuery_ScriptBinding.h
  42. 24 119
      Engine/source/cinterface/c_consoleInterface.cpp
  43. 239 0
      Engine/source/cinterface/c_controlInterface.cpp
  44. 48 0
      Engine/source/cinterface/c_controlInterface.h
  45. 0 426
      Engine/source/cinterface/c_scripting.cpp
  46. 55 0
      Engine/source/cinterface/c_simInterface.cpp
  47. 40 0
      Engine/source/cinterface/c_simdatablockInterface.cpp
  48. 69 0
      Engine/source/cinterface/c_simobjectInterface.cpp
  49. 55 426
      Engine/source/cinterface/cinterface.cpp
  50. 35 4
      Engine/source/cinterface/cinterface.h
  51. 2 2
      Engine/source/console/SimXMLDocument.cpp
  52. 23 4
      Engine/source/console/codeInterpreter.cpp
  53. 29 3
      Engine/source/console/console.cpp
  54. 0 32
      Engine/source/console/console.h
  55. 2 2
      Engine/source/console/consoleDoc.cpp
  56. 107 110
      Engine/source/console/consoleFunctions.cpp
  57. 2 2
      Engine/source/console/consoleLogger.cpp
  58. 23 0
      Engine/source/console/consoleObject.h
  59. 1 1
      Engine/source/console/consoleXMLExport.cpp
  60. 89 72
      Engine/source/console/engineAPI.h
  61. 8 1
      Engine/source/console/engineFunctions.h
  62. 6 0
      Engine/source/console/engineTypeInfo.h
  63. 3 3
      Engine/source/console/engineTypes.h
  64. 383 359
      Engine/source/console/engineXMLExport.cpp
  65. 4 4
      Engine/source/console/fieldBrushObject.cpp
  66. 153 0
      Engine/source/console/fixedTuple.h
  67. 13 13
      Engine/source/console/persistenceManager.cpp
  68. 14 16
      Engine/source/console/scriptFilename.cpp
  69. 13 13
      Engine/source/console/sim.cpp
  70. 3 3
      Engine/source/console/simDatablock.cpp
  71. 31 31
      Engine/source/console/simObject.cpp
  72. 0 1
      Engine/source/console/simObject.h
  73. 1 1
      Engine/source/console/simPersistSet.cpp
  74. 7 23
      Engine/source/console/simSet.cpp
  75. 1 1
      Engine/source/console/telnetConsole.cpp
  76. 3 3
      Engine/source/console/telnetDebugger.cpp
  77. 23 36
      Engine/source/core/color.cpp
  78. 1 1
      Engine/source/core/dnet.cpp
  79. 1 1
      Engine/source/core/fileObject.cpp
  80. 2 2
      Engine/source/core/frameAllocator.cpp
  81. 5 6
      Engine/source/core/resourceManager.cpp
  82. 51 18
      Engine/source/core/stream/bitStream.cpp
  83. 4 4
      Engine/source/core/stream/bitStream.h
  84. 2 2
      Engine/source/core/stringBuffer.cpp
  85. 1 1
      Engine/source/core/util/str.cpp
  86. 1 1
      Engine/source/environment/VolumetricFogRTManager.cpp
  87. 15 15
      Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp
  88. 14 14
      Engine/source/environment/editors/guiRiverEditorCtrl.cpp
  89. 11 11
      Engine/source/environment/editors/guiRoadEditorCtrl.cpp
  90. 1 1
      Engine/source/environment/skyBox.cpp
  91. 2 2
      Engine/source/environment/sun.cpp
  92. 1 1
      Engine/source/forest/editor/forestBrushElement.cpp
  93. 1 1
      Engine/source/forest/editor/forestBrushTool.cpp
  94. 6 6
      Engine/source/forest/editor/forestEditorCtrl.cpp
  95. 6 6
      Engine/source/forest/editor/forestSelectionTool.cpp
  96. 4 4
      Engine/source/forest/forest.cpp
  97. 1 1
      Engine/source/gfx/gfxDevice.cpp
  98. 1 1
      Engine/source/gfx/gfxInit.cpp
  99. 1 1
      Engine/source/gfx/gl/gfxGLDevice.cpp
  100. 1 1
      Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp

+ 2 - 2
Engine/lib/nativeFileDialogs/nfd_win.cpp

@@ -183,7 +183,7 @@ static nfdresult_t AddFiltersToDialog( ::IFileDialog *fileOpenDialog, const char
             /* end of filter -- add it to specList */
 
             // Empty filter name -- Windows describes them by extension.            
-            specList[specIdx].pszName = EMPTY_WSTR;
+            CopyNFDCharToWChar(specbuf, (wchar_t**)&specList[specIdx].pszName);
             CopyNFDCharToWChar( specbuf, (wchar_t**)&specList[specIdx].pszSpec );
                         
             memset( specbuf, 0, sizeof(char)*NFD_MAX_STRLEN );
@@ -203,7 +203,7 @@ static nfdresult_t AddFiltersToDialog( ::IFileDialog *fileOpenDialog, const char
 
     /* Add wildcard */
     specList[specIdx].pszSpec = WILDCARD;
-    specList[specIdx].pszName = EMPTY_WSTR;
+    specList[specIdx].pszName = WILDCARD;
     
     fileOpenDialog->SetFileTypes( filterCount+1, specList );
 

+ 13 - 13
Engine/source/T3D/aiClient.cpp

@@ -418,7 +418,7 @@ void AIClient::onAdd( const char *nameSpace ) {
 /**
  * Sets the move speed for an AI object
  */
-DefineConsoleMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpeed( float );" ) 
+DefineEngineMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpeed( float );" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    ai->setMoveSpeed( speed );
@@ -427,7 +427,7 @@ DefineConsoleMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpe
 /**
  * Stops all AI movement, halt!
  */
-DefineConsoleMethod( AIClient, stop, void, (),, "ai.stop();" ) 
+DefineEngineMethod( AIClient, stop, void, (),, "ai.stop();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    ai->setMoveMode( AIClient::ModeStop );
@@ -436,7 +436,7 @@ DefineConsoleMethod( AIClient, stop, void, (),, "ai.stop();" )
 /**
  * Tells the AI to aim at the location provided
  */
-DefineConsoleMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLocation( x y z );" ) 
+DefineEngineMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLocation( x y z );" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
 
@@ -446,7 +446,7 @@ DefineConsoleMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLo
 /**
  * Tells the AI to move to the location provided
  */
-DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setMoveDestination( x y z );" )
+DefineEngineMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setMoveDestination( x y z );" )
 {
    AIClient *ai = static_cast<AIClient *>( object );
 
@@ -456,7 +456,7 @@ DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setM
 /**
  * Returns the point the AI is aiming at
  */
-DefineConsoleMethod( AIClient, getAimLocation, Point3F, (),, "ai.getAimLocation();" ) 
+DefineEngineMethod( AIClient, getAimLocation, Point3F, (),, "ai.getAimLocation();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    return ai->getAimLocation();
@@ -465,7 +465,7 @@ DefineConsoleMethod( AIClient, getAimLocation, Point3F, (),, "ai.getAimLocation(
 /**
  * Returns the point the AI is set to move to
  */
-DefineConsoleMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDestination();" ) 
+DefineEngineMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDestination();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    return ai->getMoveDestination();
@@ -474,7 +474,7 @@ DefineConsoleMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDest
 /**
  * Sets the bots target object
  */
-DefineConsoleMethod( AIClient, setTargetObject, void, (const char * objName), , "ai.setTargetObject( obj );" ) 
+DefineEngineMethod( AIClient, setTargetObject, void, (const char * objName), , "ai.setTargetObject( obj );" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    
@@ -489,7 +489,7 @@ DefineConsoleMethod( AIClient, setTargetObject, void, (const char * objName), ,
 /**
  * Gets the object the AI is targeting
  */
-DefineConsoleMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();" ) 
+DefineEngineMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
 
@@ -499,7 +499,7 @@ DefineConsoleMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();
 /**
  * Tells the bot the mission is cycling
  */
-DefineConsoleMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleCleanup();" ) 
+DefineEngineMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleCleanup();" ) 
 {
    AIClient *ai = static_cast<AIClient*>( object );
    ai->missionCycleCleanup();
@@ -508,7 +508,7 @@ DefineConsoleMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleC
 /**
  * Sets the AI to run mode
  */
-DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" ) 
+DefineEngineMethod( AIClient, move, void, (),, "ai.move();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    ai->setMoveMode( AIClient::ModeMove );
@@ -517,7 +517,7 @@ DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" )
 /**
  * Gets the AI's location in the world
  */
-DefineConsoleMethod( AIClient, getLocation, Point3F, (),, "ai.getLocation();" ) 
+DefineEngineMethod( AIClient, getLocation, Point3F, (),, "ai.getLocation();" ) 
 {
    AIClient *ai = static_cast<AIClient *>( object );
    return ai->getLocation();
@@ -526,7 +526,7 @@ DefineConsoleMethod( AIClient, getLocation, Point3F, (),, "ai.getLocation();" )
 /**
  * Adds an AI Player to the game
  */
-DefineConsoleFunction( aiAddPlayer, S32, (const char * name, const char * ns), (""), "'playerName'[, 'AIClassType'] );")
+DefineEngineFunction( aiAddPlayer, S32, (const char * name, const char * ns), (""), "'playerName'[, 'AIClassType'] );")
 {
    // Create the player
    AIClient *aiPlayer = new AIClient();
@@ -559,7 +559,7 @@ DefineConsoleFunction( aiAddPlayer, S32, (const char * name, const char * ns), (
 /**
  * Tells the AI to move forward 100 units...TEST FXN
  */
-DefineConsoleMethod( AIClient, moveForward, void, (),, "ai.moveForward();" ) 
+DefineEngineMethod( AIClient, moveForward, void, (),, "ai.moveForward();" ) 
 {
    
    AIClient *ai = static_cast<AIClient *>( object );

+ 8 - 8
Engine/source/T3D/aiConnection.cpp

@@ -130,7 +130,7 @@ static inline F32 moveClamp(F32 v)
 
 //-----------------------------------------------------------------------------
 /// Construct and connect an AI connection object
-ConsoleFunction(aiConnect, S32 , 2, 20, "(...)"
+DefineEngineStringlyVariadicFunction(aiConnect, S32 , 2, 20, "(...)"
    "@brief Creates a new AIConnection, and passes arguments to its onConnect script callback.\n\n"
    "@returns The newly created AIConnection\n"
    "@see GameConnection for parameter information\n"
@@ -160,7 +160,7 @@ ConsoleFunction(aiConnect, S32 , 2, 20, "(...)"
 
 
 //-----------------------------------------------------------------------------
-DefineConsoleMethod(AIConnection, setMove, void, (const char * field, F32 value), ,"(string field, float value)"
+DefineEngineMethod(AIConnection, setMove, void, (const char * field, F32 value), ,"(string field, float value)"
               "Set a field on the current move.\n\n"
               "@param   field One of {'x','y','z','yaw','pitch','roll'}\n"
               "@param   value Value to set field to.")
@@ -190,7 +190,7 @@ DefineConsoleMethod(AIConnection, setMove, void, (const char * field, F32 value)
    object->setMove(&move);
 }
 
-DefineConsoleMethod(AIConnection,getMove,F32, (const char * field), ,"(string field)"
+DefineEngineMethod(AIConnection,getMove,F32, (const char * field), ,"(string field)"
               "Get the given field of a move.\n\n"
               "@param field One of {'x','y','z','yaw','pitch','roll'}\n"
               "@returns The requested field on the current move.")
@@ -212,7 +212,7 @@ DefineConsoleMethod(AIConnection,getMove,F32, (const char * field), ,"(string fi
 }
 
 
-DefineConsoleMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isFreeLook)"
+DefineEngineMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isFreeLook)"
               "Enable/disable freelook on the current move.")
 {
    Move move = object->getMove();
@@ -220,7 +220,7 @@ DefineConsoleMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isF
    object->setMove(&move);
 }
 
-DefineConsoleMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()"
+DefineEngineMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()"
               "Is freelook on for the current move?")
 {
    return object->getMove().freeLook;
@@ -229,7 +229,7 @@ DefineConsoleMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()"
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int trigger, bool set)"
+DefineEngineMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int trigger, bool set)"
               "Set a trigger.")
 {
    if (idx >= 0 && idx < MaxTriggerKeys)  
@@ -240,7 +240,7 @@ DefineConsoleMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int tr
    }
 }
 
-DefineConsoleMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)"
+DefineEngineMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)"
               "Is the given trigger set?")
 {
    if (idx >= 0 && idx < MaxTriggerKeys)
@@ -251,7 +251,7 @@ DefineConsoleMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)"
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod(AIConnection,getAddress,const char*,(), ,"")
+DefineEngineMethod(AIConnection,getAddress,const char*,(), ,"")
 {
    // Override the netConnection method to return to indicate
    // this is an ai connection.

+ 1 - 1
Engine/source/T3D/aiPlayer.cpp

@@ -1251,7 +1251,7 @@ ConsoleDocFragment _setAimObject(
    "void setAimObject(GameBase targetObject, Point3F offset);"
 );
 
-DefineConsoleMethod( AIPlayer, setAimObject, void, ( const char * objName, Point3F offset ), (Point3F::Zero), "( GameBase obj, [Point3F offset] )"
+DefineEngineMethod( AIPlayer, setAimObject, void, ( const char * objName, Point3F offset ), (Point3F::Zero), "( GameBase obj, [Point3F offset] )"
               "Sets the bot's target object. Optionally set an offset from target location."
            "@hide")
 {

+ 1 - 1
Engine/source/T3D/assets/MaterialAsset.cpp

@@ -157,7 +157,7 @@ void MaterialAsset::copyTo(SimObject* object)
    Parent::copyTo(object);
 }
 
-ConsoleMethod(MaterialAsset, compileShader, void, 2, 2, "() - Compiles the material's generated shader, if any. Not yet implemented\n")
+DefineEngineMethod(MaterialAsset, compileShader, void, (), , "Compiles the material's generated shader, if any. Not yet implemented\n")
 {
    object->compileShader();
 }

+ 7 - 6
Engine/source/T3D/components/camera/cameraComponent_ScriptBinding.h

@@ -24,13 +24,14 @@
 #include "T3D/components/camera/cameraComponent.h"
 
 //Basically, this only exists for backwards compatibility for parts of the editors
-ConsoleMethod(CameraComponent, getMode, const char*, 2, 2, "() - We get the first behavior of the requested type on our owner object.\n"
+DefineEngineMethod(CameraComponent, getMode, const char*, (),, 
+   "@brief We get the first behavior of the requested type on our owner object.\n"
    "@return (string name) The type of the behavior we're requesting")
 {
    return "fly";
 }
 
-DefineConsoleMethod(CameraComponent, getForwardVector, VectorF, (), ,
+DefineEngineMethod(CameraComponent, getForwardVector, VectorF, (), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -44,7 +45,7 @@ DefineConsoleMethod(CameraComponent, getForwardVector, VectorF, (), ,
    return returnVec;
 }
 
-DefineConsoleMethod(CameraComponent, getRightVector, VectorF, (), ,
+DefineEngineMethod(CameraComponent, getRightVector, VectorF, (), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -58,7 +59,7 @@ DefineConsoleMethod(CameraComponent, getRightVector, VectorF, (), ,
    return returnVec;
 }
 
-DefineConsoleMethod(CameraComponent, getUpVector, VectorF, (), ,
+DefineEngineMethod(CameraComponent, getUpVector, VectorF, (), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -72,14 +73,14 @@ DefineConsoleMethod(CameraComponent, getUpVector, VectorF, (), ,
    return returnVec;
 }
 
-DefineConsoleMethod(CameraComponent, setForwardVector, void, (VectorF newForward), (VectorF(0, 0, 0)),
+DefineEngineMethod(CameraComponent, setForwardVector, void, (VectorF newForward), (VectorF(0, 0, 0)),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
    object->setForwardVector(newForward);
 }
 
-DefineConsoleMethod(CameraComponent, getWorldPosition, Point3F, (), ,
+DefineEngineMethod(CameraComponent, getWorldPosition, Point3F, (), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {

+ 7 - 7
Engine/source/T3D/components/collision/collisionComponent_ScriptBinding.h

@@ -24,21 +24,21 @@
 #include "T3D/components/collision/collisionComponent.h"
 #include "materials/baseMatInstance.h"
 
-DefineConsoleMethod(CollisionComponent, getNumberOfContacts, S32, (), ,
+DefineEngineMethod(CollisionComponent, getNumberOfContacts, S32, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
    return object->getCollisionList()->getCount();
 }
 
-DefineConsoleMethod(CollisionComponent, getBestContact, S32, (), ,
+DefineEngineMethod(CollisionComponent, getBestContact, S32, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
    return 0;
 }
 
-DefineConsoleMethod(CollisionComponent, getContactNormal, Point3F, (), ,
+DefineEngineMethod(CollisionComponent, getContactNormal, Point3F, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -53,7 +53,7 @@ DefineConsoleMethod(CollisionComponent, getContactNormal, Point3F, (), ,
    return Point3F::Zero;
 }
 
-DefineConsoleMethod(CollisionComponent, getContactMaterial, S32, (), ,
+DefineEngineMethod(CollisionComponent, getContactMaterial, S32, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -69,7 +69,7 @@ DefineConsoleMethod(CollisionComponent, getContactMaterial, S32, (), ,
    return 0;
 }
 
-DefineConsoleMethod(CollisionComponent, getContactObject, S32, (), ,
+DefineEngineMethod(CollisionComponent, getContactObject, S32, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -81,7 +81,7 @@ DefineConsoleMethod(CollisionComponent, getContactObject, S32, (), ,
    return 0;
 }
 
-DefineConsoleMethod(CollisionComponent, getContactPoint, Point3F, (), ,
+DefineEngineMethod(CollisionComponent, getContactPoint, Point3F, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -96,7 +96,7 @@ DefineConsoleMethod(CollisionComponent, getContactPoint, Point3F, (), ,
    return Point3F::Zero;
 }
 
-DefineConsoleMethod(CollisionComponent, getContactTime, S32, (), ,
+DefineEngineMethod(CollisionComponent, getContactTime, S32, (), ,
    "Gets the number of contacts this collider has hit.\n"
    "@return The number of static fields defined on the object.")
 {

+ 26 - 19
Engine/source/T3D/components/component.cpp

@@ -605,8 +605,8 @@ void Component::addDependency(StringTableEntry name)
 //////////////////////////////////////////////////////////////////////////
 // Console Methods
 //////////////////////////////////////////////////////////////////////////
-ConsoleMethod(Component, beginGroup, void, 3, 3, "(groupName)\n"
-   "Starts the grouping for following fields being added to be grouped into\n"
+DefineEngineMethod(Component, beginGroup, void, (String groupName),,
+   "@brief Starts the grouping for following fields being added to be grouped into\n"
    "@param groupName The name of this group\n"
    "@param desc The Description of this field\n"
    "@param type The DataType for this field (default, int, float, Point2F, bool, enum, Object, keybind, color)\n"
@@ -616,11 +616,11 @@ ConsoleMethod(Component, beginGroup, void, 3, 3, "(groupName)\n"
    "-object: the T2D object type that are valid choices for the field.  The object types observe inheritance, so if you have a t2dSceneObject field you will be able to choose t2dStaticSrpites, t2dAnimatedSprites, etc.\n"
    "@return Nothing\n")
 {
-   object->beginFieldGroup(argv[2]);
+   object->beginFieldGroup(groupName);
 }
 
-ConsoleMethod(Component, endGroup, void, 2, 2, "()\n"
-   "Ends the grouping for prior fields being added to be grouped into\n"
+DefineEngineMethod(Component, endGroup, void, (),,
+   "@brief Ends the grouping for prior fields being added to be grouped into\n"
    "@param groupName The name of this group\n"
    "@param desc The Description of this field\n"
    "@param type The DataType for this field (default, int, float, Point2F, bool, enum, Object, keybind, color)\n"
@@ -633,7 +633,7 @@ ConsoleMethod(Component, endGroup, void, 2, 2, "()\n"
    object->endFieldGroup();
 }
 
-DefineConsoleMethod(Component, addComponentField, void, (String fieldName, String fieldDesc, String fieldType, String defValue, String userData, bool hidden),
+DefineEngineMethod(Component, addComponentField, void, (String fieldName, String fieldDesc, String fieldType, String defValue, String userData, bool hidden),
    ("", "", "", "", "", false),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
@@ -641,7 +641,8 @@ DefineConsoleMethod(Component, addComponentField, void, (String fieldName, Strin
    object->addComponentField(fieldName, fieldDesc, fieldType, defValue, userData, hidden);
 }
 
-ConsoleMethod(Component, getComponentFieldCount, S32, 2, 2, "() - Get the number of ComponentField's on this object\n"
+DefineEngineMethod(Component, getComponentFieldCount, S32, (),, 
+   "@brief Get the number of ComponentField's on this object\n"
    "@return Returns the number of BehaviorFields as a nonnegative integer\n")
 {
    return object->getComponentFieldCount();
@@ -650,11 +651,12 @@ ConsoleMethod(Component, getComponentFieldCount, S32, 2, 2, "() - Get the number
 // [tom, 1/12/2007] Field accessors split into multiple methods to allow space
 // for long descriptions and type data.
 
-ConsoleMethod(Component, getComponentField, const char *, 3, 3, "(int index) - Gets a Tab-Delimited list of information about a ComponentField specified by Index\n"
+DefineEngineMethod(Component, getComponentField, const char *, (S32 index),, 
+   "@brief Gets a Tab-Delimited list of information about a ComponentField specified by Index\n"
    "@param index The index of the behavior\n"
    "@return FieldName, FieldType and FieldDefaultValue, each separated by a TAB character.\n")
 {
-   ComponentField *field = object->getComponentField(dAtoi(argv[2]));
+   ComponentField *field = object->getComponentField(index);
    if (field == NULL)
       return "";
 
@@ -664,11 +666,12 @@ ConsoleMethod(Component, getComponentField, const char *, 3, 3, "(int index) - G
    return buf;
 }
 
-ConsoleMethod(Component, setComponentield, const char *, 3, 3, "(int index) - Gets a Tab-Delimited list of information about a ComponentField specified by Index\n"
+DefineEngineMethod(Component, setComponentield, const char *, (S32 index),, 
+   "@brief Gets a Tab-Delimited list of information about a ComponentField specified by Index\n"
    "@param index The index of the behavior\n"
    "@return FieldName, FieldType and FieldDefaultValue, each separated by a TAB character.\n")
 {
-   ComponentField *field = object->getComponentField(dAtoi(argv[2]));
+   ComponentField *field = object->getComponentField(index);
    if (field == NULL)
       return "";
 
@@ -678,7 +681,7 @@ ConsoleMethod(Component, setComponentield, const char *, 3, 3, "(int index) - Ge
    return buf;
 }
 
-DefineConsoleMethod(Component, getComponentFieldType, const char *, (String fieldName), ,
+DefineEngineMethod(Component, getComponentFieldType, const char *, (String fieldName), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -689,36 +692,40 @@ DefineConsoleMethod(Component, getComponentFieldType, const char *, (String fiel
    return field->mFieldTypeName;;
 }
 
-ConsoleMethod(Component, getBehaviorFieldUserData, const char *, 3, 3, "(int index) - Gets the UserData associated with a field by index in the field list\n"
+DefineEngineMethod(Component, getBehaviorFieldUserData, const char *, (S32 index),, 
+   "@brief Gets the UserData associated with a field by index in the field list\n"
    "@param index The index of the behavior\n"
    "@return Returns a string representing the user data of this field\n")
 {
-   ComponentField *field = object->getComponentField(dAtoi(argv[2]));
+   ComponentField *field = object->getComponentField(index);
    if (field == NULL)
       return "";
 
    return field->mUserData;
 }
 
-ConsoleMethod(Component, getComponentFieldDescription, const char *, 3, 3, "(int index) - Gets a field description by index\n"
+DefineEngineMethod(Component, getComponentFieldDescription, const char *, (S32 index),, 
+   "@brief Gets a field description by index\n"
    "@param index The index of the behavior\n"
    "@return Returns a string representing the description of this field\n")
 {
-   ComponentField *field = object->getComponentField(dAtoi(argv[2]));
+   ComponentField *field = object->getComponentField(index);
    if (field == NULL)
       return "";
 
    return field->mFieldDescription ? field->mFieldDescription : "";
 }
 
-ConsoleMethod(Component, addDependency, void, 3, 3, "(string behaviorName) - Gets a field description by index\n"
+DefineEngineMethod(Component, addDependency, void, (String behaviorName),, 
+   "@brief Gets a field description by index\n"
    "@param index The index of the behavior\n"
    "@return Returns a string representing the description of this field\n")
 {
-   object->addDependency(argv[2]);
+   object->addDependency(behaviorName);
 }
 
-ConsoleMethod(Component, setDirty, void, 2, 2, "() - Gets a field description by index\n"
+DefineEngineMethod(Component, setDirty, void, (),,
+   "@brief Gets a field description by index\n"
    "@param index The index of the behavior\n"
    "@return Returns a string representing the description of this field\n")
 {

+ 2 - 0
Engine/source/T3D/convexShape.h

@@ -201,6 +201,8 @@ public:
 
    /// @}
 
+      String getMaterialName() { return mMaterialName; }
+
 protected:
 
    void _updateMaterial();

+ 22 - 29
Engine/source/T3D/entity.cpp

@@ -1798,7 +1798,7 @@ DefineEngineMethod(Entity, setBox, void,
 }
 
 
-/*DefineConsoleMethod(Entity, callOnComponents, void, (const char* functionName), ,
+/*DefineEngineMethod(Entity, callOnComponents, void, (const char* functionName), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -1821,12 +1821,11 @@ ConsoleMethod(Entity, addComponents, void, 2, 2, "() - Add all fielded behaviors
    object->addComponents();
 }*/
 
-ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a behavior to the object\n"
+DefineEngineMethod(Entity, addComponent, bool, (Component* comp),,
+   "@brief Add a behavior to the object\n"
    "@param bi The behavior instance to add"
    "@return (bool success) Whether or not the behavior was successfully added")
 {
-   Component *comp = dynamic_cast<Component *>(Sim::findObject(argv[2]));
-
    if (comp != NULL)
    {
       bool success = object->addComponent(comp);
@@ -1846,40 +1845,33 @@ ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a
    return false;
 }
 
-ConsoleMethod(Entity, removeComponent, bool, 3, 4, "(ComponentInstance bi, [bool deleteBehavior = true])\n"
+DefineEngineMethod(Entity, removeComponent, bool, (Component* comp, bool deleteComponent), (true),
    "@param bi The behavior instance to remove\n"
    "@param deleteBehavior Whether or not to delete the behavior\n"
    "@return (bool success) Whether the behavior was successfully removed")
 {
-   bool deleteComponent = true;
-   if (argc > 3)
-      deleteComponent = dAtob(argv[3]);
-
-   return object->removeComponent(dynamic_cast<Component *>(Sim::findObject(argv[2])), deleteComponent);
+   return object->removeComponent(comp, deleteComponent);
 }
 
-ConsoleMethod(Entity, clearComponents, void, 2, 2, "() - Clear all behavior instances\n"
+DefineEngineMethod(Entity, clearComponents, void, (),, "Clear all behavior instances\n"
    "@return No return value")
 {
    object->clearComponents();
 }
 
-ConsoleMethod(Entity, getComponentByIndex, S32, 3, 3, "(int index) - Gets a particular behavior\n"
+DefineEngineMethod(Entity, getComponentByIndex, Component*, (S32 index),, 
+   "@brief Gets a particular behavior\n"
    "@param index The index of the behavior to get\n"
    "@return (ComponentInstance bi) The behavior instance you requested")
 {
-   Component *comp = object->getComponent(dAtoi(argv[2]));
-
-   return (comp != NULL) ? comp->getId() : 0;
+   return object->getComponent(index);
 }
 
-DefineConsoleMethod(Entity, getComponent, S32, (String componentName), (""),
+DefineEngineMethod(Entity, getComponent, Component*, (String componentName), (""),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
-   Component *comp = object->getComponent(componentName);
-
-   return (comp != NULL) ? comp->getId() : 0;
+   return object->getComponent(componentName);
 }
 
 /*ConsoleMethod(Entity, getBehaviorByType, S32, 3, 3, "(string BehaviorTemplateName) - gets a behavior\n"
@@ -1908,13 +1900,14 @@ DefineConsoleMethod(Entity, getComponent, S32, (String componentName), (""),
    return object->reOrder(inst, idx);
 }*/
 
-ConsoleMethod(Entity, getComponentCount, S32, 2, 2, "() - Get the count of behaviors on an object\n"
+DefineEngineMethod(Entity, getComponentCount, S32, (),, 
+   "@brief Get the count of behaviors on an object\n"
    "@return (int count) The number of behaviors on an object")
 {
    return object->getComponentCount();
 }
 
-DefineConsoleMethod(Entity, setComponentDirty, void, (S32 componentID, bool forceUpdate), (0, false),
+DefineEngineMethod(Entity, setComponentDirty, void, (S32 componentID, bool forceUpdate), (0, false),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -1923,7 +1916,7 @@ DefineConsoleMethod(Entity, setComponentDirty, void, (S32 componentID, bool forc
       object->setComponentDirty(comp, forceUpdate);*/
 }
 
-DefineConsoleMethod(Entity, getMoveVector, VectorF, (),,
+DefineEngineMethod(Entity, getMoveVector, VectorF, (),,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -1937,7 +1930,7 @@ DefineConsoleMethod(Entity, getMoveVector, VectorF, (),,
    return VectorF::Zero;
 }
 
-DefineConsoleMethod(Entity, getMoveRotation, VectorF, (), ,
+DefineEngineMethod(Entity, getMoveRotation, VectorF, (), ,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -1951,7 +1944,7 @@ DefineConsoleMethod(Entity, getMoveRotation, VectorF, (), ,
    return VectorF::Zero;
 }
 
-DefineConsoleMethod(Entity, getMoveTrigger, bool, (S32 triggerNum), (0),
+DefineEngineMethod(Entity, getMoveTrigger, bool, (S32 triggerNum), (0),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
@@ -1972,28 +1965,28 @@ DefineEngineMethod(Entity, getForwardVector, VectorF, (), ,
    return forVec;
 }
 
-DefineConsoleMethod(Entity, setForwardVector, void, (VectorF newForward), (VectorF(0,0,0)),
+DefineEngineMethod(Entity, setForwardVector, void, (VectorF newForward), (VectorF(0,0,0)),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
    object->setForwardVector(newForward);
 }
 
-DefineConsoleMethod(Entity, lookAt, void, (Point3F lookPosition),,
+DefineEngineMethod(Entity, lookAt, void, (Point3F lookPosition),,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
    //object->setForwardVector(newForward);
 }
 
-DefineConsoleMethod(Entity, rotateTo, void, (Point3F lookPosition, F32 degreePerSecond), (1.0),
+DefineEngineMethod(Entity, rotateTo, void, (Point3F lookPosition, F32 degreePerSecond), (1.0),
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object.")
 {
    //object->setForwardVector(newForward);
 }
 
-DefineConsoleMethod(Entity, notify, void, (String signalFunction, String argA, String argB, String argC, String argD, String argE),
+DefineEngineMethod(Entity, notify, void, (String signalFunction, String argA, String argB, String argC, String argD, String argE),
 ("", "", "", "", "", ""),
 "Triggers a signal call to all components for a certain function.")
 {
@@ -2003,7 +1996,7 @@ DefineConsoleMethod(Entity, notify, void, (String signalFunction, String argA, S
    object->notifyComponents(signalFunction, argA, argB, argC, argD, argE);
 }
 
-DefineConsoleFunction(findEntitiesByTag, const char*, (SimGroup* searchingGroup, String tags), (nullAsType<SimGroup*>(), ""),
+DefineEngineFunction(findEntitiesByTag, const char*, (SimGroup* searchingGroup, String tags), (nullAsType<SimGroup*>(), ""),
 "Finds all entities that have the provided tags.\n"
 "@param searchingGroup The SimGroup to search inside. If null, we'll search the entire dictionary(this can be slow!).\n"
 "@param tags Word delimited list of tags to search for. If multiple tags are included, the list is eclusively parsed, requiring all tags provided to be found on an entity for a match.\n"

+ 24 - 30
Engine/source/T3D/gameBase/gameConnection.cpp

@@ -326,7 +326,7 @@ DefineEngineMethod( GameConnection, setJoinPassword, void, (const char* password
    object->setJoinPassword(password);
 }
 
-ConsoleMethod(GameConnection, setConnectArgs, void, 3, 17,
+DefineEngineStringlyVariadicMethod(GameConnection, setConnectArgs, void, 3, 17,
    "(const char* args) @brief On the client, pass along a variable set of parameters to the server.\n\n"
    
    "Once the connection is established with the server, the server calls its onConnect() method "
@@ -2451,41 +2451,37 @@ DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
 // Object Selection in Torque by Dave Myers 
 //   http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335
 
-ConsoleMethod(GameConnection, setSelectedObj, bool, 3, 4, "(object, [propagate_to_client])")
+DefineEngineMethod(GameConnection, setSelectedObj, bool, (SceneObject* obj, bool propagate_to_client), (false), "")
 {
-   SceneObject* pending_selection;
-   if (!Sim::findObject(argv[2], pending_selection))
+   if (!obj)
       return false;
 
-   bool propagate_to_client = (argc > 3) ? dAtob(argv[3]) : false;
-   object->setSelectedObj(pending_selection, propagate_to_client);
+   object->setSelectedObj(obj, propagate_to_client);
 
    return true;
 }
 
-ConsoleMethod(GameConnection, getSelectedObj, S32, 2, 2, "()")
+DefineEngineMethod(GameConnection, getSelectedObj, SimObject*, (),, "")
 {
-   SimObject* selected = object->getSelectedObj();
-   return (selected) ? selected->getId(): -1;
+   return object->getSelectedObj();
 }
 
-ConsoleMethod(GameConnection, clearSelectedObj, void, 2, 3, "([propagate_to_client])")
+DefineEngineMethod(GameConnection, clearSelectedObj, void, (bool propagate_to_client), (false), "")
 {
-   bool propagate_to_client = (argc > 2) ? dAtob(argv[2]) : false;
    object->setSelectedObj(NULL, propagate_to_client);
 }
 
-ConsoleMethod(GameConnection, setPreSelectedObjFromRollover, void, 2, 2, "()")
+DefineEngineMethod(GameConnection, setPreSelectedObjFromRollover, void, (),, "")
 {
    object->setPreSelectedObjFromRollover();
 }
 
-ConsoleMethod(GameConnection, clearPreSelectedObj, void, 2, 2, "()")
+DefineEngineMethod(GameConnection, clearPreSelectedObj, void, (),, "")
 {
    object->clearPreSelectedObj();
 }
 
-ConsoleMethod(GameConnection, setSelectedObjFromPreSelected, void, 2, 2, "()")
+DefineEngineMethod(GameConnection, setSelectedObjFromPreSelected, void, (),, "")
 {
    object->setSelectedObjFromPreSelected();
 }
@@ -2722,33 +2718,32 @@ void GameConnection::resetDatablockCache()
    afx_saved_db_cache_CRC = 0xffffffff;
 }
 
-ConsoleFunction(resetDatablockCache, void, 1, 1, "resetDatablockCache()")
+DefineEngineFunction(resetDatablockCache, void, (),,"")
 {
    GameConnection::resetDatablockCache();
 }
 
-ConsoleFunction(isDatablockCacheSaved, bool, 1, 1, "resetDatablockCache()")
+DefineEngineFunction(isDatablockCacheSaved, bool, (),,"")
 {
    return afx_saved_db_cache;
 }
 
-ConsoleFunction(getDatablockCacheCRC, S32, 1, 1, "getDatablockCacheCRC()")
+DefineEngineFunction(getDatablockCacheCRC, S32, (),,"")
 {
    return (S32)afx_saved_db_cache_CRC;
 }
 
-ConsoleFunction(extractDatablockCacheCRC, S32, 2, 2, "extractDatablockCacheCRC(filename)")
+DefineEngineFunction(extractDatablockCacheCRC, S32, (const char* fileName),,"")
 {
    FileStream f_stream;
-   const char* fileName = argv[1];
-   if(!f_stream.open(fileName, Torque::FS::File::Read))
+   if (!f_stream.open(fileName, Torque::FS::File::Read))
    {
       Con::errorf("Failed to open file '%s'.", fileName);
       return -1;
    }
 
    U32 stream_sz = f_stream.getStreamSize();
-   if (stream_sz < 4*32)
+   if (stream_sz < 4 * 32)
    {
       Con::errorf("File '%s' is not a valid datablock cache.", fileName);
       f_stream.close();
@@ -2777,17 +2772,16 @@ ConsoleFunction(extractDatablockCacheCRC, S32, 2, 2, "extractDatablockCacheCRC(f
    return (S32)crc_code;
 }
 
-ConsoleFunction(setDatablockCacheCRC, void, 2, 2, "setDatablockCacheCRC(crc)")
+DefineEngineFunction(setDatablockCacheCRC, void, (U32 crc), , "")
 {
    GameConnection *conn = GameConnection::getConnectionToServer();
-   if(!conn)
+   if (!conn)
       return;
 
-   U32 crc_u = (U32)dAtoi(argv[1]);
-   conn->setServerCacheCRC(crc_u);
+   conn->setServerCacheCRC(crc);
 }
 
-ConsoleMethod( GameConnection, saveDatablockCache, void, 2, 2, "saveDatablockCache()")
+DefineEngineMethod(GameConnection, saveDatablockCache, void, (),, "")
 {
    if (GameConnection::serverCacheEnabled() && !afx_saved_db_cache)
    {
@@ -2802,14 +2796,14 @@ ConsoleMethod( GameConnection, saveDatablockCache, void, 2, 2, "saveDatablockCac
       Con::expandScriptFilename(filename_buffer, sizeof(filename_buffer), filename.c_str());
       Torque::Path givenPath(Torque::Path::CompressPath(filename_buffer));
       Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(givenPath);
-      if ( fileRef == NULL )
+      if (fileRef == NULL)
          Con::errorf("saveDatablockCache() failed to get CRC for file '%s'.", filename.c_str());
       else
          afx_saved_db_cache_CRC = (S32)fileRef->getChecksum();
    }
 }
 
-ConsoleMethod( GameConnection, loadDatablockCache, void, 2, 2, "loadDatablockCache()")
+DefineEngineMethod(GameConnection, loadDatablockCache, void, (),, "")
 {
    if (GameConnection::clientCacheEnabled())
    {
@@ -2817,7 +2811,7 @@ ConsoleMethod( GameConnection, loadDatablockCache, void, 2, 2, "loadDatablockCac
    }
 }
 
-ConsoleMethod( GameConnection, loadDatablockCache_Begin, bool, 2, 2, "loadDatablockCache_Begin()")
+DefineEngineMethod(GameConnection, loadDatablockCache_Begin, bool, (),, "")
 {
    if (GameConnection::clientCacheEnabled())
    {
@@ -2827,7 +2821,7 @@ ConsoleMethod( GameConnection, loadDatablockCache_Begin, bool, 2, 2, "loadDatabl
    return false;
 }
 
-ConsoleMethod( GameConnection, loadDatablockCache_Continue, bool, 2, 2, "loadDatablockCache_Continue()")
+DefineEngineMethod(GameConnection, loadDatablockCache_Continue, bool, (),, "")
 {
    if (GameConnection::clientCacheEnabled())
    {

+ 1 - 1
Engine/source/T3D/gameBase/gameProcess.cpp

@@ -34,7 +34,7 @@ ClientProcessList* ClientProcessList::smClientProcessList = NULL;
 ServerProcessList* ServerProcessList::smServerProcessList = NULL;
 static U32 gNetOrderNextId = 0;
 
-DefineConsoleFunction( dumpProcessList, void, ( ), ,
+DefineEngineFunction( dumpProcessList, void, ( ), ,
    "Dumps all ProcessObjects in ServerProcessList and ClientProcessList to the console." )
 {
    Con::printf( "client process list:" );

+ 2 - 2
Engine/source/T3D/gameFunctions.cpp

@@ -114,7 +114,7 @@ static U32 sgServerQueryIndex = 0;
 //SERVER FUNCTIONS ONLY
 ConsoleFunctionGroupBegin( Containers, "Spatial query functions. <b>Server side only!</b>");
 
-DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)"
+DefineEngineFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)"
    "@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n"
    "@returns The first object found, or an empty string if nothing was found.  Thereafter, you can get more "
    "results using containerFindNext()."
@@ -146,7 +146,7 @@ DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F o
    return buff;
 }
 
-DefineConsoleFunction( containerFindNext, const char*, (), , "()"
+DefineEngineFunction( containerFindNext, const char*, (), , "()"
    "@brief Get more results from a previous call to containerFindFirst().\n\n"
    "@note You must call containerFindFirst() to begin the search.\n"
    "@returns The next object found, or an empty string if nothing else was found.\n"

+ 2 - 2
Engine/source/T3D/lightBase.cpp

@@ -440,7 +440,7 @@ static ConsoleDocFragment _lbplayAnimation2(
    "void playAnimation(LightAnimData anim);"
 );
 
-DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""), "( [LightAnimData anim] )\t"
+DefineEngineMethod( LightBase, playAnimation, void, (const char * anim), (""), "( [LightAnimData anim] )\t"
    "Plays a light animation on the light.  If no LightAnimData is passed the "
    "existing one is played."
    "@hide")
@@ -484,7 +484,7 @@ void LightBase::playAnimation( LightAnimData *animData )
     }
 }
 
-DefineConsoleMethod( LightBase, pauseAnimation, void, (), , "Stops the light animation." )
+DefineEngineMethod( LightBase, pauseAnimation, void, (), , "Stops the light animation." )
 {
     object->pauseAnimation();
 }

+ 1 - 1
Engine/source/T3D/missionMarker.cpp

@@ -494,7 +494,7 @@ ConsoleDocFragment _SpawnSpherespawnObject1(
    "bool spawnObject(string additionalProps);"
 );
 
-DefineConsoleMethod(SpawnSphere, spawnObject, S32, (String additionalProps), ,
+DefineEngineMethod(SpawnSphere, spawnObject, S32, (String additionalProps), ,
    "([string additionalProps]) Spawns the object based on the SpawnSphere's "
    "class, datablock, properties, and script settings. Allows you to pass in "
    "extra properties."

+ 1 - 1
Engine/source/T3D/physics/physicsDebris.cpp

@@ -238,7 +238,7 @@ void PhysicsDebrisData::unpackData(BitStream* stream)
    shapeName   = stream->readSTString();
 }
 
-DefineConsoleMethod( PhysicsDebrisData, preload, void, (), , 
+DefineEngineMethod( PhysicsDebrisData, preload, void, (), , 
    "@brief Loads some information to have readily available at simulation time.\n\n"
    "Forces generation of shaders, materials, and other data used by the %PhysicsDebris object. "
    "This function should be used while a level is loading in order to shorten "

+ 18 - 15
Engine/source/T3D/physics/physicsPlugin.cpp

@@ -35,12 +35,11 @@
 #include "T3D/physics/physicsWorld.h"
 #include "core/util/tNamedFactory.h"
 
-
 PhysicsPlugin* PhysicsPlugin::smSingleton = NULL;
 PhysicsResetSignal PhysicsPlugin::smPhysicsResetSignal;
 bool PhysicsPlugin::smSinglePlayer = false;
 U32 PhysicsPlugin::smThreadCount = 2;
-
+bool PhysicsPlugin::smGpuAccelerationAllowed = false;
 
 String PhysicsPlugin::smServerWorldName( "server" );
 String PhysicsPlugin::smClientWorldName( "client" );
@@ -51,6 +50,10 @@ AFTER_MODULE_INIT( Sim )
       "@brief Informs the physics simulation if only a single player exists.\n\n"
       "If true, optimizations will be implemented to better cater to a single player environmnent.\n\n"
 	   "@ingroup Physics\n");
+   Con::addVariable("$Physics::gpuAccelerationAllowed", TypeBool, &PhysicsPlugin::smGpuAccelerationAllowed,
+      "@brief Informs the physics plugin if it is allowed to use gpu acceleration.\n\n"
+      "Not all physics implemenations or gpus can support gpu acceleration, this simply informs the plugin if it is allowed to try and use it or not.\n\n"
+      "@ingroup Physics\n");
    Con::addVariable( "$pref::Physics::threadCount", TypeS32, &PhysicsPlugin::smThreadCount, 
       "@brief Number of threads to use in a single pass of the physics engine.\n\n"
       "Defaults to 2 if not set.\n\n"
@@ -124,31 +127,31 @@ void PhysicsPlugin::_debugDraw( SceneManager *graph, const SceneRenderState *sta
       world->onDebugDraw( state );
 }
 
-DefineConsoleFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()"
+DefineEngineFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()"
    "@brief Returns true if a physics plugin exists and is initialized.\n\n"
    "@ingroup Physics" )
 {
    return PHYSICSMGR != NULL;
 }
 
-DefineConsoleFunction( physicsInit, bool, (const char * library), ("default"), "physicsInit( [string library] )")
+DefineEngineFunction( physicsInit, bool, (const char * library), ("default"), "physicsInit( [string library] )")
 {
    return PhysicsPlugin::activate( library );
 }
 
-DefineConsoleFunction( physicsDestroy, void, (), , "physicsDestroy()")
+DefineEngineFunction( physicsDestroy, void, (), , "physicsDestroy()")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->destroyPlugin();
 }
 
-DefineConsoleFunction( physicsInitWorld, bool, (const char * worldName), , "physicsInitWorld( String worldName )")
+DefineEngineFunction( physicsInitWorld, bool, (const char * worldName), , "physicsInitWorld( String worldName )")
 {
     bool res = PHYSICSMGR && PHYSICSMGR->createWorld( String( worldName ) );
    return res;
 }
 
-DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )")
+DefineEngineFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->destroyWorld( worldName );
@@ -157,19 +160,19 @@ DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "p
 
 // Control/query of the stop/started state
 // of the currently running simulation.
-DefineConsoleFunction( physicsStartSimulation, void, (const char * worldName), , "physicsStartSimulation( String worldName )")
+DefineEngineFunction( physicsStartSimulation, void, (const char * worldName), , "physicsStartSimulation( String worldName )")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->enableSimulation( String( worldName ), true );
 }
 
-DefineConsoleFunction( physicsStopSimulation, void, (const char * worldName), , "physicsStopSimulation( String worldName )")
+DefineEngineFunction( physicsStopSimulation, void, (const char * worldName), , "physicsStopSimulation( String worldName )")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->enableSimulation( String( worldName ), false );
 }
 
-DefineConsoleFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulation( String worldName )")
+DefineEngineFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulation( String worldName )")
 {
    return PHYSICSMGR && PHYSICSMGR->isSimulationEnabled();
 }
@@ -177,14 +180,14 @@ DefineConsoleFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulat
 // Used for slowing down time on the
 // physics simulation, and for pausing/restarting
 // the simulation.
-DefineConsoleFunction( physicsSetTimeScale, void, (F32 scale), , "physicsSetTimeScale( F32 scale )")
+DefineEngineFunction( physicsSetTimeScale, void, (F32 scale), , "physicsSetTimeScale( F32 scale )")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->setTimeScale( scale );
 }
 
 // Get the currently set time scale.
-DefineConsoleFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()")
+DefineEngineFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()")
 {
    return PHYSICSMGR && PHYSICSMGR->getTimeScale();
 }
@@ -193,7 +196,7 @@ DefineConsoleFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()")
 // physics simulation that they should store
 // their current state for later restoration,
 // such as when the editor is closed.
-DefineConsoleFunction( physicsStoreState, void, (), , "physicsStoreState()")
+DefineEngineFunction( physicsStoreState, void, (), , "physicsStoreState()")
 {
    PhysicsPlugin::getPhysicsResetSignal().trigger( PhysicsResetEvent_Store );
 }
@@ -201,13 +204,13 @@ DefineConsoleFunction( physicsStoreState, void, (), , "physicsStoreState()")
 // Used to send a signal to objects in the
 // physics simulation that they should restore
 // their saved state, such as when the editor is opened.
-DefineConsoleFunction( physicsRestoreState, void, (), , "physicsRestoreState()")
+DefineEngineFunction( physicsRestoreState, void, (), , "physicsRestoreState()")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->reset();
 }
 
-DefineConsoleFunction( physicsDebugDraw, void, (bool enable), , "physicsDebugDraw( bool enable )")
+DefineEngineFunction( physicsDebugDraw, void, (bool enable), , "physicsDebugDraw( bool enable )")
 {
    if ( PHYSICSMGR )
       PHYSICSMGR->enableDebugDraw( enable );

+ 4 - 0
Engine/source/T3D/physics/physicsPlugin.h

@@ -96,6 +96,10 @@ public:
    /// @see PHYSICSPLUGIN
    static PhysicsPlugin* getSingleton() { return smSingleton; }
 
+   /// Allow gpu acceleration if supported
+   static bool smGpuAccelerationAllowed;
+   static bool gpuAccelerationAllowed() { return smGpuAccelerationAllowed; }
+
    ///
    static bool activate( const char *library );
 

+ 2 - 0
Engine/source/T3D/physics/physicsWorld.cpp

@@ -26,6 +26,8 @@
 //Physics timing
 F32 PhysicsWorld::smPhysicsStepTime = 1.0f / 60.f; //default 60fps
 U32 PhysicsWorld::smPhysicsMaxSubSteps = 4;
+//Gpu acceleration
+bool PhysicsWorld::smGpuEnabled = false;
 
 PhysicsWorld::PhysicsWorld()
    : mGravity( 0, 0, -20.0f ) // NOTE: This matches the gravity used for player objects.

+ 6 - 0
Engine/source/T3D/physics/physicsWorld.h

@@ -49,6 +49,9 @@ protected:
    /// The current gravity force.
    Point3F mGravity;
 
+   /// Gpu acceleration
+   static bool smGpuEnabled;
+
 public:
 
    /// The constructor.
@@ -115,6 +118,9 @@ public:
    /// Physics timing
    static F32 smPhysicsStepTime;
    static U32 smPhysicsMaxSubSteps;
+
+   /// Gpu acceleration
+   static bool isGpuEnabled() { return smGpuEnabled; }
 };
 
 

+ 34 - 10
Engine/source/T3D/physics/physx3/px3.h

@@ -33,19 +33,43 @@
    #define WIN32
 #endif
 
+// macOS _DEBUG & NDEBUG
+#if defined(TORQUE_OS_MAC) && defined(TORQUE_DEBUG) && !defined(_DEBUG)
+   #define _DEBUG
+#elif defined(TORQUE_OS_MAC) && defined(TORQUE_RELEASE) && !defined(NDEBUG)
+   #define NDEBUG
+#endif
+
+// Linux _DEBUG & NDEBUG
+#if defined(TORQUE_OS_LINUX) && defined(TORQUE_DEBUG) && !defined(_DEBUG)
+#define _DEBUG
+#elif defined(TORQUE_OS_LINUX) && defined(TORQUE_RELEASE) && !defined(NDEBUG)
+#define NDEBUG
+#endif
+
 //-------------------------------------------------------------------------
 
+//safe release template
+template <class T> void SafeReleasePhysx(T* a)
+{
+   if (a)
+   {
+      a->release();
+      a = NULL;
+   }
+}
+
 #include <PxPhysicsAPI.h>
-#include <PxExtensionsAPI.h>
-#include <PxDefaultErrorCallback.h>
-#include <PxDefaultAllocator.h>
-#include <PxDefaultSimulationFilterShader.h>
-#include <PxDefaultCpuDispatcher.h>
-#include <PxShapeExt.h>
-#include <PxSimpleFactory.h>
-#include <PxFoundation.h>
-#include <PxController.h>
-#include <PxIO.h> 
+#include <extensions/PxExtensionsAPI.h>
+#include <extensions/PxDefaultErrorCallback.h>
+#include <extensions/PxDefaultAllocator.h>
+#include <extensions/PxDefaultSimulationFilterShader.h>
+#include <extensions/PxDefaultCpuDispatcher.h>
+#include <extensions/PxShapeExt.h>
+#include <extensions/PxSimpleFactory.h>
+#include <foundation/PxFoundation.h>
+#include <characterkinematic/PxController.h>
+#include <pvd/PxPvd.h>
 
 
 extern physx::PxPhysics* gPhysics3SDK;

+ 20 - 47
Engine/source/T3D/physics/physx3/px3Body.cpp

@@ -52,12 +52,9 @@ void Px3Body::_releaseActor()
    if ( !mActor )
       return;
 
-   mWorld->releaseWriteLock();
-
    mActor->userData = NULL;
 
-   mActor->release();
-   mActor = NULL;
+   SafeReleasePhysx(mActor);
    mBodyFlags = 0;
 
    if ( mMaterial )
@@ -80,7 +77,7 @@ bool Px3Body::init(   PhysicsCollision *shape,
    AssertFatal( shape, "Px3Body::init - Got a null collision shape!" );
    AssertFatal( dynamic_cast<Px3Collision*>( shape ), "Px3Body::init - The collision shape is the wrong type!" );
    AssertFatal( !((Px3Collision*)shape)->getShapes().empty(), "Px3Body::init - Got empty collision shape!" );
-    
+	 
    // Cleanup any previous actor.
    _releaseActor();
 
@@ -96,18 +93,20 @@ bool Px3Body::init(   PhysicsCollision *shape,
    {
       mActor = gPhysics3SDK->createRigidDynamic(physx::PxTransform(physx::PxIDENTITY()));
       physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
-      actor->setRigidDynamicFlag(physx::PxRigidDynamicFlag::eKINEMATIC, true);
+      actor->setRigidBodyFlag(physx::PxRigidBodyFlag::eKINEMATIC, true);
       actor->setMass(getMax( mass, 1.0f ));
    }
    else if ( mass > 0.0f )
    {
       mActor = gPhysics3SDK->createRigidDynamic(physx::PxTransform(physx::PxIDENTITY()));
+      physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
+      actor->setMaxAngularVelocity(80.f);
    }
    else
    {
       mActor = gPhysics3SDK->createRigidStatic(physx::PxTransform(physx::PxIDENTITY()));
       mIsStatic = true;
-   }
+	}
 
    mMaterial = gPhysics3SDK->createMaterial(0.6f,0.4f,0.1f);
   
@@ -123,12 +122,13 @@ bool Px3Body::init(   PhysicsCollision *shape,
             Con::errorf("PhysX3 Dynamic Triangle Mesh is not supported.");
          }
       }
-      physx::PxShape * pShape = mActor->createShape(*desc->pGeometry,*mMaterial);
+      
+      physx::PxShape * pShape = physx::PxRigidActorExt::createExclusiveShape(*mActor, *desc->pGeometry, *mMaterial);
       physx::PxFilterData colData;
       if(isDebris)
          colData.word0 = PX3_DEBRIS;
       else if(isTrigger)
-        colData.word0 = PX3_TRIGGER;
+         colData.word0 = PX3_TRIGGER;
       else
          colData.word0 = PX3_DEFAULT;
 
@@ -149,10 +149,6 @@ bool Px3Body::init(   PhysicsCollision *shape,
       physx::PxRigidBodyExt::setMassAndUpdateInertia(*actor,mass);
    }
 
-    // This sucks, but it has to happen if we want
-   // to avoid write lock errors from PhysX right now.
-   mWorld->releaseWriteLock();
-
    mWorld->getScene()->addActor(*mActor);
    mIsEnabled = true;
 
@@ -178,9 +174,9 @@ void Px3Body::setMaterial(  F32 restitution,
       actor->wakeUp();
    }
 
-    mMaterial->setRestitution(restitution);
-    mMaterial->setStaticFriction(staticFriction);
-    mMaterial->setDynamicFriction(friction);
+   mMaterial->setRestitution(restitution);
+   mMaterial->setStaticFriction(staticFriction);
+   mMaterial->setDynamicFriction(friction);
 
 }
 
@@ -322,15 +318,14 @@ Box3F Px3Body::getWorldBounds()
    
    physx::PxBounds3 bounds;
    bounds.setEmpty();   
-   physx::PxBounds3 shapeBounds;
- 
+   physx::PxBounds3 shapeBounds; 
   
    U32 shapeCount = mActor->getNbShapes();
    physx::PxShape **shapes = new physx::PxShape*[shapeCount];
    mActor->getShapes(shapes, shapeCount);
    for ( U32 i = 0; i < shapeCount; i++ )
    {
-      // Get the shape's bounds.    
+      // Get the shape's bounds.	   
       shapeBounds = physx::PxShapeExt::getWorldBounds(*shapes[i],*mActor);
       // Combine them into the total bounds.
       bounds.include( shapeBounds ); 
@@ -350,10 +345,6 @@ void Px3Body::setSimulationEnabled( bool enabled )
    if(mBodyFlags & BF_TRIGGER)
       return;
   
-   // This sucks, but it has to happen if we want
-   // to avoid write lock errors from PhysX right now.
-   mWorld->releaseWriteLock();
-
    U32 shapeCount = mActor->getNbShapes();
    physx::PxShape **shapes = new physx::PxShape*[shapeCount];
    mActor->getShapes(shapes, shapeCount);
@@ -367,12 +358,6 @@ void Px3Body::setSimulationEnabled( bool enabled )
 void Px3Body::setTransform( const MatrixF &transform )
 {
    AssertFatal( mActor, "Px3Body::setTransform - The actor is null!" );
-
-
-   // This sucks, but it has to happen if we want
-   // to avoid write lock errors from PhysX right now.
-   mWorld->releaseWriteLock();
-
    
    mActor->setGlobalPose(px3Cast<physx::PxTransform>(transform),false);
 
@@ -380,7 +365,7 @@ void Px3Body::setTransform( const MatrixF &transform )
       return;
 
    physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
-   bool kinematic = actor->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC;
+   bool kinematic = actor->getRigidBodyFlags() & physx::PxRigidBodyFlag::eKINEMATIC;
    // If its dynamic we have more to do.
    if ( isDynamic() && !kinematic )
    {
@@ -395,10 +380,6 @@ void Px3Body::applyCorrection( const MatrixF &transform )
    AssertFatal( mActor, "Px3Body::applyCorrection - The actor is null!" );
    AssertFatal( isDynamic(), "Px3Body::applyCorrection - This call is only for dynamics!" );
 
-   // This sucks, but it has to happen if we want
-   // to avoid write lock errors from PhysX right now.
-   mWorld->releaseWriteLock();
-
    mActor->setGlobalPose( px3Cast<physx::PxTransform>(transform) ); 
 }
 
@@ -406,35 +387,27 @@ void Px3Body::applyImpulse( const Point3F &origin, const Point3F &force )
 {
    AssertFatal( mActor, "Px3Body::applyImpulse - The actor is null!" );
 
-   // This sucks, but it has to happen if we want
-   // to avoid write lock errors from PhysX right now.
-   mWorld->releaseWriteLock();
    physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
    if ( mIsEnabled && isDynamic() )
-   physx::PxRigidBodyExt::addForceAtPos(*actor,px3Cast<physx::PxVec3>(force),
-                                    px3Cast<physx::PxVec3>(origin),
-                                    physx::PxForceMode::eIMPULSE);
-
+   physx::PxRigidBodyExt::addForceAtPos( *actor,px3Cast<physx::PxVec3>(force), px3Cast<physx::PxVec3>(origin), physx::PxForceMode::eIMPULSE );
 }
 
-void Px3Body::applyTorque( const Point3F &torque )
+void Px3Body::applyTorque(const Point3F &torque)
 {
    AssertFatal(mActor, "Px3Body::applyImpulse - The actor is null!");
 
-   mWorld->releaseWriteLock();
    physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
    if (mIsEnabled && isDynamic())
-      actor->addTorque( px3Cast<physx::PxVec3>(torque), physx::PxForceMode::eFORCE, true);
+      actor->addTorque(px3Cast<physx::PxVec3>(torque), physx::PxForceMode::eFORCE, true);
 }
 
-void Px3Body::applyForce( const Point3F &force )
+void Px3Body::applyForce(const Point3F &force)
 {
    AssertFatal(mActor, "Px3Body::applyTorque - The actor is null!");
 
-   mWorld->releaseWriteLock();
    physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
    if (mIsEnabled && isDynamic())
-      actor->addForce( px3Cast<physx::PxVec3>(force), physx::PxForceMode::eFORCE, true);
+      actor->addForce(px3Cast<physx::PxVec3>(force), physx::PxForceMode::eFORCE, true);
 }
 
 void Px3Body::findContact(SceneObject **contactObject,

+ 2 - 1
Engine/source/T3D/physics/physx3/px3Body.h

@@ -40,7 +40,8 @@ class Px3World;
 class Px3Collision;
 struct Px3CollisionDesc;
 
-namespace physx{
+namespace physx
+{
    class PxRigidActor;
    class PxMaterial;
    class PxShape;

+ 107 - 119
Engine/source/T3D/physics/physx3/px3Collision.cpp

@@ -36,136 +36,124 @@ Px3Collision::Px3Collision()
 }
 
 Px3Collision::~Px3Collision()
-{
-	
-	for ( U32 i=0; i < mColShapes.size(); i++ )
-	{
-		Px3CollisionDesc *desc = mColShapes[i];
-		delete desc->pGeometry;
-		// Delete the descriptor.
-		delete desc;
-	}
-
-	mColShapes.clear();
+{	
+   for ( U32 i=0; i < mColShapes.size(); i++ )
+   {
+      Px3CollisionDesc *desc = mColShapes[i];
+      delete desc->pGeometry;
+      // Delete the descriptor.
+      delete desc;
+   }
+
+   mColShapes.clear();
 }
 
 void Px3Collision::addPlane( const PlaneF &plane )
 {
-	physx::PxVec3 pos = px3Cast<physx::PxVec3>(plane.getPosition());
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
+   physx::PxVec3 pos = px3Cast<physx::PxVec3>(plane.getPosition());
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
    desc->pGeometry = new physx::PxPlaneGeometry();
    desc->pose = physx::PxTransform(pos, physx::PxQuat(physx::PxHalfPi, physx::PxVec3(0.0f, -1.0f, 0.0f)));
-	mColShapes.push_back(desc);
+   mColShapes.push_back(desc);
 }
 
 void Px3Collision::addBox( const Point3F &halfWidth,const MatrixF &localXfm )
 {
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
-	desc->pGeometry = new physx::PxBoxGeometry(px3Cast<physx::PxVec3>(halfWidth));
-	desc->pose = px3Cast<physx::PxTransform>(localXfm);
-	mColShapes.push_back(desc);
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
+   desc->pGeometry = new physx::PxBoxGeometry(px3Cast<physx::PxVec3>(halfWidth));
+   desc->pose = px3Cast<physx::PxTransform>(localXfm);
+   mColShapes.push_back(desc);
 }
 
-void Px3Collision::addSphere(  F32 radius,
-                              const MatrixF &localXfm )
+void Px3Collision::addSphere( F32 radius, const MatrixF &localXfm )
 {
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
-	desc->pGeometry = new physx::PxSphereGeometry(radius);
-	desc->pose = px3Cast<physx::PxTransform>(localXfm);
-	mColShapes.push_back(desc);
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
+   desc->pGeometry = new physx::PxSphereGeometry(radius);
+   desc->pose = px3Cast<physx::PxTransform>(localXfm);
+   mColShapes.push_back(desc);
 }
 
-void Px3Collision::addCapsule( F32 radius,
-                              F32 height,
-                              const MatrixF &localXfm )
+void Px3Collision::addCapsule( F32 radius, F32 height, const MatrixF &localXfm )
 {
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
-	desc->pGeometry = new physx::PxCapsuleGeometry(radius,height*0.5);//uses half height
-	desc->pose = px3Cast<physx::PxTransform>(localXfm);
-	mColShapes.push_back(desc);
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
+   desc->pGeometry = new physx::PxCapsuleGeometry(radius,height*0.5);//uses half height
+   desc->pose = px3Cast<physx::PxTransform>(localXfm);
+   mColShapes.push_back(desc);
 }
 
-bool Px3Collision::addConvex(  const Point3F *points, 
-                              U32 count,
-                              const MatrixF &localXfm )
+bool Px3Collision::addConvex( const Point3F *points, U32 count, const MatrixF &localXfm )
 {
-	physx::PxCooking *cooking = Px3World::getCooking();
-	physx::PxConvexMeshDesc convexDesc;
-	convexDesc.points.data = points;
-	convexDesc.points.stride = sizeof(Point3F);
-	convexDesc.points.count = count;
-	convexDesc.flags = physx::PxConvexFlag::eFLIPNORMALS|physx::PxConvexFlag::eCOMPUTE_CONVEX | physx::PxConvexFlag::eINFLATE_CONVEX;
-
-	Px3MemOutStream stream;
-	if(!cooking->cookConvexMesh(convexDesc,stream))
-		return false;
-
-	physx::PxConvexMesh* convexMesh;
-	Px3MemInStream in(stream.getData(), stream.getSize());
-	convexMesh = gPhysics3SDK->createConvexMesh(in);
-
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
+   physx::PxCooking *cooking = Px3World::getCooking();
+   physx::PxConvexMeshDesc convexDesc;
+   convexDesc.points.data = points;
+   convexDesc.points.stride = sizeof(Point3F);
+   convexDesc.points.count = count;
+   convexDesc.flags = physx::PxConvexFlag::eCOMPUTE_CONVEX | physx::PxConvexFlag::eCHECK_ZERO_AREA_TRIANGLES;
+   if(PhysicsWorld::isGpuEnabled())
+      convexDesc.flags |= physx::PxConvexFlag::eGPU_COMPATIBLE;
+
+   Px3MemOutStream stream;
+   if(!cooking->cookConvexMesh(convexDesc,stream))
+      return false;
+
+   physx::PxConvexMesh* convexMesh;
+   Px3MemInStream in(stream.getData(), stream.getSize());
+   convexMesh = gPhysics3SDK->createConvexMesh(in);
+
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
    physx::PxVec3 scale = px3Cast<physx::PxVec3>(localXfm.getScale());
    physx::PxQuat rotation = px3Cast<physx::PxQuat>(QuatF(localXfm));
    physx::PxMeshScale meshScale(scale,rotation);
-	desc->pGeometry = new physx::PxConvexMeshGeometry(convexMesh,meshScale);
-	desc->pose = px3Cast<physx::PxTransform>(localXfm);
-	mColShapes.push_back(desc);
-	return true;
+   desc->pGeometry = new physx::PxConvexMeshGeometry(convexMesh,meshScale);
+   desc->pose = px3Cast<physx::PxTransform>(localXfm);
+   mColShapes.push_back(desc);
+   return true;
 }
 
-bool Px3Collision::addTriangleMesh(  const Point3F *vert,
-                                    U32 vertCount,
-                                    const U32 *index,
-                                    U32 triCount,
-                                    const MatrixF &localXfm )
+bool Px3Collision::addTriangleMesh( const Point3F *vert, U32 vertCount, const U32 *index, U32 triCount, const MatrixF &localXfm )
 {
-	physx::PxCooking *cooking = Px3World::getCooking();
-	physx::PxTriangleMeshDesc meshDesc;
-	meshDesc.points.count = vertCount;
-	meshDesc.points.data = vert;
-	meshDesc.points.stride = sizeof(Point3F);
-
-	meshDesc.triangles.count = triCount;
-	meshDesc.triangles.data = index;
-	meshDesc.triangles.stride = 3*sizeof(U32);
-	meshDesc.flags = physx::PxMeshFlag::eFLIPNORMALS;
-
-	Px3MemOutStream stream;
-	if(!cooking->cookTriangleMesh(meshDesc,stream))
-		return false;
-
-	physx::PxTriangleMesh *mesh;
-	Px3MemInStream in(stream.getData(), stream.getSize());
-	mesh = gPhysics3SDK->createTriangleMesh(in);
-
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
-	desc->pGeometry = new physx::PxTriangleMeshGeometry(mesh);
-	desc->pose = px3Cast<physx::PxTransform>(localXfm);
-	mColShapes.push_back(desc);
-	return true;
+   physx::PxCooking *cooking = Px3World::getCooking();
+   physx::PxTriangleMeshDesc meshDesc;
+   meshDesc.points.count = vertCount;
+   meshDesc.points.data = vert;
+   meshDesc.points.stride = sizeof(Point3F);
+
+   meshDesc.triangles.count = triCount;
+   meshDesc.triangles.data = index;
+   meshDesc.triangles.stride = 3*sizeof(U32);
+   meshDesc.flags = physx::PxMeshFlag::eFLIPNORMALS;
+
+   Px3MemOutStream stream;
+   if(!cooking->cookTriangleMesh(meshDesc,stream))
+      return false;
+
+   physx::PxTriangleMesh *mesh;
+   Px3MemInStream in(stream.getData(), stream.getSize());
+   mesh = gPhysics3SDK->createTriangleMesh(in);
+
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
+   desc->pGeometry = new physx::PxTriangleMeshGeometry(mesh);
+   desc->pose = px3Cast<physx::PxTransform>(localXfm);
+   mColShapes.push_back(desc);
+   return true;
 }
 
-bool Px3Collision::addHeightfield(   const U16 *heights,
-                                    const bool *holes,
-                                    U32 blockSize,
-                                    F32 metersPerSample,
-                                    const MatrixF &localXfm )
+bool Px3Collision::addHeightfield( const U16 *heights, const bool *holes, U32 blockSize, F32 metersPerSample, const MatrixF &localXfm )
 {
-	const F32 heightScale = 0.03125f;
-	physx::PxHeightFieldSample* samples = (physx::PxHeightFieldSample*) new physx::PxHeightFieldSample[blockSize*blockSize];
-	memset(samples,0,blockSize*blockSize*sizeof(physx::PxHeightFieldSample));
-
-	physx::PxHeightFieldDesc heightFieldDesc;
-	heightFieldDesc.nbColumns = blockSize;
-	heightFieldDesc.nbRows = blockSize;
-	heightFieldDesc.thickness = -10.f;
-	heightFieldDesc.convexEdgeThreshold = 0;
-	heightFieldDesc.format = physx::PxHeightFieldFormat::eS16_TM;
-	heightFieldDesc.samples.data = samples;
-	heightFieldDesc.samples.stride = sizeof(physx::PxHeightFieldSample);
-
-	physx::PxU8 *currentByte = (physx::PxU8*)heightFieldDesc.samples.data;
+   const F32 heightScale = 0.03125f;
+   physx::PxHeightFieldSample* samples = (physx::PxHeightFieldSample*) new physx::PxHeightFieldSample[blockSize*blockSize];
+   memset(samples,0,blockSize*blockSize*sizeof(physx::PxHeightFieldSample));
+
+   physx::PxHeightFieldDesc heightFieldDesc;
+   heightFieldDesc.nbColumns = blockSize;
+   heightFieldDesc.nbRows = blockSize;
+   heightFieldDesc.thickness = -10.f;
+   heightFieldDesc.convexEdgeThreshold = 0;
+   heightFieldDesc.format = physx::PxHeightFieldFormat::eS16_TM;
+   heightFieldDesc.samples.data = samples;
+   heightFieldDesc.samples.stride = sizeof(physx::PxHeightFieldSample);
+
+   physx::PxU8 *currentByte = (physx::PxU8*)heightFieldDesc.samples.data;
    for ( U32 row = 0; row < blockSize; row++ )        
    {  
       const U32 tess = ( row + 1 ) % 2;
@@ -177,7 +165,6 @@ bool Px3Collision::addHeightfield(   const U16 *heights,
          U32 index = ( blockSize - row - 1 ) + ( column * blockSize );
          currentSample->height = (physx::PxI16)heights[ index ];
 
-
          if ( holes && holes[ getMax( (S32)index - 1, 0 ) ] )     // row index for holes adjusted so PhysX collision shape better matches rendered terrain
          {
             currentSample->materialIndex0 = physx::PxHeightFieldMaterial::eHOLE;
@@ -189,29 +176,30 @@ bool Px3Collision::addHeightfield(   const U16 *heights,
             currentSample->materialIndex1 = 0;
          }
 
-		int flag = ( column + tess ) % 2;
-		if(flag)
-			currentSample->clearTessFlag();
-		else
-			currentSample->setTessFlag();
+         S32 flag = ( column + tess ) % 2;
+         if(flag)
+            currentSample->clearTessFlag();
+         else
+            currentSample->setTessFlag();
 
          currentByte += heightFieldDesc.samples.stride;    
       }
    }
 
-	physx::PxHeightField * hf = gPhysics3SDK->createHeightField(heightFieldDesc);
-	physx::PxHeightFieldGeometry *geom = new physx::PxHeightFieldGeometry(hf,physx::PxMeshGeometryFlags(),heightScale,metersPerSample,metersPerSample);
+   physx::PxCooking *cooking = Px3World::getCooking();
+   physx::PxHeightField * hf = cooking->createHeightField(heightFieldDesc,gPhysics3SDK->getPhysicsInsertionCallback());
+   physx::PxHeightFieldGeometry *geom = new physx::PxHeightFieldGeometry(hf,physx::PxMeshGeometryFlags(),heightScale,metersPerSample,metersPerSample);
 		
-	physx::PxTransform pose= physx::PxTransform(physx::PxQuat(Float_HalfPi, physx::PxVec3(1, 0, 0 )));
-	physx::PxTransform pose1= physx::PxTransform(physx::PxQuat(Float_Pi, physx::PxVec3(0, 0, 1 )));
-	physx::PxTransform pose2 = pose1 * pose;
-	pose2.p = physx::PxVec3(( blockSize - 1 ) * metersPerSample, 0, 0 );
-	Px3CollisionDesc *desc = new Px3CollisionDesc;
-	desc->pGeometry = geom;
-	desc->pose = pose2;
+   physx::PxTransform pose= physx::PxTransform(physx::PxQuat(Float_HalfPi, physx::PxVec3(1, 0, 0 )));
+   physx::PxTransform pose1= physx::PxTransform(physx::PxQuat(Float_Pi, physx::PxVec3(0, 0, 1 )));
+   physx::PxTransform pose2 = pose1 * pose;
+   pose2.p = physx::PxVec3(( blockSize - 1 ) * metersPerSample, 0, 0 );
+   Px3CollisionDesc *desc = new Px3CollisionDesc;
+   desc->pGeometry = geom;
+   desc->pose = pose2;
 
-	mColShapes.push_back(desc);
+   mColShapes.push_back(desc);
 
    SAFE_DELETE(samples);
-	return true;
+   return true;
 }

+ 3 - 0
Engine/source/T3D/physics/physx3/px3Collision.h

@@ -23,6 +23,9 @@
 #ifndef _PX3COLLISION_H_
 #define _PX3COLLISION_H_
 
+#ifndef _PHYSX3_H_
+#include "T3D/physics/physx3/px3.h"
+#endif
 #ifndef _T3D_PHYSICS_PHYSICSCOLLISION_H_
 #include "T3D/physics/physicsCollision.h"
 #endif

+ 3 - 10
Engine/source/T3D/physics/physx3/px3Player.cpp

@@ -53,7 +53,7 @@ void Px3Player::_releaseController()
    {
       mController->getActor()->userData = NULL;
       mWorld->getStaticChangedSignal().remove( this, &Px3Player::_onStaticChanged );
-      mController->release();
+      SafeReleasePhysx(mController);
    }
 }
 
@@ -136,8 +136,6 @@ Point3F Px3Player::move( const VectorF &disp, CollisionList &outCol )
       return newPos;
    }
 
-   mWorld->releaseWriteLock();
-
    mCollisionList = &outCol;
 
    physx::PxVec3 dispNx( disp.x, disp.y, disp.z );
@@ -151,8 +149,8 @@ Point3F Px3Player::move( const VectorF &disp, CollisionList &outCol )
    physx::PxFilterData data;
    data.word0=groups;
    filter.mFilterData = &data;
-   filter.mFilterFlags = physx::PxSceneQueryFilterFlags(physx::PxControllerFlag::eCOLLISION_DOWN|physx::PxControllerFlag::eCOLLISION_SIDES|physx::PxControllerFlag::eCOLLISION_UP);
-
+   filter.mFilterFlags = physx::PxQueryFlags(physx::PxQueryFlag::eDYNAMIC | physx::PxQueryFlag::eSTATIC);
+   
    mController->move( dispNx,0.0001f,0, filter );
 
    Point3F newPos = px3Cast<Point3F>( mController->getPosition() );
@@ -272,7 +270,6 @@ void Px3Player::enableCollision()
 {
    AssertFatal( mController, "Px3Player::enableCollision - The controller is null!" );
 
-   mWorld->releaseWriteLock();
    px3GetFirstShape(mController->getActor())->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,true);
 }
 
@@ -280,7 +277,6 @@ void Px3Player::disableCollision()
 {
    AssertFatal( mController, "Px3Player::disableCollision - The controller is null!" );
 
-   mWorld->releaseWriteLock();
 	px3GetFirstShape(mController->getActor())->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,false); 
 }
 
@@ -293,8 +289,6 @@ void Px3Player::setTransform( const MatrixF &transform )
 {
    AssertFatal( mController, "Px3Player::setTransform - The controller is null!" );
 
-   mWorld->releaseWriteLock();
-
    Point3F newPos = transform.getPosition();
    newPos.z += mOriginOffset;
 
@@ -355,7 +349,6 @@ void Px3Player::setSpacials(const Point3F &nPos, const Point3F &nSize)
    F32 height = nSize.z - (radius * 2.0f);
    height -= mSkinWidth * 2.0f;
 
-   mWorld->releaseWriteLock();
    mController->resize(height);
    px3GetFirstShape(mController->getActor())->getCapsuleGeometry(mGeometry);
 }

+ 3 - 6
Engine/source/T3D/physics/physx3/px3Stream.cpp

@@ -83,10 +83,7 @@ Px3ConsoleStream::~Px3ConsoleStream()
 {
 }
 
-void Px3ConsoleStream::reportError( physx::PxErrorCode code, const char *message, const char* file, int line )
+void Px3ConsoleStream::reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line)
 {
-	UTF8 info[1024];
-	dSprintf( info, 1024, "File: %s\nLine: %d\n%s", file, line, message );
-	Platform::AlertOK( "PhysX Error", info );
-	// Con::printf( "PhysX Error:\n   %s(%d) : %s\n", file, line, message );
-}
+   Con::warnf( "PhysX Warning: %s(%d) : %s", file, line, message );
+}

+ 2 - 2
Engine/source/T3D/physics/physx3/px3Stream.h

@@ -62,11 +62,11 @@ protected:
 
 	};
 
-class Px3ConsoleStream : public physx::PxDefaultErrorCallback
+class Px3ConsoleStream : public physx::PxErrorCallback
 {
 protected:
 
-  virtual void reportError( physx::PxErrorCode code, const char *message, const char* file, int line );
+   virtual void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line);
 
 public:
 

+ 110 - 121
Engine/source/T3D/physics/physx3/px3World.cpp

@@ -41,27 +41,31 @@
 #include "gfx/sim/debugDraw.h"
 #include "gfx/primBuilder.h"
 
-
 physx::PxPhysics* gPhysics3SDK = NULL;
 physx::PxCooking* Px3World::smCooking = NULL;
 physx::PxFoundation* Px3World::smFoundation = NULL;
-physx::PxProfileZoneManager* Px3World::smProfileZoneManager = NULL;
-physx::PxDefaultCpuDispatcher* Px3World::smCpuDispatcher=NULL;
+physx::PxDefaultCpuDispatcher* Px3World::smCpuDispatcher = NULL;
+#ifndef TORQUE_OS_MAC
+physx::PxCudaContextManager* Px3World::smCudaContextManager = NULL;
+#endif
 Px3ConsoleStream* Px3World::smErrorCallback = NULL;
-physx::PxVisualDebuggerConnection* Px3World::smPvdConnection=NULL;
+physx::PxPvd* Px3World::smPvdConnection = NULL;
+physx::PxPvdTransport* Px3World::smPvdTransport = NULL;
 physx::PxDefaultAllocator Px3World::smMemoryAlloc;
 
-Px3World::Px3World(): mScene( NULL ),
-   mProcessList( NULL ),
+Px3World::Px3World() :
+   mScene( NULL ),
+   mIsEnabled( false ),
    mIsSimulating( false ),
-   mErrorReport( false ),
+   mIsServer( false ),
+   mIsSceneLocked( false ),
    mTickCount( 0 ),
-   mIsEnabled( false ),
+   mProcessList( NULL ),
    mEditorTimeScale( 1.0f ),
-   mAccumulator( 0 ),
+   mErrorReport( false ),
    mControllerManager(NULL),
-   mIsSceneLocked(false),
-   mRenderBuffer(NULL)
+   mRenderBuffer(NULL),
+   mAccumulator( 0 )
 {
 }
 
@@ -80,33 +84,25 @@ bool Px3World::restartSDK( bool destroyOnly, Px3World *clientWorld, Px3World *se
    // then we cannot reset the SDK.
    if ( clientWorld || serverWorld )
       return false;
-
-   if(smPvdConnection)
-      smPvdConnection->release();
-
-   if(smCooking)
-      smCooking->release();
-
-   if(smCpuDispatcher)
-      smCpuDispatcher->release();
+#ifndef TORQUE_OS_MAC
+   SafeReleasePhysx(smCudaContextManager);
+#endif
+   SafeReleasePhysx(smCpuDispatcher);
+   SafeReleasePhysx(smCooking);
+   smGpuEnabled = false;
 
    // Destroy the existing SDK.
    if ( gPhysics3SDK )
    {
       PxCloseExtensions();
-      gPhysics3SDK->release();
+      SafeReleasePhysx(gPhysics3SDK);
    }
 
-   if(smErrorCallback)
-   {
-      SAFE_DELETE(smErrorCallback);
-   }
+   SafeReleasePhysx(smPvdConnection);
+   SafeReleasePhysx(smPvdTransport);
 
-   if(smFoundation)
-   {
-      smFoundation->release();
-      SAFE_DELETE(smErrorCallback);
-   }
+   SAFE_DELETE(smErrorCallback);
+   SafeReleasePhysx(smFoundation);
 
    // If we're not supposed to restart... return.
    if ( destroyOnly )
@@ -114,20 +110,18 @@ bool Px3World::restartSDK( bool destroyOnly, Px3World *clientWorld, Px3World *se
 
    bool memTrack = false;
  #ifdef TORQUE_DEBUG
-   memTrack = true;
+   memTrack = false;
  #endif
-
+   
    smErrorCallback  = new Px3ConsoleStream;
-   smFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, smMemoryAlloc, *smErrorCallback);
-   smProfileZoneManager = &physx::PxProfileZoneManager::createProfileZoneManager(smFoundation);
-   gPhysics3SDK = PxCreatePhysics(PX_PHYSICS_VERSION, *smFoundation, physx::PxTolerancesScale(),memTrack,smProfileZoneManager);
+   smFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, smMemoryAlloc, *smErrorCallback);
+   smPvdConnection = PxCreatePvd(*smFoundation);
+   gPhysics3SDK = PxCreatePhysics(PX_PHYSICS_VERSION, *smFoundation, physx::PxTolerancesScale(),memTrack, smPvdConnection);
 
    if ( !gPhysics3SDK )
    {
       Con::errorf( "PhysX3 failed to initialize!" );
-      Platform::messageBox(   Con::getVariable( "$appName" ),
-                              avar("PhysX3 could not be started!\r\n"),
-                              MBOk, MIStop );
+      Platform::messageBox( Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop );
       Platform::forceShutdown( -1 );
       
       // We shouldn't get here, but this shuts up
@@ -135,33 +129,67 @@ bool Px3World::restartSDK( bool destroyOnly, Px3World *clientWorld, Px3World *se
       return false;
    }
 
-   if(!PxInitExtensions(*gPhysics3SDK))
+   if(!PxInitExtensions(*gPhysics3SDK, smPvdConnection))
    {
       Con::errorf( "PhysX3 failed to initialize extensions!" );
-      Platform::messageBox(   Con::getVariable( "$appName" ),
-                              avar("PhysX3 could not be started!\r\n"),
-                              MBOk, MIStop );
+      Platform::messageBox(   Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop );
       Platform::forceShutdown( -1 );
       return false;
    }
+//no gpu support on macOS
+#ifndef TORQUE_OS_MAC
+   //check if we are allowed to use gpu acceleration
+   if (PhysicsPlugin::gpuAccelerationAllowed())
+   {
+      // attempt to create a cuda context manager - only works on nvidia gpu (SM 3.0+ i.e kepler or better)
+      if (!smCpuDispatcher)
+      {
+         //check we have capable gpu, -1 means none found
+         S32 suggestedGpu = PxGetSuggestedCudaDeviceOrdinal(*smErrorCallback);
+         if (suggestedGpu != -1)
+         {
+            physx::PxCudaContextManagerDesc cudaContextManagerDesc;
+            smCudaContextManager = PxCreateCudaContextManager(*smFoundation, cudaContextManagerDesc);
+            if (smCudaContextManager)
+               smGpuEnabled = true;
+         }
+      }
+   }
+#endif
+
+   //cpu dispatcher
+   if (!smCpuDispatcher)
+      smCpuDispatcher = physx::PxDefaultCpuDispatcherCreate(PHYSICSMGR->getThreadCount());
 
-   smCooking = PxCreateCooking(PX_PHYSICS_VERSION, *smFoundation, physx::PxCookingParams(physx::PxTolerancesScale()));
+   physx::PxCookingParams params = physx::PxCookingParams(physx::PxTolerancesScale());
+   params.meshWeldTolerance = 0.001f;
+   params.meshPreprocessParams = physx::PxMeshPreprocessingFlags(physx::PxMeshPreprocessingFlag::eWELD_VERTICES);
+#ifndef TORQUE_OS_MAC
+   if(smGpuEnabled)
+      params.buildGPUData = true;
+#endif
+
+   smCooking = PxCreateCooking(PX_PHYSICS_VERSION, *smFoundation, params);
    if(!smCooking)
    {
       Con::errorf( "PhysX3 failed to initialize cooking!" );
-      Platform::messageBox(   Con::getVariable( "$appName" ),
-                              avar("PhysX3 could not be started!\r\n"),
-                              MBOk, MIStop );
+      Platform::messageBox( Con::getVariable( "$appName" ), avar("PhysX3 could not be started!\r\n"), MBOk, MIStop );
       Platform::forceShutdown( -1 );      
       return false;
    }
 
+   //TODO: enable/disable this from script
 #ifdef TORQUE_DEBUG
-   physx::PxVisualDebuggerConnectionFlags connectionFlags(physx::PxVisualDebuggerExt::getAllConnectionFlags());
-   smPvdConnection = physx::PxVisualDebuggerExt::createConnection(gPhysics3SDK->getPvdConnectionManager(), 
-            "localhost", 5425, 100, connectionFlags); 
+   if(!smPvdTransport)
+      smPvdTransport = physx::PxDefaultPvdSocketTransportCreate("localhost", 5425, 100);
+
+   smPvdConnection->connect(*smPvdTransport, physx::PxPvdInstrumentationFlag::eALL);
 #endif
 
+   //use legacy heightfield
+   //TODO: new method causing crashes on collision in debug build (unified HeightFields)
+   PxRegisterLegacyHeightFields(*gPhysics3SDK);
+
    return true;
 }
 
@@ -169,8 +197,6 @@ void Px3World::destroyWorld()
 {
    getPhysicsResults();
 
-   mRenderBuffer = NULL;
-
    // Release the tick processing signals.
    if ( mProcessList )
    {
@@ -179,19 +205,9 @@ void Px3World::destroyWorld()
       mProcessList = NULL;
    }
 
-   if(mControllerManager)
-   {
-      mControllerManager->release();
-      mControllerManager = NULL;
-   }
-   
+   SafeReleasePhysx(mControllerManager);
    // Destroy the scene.
-   if ( mScene )
-   {
-      // Release the scene.
-      mScene->release();
-      mScene = NULL;
-   }
+   SafeReleasePhysx(mScene);
 }
 
 bool Px3World::initWorld( bool isServer, ProcessList *processList )
@@ -203,27 +219,32 @@ bool Px3World::initWorld( bool isServer, ProcessList *processList )
    }
 
    mIsServer = isServer;
-   
+	
    physx::PxSceneDesc sceneDesc(gPhysics3SDK->getTolerancesScale());
 
    sceneDesc.gravity = px3Cast<physx::PxVec3>(mGravity);
    sceneDesc.userData = this;
-   if(!sceneDesc.cpuDispatcher)
-   {
-      //Create shared cpu dispatcher
-      if(!smCpuDispatcher)
-         smCpuDispatcher = physx::PxDefaultCpuDispatcherCreate(PHYSICSMGR->getThreadCount());
  
-      sceneDesc.cpuDispatcher = smCpuDispatcher;
-      Con::printf("PhysX3 using Cpu: %d workers", smCpuDispatcher->getWorkerCount());
+   sceneDesc.cpuDispatcher = smCpuDispatcher;
+   Con::printf("PhysX3 using Cpu: %d workers", smCpuDispatcher->getWorkerCount());
+
+#ifndef TORQUE_OS_MAC
+   if (smGpuEnabled)
+   {
+      sceneDesc.flags |= physx::PxSceneFlag::eENABLE_GPU_DYNAMICS;
+      sceneDesc.flags |= physx::PxSceneFlag::eENABLE_PCM;
+      sceneDesc.broadPhaseType = physx::PxBroadPhaseType::eGPU;
+      sceneDesc.gpuDispatcher = smCudaContextManager->getGpuDispatcher();
+      Con::printf("PhysX3 using Gpu: %s", smCudaContextManager->getDeviceName());
    }
-   
+#endif
+
    sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD;
    sceneDesc.flags |= physx::PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
    sceneDesc.filterShader  = physx::PxDefaultSimulationFilterShader;
 
-   mScene = gPhysics3SDK->createScene(sceneDesc);
-   //cache renderbuffer for use with debug drawing
+	mScene = gPhysics3SDK->createScene(sceneDesc);
+
    mRenderBuffer = const_cast<physx::PxRenderBuffer*>(&mScene->getRenderBuffer());
 
    physx::PxDominanceGroupPair debrisDominance( 0.0f, 1.0f );
@@ -252,15 +273,16 @@ bool Px3World::_simulate(const F32 dt)
    if (numSimulationSubSteps)
    {
       //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
-      S32 clampedSimulationSteps = (numSimulationSubSteps > smPhysicsMaxSubSteps)? smPhysicsMaxSubSteps : numSimulationSubSteps;
-      
+      S32 clampedSimulationSteps = (numSimulationSubSteps > smPhysicsMaxSubSteps) ? smPhysicsMaxSubSteps : numSimulationSubSteps;
+		
       for (S32 i=0;i<clampedSimulationSteps;i++)
       {
-         mScene->fetchResults(true);
+         if(i > 0)
+            mScene->fetchResults(true);
          mScene->simulate(smPhysicsStepTime);
       }
    }
-   
+	
    mIsSimulating = true;
 
    return true;
@@ -299,36 +321,6 @@ void Px3World::getPhysicsResults()
    mScene->fetchResults(true);
    mIsSimulating = false;
    mTickCount++;
-
-  // Con::printf( "%s PhysXWorld::getPhysicsResults!", this == smClientWorld ? "Client" : "Server" );
-}
-
-void Px3World::releaseWriteLocks()
-{
-   Px3World *world = dynamic_cast<Px3World*>( PHYSICSMGR->getWorld( "server" ) );
-
-   if ( world )
-      world->releaseWriteLock();
-
-   world = dynamic_cast<Px3World*>( PHYSICSMGR->getWorld( "client" ) );
-
-   if ( world )
-      world->releaseWriteLock();
-}
-
-void Px3World::releaseWriteLock()
-{
-   if ( !mScene || !mIsSimulating ) 
-      return;
-
-   PROFILE_SCOPE(PxWorld_ReleaseWriteLock);
-
-   // We use checkResults here to release the write lock
-   // but we do not change the simulation flag or increment
-   // the tick count... we may have gotten results, but the
-   // simulation hasn't really ticked!
-   mScene->checkResults( true );
-   //AssertFatal( mScene->isWritable(), "PhysX3World::releaseWriteLock() - We should have been writable now!" );
 }
 
 void Px3World::lockScenes()
@@ -388,8 +380,7 @@ void Px3World::unlockScene()
 }
 
 bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse )
-{
-    
+{    
    physx::PxVec3 orig = px3Cast<physx::PxVec3>( startPnt );
    physx::PxVec3 dir = px3Cast<physx::PxVec3>( endPnt - startPnt );
    physx::PxF32 maxDist = dir.magnitude();
@@ -398,15 +389,15 @@ bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo
    U32 groups = 0xffffffff;
    groups &= ~( PX3_TRIGGER ); // No trigger shapes!
 
-   physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::eIMPACT | physx::PxHitFlag::eNORMAL);
+   physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL);
    physx::PxQueryFilterData filterData(physx::PxQueryFlag::eSTATIC|physx::PxQueryFlag::eDYNAMIC);
    filterData.data.word0 = groups;
    physx::PxRaycastBuffer buf;
 
    if(!mScene->raycast(orig,dir,maxDist,buf,outFlags,filterData))
-     return false;
+      return false;
    if(!buf.hasBlock)
-    return false;
+      return false;
 
    const physx::PxRaycastHit hit = buf.block;
    physx::PxRigidActor *actor = hit.actor;
@@ -425,8 +416,8 @@ bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo
    }
 
    if ( impulse.isZero() ||
-        !actor->isRigidDynamic() ||
-        actor->is<physx::PxRigidDynamic>()->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC )
+        !actor->is<physx::PxRigidDynamic>() ||
+        actor->is<physx::PxRigidDynamic>()->getRigidBodyFlags() & physx::PxRigidBodyFlag::eKINEMATIC )
       return true;
   
    physx::PxRigidBody *body = actor->is<physx::PxRigidBody>();
@@ -453,7 +444,7 @@ PhysicsBody* Px3World::castRay( const Point3F &start, const Point3F &end, U32 bo
    groups &= ~( PX3_TRIGGER ); // triggers
    groups &= ~( PX3_DEBRIS ); // debris
 
-   physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::eIMPACT | physx::PxHitFlag::eNORMAL);
+   physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::ePOSITION | physx::PxHitFlag::eNORMAL);
    physx::PxQueryFilterData filterData;
    if(bodyTypes & BT_Static)
       filterData.flags |= physx::PxQueryFlag::eSTATIC;
@@ -491,12 +482,12 @@ void Px3World::explosion( const Point3F &pos, F32 radius, F32 forceMagnitude )
    {
       physx::PxRigidActor *actor = buffer.touches[i].actor;
       
-      bool dynamic = actor->isRigidDynamic();
+      bool dynamic = actor->is<physx::PxRigidDynamic>();
       
       if ( !dynamic )
          continue;
 
-      bool kinematic = actor->is<physx::PxRigidDynamic>()->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC;
+      bool kinematic = actor->is<physx::PxRigidDynamic>()->getRigidBodyFlags() & physx::PxRigidBodyFlag::eKINEMATIC;
       
       if ( kinematic )
          continue;
@@ -523,8 +514,6 @@ physx::PxController* Px3World::createController( physx::PxControllerDesc &desc )
    if ( !mScene )
       return NULL;
 
-   // We need the writelock!
-   releaseWriteLock();
    physx::PxController* pController = mControllerManager->createController(desc);
    AssertFatal( pController, "Px3World::createController - Got a null!" );
    return pController;
@@ -543,7 +532,7 @@ static ColorI getDebugColor( physx::PxU32 packed )
 
 void Px3World::onDebugDraw( const SceneRenderState *state )
 {
-   if ( !mScene || !mRenderBuffer )
+   if ( !mScene || !mRenderBuffer)
       return;
 
    mScene->setVisualizationParameter(physx::PxVisualizationParameter::eSCALE,1.0f);

+ 15 - 13
Engine/source/T3D/physics/physx3/px3World.h

@@ -23,15 +23,15 @@
 #ifndef _PX3WORLD_H_
 #define _PX3WORLD_H_
 
+#ifndef _PHYSX3_H_
+#include "T3D/physics/physx3/px3.h"
+#endif
 #ifndef _T3D_PHYSICS_PHYSICSWORLD_H_
 #include "T3D/physics/physicsWorld.h"
 #endif
 #ifndef _MMATH_H_
 #include "math/mMath.h"
 #endif
-#ifndef _PHYSX3_H_
-#include "T3D/physics/physx3/px3.h"
-#endif
 #ifndef _TVECTOR_H_
 #include "core/util/tVector.h"
 #endif
@@ -51,26 +51,29 @@ enum Px3CollisionGroup
 class Px3World : public PhysicsWorld
 {
 protected:
-
    physx::PxScene* mScene;
    bool mIsEnabled;
    bool mIsSimulating;
    bool mIsServer;
-   bool mIsSceneLocked;
+   bool mIsSceneLocked;   
    U32 mTickCount;
    ProcessList *mProcessList;
    F32 mEditorTimeScale;
    bool mErrorReport;
-   physx::PxRenderBuffer *mRenderBuffer;
    physx::PxControllerManager* mControllerManager;
+   physx::PxRenderBuffer *mRenderBuffer;
+   F32 mAccumulator;
    static Px3ConsoleStream *smErrorCallback;
    static physx::PxDefaultAllocator smMemoryAlloc;
    static physx::PxFoundation* smFoundation;
    static physx::PxCooking *smCooking;
-   static physx::PxProfileZoneManager* smProfileZoneManager;
    static physx::PxDefaultCpuDispatcher* smCpuDispatcher;
-   static physx::PxVisualDebuggerConnection* smPvdConnection;
-   F32 mAccumulator;
+#ifndef TORQUE_OS_MAC
+   static physx::PxCudaContextManager* smCudaContextManager;
+#endif
+   static physx::PxPvd* smPvdConnection;
+   static physx::PxPvdTransport* smPvdTransport;
+   
    bool _simulate(const F32 dt);
 
 public:
@@ -86,21 +89,20 @@ public:
    virtual PhysicsBody* castRay( const Point3F &start, const Point3F &end, U32 bodyTypes = BT_All );
    virtual void explosion( const Point3F &pos, F32 radius, F32 forceMagnitude ); 
    virtual bool isEnabled() const { return mIsEnabled; }
-   physx::PxScene* getScene(){ return mScene;}
+   physx::PxScene* getScene(){ return mScene; }
    void setEnabled( bool enabled );
    U32 getTick() { return mTickCount; }
    void tickPhysics( U32 elapsedMs );
    void getPhysicsResults();
    void setEditorTimeScale( F32 timeScale ) { mEditorTimeScale = timeScale; }
    const F32 getEditorTimeScale() const { return mEditorTimeScale; }
-   void releaseWriteLock();
-   bool isServer(){return mIsServer;}
+   bool isServer() { return mIsServer; }
+   
    physx::PxController* createController( physx::PxControllerDesc &desc );
    void lockScene();
    void unlockScene();
    //static
    static bool restartSDK( bool destroyOnly = false, Px3World *clientWorld = NULL, Px3World *serverWorld = NULL );
-   static void releaseWriteLocks();
    static physx::PxCooking *getCooking();
    static void lockScenes();
    static void unlockScenes();

+ 9 - 11
Engine/source/T3D/player.cpp

@@ -7518,7 +7518,7 @@ U32 Player::lockAnimation()
    return last_anim_lock_tag;
 }
 
-ConsoleMethod(Player, isAnimationLocked, bool, 2, 2, "isAnimationLocked()")
+DefineEngineMethod(Player, isAnimationLocked, bool, (),, "")
 {
    return object->isAnimationLocked();
 }
@@ -7534,14 +7534,13 @@ void Player::setLookAnimationOverride(bool flag)
 #endif
 }
 
-ConsoleMethod(Player, setLookAnimationOverride, void, 3, 3, "setLookAnimationOverride(flag)")
+DefineEngineMethod(Player, setLookAnimationOverride, void, (bool flag),, "")
 {
-   object->setLookAnimationOverride(dAtob(argv[2]));
+   object->setLookAnimationOverride(flag);
 }
 
-ConsoleMethod(Player, copyHeadRotation, void, 3, 3, "copyHeadRotation(other_player)")
+DefineEngineMethod(Player, copyHeadRotation, void, (Player* other_player),, "")
 {
-   Player* other_player = dynamic_cast<Player*>(Sim::findObject(argv[2]));
    if (other_player)
       object->copyHeadRotation(other_player);
 }
@@ -7610,9 +7609,9 @@ void Player::restoreMovement(U32 tag)
    }
 }
 
-ConsoleMethod(Player, setMovementSpeedBias, void, 3, 3, "setMovementSpeedBias(F32 bias)")
+DefineEngineMethod(Player, setMovementSpeedBias, void, (F32 bias),, "setMovementSpeedBias(F32 bias)")
 {
-   object->setMovementSpeedBias(dAtof(argv[2]));
+   object->setMovementSpeedBias(bias);
 }
 
 void Player::overrideFootfallFX(bool decals, bool sounds, bool dust) 
@@ -7643,12 +7642,11 @@ void Player::setControllers(Vector<OpenVRTrackedObject*> controllerList)
    mControllers[1] = controllerList.size() > 1 ? controllerList[1] : NULL;
 }
 
-ConsoleMethod(Player, setVRControllers, void, 4, 4, "")
+DefineEngineMethod(Player, setVRControllers, void, (OpenVRTrackedObject* controllerL, OpenVRTrackedObject* controllerR,, "")
 {
-   OpenVRTrackedObject *controllerL, *controllerR;
    Vector<OpenVRTrackedObject*> list;
 
-   if (Sim::findObject(argv[2], controllerL))
+   if (controllerL)
    {
       list.push_back(controllerL);
    }
@@ -7657,7 +7655,7 @@ ConsoleMethod(Player, setVRControllers, void, 4, 4, "")
       list.push_back(NULL);
    }
 
-   if (Sim::findObject(argv[3], controllerR))
+   if (controllerR)
    {
       list.push_back(controllerR);
    }

+ 2 - 2
Engine/source/T3D/staticShape.cpp

@@ -314,7 +314,7 @@ void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream)
 // This appears to be legacy T2 stuff
 // Marked internal, as this is flagged to be deleted
 // [8/1/2010 mperry]
-DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
+DefineEngineMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
            "@internal")
 {
    if(!object->isServerObject())
@@ -322,7 +322,7 @@ DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(b
    object->setPowered(isPowered);
 }
 
-DefineConsoleMethod( StaticShape, getPoweredState, bool, (), , "@internal")
+DefineEngineMethod( StaticShape, getPoweredState, bool, (), , "@internal")
 {
    if(!object->isServerObject())
       return(false);

+ 49 - 66
Engine/source/afx/afxCamera.cpp

@@ -450,7 +450,7 @@ const char* afxCamera::getMode()
 //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 // Console Methods
 
-ConsoleMethod(afxCamera, setOrbitMode, void, 7, 8, 
+DefineEngineStringlyVariadicMethod(afxCamera, setOrbitMode, void, 7, 8,
   "(GameBase orbitObject, TransformF mat, float minDistance, float maxDistance, float curDistance, bool ownClientObject)"
   "Set the camera to orbit around some given object.\n\n"
   "@param   orbitObject  Object we want to orbit.\n"
@@ -481,108 +481,91 @@ ConsoleMethod(afxCamera, setOrbitMode, void, 7, 8,
   object->setOrbitMode(orbitObject, pos, aa, minDis, maxDis, curDis, (argc == 8) ? dAtob(argv[7]) : false);
 }
 
-ConsoleMethod( afxCamera, setFlyMode, void, 2, 2, "()" "Set the camera to be able to fly freely.")
+DefineEngineMethod(afxCamera, setFlyMode, void, (),, 
+   "@brief Set the camera to be able to fly freely.")
 {
-  object->setFlyMode();
+   object->setFlyMode();
 }
 
-ConsoleMethod( afxCamera, getPosition, const char *, 2, 2, "()"
-              "Get the position of the camera.\n\n"
-              "@returns A string of form \"x y z\".")
-{ 
-  Point3F& pos = object->getPosition();
-  char buffer[100];
-  dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z);
-  return buffer;
+DefineEngineMethod(afxCamera, getPosition, Point3F, (),,
+   "@brief Get the position of the camera.\n\n"
+   "@returns The position of the camera.")
+{
+   return object->getPosition();
 }
 
-ConsoleMethod(afxCamera, setCameraSubject, bool, 3, 3, "") 
-{   
-  SceneObject* subject;
-  if (!Sim::findObject(argv[2], subject))
-  {
-    Con::errorf("Camera subject \"%s\" not found.", argv[2].getStringValue());
-    return false;
-  }
-  
-  object->setCameraSubject(subject);
-  
-  return true;
+DefineEngineMethod(afxCamera, setCameraSubject, bool, (SceneObject* subject),, "")
+{
+   if (!subject)
+   {
+      Con::errorf("Camera subject not found.");
+      return false;
+   }
+
+   object->setCameraSubject(subject);
+
+   return true;
 }
 
-ConsoleMethod(afxCamera, setThirdPersonDistance, bool, 3, 3, "") 
-{   
-  F32 distance; 
-  dSscanf(argv[2], "%f", &distance);
+DefineEngineMethod(afxCamera, setThirdPersonDistance, bool, (F32 distance),, "")
+{
+   object->setThirdPersonDistance(distance);
 
-  object->setThirdPersonDistance(distance);
-  
-  return true;
+   return true;
 }
 
-ConsoleMethod(afxCamera, getThirdPersonDistance, F32, 2, 2, "")
+DefineEngineMethod(afxCamera, getThirdPersonDistance, F32, (),, "")
 {
    return object->getThirdPersonDistance();
 }
 
-ConsoleMethod(afxCamera, setThirdPersonAngle, bool, 3, 3, "") 
-{   
-  F32 angle; 
-  dSscanf(argv[2], "%f", &angle);
+DefineEngineMethod(afxCamera, setThirdPersonAngle, bool, (F32 distance),, "")
+{
+   object->setThirdPersonAngle(distance);
 
-  object->setThirdPersonAngle(angle);
-  
-  return true;
+   return true;
 }
 
-ConsoleMethod(afxCamera, getThirdPersonAngle, F32, 2, 2, "")
+DefineEngineMethod(afxCamera, getThirdPersonAngle, F32, (),, "")
 {
    return object->getThirdPersonAngle();
 }
 
-ConsoleMethod(afxCamera, setThirdPersonOffset, void, 3, 4, "(Point3F offset [, Point3F coi_offset])") 
+DefineEngineMethod(afxCamera, setThirdPersonOffset, void, (Point3F offset, Point3F coi_offset), (Point3F::Max), "")
 {
-  Point3F offset; 
-  dSscanf(argv[2], "%f %f %f", &offset.x, &offset.y, &offset.z);
-  if (argc > 3)
-  {
-    Point3F coi_offset; 
-    dSscanf(argv[3], "%f %f %f", &coi_offset.x, &coi_offset.y, &coi_offset.z);
-    object->setThirdPersonOffset(offset, coi_offset);
-  }
-  else
-    object->setThirdPersonOffset(offset);
+   if (coi_offset == Point3F::Max)
+   {
+      object->setThirdPersonOffset(offset);
+   }
+   else
+   {
+      object->setThirdPersonOffset(offset, coi_offset);
+   }
 }
 
-ConsoleMethod(afxCamera, getThirdPersonOffset, const char *, 2, 2, "()")
+DefineEngineMethod(afxCamera, getThirdPersonOffset, Point3F, (),, "")
 {
-  const Point3F& pos = object->getThirdPersonOffset();
-  char buffer[100];
-  dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z);
-  return buffer;
+   return object->getThirdPersonOffset();
 }
 
-ConsoleMethod(afxCamera, getThirdPersonCOIOffset, const char *, 2, 2, "()")
+DefineEngineMethod(afxCamera, getThirdPersonCOIOffset, Point3F, (),, "")
 {
-  const Point3F& pos = object->getThirdPersonCOIOffset();
-  char buffer[100];
-  dSprintf(buffer, sizeof(buffer),"%f %f %f",pos.x,pos.y,pos.z);
-  return buffer;
+   return object->getThirdPersonCOIOffset();
 }
 
-ConsoleMethod(afxCamera, setThirdPersonMode, void, 2, 2, "()")
+DefineEngineMethod(afxCamera, setThirdPersonMode, void, (),, "")
 {
-  object->setThirdPersonMode();
+   object->setThirdPersonMode();
 }
 
-ConsoleMethod(afxCamera, setThirdPersonSnap, void, 2, 2, "()")
+DefineEngineMethod(afxCamera, setThirdPersonSnap, void, (),, "")
 {
-  object->setThirdPersonSnap();
+   object->setThirdPersonSnap();
 }
 
-ConsoleMethod(afxCamera, getMode, const char *, 2, 2, "()")
+DefineEngineMethod(afxCamera, getMode, const char*, (),, "")
 {
-  return object->getMode();
+   return object->getMode();
 }
 
 //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

+ 22 - 22
Engine/source/afx/afxMagicSpell.cpp

@@ -2633,29 +2633,29 @@ DefineEngineMethod(afxMagicSpell, getImpactedObject, S32, (),,
   return (imp_obj) ? imp_obj->getId() : -1;
 }
 
-ConsoleMethod(afxMagicSpell, setTimeFactor, void, 3, 4, "(F32 factor) or (string phase, F32 factor)"
-              "Sets the time-factor for the spell, either overall or for a specific phrase.\n\n"
-              "@ingroup AFX")
+DefineEngineStringlyVariadicMethod(afxMagicSpell, setTimeFactor, void, 3, 4, "(F32 factor) or (string phase, F32 factor)"
+   "Sets the time-factor for the spell, either overall or for a specific phrase.\n\n"
+   "@ingroup AFX")
 {
-  if (argc == 3)
-    object->setTimeFactor(dAtof(argv[2]));
-  else
-  {
-    if (dStricmp(argv[2], "overall") == 0)
-      object->setTimeFactor(dAtof(argv[3]));
-    else if (dStricmp(argv[2], "casting") == 0)
-      object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, dAtof(argv[3]));
-    else if (dStricmp(argv[2], "launch") == 0)
-      object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, dAtof(argv[3]));
-    else if (dStricmp(argv[2], "delivery") == 0)
-      object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, dAtof(argv[3]));
-    else if (dStricmp(argv[2], "impact") == 0)
-      object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, dAtof(argv[3]));
-    else if (dStricmp(argv[2], "linger") == 0)
-      object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, dAtof(argv[3]));
-    else
-      Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getStringValue());
-  }
+   if (argc == 3)
+      object->setTimeFactor(dAtof(argv[2]));
+   else
+   {
+      if (dStricmp(argv[2], "overall") == 0)
+         object->setTimeFactor(dAtof(argv[3]));
+      else if (dStricmp(argv[2], "casting") == 0)
+         object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, dAtof(argv[3]));
+      else if (dStricmp(argv[2], "launch") == 0)
+         object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, dAtof(argv[3]));
+      else if (dStricmp(argv[2], "delivery") == 0)
+         object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, dAtof(argv[3]));
+      else if (dStricmp(argv[2], "impact") == 0)
+         object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, dAtof(argv[3]));
+      else if (dStricmp(argv[2], "linger") == 0)
+         object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, dAtof(argv[3]));
+      else
+         Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getStringValue());
+   }
 }
 
 DefineEngineMethod(afxMagicSpell, interruptStage, void, (),,

+ 24 - 60
Engine/source/afx/arcaneFX.cpp

@@ -584,69 +584,33 @@ DefineEngineFunction(getRandomDir, Point3F, (Point3F axis, float thetaMin, float
   return MathUtils::randomDir(axis, thetaMin, thetaMax, phiMin, phiMax);
 }
 
-ConsoleFunction( MatrixInverseMulVector, const char*, 3, 3, "(MatrixF xfrm, Point3F vector)"
-                "@brief Multiply the vector by the affine inverse of the transform.\n\n"
-                "@ingroup AFX")
+DefineEngineFunction(MatrixInverseMulVector, Point3F, (MatrixF xfrm, Point3F vector),,
+   "@brief Multiply the vector by the affine inverse of the transform.\n\n"
+   "@ingroup AFX")
 {
-   Point3F pos1(0.0f,0.0f,0.0f);
-   AngAxisF aa1(Point3F(0.0f,0.0f,0.0f),0.0f);
-   dSscanf(argv[1], "%g %g %g %g %g %g %g", &pos1.x, &pos1.y, &pos1.z, &aa1.axis.x, &aa1.axis.y, &aa1.axis.z, &aa1.angle);
-
-   MatrixF temp1(true);
-   aa1.setMatrix(&temp1);
-   temp1.setColumn(3, pos1);
-
-   Point3F vec1(0.0f,0.0f,0.0f);
-   dSscanf(argv[2], "%g %g %g", &vec1.x, &vec1.y, &vec1.z);
-
-   temp1.affineInverse();
+   xfrm.affineInverse();
 
    Point3F result;
-   temp1.mulV(vec1, &result);
+   xfrm.mulV(vector, &result);
 
-   char* ret = Con::getReturnBuffer(256);
-   dSprintf(ret, 255, "%g %g %g", result.x, result.y, result.z);
-   return ret;
+   return result;
 }
 
-ConsoleFunction(moveTransformAbs, const char*, 3, 3, "(MatrixF xfrm, Point3F pos)"
-                "@brief Move the transform to the new absolute position.\n\n"
-                "@ingroup AFX")
+DefineEngineFunction(moveTransformAbs, MatrixF, (MatrixF xfrm, Point3F pos),,
+   "@brief Move the transform to the new absolute position.\n\n"
+   "@ingroup AFX")
 {
-   Point3F pos1(0.0f,0.0f,0.0f);
-   AngAxisF aa1(Point3F(0.0f,0.0f,0.0f),0.0f);
-   dSscanf(argv[1], "%g %g %g %g %g %g %g", &pos1.x, &pos1.y, &pos1.z, &aa1.axis.x, &aa1.axis.y, &aa1.axis.z, &aa1.angle);
-
-   Point3F pos2(0.0f,0.0f,0.0f);
-   dSscanf(argv[2], "%g %g %g", &pos2.x, &pos2.y, &pos2.z);
-
-   char* returnBuffer = Con::getReturnBuffer(256);
-   dSprintf(returnBuffer, 255, "%g %g %g %g %g %g %g",
-            pos2.x, pos2.y, pos2.z,
-            aa1.axis.x, aa1.axis.y, aa1.axis.z,
-            aa1.angle);
-   return returnBuffer;
+   xfrm.setPosition(pos);
+   return xfrm;
 }
 
-ConsoleFunction(moveTransformRel, const char*, 3, 3, "(MatrixF xfrm, Point3F pos)"
-                "@brief Move the transform to the new relative position.\n\n"
-                "@ingroup AFX")
+DefineEngineFunction(moveTransformRel, MatrixF, (MatrixF xfrm, Point3F pos),,
+   "@brief Move the transform to the new relative position.\n\n"
+   "@ingroup AFX")
 {
-   Point3F pos1(0.0f,0.0f,0.0f);
-   AngAxisF aa1(Point3F(0.0f,0.0f,0.0f),0.0f);
-   dSscanf(argv[1], "%g %g %g %g %g %g %g", &pos1.x, &pos1.y, &pos1.z, &aa1.axis.x, &aa1.axis.y, &aa1.axis.z, &aa1.angle);
-
-   Point3F pos2(0.0f,0.0f,0.0f);
-   dSscanf(argv[2], "%g %g %g", &pos2.x, &pos2.y, &pos2.z);
-
-   pos2 += pos1;
-
-   char* returnBuffer = Con::getReturnBuffer(256);
-   dSprintf(returnBuffer, 255, "%g %g %g %g %g %g %g",
-            pos2.x, pos2.y, pos2.z,
-            aa1.axis.x, aa1.axis.y, aa1.axis.z,
-            aa1.angle);
-   return returnBuffer;
+   pos += xfrm.getPosition();
+   xfrm.setPosition(pos);
+   return xfrm;
 }
 
 DefineEngineFunction(getFreeTargetPosition, Point3F, (),,
@@ -896,18 +860,18 @@ DefineEngineFunction(getMaxF, F32, (float a, float b),,
    return getMax(a, b);
 }
 
-ConsoleFunction(echoThru, const char*, 2, 0, "(string passthru, string text...)"
-                "Like echo(), but first argument is returned.\n"
-                "@ingroup AFX")
+DefineEngineStringlyVariadicFunction(echoThru, const char*, 2, 0, "(string passthru, string text...)"
+   "Like echo(), but first argument is returned.\n"
+   "@ingroup AFX")
 {
    U32 len = 0;
    S32 i;
-   for(i = 2; i < argc; i++)
+   for (i = 2; i < argc; i++)
       len += dStrlen(argv[i]);
 
    char *ret = Con::getReturnBuffer(len + 1);
    ret[0] = 0;
-   for(i = 2; i < argc; i++)
+   for (i = 2; i < argc; i++)
       dStrcat(ret, argv[i], len + 1);
 
    Con::printf("%s -- [%s]", ret, argv[1].getStringValue());
@@ -916,7 +880,7 @@ ConsoleFunction(echoThru, const char*, 2, 0, "(string passthru, string text...)"
    return argv[1];
 }
 
-ConsoleFunction(warnThru, const char*, 2, 0, "(string passthru, string text...)"
+DefineEngineStringlyVariadicFunction(warnThru, const char*, 2, 0, "(string passthru, string text...)"
                 "Like warn(), but first argument is returned.\n"
                 "@ingroup AFX")
 {
@@ -936,7 +900,7 @@ ConsoleFunction(warnThru, const char*, 2, 0, "(string passthru, string text...)"
    return argv[1];
 }
 
-ConsoleFunction(errorThru, const char*, 2, 0, "(string passthru, string text...)"
+DefineEngineStringlyVariadicFunction(errorThru, const char*, 2, 0, "(string passthru, string text...)"
                 "Like error(), but first argument is returned.\n"
                 "@ingroup AFX")
 {

+ 15 - 13
Engine/source/app/game.cpp

@@ -67,7 +67,7 @@ bool gEditingMission = false;
 
 ConsoleFunctionGroupBegin( InputManagement, "Functions that let you deal with input from scripts" );
 
-DefineConsoleFunction( deactivateDirectInput, void, (), ,
+DefineEngineFunction( deactivateDirectInput, void, (), ,
          "()"
             "@brief Disables DirectInput.\n\n"
             "Also deactivates any connected joysticks.\n\n"
@@ -77,7 +77,7 @@ DefineConsoleFunction( deactivateDirectInput, void, (), ,
       Input::deactivate();
 }
 
-DefineConsoleFunction( activateDirectInput, void, (), ,
+DefineEngineFunction( activateDirectInput, void, (), ,
             "()"
             "@brief Activates DirectInput.\n\n"
             "Also activates any connected joysticks."
@@ -91,7 +91,7 @@ ConsoleFunctionGroupEnd( InputManagement );
 //--------------------------------------------------------------------------
 
 static const U32 MaxPlayerNameLength = 16;
-DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" )
+DefineEngineFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" )
 {
 
 	// Strip leading spaces and underscores:
@@ -147,7 +147,7 @@ DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strT
 
 ConsoleFunctionGroupBegin( Platform , "General platform functions.");
 
-DefineConsoleFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)" 
+DefineEngineFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)"
             "@brief Lock or unlock the mouse to the window.\n\n"
             "When true, prevents the mouse from leaving the bounds of the game window.\n\n"
             "@ingroup Input")
@@ -156,7 +156,7 @@ DefineConsoleFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)"
 }
 
 
-DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int port, bool bind=true)" 
+DefineEngineFunction( setNetPort, bool, (int port, bool bind), (true), "(int port, bool bind=true)" 
    "@brief Set the network port for the game to use.\n\n"
 
    "@param port The port to use.\n"
@@ -171,28 +171,28 @@ DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int po
    return Net::openPort((S32)port, bind);
 }
 
-DefineConsoleFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
+DefineEngineFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
 	"@brief Determines if a specified address type can be reached.\n\n"
 	"@ingroup Networking")
 {
 	return Net::isAddressTypeAvailable((NetAddress::Type)addressType);
 }
 
-DefineConsoleFunction( closeNetPort, void, (), , "()" 
+DefineEngineFunction( closeNetPort, void, (), , "()" 
    "@brief Closes the current network port\n\n"
    "@ingroup Networking")
 {
    Net::closePort();
 }
 
-DefineConsoleFunction( saveJournal, void, (const char * filename), , "(string filename)" 
+DefineEngineFunction( saveJournal, void, (const char * filename), , "(string filename)" 
                 "Save the journal to the specified file.\n\n"
 				"@ingroup Platform")
 {
    Journal::Record(filename);
 }
 
-DefineConsoleFunction( playJournal, void, (const char * filename), , "(string filename)" 
+DefineEngineFunction( playJournal, void, (const char * filename), , "(string filename)" 
                 "@brief Begin playback of a journal from a specified field.\n\n"
 				"@param filename Name and path of file journal file\n"
 				"@ingroup Platform")
@@ -202,7 +202,7 @@ DefineConsoleFunction( playJournal, void, (const char * filename), , "(string fi
    Journal::Play(filename);
 }
 
-DefineConsoleFunction( getSimTime, S32, (), , "()" 
+DefineEngineFunction( getSimTime, S32, (), , "()" 
 				"Return the current sim time in milliseconds.\n\n"
                 "@brief Sim time is time since the game started.\n\n"
 				"@ingroup Platform")
@@ -210,7 +210,7 @@ DefineConsoleFunction( getSimTime, S32, (), , "()"
    return Sim::getCurrentTime();
 }
 
-DefineConsoleFunction( getRealTime, S32, (), , "()" 
+DefineEngineFunction( getRealTime, S32, (), , "()" 
 				"@brief Return the current real time in milliseconds.\n\n"
                 "Real time is platform defined; typically time since the computer booted.\n\n"
 				"@ingroup Platform")
@@ -218,8 +218,10 @@ DefineConsoleFunction( getRealTime, S32, (), , "()"
    return Platform::getRealMilliseconds();
 }
 
-ConsoleFunction( getLocalTime, const char *, 1, 1, "Return the current local time as: weekday month day year hour min sec.\n\n"
-                "Local time is platform defined.")
+DefineEngineFunction(getLocalTime, const char*, (),,
+   "@brief Return the current local time as: weekday month day year hour min sec.\n\n"
+   "Local time is platform defined."
+   "@ingroup Platform")
 {
    Platform::LocalTime lt;
    Platform::getLocalTime(lt);

+ 9 - 0
Engine/source/app/mainLoop.cpp

@@ -61,6 +61,7 @@
 
 // For the TickMs define... fix this for T2D...
 #include "T3D/gameBase/processList.h"
+#include "cinterface/cinterface.h"
 
 #ifdef TORQUE_ENABLE_VFS
 #include "platform/platformVFS.h"
@@ -267,6 +268,9 @@ void StandardMainLoop::init()
    
    ThreadPool::GlobalThreadPool::createSingleton();
 
+   // Set engineAPI initialized to true
+   engineAPI::gIsInitialized = true;
+
    // Initialize modules.
    
    EngineModuleManager::initializeSystem();
@@ -440,6 +444,11 @@ bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
    // directly because the resource system restricts
    // access to the "root" directory.
 
+   bool foundExternalMain = false;
+   CInterface::CallMain(&foundExternalMain);
+   if (foundExternalMain)
+      return true;
+
 #ifdef TORQUE_ENABLE_VFS
    Zip::ZipArchive *vfs = openEmbeddedVFSArchive();
    bool useVFS = vfs != NULL;

+ 3 - 3
Engine/source/app/net/net.cpp

@@ -212,7 +212,7 @@ ConsoleDocClass( RemoteCommandEvent,
 ConsoleFunctionGroupBegin( Net, "Functions for use with the network; tagged strings and remote commands.");
 
 
-ConsoleFunction( commandToServer, void, 2, RemoteCommandEvent::MaxRemoteCommandArgs + 1, "(string func, ...)"
+DefineEngineStringlyVariadicFunction( commandToServer, void, 2, RemoteCommandEvent::MaxRemoteCommandArgs + 1, "(string func, ...)"
 	"@brief Send a command to the server.\n\n"
 
    "@param func Name of the server command being called\n"
@@ -255,7 +255,7 @@ ConsoleFunction( commandToServer, void, 2, RemoteCommandEvent::MaxRemoteCommandA
    RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args);
 }
 
-ConsoleFunction( commandToClient, void, 3, RemoteCommandEvent::MaxRemoteCommandArgs + 2, "(NetConnection client, string func, ...)"
+DefineEngineStringlyVariadicFunction( commandToClient, void, 3, RemoteCommandEvent::MaxRemoteCommandArgs + 2, "(NetConnection client, string func, ...)"
    "@brief Send a command from the server to the client\n\n"
 
    "@param client The numeric ID of a client GameConnection\n"
@@ -349,7 +349,7 @@ DefineEngineFunction(getTaggedString, const char* , (const char *tag), (""),
 
 
 
-ConsoleFunction( buildTaggedString, const char*, 2, 11, "(string format, ...)"
+DefineEngineStringlyVariadicFunction( buildTaggedString, const char*, 2, 11, "(string format, ...)"
    "@brief Build a string using the specified tagged string format.\n\n"
 
    "This function takes an already tagged string (passed in as a tagged string ID) and one "

+ 10 - 10
Engine/source/app/net/serverQuery.cpp

@@ -429,7 +429,7 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( queryAllServers
+DefineEngineFunction( queryAllServers
                      , void, ( U32 lanPort
                              , U32 flags
                              , const char * gameType
@@ -455,7 +455,7 @@ DefineConsoleFunction( queryAllServers
 
 }
 
-DefineConsoleFunction( queryLanServers
+DefineEngineFunction( queryLanServers
                      , void, ( U32 lanPort
                              , U32 flags
                              , const char * gameType
@@ -560,7 +560,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
       processMasterServerQuery( gPingSession );
 }
 
-DefineConsoleFunction( queryMasterServer
+DefineEngineFunction( queryMasterServer
                      , void, (  U32 flags
                              , const char * gameType
                              , const char * missionType
@@ -582,7 +582,7 @@ DefineConsoleFunction( queryMasterServer
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( querySingleServer
+DefineEngineFunction( querySingleServer
                      , void, ( const char* addrText, U8 flags )
                      , (0), "querySingleServer(address, flags);" )
 {
@@ -668,7 +668,7 @@ void cancelServerQuery()
    }
 }
 
-DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery();" )
+DefineEngineFunction( cancelServerQuery, void, (), , "cancelServerQuery();" )
 {
    cancelServerQuery();
 }
@@ -696,14 +696,14 @@ void stopServerQuery()
    }
 }
 
-DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery();" )
+DefineEngineFunction( stopServerQuery, void, (), , "stopServerQuery();" )
 {
    stopServerQuery();
 }
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat();" )
+DefineEngineFunction( startHeartbeat, void, (), , "startHeartbeat();" )
 {
    if (validateAuthenticatedServer()) {
       gHeartbeatSeq++;
@@ -711,19 +711,19 @@ DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat();" )
    }
 }
 
-DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat();" )
+DefineEngineFunction( stopHeartbeat, void, (), , "stopHeartbeat();" )
 {
    gHeartbeatSeq++;
 }
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getServerCount, int, (), , "getServerCount();" )
+DefineEngineFunction( getServerCount, int, (), , "getServerCount();" )
 {
    return gServerList.size();
 }
 
-DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(index);" )
+DefineEngineFunction( setServerInfo, bool, (U32 index), , "setServerInfo(index);" )
 {
    if (index < gServerList.size()) {
       ServerInfo& info = gServerList[index];

+ 7 - 7
Engine/source/app/version.cpp

@@ -92,44 +92,44 @@ const char* getCompileTimeString()
 
 ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
 
-DefineConsoleFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n" 
+DefineEngineFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n" 
 				"@ingroup Debugging")
 {
    return getVersionNumber();
 }
 
-DefineConsoleFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n" 
+DefineEngineFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n" 
             "@ingroup Debugging")
 {
    return getAppVersionNumber();
 }
 
 
-DefineConsoleFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n" 
+DefineEngineFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n" 
 				"@ingroup Debugging")
 {
    return getVersionString();
 }
 
-DefineConsoleFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n" 
+DefineEngineFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n" 
             "@ingroup Debugging")
 {
    return getAppVersionString();
 }
 
-DefineConsoleFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n" 
+DefineEngineFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n" 
 				"@ingroup Debugging")
 {
    return getEngineProductString();
 }
 
-DefineConsoleFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n" 
+DefineEngineFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n" 
 				"@ingroup Debugging")
 {
    return getCompileTimeString();
 }
 
-DefineConsoleFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
+DefineEngineFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
 				"@ingroup Debugging")
 {
 #ifdef TORQUE_DEBUG

+ 4 - 4
Engine/source/assets/assetQuery_ScriptBinding.h

@@ -26,7 +26,7 @@
 
 #include "console/engineAPI.h"
 
-DefineConsoleMethod(AssetQuery, clear, void, (),,"Clears all asset Id results."
+DefineEngineMethod(AssetQuery, clear, void, (),,"Clears all asset Id results."
    "Clears all asset Id results.\n"
    "@return () No return value.\n")
 {
@@ -36,7 +36,7 @@ DefineConsoleMethod(AssetQuery, clear, void, (),,"Clears all asset Id results."
 //-----------------------------------------------------------------------------
 
 
-DefineConsoleMethod(AssetQuery, set, bool, (S32 queryId), ,
+DefineEngineMethod(AssetQuery, set, bool, (S32 queryId), ,
    "Sets the asset query to a copy of the specified asset query.\n"
    "@param assetQuery The asset query to copy.\n"
    "@return Whether the operation succeeded or not.\n")
@@ -59,7 +59,7 @@ DefineConsoleMethod(AssetQuery, set, bool, (S32 queryId), ,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod(AssetQuery, getCount, S32, (), , 
+DefineEngineMethod(AssetQuery, getCount, S32, (), , 
    "Gets the count of asset Id results.\n"
    "@return (int)The count of asset Id results.\n")
 {
@@ -68,7 +68,7 @@ DefineConsoleMethod(AssetQuery, getCount, S32, (), ,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod(AssetQuery, getAsset, const char*, (S32 resultIndex), (-1), 
+DefineEngineMethod(AssetQuery, getAsset, const char*, (S32 resultIndex), (-1), 
    "Gets the asset Id at the specified query result index.\n"
    "@param resultIndex The query result index to use.\n"
    "@return (assetId)The asset Id at the specified index or NULL if not valid.\n")

+ 24 - 119
Engine/source/cinterface/c_consoleInterface.cpp

@@ -20,154 +20,59 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "platform/platform.h"
-#include "console/compiler.h"
 #include "console/consoleInternal.h"
 #include "console/simSet.h"
+#include "console/engineAPI.h"
 
-extern "C" {
-
-   // SimObject C interface
-   const char *SimObject_GetName(SimObject *so)
-   {
-      return so->getName();
-   }
-
-   U32 SimObject_GetId(SimObject *so)
-   {
-      return so->getId();
-   }
-
-   const char *SimObject_GetClassName(SimObject *so)
-   {
-      return so->getClassName();
-   }
-
-   void *SimObject_GetFieldList(SimObject *so, S32 &outNumFields)
-   {
-      const AbstractClassRep::FieldList &fl = so->getFieldList();
-      outNumFields = fl.size();
-      return fl.address();
-   }
-
-   bool SimObject_IsLocked(SimObject *so)
+namespace Con
+{
+   DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "")
    {
-      return so->isLocked();
+      addConsumer(cb);
    }
 
-   void SimObject_SetDataField(SimObject *so, const char *fieldName, const char *arr, const char *val)
+   DefineNewEngineFunction(RemoveConsumer, void, (ConsumerCallback cb), , "")
    {
-      so->setDataField(StringTable->insert(fieldName), arr, val);
+      removeConsumer(cb);
    }
 
-   const char *SimObject_GetDataField(SimObject *so, const char *fieldName, const char *arr)
+   DefineNewEngineFunction(GetConsoleString, String, (String name),, "")
    {
-      return so->getDataField(StringTable->insert(fieldName), arr);
+      return getVariable(StringTable->insert(name));
    }
 
-   void SimObject_InspectPreApply(SimObject *so)
+   DefineNewEngineFunction(SetConsoleString, void, (String name, String value),, "")
    {
-      so->inspectPreApply();
+      setVariable(StringTable->insert(name), StringTable->insert(value));
    }
 
-   void SimObject_InspectPostApply(SimObject *so)
+   DefineNewEngineFunction(GetConsoleInt, S32, (String name),, "")
    {
-      so->inspectPostApply();
+      return getIntVariable(StringTable->insert(name));
    }
 
-   // Con C interface
-   void Con_AddConsumer(ConsumerCallback cb)
+   DefineNewEngineFunction(SetConsoleInt, void, (String name, S32 value),, "")
    {
-      Con::addConsumer(cb);
+      setIntVariable(StringTable->insert(name), value);
    }
 
-   void Con_RemoveConsumer(ConsumerCallback cb)
+   DefineNewEngineFunction(GetConsoleFloat, F32, (String name),, "")
    {
-      Con::removeConsumer(cb);
+      return getFloatVariable(StringTable->insert(name));
    }
 
-   void Con_AddCommand_String(StringCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
+   DefineNewEngineFunction(SetConsoleFloat, void, (String name, F32 value),, "")
    {
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
+      setFloatVariable(StringTable->insert(name), value);
    }
 
-   // ConsoleBaseType C interface
-   ConsoleBaseType *ConsoleBaseType_GetTypeById(const S32 typeId)
+   DefineNewEngineFunction(GetConsoleBool, bool, (String name),, "")
    {
-      return ConsoleBaseType::getType(typeId);
+      return getBoolVariable(StringTable->insert(name));
    }
 
-   S32 ConsoleBaseType_GetTypeId(ConsoleBaseType *cbt)
+   DefineNewEngineFunction(SetConsoleBool, void, (String name, bool value),, "")
    {
-      return cbt->getTypeID();
+      setBoolVariable(StringTable->insert(name), value);
    }
-
-   S32 ConsoleBaseType_GetTypeSize(ConsoleBaseType *cbt)
-   {
-      return cbt->getTypeSize();
-   }
-
-   const char *ConsoleBaseType_GetTypeName(ConsoleBaseType *cbt)
-   {
-      return cbt->getTypeName();
-   }
-
-   const char *ConsoleBaseType_GetInspectorFieldType(ConsoleBaseType *cbt)
-   {
-      return cbt->getInspectorFieldType();
-   }
-
-   void ConsoleBaseType_SetData(ConsoleBaseType *cbt, void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
-   {
-      return cbt->setData(dptr, argc, argv, tbl, flag);
-   }
-
-   const char *ConsoleBaseType_GetData(ConsoleBaseType *cbt, void *dptr, const EnumTable *tbl, BitSet32 flag)
-   {
-      return cbt->getData(dptr, tbl, flag);
-   }
-
-   // Abstract Class Rep
-   AbstractClassRep *AbstractClassRep_GetCommonParent(AbstractClassRep *acr, AbstractClassRep *otheracr)
-   {
-      return acr->getCommonParent(otheracr);
-   }
-
-   AbstractClassRep *AbstractClassRep_FindClassRep(const char* in_pClassName)
-   {
-      return AbstractClassRep::findClassRep(in_pClassName);
-   }
-
-   U32 AbstractClassRep_GetFieldStructSize()
-   {
-      return sizeof(AbstractClassRep::Field);
-   }
-
-   // Sim C interface
-   SimObject *Sim_FindObjectByString(const char *param)
-   {
-      return Sim::findObject(param);
-   }
-   
-   SimObject *Sim_FindObjectById(S32 param)
-   {
-      return Sim::findObject(param);
-   }
-
-   // Sim Set
-   SimObject **SimSet_Begin(SimObject *simObject)
-   {
-      return dynamic_cast<SimSet *>(simObject)->begin();
-   }
-
-   SimObject **SimSet_End(SimObject *simObject)
-   {
-      return dynamic_cast<SimSet *>(simObject)->end();
-   }
-
-};
-
-
+}

+ 239 - 0
Engine/source/cinterface/c_controlInterface.cpp

@@ -0,0 +1,239 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#include "c_controlInterface.h"
+
+#include "console/consoleInternal.h"
+#include "console/simSet.h"
+#include "app/mainLoop.h"
+#include "windowManager/platformWindow.h"
+#include "windowManager/platformWindowMgr.h"
+
+#ifdef TORQUE_OS_WIN
+#include "windowManager/win32/win32Window.h"
+#include "windowManager/win32/winDispatch.h"
+extern void createFontInit(void);
+extern void createFontShutdown(void);
+#endif
+
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+extern S32 CreateMiniDump(LPEXCEPTION_POINTERS ExceptionInfo);
+#endif
+
+extern bool LinkConsoleFunctions;
+
+extern "C" {
+
+   // reset the engine, unloading any current level and returning to the main menu
+   void torque_reset()
+   {
+      Con::evaluate("disconnect();");
+   }
+
+   // initialize Torque 3D including argument handling
+   bool torque_engineinit(S32 argc, const char **argv)
+   {
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      __try {
+#endif
+
+         LinkConsoleFunctions = true;
+
+#if defined(_MSC_VER)
+         createFontInit();
+#endif
+
+         // Initialize the subsystems.
+         StandardMainLoop::init();
+
+         // Handle any command line args.
+         if (!StandardMainLoop::handleCommandLine(argc, argv))
+         {
+            Platform::AlertOK("Error", "Failed to initialize game, shutting down.");
+            return false;
+         }
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      }
+
+      __except (CreateMiniDump(GetExceptionInformation()))
+      {
+         _exit(0);
+      }
+#endif
+
+      return true;
+
+   }
+
+   // tick Torque 3D's main loop
+   S32 torque_enginetick()
+   {
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      __try {
+#endif
+
+         bool ret = StandardMainLoop::doMainLoop();
+         return ret;
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      }
+      __except (CreateMiniDump(GetExceptionInformation()))
+      {
+         _exit(0);
+      }
+#endif
+
+   }
+
+   S32 torque_getreturnstatus()
+   {
+      return StandardMainLoop::getReturnStatus();
+   }
+
+   // signal an engine shutdown (as with the quit(); console command)
+   void torque_enginesignalshutdown()
+   {
+      Con::evaluate("quit();");
+   }
+
+   // shutdown the engine
+   S32 torque_engineshutdown()
+   {
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      __try {
+#endif
+
+         // Clean everything up.
+         StandardMainLoop::shutdown();
+
+#if defined(_MSC_VER)
+         createFontShutdown();
+#endif
+
+#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
+      }
+
+      __except (CreateMiniDump(GetExceptionInformation()))
+      {
+         _exit(0);
+      }
+#endif
+
+      // Return.  
+      return true;
+
+   }
+
+   bool torque_isdebugbuild()
+   {
+#ifdef _DEBUG
+      return true;
+#else
+      return false;
+#endif
+
+   }
+
+   // set Torque 3D into web deployment mode (disable fullscreen exlusive mode, etc)
+   void torque_setwebdeployment()
+   {
+      Platform::setWebDeployment(true);
+   }
+
+   // resize the Torque 3D child window to the specified width and height
+   void torque_resizewindow(S32 width, S32 height)
+   {
+      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
+         PlatformWindowManager::get()->getFirstWindow()->setSize(Point2I(width, height));
+   }
+
+#if defined(TORQUE_OS_WIN) && !defined(TORQUE_SDL)
+   // retrieve the hwnd of our render window
+   void* torque_gethwnd()
+   {
+      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
+      {
+         Win32Window* w = (Win32Window*)PlatformWindowManager::get()->getFirstWindow();
+         return (void *)w->getHWND();
+      }
+
+      return NULL;
+   }
+
+   // directly add a message to the Torque 3D event queue, bypassing the Windows event queue
+   // this is useful in the case of the IE plugin, where we are hooking into an application 
+   // level message, and posting to the windows queue would cause a hang
+   void torque_directmessage(U32 message, U32 wparam, U32 lparam)
+   {
+      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
+      {
+         Win32Window* w = (Win32Window*)PlatformWindowManager::get()->getFirstWindow();
+         Dispatch(DelayedDispatch, w->getHWND(), message, wparam, lparam);
+      }
+   }
+
+#endif
+
+#ifdef TORQUE_OS_WIN
+   void torque_inputevent(S32 type, S32 value1, S32 value2)
+   {
+      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
+      {
+         Win32Window* w = (Win32Window*)PlatformWindowManager::get()->getFirstWindow();
+         WindowId devId = w->getWindowId();
+
+         switch (type)
+         {
+         case 0:
+            w->mouseEvent.trigger(devId, 0, value1, value2, w->isMouseLocked());
+            break;
+         case 1:
+            if (value2)
+               w->buttonEvent.trigger(devId, 0, IA_MAKE, value1);
+            else
+               w->buttonEvent.trigger(devId, 0, IA_BREAK, value1);
+            break;
+
+         }
+      }
+   }
+#endif
+
+   static char* gExecutablePath = NULL;
+
+   const char* torque_getexecutablepath()
+   {
+      return gExecutablePath;
+   }
+
+   void torque_setexecutablepath(const char* directory)
+   {
+      dsize_t pathLen = dStrlen(directory) + 1;
+      gExecutablePath = new char[pathLen];
+      dStrcpy(gExecutablePath, directory, pathLen);
+   }
+}

+ 48 - 0
Engine/source/cinterface/c_controlInterface.h

@@ -0,0 +1,48 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#ifndef C_CONTROLINTERFACE_H
+#define C_CONTROLINTERFACE_H
+#include "platform/platformDlibrary.h"
+#include "console/engineFunctions.h"
+
+TORQUE_API void torque_reset();
+TORQUE_API bool torque_engineinit(S32 argc, const char **argv);
+TORQUE_API S32 torque_enginetick();
+TORQUE_API S32 torque_getreturnstatus();
+TORQUE_API void torque_enginesignalshutdown();
+TORQUE_API S32 torque_engineshutdown();
+TORQUE_API bool torque_isdebugbuild();
+TORQUE_API void torque_setwebdeployment();
+TORQUE_API void torque_resizewindow(S32 width, S32 height);
+
+#if defined(TORQUE_OS_WIN) && !defined(TORQUE_SDL)
+TORQUE_API void* torque_gethwnd();
+TORQUE_API void torque_directmessage(U32 message, U32 wparam, U32 lparam);
+#endif
+#ifdef TORQUE_OS_WIN
+TORQUE_API void torque_inputevent(S32 type, S32 value1, S32 value2);
+#endif
+
+TORQUE_API const char* torque_getexecutablepath();
+
+#endif // C_CONTROLINTERFACE_H

+ 0 - 426
Engine/source/cinterface/c_scripting.cpp

@@ -1,426 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "platform/platform.h"
-#include "console/compiler.h"
-#include "console/console.h"
-#include "console/consoleInternal.h"
-#include "core/util/tDictionary.h"
-#include "app/mainLoop.h"
-
-// External scripting cinterface, suitable for import into any scripting system which support "C" interfaces (C#, Python, Lua, Java, etc)
-
-#ifdef TORQUE_OS_WIN
-#include "windowManager/win32/win32Window.h"
-#include "windowManager/win32/winDispatch.h"
-#endif
-
-extern "C" {
-
-   struct MarshalNativeEntry
-   {
-      const char* nameSpace;
-      const char* name;
-      Namespace::Entry* entry; 
-      S32 minArgs;
-      S32 maxArgs;
-      S32 cbType;
-   };
-
-
-   static Namespace::Entry* GetEntry(const char* nameSpace, const char* name)                                          
-   {
-      Namespace* ns = NULL;
-
-      if (!nameSpace || !dStrlen(nameSpace))
-         ns = Namespace::mGlobalNamespace;
-      else
-      {
-         nameSpace = StringTable->insert(nameSpace);
-         ns = Namespace::find(nameSpace); //can specify a package here, maybe need, maybe not
-      }
-
-      if (!ns)
-         return NULL;
-
-      name = StringTable->insert(name);
-
-      Namespace::Entry* entry = ns->lookupRecursive(name);
-
-      return entry;
-   }
-
-   const char * script_getconsolexml()
-   {
-      Namespace::Entry* entry = GetEntry("", "consoleExportXML");
-
-      if (!entry)
-         return "";
-
-      static const char* exportArgv[1] = { "consoleExportXML" };
-      static StringStackConsoleWrapper exportCmd(1, exportArgv);
-
-      return entry->cb.mStringCallbackFunc(NULL, exportCmd.argc, exportCmd.argv);      
-   }
-
-   MarshalNativeEntry* script_get_namespace_entry(const char* nameSpace, const char* name)
-   {
-      static MarshalNativeEntry mentry;
-
-      Namespace::Entry* e = GetEntry(nameSpace, name);
-
-      if (!e)
-         return NULL;
-
-      mentry.nameSpace = e->mNamespace->mName;
-      mentry.name = e->mFunctionName;
-      mentry.minArgs = e->mMinArgs;
-      mentry.maxArgs = e->mMaxArgs;
-      mentry.cbType = e->mType;
-      mentry.entry = e;
-
-      return &mentry;
-   }
-
-   void* script_get_stringtable_entry(const char* string)
-   {
-      return (void*)StringTable->insert(string);
-   }
-
-   // FIELD ACCESS
-
-   // fieldNames must be from stringTable coming in! See Engine.stringTable
-
-   const char* script_simobject_getfield_string(U32 id, const char* fieldName)
-   {
-      SimObject *object = Sim::findObject( id );
-      if( object )
-      {
-         return (const char *) object->getDataField(fieldName, "");
-      }
-      return "";
-   }
-
-   void script_simobject_setfield_string(U32 objectId, const char* fieldName, const char* v)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         object->setDataField(fieldName, "", v);
-      }
-   }
-
-
-   bool script_simobject_getfield_bool(U32 objectId, const char* fieldName)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         const char *v = object->getDataField(fieldName, "");
-
-         return dAtob(v);
-      }
-
-      return false;
-   }
-
-   void script_simobject_setfield_bool(U32 objectId, const char* fieldName, bool v)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         object->setDataField(fieldName, "", v ? "1" : "0");
-      }
-   }
-
-   S32 script_simobject_getfield_int(U32 objectId, const char* fieldName)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         const char *v = object->getDataField(fieldName, "");
-
-         return dAtoi(v);
-      }
-
-      return false;
-   }
-
-   void script_simobject_setfield_int(U32 objectId, const char* fieldName, S32 v)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         // this seems pretty lame, though it is how it is handled in consoleType.cpp
-         char buf[256];
-         dSprintf(buf, 256, "%d", v );
-         object->setDataField(fieldName, "", buf);
-      }
-   }
-
-   F32 script_simobject_getfield_float(U32 objectId, const char* fieldName)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         const char *v = object->getDataField(fieldName, "");
-
-         return dAtof(v);
-      }
-
-      return false;
-   }
-
-   void script_simobject_setfield_float(U32 objectId, const char* fieldName, F32 v)
-   {
-      SimObject *object = Sim::findObject( objectId );
-      if( object )
-      {
-         char buf[256];
-         dSprintf(buf, 256, "%g", v );
-         object->setDataField(fieldName, "", buf);
-      }
-   }
-
-   const char* script_call_namespace_entry_string(Namespace::Entry* entry, S32 argc, const char** argv)
-   {
-      // maxArgs improper on a number of console function/methods
-      if (argc < entry->mMinArgs)// || argc > entry->mMaxArgs)
-         return "";
-
-      SimObject* o = NULL;
-
-      if (entry->mNamespace && entry->mNamespace->isClass())
-      {
-         o = Sim::findObject(dAtoi(argv[1]));
-         if (!o)
-            return "";
-      }
-
-      StringStackConsoleWrapper args(argc, argv);
-      return entry->cb.mStringCallbackFunc(o, args.count(), args);
-   }
-
-   bool script_call_namespace_entry_bool(Namespace::Entry* entry, S32 argc, const char** argv)
-   {
-      // maxArgs improper on a number of console function/methods
-      if (argc < entry->mMinArgs)// || argc > entry->mMaxArgs)
-         return false;
-
-      SimObject* o = NULL;
-
-      if (entry->mNamespace && entry->mNamespace->isClass())
-      {
-         o = Sim::findObject(dAtoi(argv[1]));
-         if (!o)
-            return false;
-      }
-
-      StringStackConsoleWrapper args(argc, argv);
-      return entry->cb.mBoolCallbackFunc(o, args.count(), args);
-   }
-
-   S32 script_call_namespace_entry_int(Namespace::Entry* entry, S32 argc, const char** argv)
-   {
-      // maxArgs improper on a number of console function/methods
-      if (argc < entry->mMinArgs)// || argc > entry->mMaxArgs)
-         return 0;
-
-      SimObject* o = NULL;
-
-      if (entry->mNamespace && entry->mNamespace->isClass())
-      {
-         o = Sim::findObject(dAtoi(argv[1]));
-         if (!o)
-            return 0;
-      }
-
-      StringStackConsoleWrapper args(argc, argv);
-      return entry->cb.mIntCallbackFunc(o, args.count(), args);
-   }
-
-   F32 script_call_namespace_entry_float(Namespace::Entry* entry, S32 argc, const char** argv)
-   {
-      // maxArgs improper on a number of console function/methods
-      if (argc < entry->mMinArgs)// || argc > entry->mMaxArgs)
-         return 0.0f;
-
-      SimObject* o = NULL;
-
-      if (entry->mNamespace && entry->mNamespace->isClass())
-      {
-         o = Sim::findObject(dAtoi(argv[1]));
-         if (!o)
-            return 0.0f;
-      }
-
-      StringStackConsoleWrapper args(argc, argv);
-      return entry->cb.mFloatCallbackFunc(o, args.count(), args);
-   }
-
-
-   void script_call_namespace_entry_void(Namespace::Entry* entry, S32 argc, const char** argv)
-   {
-      // maxArgs improper on a number of console function/methods
-      if (argc < entry->mMinArgs)// || argc > entry->mMaxArgs)
-         return;
-
-      SimObject* o = NULL;
-
-      if (entry->mNamespace && entry->mNamespace->isClass())
-      {
-         Sim::findObject(dAtoi(argv[1]));
-         if (!o)
-            return;
-      }
-
-      StringStackConsoleWrapper args(argc, argv);
-      entry->cb.mVoidCallbackFunc(o, args.count(), args);
-   }
-
-   S32 script_simobject_get_id(SimObject* so)
-   {
-      return so->getId();
-   }
-
-   S32 script_simobject_find(const char* classname, const char* name)
-   {
-      SimObject *object;
-      if( Sim::findObject( name, object ) )
-      {
-         // if we specified a classname do type checking
-         if (classname && dStrlen(classname))
-         {
-            AbstractClassRep* ocr = object->getClassRep();
-            while (ocr)
-            {
-               if (!dStricmp(ocr->getClassName(), classname))
-                  return object->getId();
-               ocr = ocr->getParentClass();
-            }
-
-         }
-
-         // invalid type
-         return 0;
-      }
-
-      // didn't find object
-      return 0;
-   }
-
-   void script_export_callback_string(StringCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-   {
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-   }
-
-   void script_export_callback_void(VoidCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-   {
-
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-
-
-
-      // example of package support
-      // note that Parent:: does not work with this, at least not yet anyway
-
-      /*
-      Namespace* ns;
-
-      StringTableEntry nspace = NULL;
-
-      if (nameSpace && dStrlen(nameSpace))
-      nspace = StringTable->insert(nameSpace);
-
-      Namespace::unlinkPackages();
-      ns = Namespace::find(nspace, StringTable->insert("fps"));
-      ns->addCommand(StringTable->insert(funcName), cb, StringTable->insert(usage), minArgs + 1, maxArgs + 1 );
-      Namespace::relinkPackages();
-      */
-   }
-
-   void script_export_callback_bool(BoolCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-   {
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-   }
-
-   void script_export_callback_int(IntCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-   {
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-   }
-
-   void script_export_callback_float(FloatCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-   {
-      if (!nameSpace || !dStrlen(nameSpace))
-         Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-      else
-         Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-   }
-
-
-#ifdef TORQUE_OS_WIN
-
-   void script_input_event(S32 type, S32 value1, S32 value2)
-   {
-      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
-      {
-         Win32Window* w = (Win32Window*) PlatformWindowManager::get()->getFirstWindow();
-         WindowId devId = w->getWindowId();
-
-         switch (type)
-         {
-         case 0:
-            w->mouseEvent.trigger(devId,0,value1,value2,w->isMouseLocked());
-            break;
-         case 1:
-            if (value2)
-               w->buttonEvent.trigger(devId,0,IA_MAKE,value1);
-            else
-               w->buttonEvent.trigger(devId,0,IA_BREAK,value1);
-            break;
-
-         }
-
-      }      
-
-   }
-#endif
-
-}
-
-
-ConsoleFunction(TestFunction2Args, const char *, 3, 3, "testFunction(arg1, arg2)")
-{
-   return "Return Value";
-}

+ 55 - 0
Engine/source/cinterface/c_simInterface.cpp

@@ -0,0 +1,55 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#include "console/consoleInternal.h"
+#include "console/simDatablock.h"
+#include "console/simSet.h"
+#include "console/engineAPI.h"
+
+namespace Sim
+{
+   DefineNewEngineFunction(FindObjectById, SimObject*, (U32 pId), , "")
+   {
+      return Sim::findObject(pId);
+   }
+
+   DefineNewEngineFunction(FindObjectByName, SimObject*, (String pName), , "")
+   {
+      return Sim::findObject(StringTable->insert(pName));
+   }
+
+   DefineNewEngineFunction(FindDataBlockByName, SimObject*, (String pName), , "")
+   {
+      return Sim::getDataBlockGroup()->findObject(StringTable->insert(pName));
+   }
+
+   // EngineAPI doesn't work with SimObjectPtr
+   TORQUE_API SimObjectPtr<SimObject>* fnWrapObject (SimObject* pObject)
+   {
+      return new SimObjectPtr<SimObject>(pObject);
+   }
+
+   TORQUE_API void fnDeleteObjectPtr(SimObjectPtr<SimObject>* pObjectPtr)
+   {
+      delete pObjectPtr;
+   }
+}

+ 40 - 0
Engine/source/cinterface/c_simdatablockInterface.cpp

@@ -0,0 +1,40 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#include "console/simDatablock.h"
+#include "console/engineAPI.h"
+
+DefineNewEngineMethod(SimDataBlock, AssignId, void, (),, "")
+{
+   object->assignId();
+}
+
+DefineNewEngineMethod(SimDataBlock, Preload, void, (),, "")
+{
+   static String errorStr;
+   if (!object->preload(true, errorStr))
+   {
+      Con::errorf(ConsoleLogEntry::General, "Preload failed for %s: %s.",
+         object->getName(), errorStr.c_str());
+      object->deleteObject();
+   }
+}

+ 69 - 0
Engine/source/cinterface/c_simobjectInterface.cpp

@@ -0,0 +1,69 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#include "console/engineAPI.h"
+#include "console/simObject.h"
+
+DefineNewEngineMethod(SimObject, RegisterObject, bool, (),,"")
+{
+   return object->registerObject();
+}
+
+DefineNewEngineMethod(SimObject, GetField, String, (String fieldName, String arrayIndex),, "")
+{
+   return object->getDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex));
+}
+
+DefineNewEngineMethod(SimObject, SetField, void, (String fieldName, String arrayIndex, String value),, "")
+{
+   object->setDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex), StringTable->insert(value));
+}
+
+DefineNewEngineMethod(SimObject, CopyFrom, void, (SimObject* parent),, "")
+{
+   if (parent)
+   {
+      object->setCopySource(parent);
+      object->assignFieldsFrom(parent);
+   }
+}
+
+DefineNewEngineMethod(SimObject, SetMods, void, (bool modStaticFields, bool modDynamicFields), , "")
+{
+   object->setModStaticFields(modStaticFields);
+   object->setModDynamicFields(modDynamicFields);
+}
+
+DefineNewEngineMethod(SimObject, IsLocked, bool, (), , "")
+{
+   return object->isLocked();
+}
+
+DefineNewEngineMethod(SimObject, InspectPreApply, void, (), , "")
+{
+   object->inspectPreApply();
+}
+
+DefineNewEngineMethod(SimObject, InspectPostApply, void, (), , "")
+{
+   object->inspectPostApply();
+}

+ 55 - 426
Engine/source/cinterface/cinterface.cpp

@@ -19,449 +19,78 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
+#include "cinterface.h"
 
-#include "platform/platform.h"
 #include "console/compiler.h"
-#include "console/consoleInternal.h"
-#include "console/engineAPI.h"
-#include "core/util/tDictionary.h"
-#include "core/strings/stringFunctions.h"
-#include "app/mainLoop.h"
 #include "windowManager/platformWindow.h"
-#include "windowManager/platformWindowMgr.h"
 
-#ifdef TORQUE_OS_WIN
-#include "windowManager/win32/win32Window.h"
-#include "windowManager/win32/winDispatch.h"
-extern void createFontInit(void);
-extern void createFontShutdown(void);   
-#endif
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-   extern S32 CreateMiniDump(LPEXCEPTION_POINTERS ExceptionInfo);
-#endif
-
-static HashTable<StringTableEntry,StringTableEntry> gSecureScript;
-
-extern bool LinkConsoleFunctions;
-
-extern "C" {
-
-   // reset the engine, unloading any current level and returning to the main menu
-	void torque_reset()
-	{
-		Con::evaluate("disconnect();");
-	}
-
-   // initialize Torque 3D including argument handling
-	S32 torque_engineinit(S32 argc, const char **argv)
-	{
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      __try {
-#endif
-
-		LinkConsoleFunctions = true;
-
-#if defined(_MSC_VER)
-		createFontInit();
-#endif
-
-		// Initialize the subsystems.
-		StandardMainLoop::init();
-
-		// Handle any command line args.
-		if(!StandardMainLoop::handleCommandLine(argc, argv))
-		{
-			Platform::AlertOK("Error", "Failed to initialize game, shutting down.");
-			return false;
-		}
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      }
-
-		__except( CreateMiniDump(GetExceptionInformation()) )
-		{
-			_exit(0);
-		}
-#endif
-
-      return true;
-
-	}
-
-   // tick Torque 3D's main loop
-	S32 torque_enginetick()
-	{
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      __try {
-#endif
-
-		bool ret = StandardMainLoop::doMainLoop(); 
-      return ret;
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      }
-		__except( CreateMiniDump(GetExceptionInformation()) )
-		{
-			_exit(0);
-		}
-#endif
-
-      
-
-	}
-
-	S32 torque_getreturnstatus()
-	{
-		return StandardMainLoop::getReturnStatus();
-	}
-
-   // signal an engine shutdown (as with the quit(); console command)
-	void torque_enginesignalshutdown()
-	{
-		Con::evaluate("quit();");
-	}
-
-   // shutdown the engine
-	S32 torque_engineshutdown()
-	{
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      __try {
-#endif
-
-		// Clean everything up.
-		StandardMainLoop::shutdown();
-
-#if defined(_MSC_VER)
-		createFontShutdown();
-#endif
-
-#if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
-      }
-
-		__except( CreateMiniDump(GetExceptionInformation()) )
-		{
-			_exit(0);
-		}
-#endif
-
-		// Return.  
-		return true;
-
-	}
-
-	bool torque_isdebugbuild()
-	{
-#ifdef _DEBUG
-		return true;
-#else
-		return false;
-#endif
-
-	}
-
-	S32 torque_getconsolebool(const char* name)
-	{
-		return Con::getBoolVariable(name);
-	}
-
-	void torque_setconsolebool(const char* name, bool value)
-	{
-		Con::setBoolVariable(name, value);
-	}
-
-	static char* gExecutablePath = NULL;
-
-	const char* torque_getexecutablepath()
-	{
-		return gExecutablePath;
-	} 
-
-	void torque_setexecutablepath(const char* directory)
-	{
-		dsize_t pathLen = dStrlen(directory) + 1;
-		gExecutablePath = new char[pathLen];
-		dStrcpy(gExecutablePath, directory, pathLen);
-	} 
-
-   // set Torque 3D into web deployment mode (disable fullscreen exlusive mode, etc)
-	void torque_setwebdeployment()
-	{
-		Platform::setWebDeployment(true);
-	}
-
-   // Get a console variable
-	const char* torque_getvariable(const char* name)
-	{
-		return Con::getVariable(StringTable->insert(name));
-	}
-
-   // Set a console variable
-	void torque_setvariable(const char* name, const char* value)
-	{
-		Con::setVariable(StringTable->insert(name), StringTable->insert(value));
-	}
-
-	static Namespace::Entry* GetEntry(const char* nameSpace, const char* name)                                          
-	{
-		Namespace* ns = NULL;
-
-		if (!nameSpace || !dStrlen(nameSpace))
-			ns = Namespace::mGlobalNamespace;
-		else
-		{
-			nameSpace = StringTable->insert(nameSpace);
-			ns = Namespace::find(nameSpace); //can specify a package here, maybe need, maybe not
-		}
-
-		if (!ns)
-			return NULL;
-
-		name = StringTable->insert(name);
-
-		Namespace::Entry* entry = ns->lookupRecursive(name);
-
-		return entry;
-	}
-
-   // Export a function to the Torque 3D console system which matches the StringCallback function prototype
-   // specify the nameSpace, functionName, usage, min and max arguments 
-	void torque_exportstringcallback(StringCallback cb, const char *nameSpace, const char *funcName, const char* usage,  S32 minArgs, S32 maxArgs)
-	{
-		if (!nameSpace || !dStrlen(nameSpace))
-			Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
-		else
-			Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
-	}
-
-	void torque_callvoidfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return;
-
-		StringStackConsoleWrapper args(argc, argv);
-		entry->cb.mVoidCallbackFunc(NULL, args.count(), args);
-	}
-
-	F32 torque_callfloatfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return 0.0f;
-
-		StringStackConsoleWrapper args(argc, argv);
-		return entry->cb.mFloatCallbackFunc(NULL, args.count(), args);
-	}
-
-	S32 torque_callintfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return 0;
-
-		StringStackConsoleWrapper args(argc, argv);
-		return entry->cb.mIntCallbackFunc(NULL, args.count(), args);
-	}
-
-
-	const char * torque_callstringfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return "";
-
-		StringStackConsoleWrapper args(argc, argv);
-		return entry->cb.mStringCallbackFunc(NULL, args.count(), args);
-	}
-
-	bool torque_callboolfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return false;
-
-		StringStackConsoleWrapper args(argc, argv);
-		return entry->cb.mBoolCallbackFunc(NULL, args.count(), args);
-	}
-
-
-	const char * torque_callscriptfunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-		Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-		if (!entry)
-			return "";
-
-		if(!entry->mFunctionOffset)
-			return "";
-
-		StringStackConsoleWrapper args(argc, argv);
-		const char* ret = entry->mCode->exec(entry->mFunctionOffset, StringTable->insert(name), entry->mNamespace, args.count(), args, false, entry->mPackage);
-
-		if (!ret || !dStrlen(ret))
-			return "";
-
-		return ret;
-
-	}
-
-
-   // Call a TorqueScript console function that has been marked as secure
-	const char* torque_callsecurefunction(const char* nameSpace, const char* name, S32 argc, const char ** argv)
-	{
-		static const char* invalidChars = "()=:{}";
-		String s = nameSpace;
-		s += "::";
-		s += name;
-		s = String::ToUpper(s);
-
-		if (!gSecureScript.count(StringTable->insert(s.c_str())))
-		{
-			Con::warnf("\nAttempt to call insecure script: %s\n", s.c_str());
-			return "";
-		}
-
-		// scan through for invalid characters
-		for (S32 i = 0; i < argc ; i++)
-			for (S32 j = 0; j < dStrlen(invalidChars) ; j++)
-				for (S32 k = 0; k < dStrlen(argv[i]); k++)
-					if (invalidChars[j] == argv[i][k])
-					{
-						Con::warnf("\nInvalid parameter passed to secure script: %s, %s\n", s.c_str(), argv[i]);
-						return "";
-					}
-
-					Namespace::Entry* entry = GetEntry(nameSpace, name);
-
-					if (!entry)
-						return "";
-
-					static char returnBuffer[32];
-
-					switch(entry->mType)
-					{
-					case Namespace::Entry::ConsoleFunctionType:
-						return torque_callscriptfunction(nameSpace, name, argc, argv);
-
-					case Namespace::Entry::StringCallbackType:
-						return torque_callstringfunction(nameSpace, name, argc, argv);
-
-					case Namespace::Entry::IntCallbackType:
-						dSprintf(returnBuffer, sizeof(returnBuffer), "%d", torque_callintfunction(nameSpace, name, argc, argv));
-						return returnBuffer;
-
-					case Namespace::Entry::FloatCallbackType:
-						dSprintf(returnBuffer, sizeof(returnBuffer), "%g", torque_callfloatfunction(nameSpace, name, argc, argv));
-						return returnBuffer;
-
-					case Namespace::Entry::VoidCallbackType:
-						torque_callvoidfunction(nameSpace, name, argc, argv);
-						return "";
-
-					case Namespace::Entry::BoolCallbackType:
-						dSprintf(returnBuffer, sizeof(returnBuffer), "%d", (U32) torque_callboolfunction(nameSpace, name, argc, argv));
-						return returnBuffer;
-					};
-
-					return "";
-
-	}
-
-   // Set a TorqueScript console function as secure and available for JavaScript via the callScript plugin method
-	void torque_addsecurefunction(const char* nameSpace, const char* fname)
-	{
-		String s = nameSpace;
-		s += "::";
-		s += fname;
-		s = String::ToUpper(s);
-
-		gSecureScript.insertEqual(StringTable->insert(s.c_str()), StringTable->insert(s.c_str()));
-	}
-
-
-   // Evaluate arbitrary TorqueScript (ONLY CALL torque_evaluate FROM TRUSTED CODE!!!)
-	const char* torque_evaluate(const char* code)
-	{
-		return Con::evaluate(code);
-	}
-
-   // resize the Torque 3D child window to the specified width and height
-	void torque_resizewindow(S32 width, S32 height)
-	{
-		if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
-			PlatformWindowManager::get()->getFirstWindow()->setSize(Point2I(width,height));
-	}
-
-#if defined(TORQUE_OS_WIN) && !defined(TORQUE_SDL)
-   // retrieve the hwnd of our render window
-   void* torque_gethwnd()
-   {
-      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
-      {
-         Win32Window* w = (Win32Window*) PlatformWindowManager::get()->getFirstWindow();
-         return (void *) w->getHWND();
-      }
+CInterface& CInterface::GetCInterface()
+{
+   static CInterface INSTANCE;
+   return INSTANCE;
+}
 
-      return NULL;
-   }
+bool CInterface::isMethod(const char* className, const char* methodName)
+{
+   return GetCInterface()._isMethod(className, methodName);
+}
 
-   // directly add a message to the Torque 3D event queue, bypassing the Windows event queue
-   // this is useful in the case of the IE plugin, where we are hooking into an application 
-   // level message, and posting to the windows queue would cause a hang
-   void torque_directmessage(U32 message, U32 wparam, U32 lparam)
-   {
-      if (PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow())
-      {
-         Win32Window* w = (Win32Window*) PlatformWindowManager::get()->getFirstWindow();
-         Dispatch(DelayedDispatch,w->getHWND(),message,wparam,lparam);
-      }      
-   }
-   
-#endif
+const char* CInterface::CallFunction(const char* nameSpace, const char* name, const char **argv, int argc, bool *result)
+{
+   return GetCInterface()._CallFunction(nameSpace, name, argv, argc, result);
 }
 
-// This function is solely to test the TorqueScript <-> Javascript binding
-// By default, it is marked as secure by the web plugins and then can be called from
-// Javascript on the web page to ensure that function calls across the language
-// boundry are working with arguments and return values
-DefineConsoleFunction( testJavaScriptBridge, const char *, (const char* arg1, const char* arg2, const char* arg3), , "testBridge(arg1, arg2, arg3)")
+const char* CInterface::CallMethod(SimObject* obj, const char* name, const char **argv, int argc, bool *res)
 {
-	S32 failed = 0;
-		if (dStrcmp(arg1,"one"))
-			failed = 2;
-		if (dStrcmp(arg2,"two"))
-			failed = 2;
-		if (dStrcmp(arg3,"three"))
-			failed = 2;
-	
+   return GetCInterface()._CallMethod(obj->getClassName(), obj->getClassNamespace(), obj->getId(), name, argv, argc, res);
+}
 
-	//attempt to call from TorqueScript -> JavaScript
-	const char* jret = Con::evaluate("JS::bridgeCallback(\"one\",\"two\",\"three\");");
+void CInterface::CallMain(bool *res)
+{
+   GetCInterface()._CallMain(res);
+}
 
-	if (dStrcmp(jret,"42"))
-		failed = 3;
+bool CInterface::_isMethod(const char* className, const char* methodName) const
+{
+   if (mIsMethodCallback)
+      return mIsMethodCallback(className, methodName);
 
-	static const U32 bufSize = 256;
-	char *ret = Con::getReturnBuffer(bufSize);
+   return NULL;
+}
 
-	dSprintf(ret, bufSize, "%i", failed);
+const char* CInterface::_CallFunction(const char* nameSpace, const char* name, const char **argv, int argc, bool *result) const
+{
+   if (mFunctionCallback)
+      return mFunctionCallback(nameSpace, name, argv, argc, result);
 
-	return ret;
+   *result = false;
+   return NULL;
 }
 
+const char* CInterface::_CallMethod(const char* className, const char* classNamespace, U32 object, const char* name, const char **argv, int argc, bool *res) const
+{
+   if (mMethodCallback)
+      return mMethodCallback(className, classNamespace, object, name, argv, argc, res);
 
+   *res = false;
+   return NULL;
+}
 
+void CInterface::_CallMain(bool *res) const
+{
+   if (mMainCallback)
+   {
+      *res = true;
+      mMainCallback();
+      return;
+   }
 
+   *res = false;
+}
 
+TORQUE_API void SetCallbacks(void* ptr, void* methodPtr, void* isMethodPtr, void* mainPtr) {
+   CInterface::GetCInterface().SetCallFunctionCallback(ptr);
+   CInterface::GetCInterface().SetCallMethodCallback(methodPtr);
+   CInterface::GetCInterface().SetCallIsMethodCallback(isMethodPtr);
+   CInterface::GetCInterface().SetMainCallback(mainPtr);
+}

+ 35 - 4
Engine/source/cinterface/cinterface.h

@@ -21,10 +21,41 @@
 //-----------------------------------------------------------------------------
 
 #pragma once
+#include "platform/platformDlibrary.h"
+#include "console/engineAPI.h"
+#include "console/simBase.h"
 
-// cinterface can override this (useful for plugins, etc)
-extern "C" {
+#define CALL_CINTERFACE_FUNCTION(name, ...){const char *v[] = { __VA_ARGS__ }; CInterface::CallFunction(name, v, sizeof(v) / sizeof(*v));}
 
-const char* torque_getexecutablepath(); 
+class CInterface {
+   typedef bool(*IsMethodCallback)(const char* className, const char* methodName);
+   typedef void(*CallMainCallback)();
+   typedef const char* (*CallFunctionCallback)(const char* nameSpace, const char* name, const char **argv, int argc, bool *result);
+   typedef const char* (*CallMethodCallback)(const char* className, const char* classNamespace, U32 object, const char* name, const char **argv, int argc, bool *result);
+   IsMethodCallback mIsMethodCallback;
+   CallFunctionCallback mFunctionCallback;
+   CallMethodCallback mMethodCallback;
+   CallMainCallback mMainCallback;
+   const char* _CallFunction(const char* nameSpace, const char* name, const char **argv, int argc, bool *result) const;
+   const char* _CallMethod(const char* className, const char* classNamespace, U32 object, const char* name, const char **argv, int argc, bool *res) const;
+   void _CallMain(bool *res) const;
+   bool _isMethod(const char* className, const char* methodName) const;
+public:
+   CInterface()
+   {
+      mFunctionCallback = NULL;
+      mMethodCallback = NULL;
+      mIsMethodCallback = NULL;
+      mMainCallback = NULL;
+   }
 
-}
+   static const char* CallFunction(const char* nameSpace, const char* name, const char **argv, int argc, bool *result);
+   static const char* CallMethod(SimObject* obj, const char* name, const char **argv, int argc, bool *res);
+   static void CallMain(bool *res);
+   static bool isMethod(const char* className, const char* methodName);
+   static CInterface& GetCInterface();
+   void SetCallFunctionCallback(void* ptr) { mFunctionCallback = (CallFunctionCallback)ptr; };
+   void SetCallMethodCallback(void* ptr) { mMethodCallback = (CallMethodCallback)ptr; };
+   void SetCallIsMethodCallback(void* ptr) { mIsMethodCallback = (IsMethodCallback)ptr; };
+   void SetMainCallback(void* ptr) { mMainCallback = (CallMainCallback)ptr; };
+};

+ 2 - 2
Engine/source/console/SimXMLDocument.cpp

@@ -571,7 +571,7 @@ DefineEngineMethod( SimXMLDocument, attribute, const char*, ( const char* attrib
 }
 
 // These two methods don't make a lot of sense the way TS works.  Leaving them in for backwards-compatibility.
-DefineConsoleMethod( SimXMLDocument, attributeF32, F32, (const char * attributeName), , "(string attributeName)"
+DefineEngineMethod( SimXMLDocument, attributeF32, F32, (const char * attributeName), , "(string attributeName)"
    "@brief Get float attribute from the current Element on the stack.\n\n"
    "@param attributeName Name of attribute to retrieve.\n"
    "@return The value of the given attribute in the form of a float.\n"
@@ -580,7 +580,7 @@ DefineConsoleMethod( SimXMLDocument, attributeF32, F32, (const char * attributeN
    return dAtof( object->attribute( attributeName ) );
 }
 
-DefineConsoleMethod(SimXMLDocument, attributeS32, S32, (const char * attributeName), , "(string attributeName)"
+DefineEngineMethod(SimXMLDocument, attributeS32, S32, (const char * attributeName), , "(string attributeName)"
    "@brief Get int attribute from the current Element on the stack.\n\n"
    "@param attributeName Name of attribute to retrieve.\n"
    "@return The value of the given attribute in the form of an integer.\n"

+ 23 - 4
Engine/source/console/codeInterpreter.cpp

@@ -37,6 +37,7 @@
 #include "core/strings/stringUnit.h"
 #include "console/console.h"
 #include "console/consoleInternal.h"
+#include "cinterface/cinterface.h"
 
 //#define TORQUE_VALIDATE_STACK
 
@@ -2023,7 +2024,7 @@ OPCodeReturn CodeInterpreter::op_callfunc_resolve(U32 &ip)
 
    // Try to look it up.
    mNSEntry = Namespace::find(fnNamespace)->lookup(fnName);
-   if (!mNSEntry)
+   if (!CInterface::GetCInterface().isMethod(fnNamespace, fnName) && !mNSEntry)
    {
       ip += 5;
       Con::warnf(ConsoleLogEntry::General,
@@ -2051,6 +2052,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
 
    U32 *code = mCodeBlock->code;
 
+   StringTableEntry fnNamespace = CodeToSTE(mCodeBlock->code, ip + 2);
    StringTableEntry fnName = CodeToSTE(code, ip);
 
    //if this is called from inside a function, append the ip and codeptr
@@ -2068,10 +2070,16 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
    const char *componentReturnValue = "";
    Namespace *ns = NULL;
 
+   bool cFunctionRes = false;
+   const char* cRetRes = NULL;
+
    if (callType == FuncCallExprNode::FunctionCall)
    {
       if (!mNSEntry)
          mNSEntry = Namespace::global()->lookup(fnName);
+
+      StringStackWrapper args(mCallArgc, mCallArgv);
+      cRetRes = CInterface::GetCInterface().CallFunction(fnNamespace, fnName, args.argv, args.argc, &cFunctionRes);
    }
    else if (callType == FuncCallExprNode::MethodCall)
    {
@@ -2102,6 +2110,9 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
          mNSEntry = ns->lookup(fnName);
       else
          mNSEntry = NULL;
+
+      StringStackWrapper args(mCallArgc, mCallArgv);
+      cRetRes = CInterface::GetCInterface().CallMethod(gEvalState.thisObject, fnName, args.argv, args.argc, &cFunctionRes);
    }
    else // it's a ParentCall
    {
@@ -2128,7 +2139,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
       nsUsage = mNSEntry->mUsage;
       routingId = 0;
    }
-   if (!mNSEntry || mExec.noCalls)
+   if (!cFunctionRes && (!mNSEntry || mExec.noCalls))
    {
       if (!mExec.noCalls && !(routingId == MethodOnComponent))
       {
@@ -2167,11 +2178,19 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
 
    // ConsoleFunctionType is for any function defined by script.
    // Any 'callback' type is an engine function that is exposed to script.
-   if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType)
+   if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType
+      || cFunctionRes)
    {
       ConsoleValueRef ret;
-      if (mNSEntry->mFunctionOffset)
+      if (cFunctionRes)
+      {
+         StringStackConsoleWrapper retVal(1, &cRetRes);
+         ret = retVal.argv[0];
+      }
+      else if (mNSEntry->mFunctionOffset)
+      {
          ret = mNSEntry->mCode->exec(mNSEntry->mFunctionOffset, fnName, mNSEntry->mNamespace, mCallArgc, mCallArgv, false, mNSEntry->mPackage);
+      }
 
       STR.popFrame();
       // Functions are assumed to return strings, so look ahead to see if we can skip the conversion

+ 29 - 3
Engine/source/console/console.cpp

@@ -40,6 +40,7 @@
 #include <stdarg.h>
 #include "platform/threads/mutex.h"
 #include "core/util/journal/journal.h"
+#include "cinterface/cinterface.h"
 
 extern StringStack STR;
 extern ConsoleValueStack CSTK;
@@ -277,7 +278,7 @@ bool useTimestamp = false;
 
 ConsoleFunctionGroupBegin( Clipboard, "Miscellaneous functions to control the clipboard and clear the console.");
 
-DefineConsoleFunction( cls, void, (), , "()"
+DefineEngineFunction( cls, void, (), , "()"
             "@brief Clears the console output.\n\n"
             "@ingroup Console")
 {
@@ -287,14 +288,14 @@ DefineConsoleFunction( cls, void, (), , "()"
    consoleLog.setSize(0);
 };
 
-DefineConsoleFunction( getClipboard, const char*, (), , "()"
+DefineEngineFunction( getClipboard, const char*, (), , "()"
             "@brief Get text from the clipboard.\n\n"
             "@internal")
 {
    return Platform::getClipboard();
 };
 
-DefineConsoleFunction( setClipboard, bool, (const char* text), , "(string text)"
+DefineEngineFunction( setClipboard, bool, (const char* text), , "(string text)"
                "@brief Set the system clipboard.\n\n"
             "@internal")
 {
@@ -1488,6 +1489,18 @@ ConsoleValueRef evaluatef(const char* string, ...)
 // Internal execute for global function which does not save the stack
 ConsoleValueRef _internalExecute(S32 argc, ConsoleValueRef argv[])
 {
+   const char** argv_str = static_cast<const char**>(malloc((argc - 1) * sizeof(char *)));
+   for (int i = 0; i < argc - 1; i++)
+   {
+      argv_str[i] = argv[i + 1];
+   }
+   bool result;
+   const char* methodRes = CInterface::CallFunction(NULL, argv[0], argv_str, argc - 1, &result);
+   if (result)
+   {
+      return ConsoleValueRef::fromValue(CSTK.pushString(methodRes));
+   }
+   
    Namespace::Entry *ent;
    StringTableEntry funcName = StringTable->insert(argv[0]);
    ent = Namespace::global()->lookup(funcName);
@@ -1559,6 +1572,18 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar
       }
    }
 
+   const char** argv_str = static_cast<const char**>(malloc((argc - 2) * sizeof(char *)));
+   for (int i = 0; i < argc - 2; i++)
+   {
+      argv_str[i] = argv[i + 2];
+   }
+   bool result;
+   const char* methodRes = CInterface::CallMethod(object, argv[0], argv_str, argc - 2, &result);
+   if (result)
+   {
+      return ConsoleValueRef::fromValue(CSTK.pushString(methodRes));
+   }
+
    if(object->getNamespace())
    {
       U32 ident = object->getId();
@@ -1655,6 +1680,7 @@ inline ConsoleValueRef _executef(S32 checkArgc, S32 argc, ConsoleValueRef *argv)
 //------------------------------------------------------------------------------
 bool isFunction(const char *fn)
 {
+   if (CInterface::isMethod(NULL, fn)) return true;
    const char *string = StringTable->lookup(fn);
    if(!string)
       return false;

+ 0 - 32
Engine/source/console/console.h

@@ -1191,11 +1191,6 @@ public:
 #  define ConsoleFunctionGroupBegin(groupName, usage) \
       static ConsoleConstructor cfg_ConsoleFunctionGroup_##groupName##_GroupBegin(NULL,#groupName,usage)
 
-#  define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \
-   returnType cf_##name(SimObject *, S32, ConsoleValueRef *argv); \
-   ConsoleConstructor cc_##name##_obj(NULL,#name,cf_##name,usage1,minArgs,maxArgs); \
-      returnType cf_##name(SimObject *, S32 argc, ConsoleValueRef *argv)
-
 #  define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \
    returnType ctf_##name(SimObject *, S32, ConsoleValueRef *argv); \
    ConsoleConstructor cc_##name##_obj(NULL,#name,ctf_##name,usage1,minArgs,maxArgs, true); \
@@ -1211,24 +1206,6 @@ public:
 #  define ConsoleMethodGroupBegin(className, groupName, usage) \
    static ConsoleConstructor cc_##className##_##groupName##_GroupBegin(#className,#groupName,usage)
 
-#  define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \
-   inline returnType cm_##className##_##name(className *, S32, ConsoleValueRef *argv); \
-   returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \
-         AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \
-         conmethod_return_##returnType ) cm_##className##_##name(static_cast<className*>(object),argc,argv); \
-      };                                                                                              \
-      ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \
-      inline returnType cm_##className##_##name(className *object, S32 argc, ConsoleValueRef *argv)
-
-#  define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1) \
-   inline returnType cm_##className##_##name(S32, ConsoleValueRef *); \
-   returnType cm_##className##_##name##_caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \
-   conmethod_return_##returnType ) cm_##className##_##name(argc,argv); \
-   }; \
-   ConsoleConstructor \
-   cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage1,minArgs,maxArgs); \
-   inline returnType cm_##className##_##name(S32 argc, ConsoleValueRef *argv)
-
 #  define ConsoleMethodGroupEnd(className, groupName) \
    static ConsoleConstructor cc_##className##_##groupName##_GroupEnd(#className,#groupName,NULL)
 
@@ -1268,15 +1245,6 @@ public:
          className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs);        \
       static inline returnType c##className##name(className *object, S32 argc, ConsoleValueRef *argv)
 
-#  define ConsoleStaticMethod(className,name,returnType,minArgs,maxArgs,usage1)                       \
-      static inline returnType c##className##name(S32, ConsoleValueRef*);                                \
-      static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValueRef *argv) {  \
-         conmethod_return_##returnType ) c##className##name(argc,argv);                                                        \
-      };                                                                                              \
-      static ConsoleConstructor                                                                       \
-         className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs);        \
-      static inline returnType c##className##name(S32 argc, ConsoleValueRef *argv)
-
 #define ConsoleDoc( text )
 
 #endif

+ 2 - 2
Engine/source/console/consoleDoc.cpp

@@ -41,7 +41,7 @@
 
 ConsoleFunctionGroupBegin(ConsoleDoc, "Console self-documentation functions. These output psuedo C++ suitable for feeeding through Doxygen or another auto documentation tool.");
 
-DefineConsoleFunction( dumpConsoleClasses, void, (bool dumpScript, bool dumpEngine), ( true, true ),
+DefineEngineFunction( dumpConsoleClasses, void, (bool dumpScript, bool dumpEngine), ( true, true ),
             "@brief Dumps all declared console classes to the console.\n\n"
             "@param dumpScript Optional parameter specifying whether or not classes defined in script should be dumped.\n"
             "@param dumpEngine Optional parameter specifying whether or not classes defined in the engine should be dumped.\n"
@@ -50,7 +50,7 @@ DefineConsoleFunction( dumpConsoleClasses, void, (bool dumpScript, bool dumpEngi
    Namespace::dumpClasses( dumpScript, dumpEngine );
 }
 
-DefineConsoleFunction(dumpConsoleFunctions, void, ( bool dumpScript, bool dumpEngine ), ( true, true ),
+DefineEngineFunction(dumpConsoleFunctions, void, ( bool dumpScript, bool dumpEngine ), ( true, true ),
             "@brief Dumps all declared console functions to the console.\n"
             "@param dumpScript Optional parameter specifying whether or not functions defined in script should be dumped.\n"
             "@param dumpEngine Optional parameter specitying whether or not functions defined in the engine should be dumped.\n"

+ 107 - 110
Engine/source/console/consoleFunctions.cpp

@@ -184,7 +184,7 @@ bool isValidPort(U16 port)
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strasc, int, ( const char* chr ),,
+DefineEngineFunction( strasc, int, ( const char* chr ),,
    "Return the integer character code value corresponding to the first character in the given string.\n"
    "@param chr a (one-character) string.\n"
    "@return the UTF32 code value for the first character in the given string.\n"
@@ -195,7 +195,7 @@ DefineConsoleFunction( strasc, int, ( const char* chr ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strformat, const char*, ( const char* format, const char* value ),,
+DefineEngineFunction( strformat, const char*, ( const char* format, const char* value ),,
    "Format the given value as a string using printf-style formatting.\n"
    "@param format A printf-style format string.\n"
    "@param value The value argument matching the given format string.\n\n"
@@ -252,7 +252,7 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strcmp, S32, ( const char* str1, const char* str2 ),,
+DefineEngineFunction( strcmp, S32, ( const char* str1, const char* str2 ),,
    "Compares two strings using case-<b>sensitive</b> comparison.\n"
    "@param str1 The first string.\n"
    "@param str2 The second string.\n"
@@ -271,7 +271,7 @@ DefineConsoleFunction( strcmp, S32, ( const char* str1, const char* str2 ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( stricmp, S32, ( const char* str1, const char* str2 ),,
+DefineEngineFunction( stricmp, S32, ( const char* str1, const char* str2 ),,
    "Compares two strings using case-<b>insensitive</b> comparison.\n"
    "@param str1 The first string.\n"
    "@param str2 The second string.\n"
@@ -290,7 +290,7 @@ DefineConsoleFunction( stricmp, S32, ( const char* str1, const char* str2 ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strnatcmp, S32, ( const char* str1, const char* str2 ),,
+DefineEngineFunction( strnatcmp, S32, ( const char* str1, const char* str2 ),,
    "Compares two strings using \"natural order\" case-<b>sensitive</b> comparison.\n"
    "Natural order means that rather than solely comparing single character code values, strings are ordered in a "
    "natural way.  For example, the string \"hello10\" is considered greater than the string \"hello2\" even though "
@@ -325,7 +325,7 @@ DefineConsoleFunction( strnatcmp, S32, ( const char* str1, const char* str2 ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strinatcmp, S32, ( const char* str1, const char* str2 ),,
+DefineEngineFunction( strinatcmp, S32, ( const char* str1, const char* str2 ),,
    "Compares two strings using \"natural order\" case-<b>insensitive</b> comparison.\n"
    "Natural order means that rather than solely comparing single character code values, strings are ordered in a "
    "natural way.  For example, the string \"hello10\" is considered greater than the string \"hello2\" even though "
@@ -360,7 +360,7 @@ DefineConsoleFunction( strinatcmp, S32, ( const char* str1, const char* str2 ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strlen, S32, ( const char* str ),,
+DefineEngineFunction( strlen, S32, ( const char* str ),,
    "Get the length of the given string in bytes.\n"
    "@note This does <b>not</b> return a true character count for strings with multi-byte characters!\n"
    "@param str A string.\n"
@@ -371,7 +371,7 @@ DefineConsoleFunction( strlen, S32, ( const char* str ),,
 }
 
 //-----------------------------------------------------------------------------
-DefineConsoleFunction( strlenskip, S32, ( const char* str, const char* first, const char* last ),,
+DefineEngineFunction( strlenskip, S32, ( const char* str, const char* first, const char* last ),,
    "Calculate the length of a string in characters, skipping everything between and including first and last.\n"
    "@param str A string.\n"
    "@param first First character to look for to skip block of text.\n"
@@ -406,7 +406,7 @@ DefineConsoleFunction( strlenskip, S32, ( const char* str, const char* first, co
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strstr, S32, ( const char* string, const char* substring ),,
+DefineEngineFunction( strstr, S32, ( const char* string, const char* substring ),,
    "Find the start of @a substring in the given @a string searching from left to right.\n"
    "@param string The string to search.\n"
    "@param substring The string to search for.\n"
@@ -425,7 +425,7 @@ DefineConsoleFunction( strstr, S32, ( const char* string, const char* substring
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strpos, S32, ( const char* haystack, const char* needle, S32 offset ), ( 0 ),
+DefineEngineFunction( strpos, S32, ( const char* haystack, const char* needle, S32 offset ), ( 0 ),
    "Find the start of @a needle in @a haystack searching from left to right beginning at the given offset.\n"
    "@param haystack The string to search.\n"
    "@param needle The string to search for.\n"
@@ -450,7 +450,7 @@ DefineConsoleFunction( strpos, S32, ( const char* haystack, const char* needle,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strposr, S32, ( const char* haystack, const char* needle, S32 offset ), ( 0 ),
+DefineEngineFunction( strposr, S32, ( const char* haystack, const char* needle, S32 offset ), ( 0 ),
    "Find the start of @a needle in @a haystack searching from right to left beginning at the given offset.\n"
    "@param haystack The string to search.\n"
    "@param needle The string to search for.\n"
@@ -477,7 +477,7 @@ DefineConsoleFunction( strposr, S32, ( const char* haystack, const char* needle,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( ltrim, const char*, ( const char* str ),,
+DefineEngineFunction( ltrim, const char*, ( const char* str ),,
    "Remove leading whitespace from the string.\n"
    "@param str A string.\n"
    "@return A string that is the same as @a str but with any leading (i.e. leftmost) whitespace removed.\n\n"
@@ -496,7 +496,7 @@ DefineConsoleFunction( ltrim, const char*, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( rtrim, const char*, ( const char* str ),,
+DefineEngineFunction( rtrim, const char*, ( const char* str ),,
    "Remove trailing whitespace from the string.\n"
    "@param str A string.\n"
    "@return A string that is the same as @a str but with any trailing (i.e. rightmost) whitespace removed.\n\n"
@@ -523,7 +523,7 @@ DefineConsoleFunction( rtrim, const char*, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( trim, const char*, ( const char* str ),,
+DefineEngineFunction( trim, const char*, ( const char* str ),,
    "Remove leading and trailing whitespace from the string.\n"
    "@param str A string.\n"
    "@return A string that is the same as @a str but with any leading (i.e. leftmost) and trailing (i.e. rightmost) whitespace removed.\n\n"
@@ -551,7 +551,7 @@ DefineConsoleFunction( trim, const char*, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( stripChars, const char*, ( const char* str, const char* chars ),,
+DefineEngineFunction( stripChars, const char*, ( const char* str, const char* chars ),,
    "Remove all occurrences of characters contained in @a chars from @a str.\n"
    "@param str The string to filter characters out from.\n"
    "@param chars A string of characters to filter out from @a str.\n"
@@ -575,7 +575,7 @@ DefineConsoleFunction( stripChars, const char*, ( const char* str, const char* c
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strlwr, const char*, ( const char* str ),,
+DefineEngineFunction( strlwr, const char*, ( const char* str ),,
    "Return an all lower-case version of the given string.\n"
    "@param str A string.\n"
    "@return A version of @a str with all characters converted to lower-case.\n\n"
@@ -593,7 +593,7 @@ DefineConsoleFunction( strlwr, const char*, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strupr, const char*, ( const char* str ),,
+DefineEngineFunction( strupr, const char*, ( const char* str ),,
    "Return an all upper-case version of the given string.\n"
    "@param str A string.\n"
    "@return A version of @a str with all characters converted to upper-case.\n\n"
@@ -611,7 +611,7 @@ DefineConsoleFunction( strupr, const char*, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strchr, const char*, ( const char* str, const char* chr ),,
+DefineEngineFunction( strchr, const char*, ( const char* str, const char* chr ),,
    "Find the first occurrence of the given character in @a str.\n"
    "@param str The string to search.\n"
    "@param chr The character to search for.  Only the first character from the string is taken.\n"
@@ -625,7 +625,7 @@ DefineConsoleFunction( strchr, const char*, ( const char* str, const char* chr )
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strrchr, const char*, ( const char* str, const char* chr ),,
+DefineEngineFunction( strrchr, const char*, ( const char* str, const char* chr ),,
    "Find the last occurrence of the given character in @a str."
    "@param str The string to search.\n"
    "@param chr The character to search for.  Only the first character from the string is taken.\n"
@@ -639,7 +639,7 @@ DefineConsoleFunction( strrchr, const char*, ( const char* str, const char* chr
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strreplace, const char*, ( const char* source, const char* from, const char* to ),,
+DefineEngineFunction( strreplace, const char*, ( const char* source, const char* from, const char* to ),,
    "Replace all occurrences of @a from in @a source with @a to.\n"
    "@param source The string in which to replace the occurrences of @a from.\n"
    "@param from The string to replace in @a source.\n"
@@ -690,7 +690,7 @@ DefineConsoleFunction( strreplace, const char*, ( const char* source, const char
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strrepeat, const char*, ( const char* str, S32 numTimes, const char* delimiter ), ( "" ),
+DefineEngineFunction( strrepeat, const char*, ( const char* str, S32 numTimes, const char* delimiter ), ( "" ),
    "Return a string that repeats @a str @a numTimes number of times delimiting each occurrence with @a delimiter.\n"
    "@param str The string to repeat multiple times.\n"
    "@param numTimes The number of times to repeat @a str in the result string.\n"
@@ -717,7 +717,7 @@ DefineConsoleFunction( strrepeat, const char*, ( const char* str, S32 numTimes,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getSubStr, const char*, ( const char* str, S32 start, S32 numChars ), ( -1 ),
+DefineEngineFunction( getSubStr, const char*, ( const char* str, S32 start, S32 numChars ), ( -1 ),
    "@brief Return a substring of @a str starting at @a start and continuing either through to the end of @a str "
    "(if @a numChars is -1) or for @a numChars characters (except if this would exceed the actual source "
    "string length).\n"
@@ -758,7 +758,7 @@ DefineConsoleFunction( getSubStr, const char*, ( const char* str, S32 start, S32
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strIsMatchExpr, bool, ( const char* pattern, const char* str, bool caseSensitive ), ( false ),
+DefineEngineFunction( strIsMatchExpr, bool, ( const char* pattern, const char* str, bool caseSensitive ), ( false ),
    "Match a pattern against a string.\n"
    "@param pattern The wildcard pattern to match against.  The pattern can include characters, '*' to match "
       "any number of characters and '?' to match a single character.\n"
@@ -777,7 +777,7 @@ DefineConsoleFunction( strIsMatchExpr, bool, ( const char* pattern, const char*
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( strIsMatchMultipleExpr, bool, ( const char* patterns, const char* str, bool caseSensitive ), ( false ),
+DefineEngineFunction( strIsMatchMultipleExpr, bool, ( const char* patterns, const char* str, bool caseSensitive ), ( false ),
    "Match a multiple patterns against a single string.\n"
    "@param patterns A tab-separated list of patterns.  Each pattern can include charaters, '*' to match "
       "any number of characters and '?' to match a single character.  Each of the patterns is tried in turn.\n"
@@ -796,7 +796,7 @@ DefineConsoleFunction( strIsMatchMultipleExpr, bool, ( const char* patterns, con
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getTrailingNumber, S32, ( const char* str ),,
+DefineEngineFunction( getTrailingNumber, S32, ( const char* str ),,
    "Get the numeric suffix of the given input string.\n"
    "@param str The string from which to read out the numeric suffix.\n"
    "@return The numeric value of the number suffix of @a str or -1 if @a str has no such suffix.\n\n"
@@ -813,7 +813,7 @@ DefineConsoleFunction( getTrailingNumber, S32, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( stripTrailingNumber, String, ( const char* str ),,
+DefineEngineFunction( stripTrailingNumber, String, ( const char* str ),,
    "Strip a numeric suffix from the given string.\n"
    "@param str The string from which to strip its numeric suffix.\n"
    "@return The string @a str without its number suffix or the original string @a str if it has no such suffix.\n\n"
@@ -829,7 +829,7 @@ DefineConsoleFunction( stripTrailingNumber, String, ( const char* str ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getFirstNumber, String, ( const char* str ),,
+DefineEngineFunction( getFirstNumber, String, ( const char* str ),,
    "Get the first occuring number from @a str.\n"
    "@param str The string from which to read out the first number.\n"
    "@return String representation of the number or "" if no number.\n\n")
@@ -841,7 +841,7 @@ DefineConsoleFunction( getFirstNumber, String, ( const char* str ),,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( isspace, bool, ( const char* str, S32 index ),,
+DefineEngineFunction( isspace, bool, ( const char* str, S32 index ),,
    "Test whether the character at the given position is a whitespace character.\n"
    "Characters such as tab, space, or newline are considered whitespace.\n"
    "@param str The string to test.\n"
@@ -858,7 +858,7 @@ DefineConsoleFunction( isspace, bool, ( const char* str, S32 index ),,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( isalnum, bool, ( const char* str, S32 index ),,
+DefineEngineFunction( isalnum, bool, ( const char* str, S32 index ),,
    "Test whether the character at the given position is an alpha-numeric character.\n"
    "Alpha-numeric characters are characters that are either alphabetic (a-z, A-Z) or numbers (0-9).\n"
    "@param str The string to test.\n"
@@ -875,7 +875,7 @@ DefineConsoleFunction( isalnum, bool, ( const char* str, S32 index ),,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( startsWith, bool, ( const char* str, const char* prefix, bool caseSensitive ), ( false ),
+DefineEngineFunction( startsWith, bool, ( const char* str, const char* prefix, bool caseSensitive ), ( false ),
    "Test whether the given string begins with the given prefix.\n"
    "@param str The string to test.\n"
    "@param prefix The potential prefix of @a str.\n"
@@ -924,7 +924,7 @@ DefineConsoleFunction( startsWith, bool, ( const char* str, const char* prefix,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( endsWith, bool, ( const char* str, const char* suffix, bool caseSensitive ), ( false ),
+DefineEngineFunction( endsWith, bool, ( const char* str, const char* suffix, bool caseSensitive ), ( false ),
    "@brief Test whether the given string ends with the given suffix.\n\n"
    "@param str The string to test.\n"
    "@param suffix The potential suffix of @a str.\n"
@@ -978,7 +978,7 @@ DefineConsoleFunction( endsWith, bool, ( const char* str, const char* suffix, bo
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( strchrpos, S32, ( const char* str, const char* chr, S32 start ), ( 0 ),
+DefineEngineFunction( strchrpos, S32, ( const char* str, const char* chr, S32 start ), ( 0 ),
    "Find the first occurrence of the given character in the given string.\n"
    "@param str The string to search.\n"
    "@param chr The character to look for.  Only the first character of this string will be searched for.\n"
@@ -998,7 +998,7 @@ DefineConsoleFunction( strchrpos, S32, ( const char* str, const char* chr, S32 s
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( strrchrpos, S32, ( const char* str, const char* chr, S32 start ), ( 0 ),
+DefineEngineFunction( strrchrpos, S32, ( const char* str, const char* chr, S32 start ), ( 0 ),
    "Find the last occurrence of the given character in the given string.\n"
    "@param str The string to search.\n"
    "@param chr The character to look for.  Only the first character of this string will be searched for.\n"
@@ -1025,7 +1025,7 @@ DefineConsoleFunction( strrchrpos, S32, ( const char* str, const char* chr, S32
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction(ColorFloatToInt, ColorI, (LinearColorF color), ,
+DefineEngineFunction(ColorFloatToInt, ColorI, (LinearColorF color), ,
    "Convert from a float color to an integer color (0.0 - 1.0 to 0 to 255).\n"
    "@param color Float color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha.\n"
    "@return Converted color value (0 - 255)\n\n"
@@ -1037,7 +1037,7 @@ DefineConsoleFunction(ColorFloatToInt, ColorI, (LinearColorF color), ,
    return color.toColorI();
 }
 
-DefineConsoleFunction(ColorIntToFloat, LinearColorF, (ColorI color), ,
+DefineEngineFunction(ColorIntToFloat, LinearColorF, (ColorI color), ,
    "Convert from a integer color to an float color (0 to 255 to 0.0 - 1.0).\n"
    "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha.\n"
    "@return Converted color value (0.0 - 1.0)\n\n"
@@ -1049,7 +1049,7 @@ DefineConsoleFunction(ColorIntToFloat, LinearColorF, (ColorI color), ,
    return LinearColorF(color);
 }
 
-DefineConsoleFunction(ColorRGBToHEX, const char*, (ColorI color), ,
+DefineEngineFunction(ColorRGBToHEX, const char*, (ColorI color), ,
    "Convert from a integer RGB (red, green, blue) color to hex color value (0 to 255 to 00 - FF).\n"
    "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n"
    "@return Hex color value (#000000 - #FFFFFF), alpha isn't handled/converted so it is only the RGB value\n\n"
@@ -1061,7 +1061,7 @@ DefineConsoleFunction(ColorRGBToHEX, const char*, (ColorI color), ,
    return Con::getReturnBuffer(color.getHex());
 }
 
-DefineConsoleFunction(ColorRGBToHSB, const char*, (ColorI color), ,
+DefineEngineFunction(ColorRGBToHSB, const char*, (ColorI color), ,
    "Convert from a integer RGB (red, green, blue) color to HSB (hue, saturation, brightness). HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n"
    "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n"
    "@return HSB color value, alpha isn't handled/converted so it is only the RGB value\n\n"
@@ -1075,7 +1075,7 @@ DefineConsoleFunction(ColorRGBToHSB, const char*, (ColorI color), ,
    return Con::getReturnBuffer(s);
 }
 
-DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
+DefineEngineFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
    "Convert from a hex color value to an integer RGB (red, green, blue) color (00 - FF to 0 to 255).\n"
    "@param hex Hex color value (#000000 - #FFFFFF) to be converted to an RGB (red, green, blue) value.\n"
    "@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n"
@@ -1089,7 +1089,7 @@ DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
    return color;
 }
 
-DefineConsoleFunction(ColorHSBToRGB, ColorI, (Point3I hsb), ,
+DefineEngineFunction(ColorHSBToRGB, ColorI, (Point3I hsb), ,
    "Convert from a HSB (hue, saturation, brightness) to an integer RGB (red, green, blue) color. HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n"
    "@param hsb HSB (hue, saturation, brightness) value to be converted.\n"
    "@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n"
@@ -1105,7 +1105,7 @@ DefineConsoleFunction(ColorHSBToRGB, ColorI, (Point3I hsb), ,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( strToggleCaseToWords, const char*, ( const char* str ),,
+DefineEngineFunction( strToggleCaseToWords, const char*, ( const char* str ),,
    "Parse a Toggle Case word into separate words.\n"
    "@param str The string to parse.\n"
    "@return new string space separated.\n\n"
@@ -1130,7 +1130,7 @@ DefineConsoleFunction( strToggleCaseToWords, const char*, ( const char* str ),,
 //----------------------------------------------------------------
 
 // Warning: isInt and isFloat are very 'strict' and might need to be adjusted to allow other values. //seanmc
-DefineConsoleFunction( isInt, bool, ( const char* str),,
+DefineEngineFunction( isInt, bool, ( const char* str),,
    "Returns true if the string is an integer.\n"
    "@param str The string to test.\n"
    "@return true if @a str is an integer and false if not\n\n"
@@ -1144,7 +1144,7 @@ DefineConsoleFunction( isInt, bool, ( const char* str),,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( isFloat, bool, ( const char* str, bool sciOk), (false),
+DefineEngineFunction( isFloat, bool, ( const char* str, bool sciOk), (false),
    "Returns true if the string is a float.\n"
    "@param str The string to test.\n"
    "@param sciOk Test for correct scientific notation and accept it (ex. 1.2e+14)"
@@ -1159,7 +1159,7 @@ DefineConsoleFunction( isFloat, bool, ( const char* str, bool sciOk), (false),
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( isValidPort, bool, ( const char* str),,
+DefineEngineFunction( isValidPort, bool, ( const char* str),,
    "Returns true if the string is a valid port number.\n"
    "@param str The string to test.\n"
    "@return true if @a str is a port and false if not\n\n"
@@ -1179,7 +1179,7 @@ DefineConsoleFunction( isValidPort, bool, ( const char* str),,
 
 //----------------------------------------------------------------
 
-DefineConsoleFunction( isValidIP, bool, ( const char* str),,
+DefineEngineFunction( isValidIP, bool, ( const char* str),,
    "Returns true if the string is a valid ip address, excepts localhost.\n"
    "@param str The string to test.\n"
    "@return true if @a str is a valid ip address and false if not\n\n"
@@ -1200,7 +1200,7 @@ DefineConsoleFunction( isValidIP, bool, ( const char* str),,
 
 // Torque won't normally add another string if it already exists with another casing,
 // so this forces the addition. It should be called once near the start, such as in main.cs.
-ConsoleFunction(addCaseSensitiveStrings,void,2,0,"[string1, string2, ...]"
+DefineEngineStringlyVariadicFunction(addCaseSensitiveStrings,void,2,0,"[string1, string2, ...]"
                 "Adds case sensitive strings to the StringTable.")
 {
    for(int i = 1; i < argc; i++)
@@ -1214,7 +1214,7 @@ ConsoleFunction(addCaseSensitiveStrings,void,2,0,"[string1, string2, ...]"
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getWord, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( getWord, const char*, ( const char* text, S32 index ),,
    "Extract the word at the given @a index in the whitespace-separated list in @a text.\n"
    "Words in @a text must be separated by newlines, spaces, and/or tabs.\n"
    "@param text A whitespace-separated list of words.\n"
@@ -1235,7 +1235,7 @@ DefineConsoleFunction( getWord, const char*, ( const char* text, S32 index ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getWords, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
+DefineEngineFunction( getWords, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
    "Extract a range of words from the given @a startIndex onwards thru @a endIndex.\n"
    "Words in @a text must be separated by newlines, spaces, and/or tabs.\n"
    "@param text A whitespace-separated list of words.\n"
@@ -1262,7 +1262,7 @@ DefineConsoleFunction( getWords, const char*, ( const char* text, S32 startIndex
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( setWord, const char*, ( const char* text, S32 index, const char* replacement ),,
+DefineEngineFunction( setWord, const char*, ( const char* text, S32 index, const char* replacement ),,
    "Replace the word in @a text at the given @a index with @a replacement.\n"
    "Words in @a text must be separated by newlines, spaces, and/or tabs.\n"
    "@param text A whitespace-separated list of words.\n"
@@ -1284,7 +1284,7 @@ DefineConsoleFunction( setWord, const char*, ( const char* text, S32 index, cons
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( removeWord, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( removeWord, const char*, ( const char* text, S32 index ),,
    "Remove the word in @a text at the given @a index.\n"
    "Words in @a text must be separated by newlines, spaces, and/or tabs.\n"
    "@param text A whitespace-separated list of words.\n"
@@ -1304,7 +1304,7 @@ DefineConsoleFunction( removeWord, const char*, ( const char* text, S32 index ),
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getWordCount, S32, ( const char* text ),,
+DefineEngineFunction( getWordCount, S32, ( const char* text ),,
    "Return the number of whitespace-separated words in @a text.\n"
    "Words in @a text must be separated by newlines, spaces, and/or tabs.\n"
    "@param text A whitespace-separated list of words.\n"
@@ -1365,7 +1365,7 @@ DefineEngineFunction( weekdayNumToStr, String, ( S32 num, bool abbreviate ), (fa
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getField, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( getField, const char*, ( const char* text, S32 index ),,
    "Extract the field at the given @a index in the newline and/or tab separated list in @a text.\n"
    "Fields in @a text must be separated by newlines and/or tabs.\n"
    "@param text A list of fields separated by newlines and/or tabs.\n"
@@ -1385,7 +1385,7 @@ DefineConsoleFunction( getField, const char*, ( const char* text, S32 index ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getFields, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
+DefineEngineFunction( getFields, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
    "Extract a range of fields from the given @a startIndex onwards thru @a endIndex.\n"
    "Fields in @a text must be separated by newlines and/or tabs.\n"
    "@param text A list of fields separated by newlines and/or tabs.\n"
@@ -1411,7 +1411,7 @@ DefineConsoleFunction( getFields, const char*, ( const char* text, S32 startInde
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( setField, const char*, ( const char* text, S32 index, const char* replacement ),,
+DefineEngineFunction( setField, const char*, ( const char* text, S32 index, const char* replacement ),,
    "Replace the field in @a text at the given @a index with @a replacement.\n"
    "Fields in @a text must be separated by newlines and/or tabs.\n"
    "@param text A list of fields separated by newlines and/or tabs.\n"
@@ -1432,7 +1432,7 @@ DefineConsoleFunction( setField, const char*, ( const char* text, S32 index, con
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( removeField, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( removeField, const char*, ( const char* text, S32 index ),,
    "Remove the field in @a text at the given @a index.\n"
    "Fields in @a text must be separated by newlines and/or tabs.\n"
    "@param text A list of fields separated by newlines and/or tabs.\n"
@@ -1451,7 +1451,7 @@ DefineConsoleFunction( removeField, const char*, ( const char* text, S32 index )
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getFieldCount, S32, ( const char* text ),,
+DefineEngineFunction( getFieldCount, S32, ( const char* text ),,
    "Return the number of newline and/or tab separated fields in @a text.\n"
    "@param text A list of fields separated by newlines and/or tabs.\n"
    "@return The number of newline and/or tab sepearated elements in @a text.\n\n"
@@ -1467,7 +1467,7 @@ DefineConsoleFunction( getFieldCount, S32, ( const char* text ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getRecord, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( getRecord, const char*, ( const char* text, S32 index ),,
    "Extract the record at the given @a index in the newline-separated list in @a text.\n"
    "Records in @a text must be separated by newlines.\n"
    "@param text A list of records separated by newlines.\n"
@@ -1487,7 +1487,7 @@ DefineConsoleFunction( getRecord, const char*, ( const char* text, S32 index ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getRecords, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
+DefineEngineFunction( getRecords, const char*, ( const char* text, S32 startIndex, S32 endIndex ), ( -1 ),
    "Extract a range of records from the given @a startIndex onwards thru @a endIndex.\n"
    "Records in @a text must be separated by newlines.\n"
    "@param text A list of records separated by newlines.\n"
@@ -1513,7 +1513,7 @@ DefineConsoleFunction( getRecords, const char*, ( const char* text, S32 startInd
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( setRecord, const char*, ( const char* text, S32 index, const char* replacement ),,
+DefineEngineFunction( setRecord, const char*, ( const char* text, S32 index, const char* replacement ),,
    "Replace the record in @a text at the given @a index with @a replacement.\n"
    "Records in @a text must be separated by newlines.\n"
    "@param text A list of records separated by newlines.\n"
@@ -1534,7 +1534,7 @@ DefineConsoleFunction( setRecord, const char*, ( const char* text, S32 index, co
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( removeRecord, const char*, ( const char* text, S32 index ),,
+DefineEngineFunction( removeRecord, const char*, ( const char* text, S32 index ),,
    "Remove the record in @a text at the given @a index.\n"
    "Records in @a text must be separated by newlines.\n"
    "@param text A list of records separated by newlines.\n"
@@ -1553,7 +1553,7 @@ DefineConsoleFunction( removeRecord, const char*, ( const char* text, S32 index
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getRecordCount, S32, ( const char* text ),,
+DefineEngineFunction( getRecordCount, S32, ( const char* text ),,
    "Return the number of newline-separated records in @a text.\n"
    "@param text A list of records separated by newlines.\n"
    "@return The number of newline-sepearated elements in @a text.\n\n"
@@ -1569,7 +1569,7 @@ DefineConsoleFunction( getRecordCount, S32, ( const char* text ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( firstWord, const char*, ( const char* text ),,
+DefineEngineFunction( firstWord, const char*, ( const char* text ),,
    "Return the first word in @a text.\n"
    "@param text A list of words separated by newlines, spaces, and/or tabs.\n"
    "@return The word at index 0 in @a text or \"\" if @a text is empty.\n\n"
@@ -1585,7 +1585,7 @@ DefineConsoleFunction( firstWord, const char*, ( const char* text ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( restWords, const char*, ( const char* text ),,
+DefineEngineFunction( restWords, const char*, ( const char* text ),,
    "Return all but the first word in @a text.\n"
    "@param text A list of words separated by newlines, spaces, and/or tabs.\n"
    "@return @a text with the first word removed.\n\n"
@@ -1619,7 +1619,7 @@ static bool isInSet(char c, const char *set)
    return false;
 }
 
-DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* token, const char* delim), , "( string str, string token, string delimiters ) "
+DefineEngineFunction( nextToken, const char*, ( const char* str1, const char* token, const char* delim), , "( string str, string token, string delimiters ) "
    "Tokenize a string using a set of delimiting characters.\n"
    "This function first skips all leading charaters in @a str that are contained in @a delimiters. "
    "From that position, it then scans for the next character in @a str that is contained in @a delimiters and stores all characters "
@@ -1688,7 +1688,7 @@ DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* t
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getToken, const char*, ( const char* text, const char* delimiters, S32 index ),,
+DefineEngineFunction( getToken, const char*, ( const char* text, const char* delimiters, S32 index ),,
    "Extract the substring at the given @a index in the @a delimiters separated list in @a text.\n"
    "@param text A @a delimiters list of substrings.\n"
    "@param delimiters Character or characters that separate the list of substrings in @a text.\n"
@@ -1709,7 +1709,7 @@ DefineConsoleFunction( getToken, const char*, ( const char* text, const char* de
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getTokens, const char*, ( const char* text, const char* delimiters, S32 startIndex, S32 endIndex ), ( -1 ),
+DefineEngineFunction( getTokens, const char*, ( const char* text, const char* delimiters, S32 startIndex, S32 endIndex ), ( -1 ),
    "Extract a range of substrings separated by @a delimiters at the given @a startIndex onwards thru @a endIndex.\n"
    "@param text A @a delimiters list of substrings.\n"
    "@param delimiters Character or characters that separate the list of substrings in @a text.\n"
@@ -1736,7 +1736,7 @@ DefineConsoleFunction( getTokens, const char*, ( const char* text, const char* d
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( setToken, const char*, ( const char* text, const char* delimiters, S32 index, const char* replacement ),,
+DefineEngineFunction( setToken, const char*, ( const char* text, const char* delimiters, S32 index, const char* replacement ),,
    "Replace the substring in @a text separated by @a delimiters at the given @a index with @a replacement.\n"
    "@param text A @a delimiters list of substrings.\n"
    "@param delimiters Character or characters that separate the list of substrings in @a text.\n"
@@ -1758,7 +1758,7 @@ DefineConsoleFunction( setToken, const char*, ( const char* text, const char* de
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( removeToken, const char*, ( const char* text, const char* delimiters, S32 index ),,
+DefineEngineFunction( removeToken, const char*, ( const char* text, const char* delimiters, S32 index ),,
    "Remove the substring in @a text separated by @a delimiters at the given @a index.\n"
    "@param text A @a delimiters list of substrings.\n"
    "@param delimiters Character or characters that separate the list of substrings in @a text.\n"
@@ -1778,7 +1778,7 @@ DefineConsoleFunction( removeToken, const char*, ( const char* text, const char*
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getTokenCount, S32, ( const char* text, const char* delimiters),,
+DefineEngineFunction( getTokenCount, S32, ( const char* text, const char* delimiters),,
    "Return the number of @a delimiters substrings in @a text.\n"
    "@param text A @a delimiters list of substrings.\n"
    "@param delimiters Character or characters that separate the list of substrings in @a text.\n"
@@ -1837,7 +1837,7 @@ DefineEngineFunction( detag, const char*, ( const char* str ),,
       return str;
 }
 
-DefineConsoleFunction( getTag, const char*, ( const char* textTagString ), , "( string textTagString ) "
+DefineEngineFunction( getTag, const char*, ( const char* textTagString ), , "( string textTagString ) "
    "@brief Extracts the tag from a tagged string\n\n"
 
    "Should only be used within the context of a function that receives a tagged "
@@ -1879,7 +1879,7 @@ DefineConsoleFunction( getTag, const char*, ( const char* textTagString ), , "(
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( echo, void, 2, 0, "( string message... ) "
+DefineEngineStringlyVariadicFunction( echo, void, 2, 0, "( string message... ) "
    "@brief Logs a message to the console.\n\n"
    "Concatenates all given arguments to a single string and prints the string to the console. "
    "A newline is added automatically after the text.\n\n"
@@ -1902,7 +1902,7 @@ ConsoleFunction( echo, void, 2, 0, "( string message... ) "
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( warn, void, 2, 0, "( string message... ) "
+DefineEngineStringlyVariadicFunction( warn, void, 2, 0, "( string message... ) "
    "@brief Logs a warning message to the console.\n\n"
    "Concatenates all given arguments to a single string and prints the string to the console as a warning "
    "message (in the in-game console, these will show up using a turquoise font by default). "
@@ -1926,7 +1926,7 @@ ConsoleFunction( warn, void, 2, 0, "( string message... ) "
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( error, void, 2, 0, "( string message... ) "
+DefineEngineStringlyVariadicFunction( error, void, 2, 0, "( string message... ) "
    "@brief Logs an error message to the console.\n\n"
    "Concatenates all given arguments to a single string and prints the string to the console as an error "
    "message (in the in-game console, these will show up using a red font by default). "
@@ -1968,7 +1968,7 @@ DefineEngineFunction( debugv, void, ( const char* variableName ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( expandEscape, const char*, ( const char* text ),,
+DefineEngineFunction( expandEscape, const char*, ( const char* text ),,
    "@brief Replace all characters in @a text that need to be escaped for the string to be a valid string literal with their "
    "respective escape sequences.\n\n"
    "All characters in @a text that cannot appear in a string literal will be replaced by an escape sequence (\\\\n, \\\\t, etc).\n\n"
@@ -1990,7 +1990,7 @@ DefineConsoleFunction( expandEscape, const char*, ( const char* text ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( collapseEscape, const char*, ( const char* text ),,
+DefineEngineFunction( collapseEscape, const char*, ( const char* text ),,
    "Replace all escape sequences in @a text with their respective character codes.\n\n"
    "This function replaces all escape sequences (\\\\n, \\\\t, etc) in the given string "
    "with the respective characters they represent.\n\n"
@@ -2046,7 +2046,7 @@ DefineEngineFunction( setLogMode, void, ( S32 mode ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( quit, void, ( ),,
+DefineEngineFunction( quit, void, ( ),,
    "Shut down the engine and exit its process.\n"
    "This function cleanly uninitializes the engine and then exits back to the system with a process "
    "exit status indicating a clean exit.\n\n"
@@ -2059,7 +2059,7 @@ DefineConsoleFunction( quit, void, ( ),,
 //-----------------------------------------------------------------------------
 
 
-DefineConsoleFunction( realQuit, void, (), , "")
+DefineEngineFunction( realQuit, void, (), , "")
 {
    Platform::postQuitMessage(0);
 }
@@ -2067,7 +2067,7 @@ DefineConsoleFunction( realQuit, void, (), , "")
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( quitWithErrorMessage, void, ( const char* message, S32 status ), (0),
+DefineEngineFunction( quitWithErrorMessage, void, ( const char* message, S32 status ), (0),
    "Display an error message box showing the given @a message and then shut down the engine and exit its process.\n"
    "This function cleanly uninitialized the engine and then exits back to the system with a process "
    "exit status indicating an error.\n\n"
@@ -2088,7 +2088,7 @@ DefineConsoleFunction( quitWithErrorMessage, void, ( const char* message, S32 st
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( quitWithStatus, void, ( S32 status ), (0),
+DefineEngineFunction( quitWithStatus, void, ( S32 status ), (0),
    "Shut down the engine and exit its process.\n"
    "This function cleanly uninitializes the engine and then exits back to the system with a given "
    "return status code.\n\n"
@@ -2236,7 +2236,7 @@ DefineEngineFunction( generateUUID, Torque::UUID, (),,
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( call, const char *, 2, 0, "( string functionName, string args... ) "
+DefineEngineStringlyVariadicFunction( call, const char *, 2, 0, "( string functionName, string args... ) "
    "Apply the given arguments to the specified global function and return the result of the call.\n\n"
    "@param functionName The name of the function to call.  This function must be in the global namespace, i.e. "
       "you cannot call a function in a namespace through #call.  Use eval() for that.\n"
@@ -2259,7 +2259,7 @@ ConsoleFunction( call, const char *, 2, 0, "( string functionName, string args..
 static U32 execDepth = 0;
 static U32 journalDepth = 1;
 
-DefineConsoleFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
+DefineEngineFunction( getDSOPath, const char*, ( const char* scriptFileName ),,
    "Get the absolute path to the file in which the compiled code for the given script file will be stored.\n"
    "@param scriptFileName %Path to the .cs script file.\n"
    "@return The absolute path to the .dso file for the given script file.\n\n"
@@ -2373,12 +2373,12 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou
    return Con::executeFile(fileName, noCalls, journalScript);
 }
 
-DefineConsoleFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" )
+DefineEngineFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" )
 {
    return Con::evaluate(consoleString, false, NULL);
 }
 
-DefineConsoleFunction( getVariable, const char*, ( const char* varName ), , "(string varName)\n" 
+DefineEngineFunction( getVariable, const char*, ( const char* varName ), , "(string varName)\n" 
    "@brief Returns the value of the named variable or an empty string if not found.\n\n"
    "@varName Name of the variable to search for\n"
    "@return Value contained by varName, \"\" if the variable does not exist\n"
@@ -2387,7 +2387,7 @@ DefineConsoleFunction( getVariable, const char*, ( const char* varName ), , "(st
    return Con::getVariable(varName);
 }
 
-DefineConsoleFunction( setVariable, void, ( const char* varName, const char* value ), , "(string varName, string value)\n" 
+DefineEngineFunction( setVariable, void, ( const char* varName, const char* value ), , "(string varName, string value)\n" 
    "@brief Sets the value of the named variable.\n\n"
    "@param varName Name of the variable to locate\n"
    "@param value New value of the variable\n"
@@ -2397,7 +2397,7 @@ DefineConsoleFunction( setVariable, void, ( const char* varName, const char* val
    return Con::setVariable(varName, value);
 }
 
-DefineConsoleFunction( isFunction, bool, ( const char* funcName ), , "(string funcName)" 
+DefineEngineFunction( isFunction, bool, ( const char* funcName ), , "(string funcName)" 
    "@brief Determines if a function exists or not\n\n"
    "@param funcName String containing name of the function\n"
    "@return True if the function exists, false if not\n"
@@ -2406,7 +2406,7 @@ DefineConsoleFunction( isFunction, bool, ( const char* funcName ), , "(string fu
    return Con::isFunction(funcName);
 }
 
-DefineConsoleFunction( getFunctionPackage, const char*, ( const char* funcName ), , "(string funcName)" 
+DefineEngineFunction( getFunctionPackage, const char*, ( const char* funcName ), , "(string funcName)" 
    "@brief Provides the name of the package the function belongs to\n\n"
    "@param funcName String containing name of the function\n"
    "@return The name of the function's package\n"
@@ -2419,7 +2419,7 @@ DefineConsoleFunction( getFunctionPackage, const char*, ( const char* funcName )
    return nse->mPackage;
 }
 
-DefineConsoleFunction( isMethod, bool, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" 
+DefineEngineFunction( isMethod, bool, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" 
    "@brief Determines if a class/namespace method exists\n\n"
    "@param namespace Class or namespace, such as Player\n"
    "@param method Name of the function to search for\n"
@@ -2434,7 +2434,7 @@ DefineConsoleFunction( isMethod, bool, ( const char* nameSpace, const char* meth
    return true;
 }
 
-DefineConsoleFunction( getMethodPackage, const char*, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" 
+DefineEngineFunction( getMethodPackage, const char*, ( const char* nameSpace, const char* method ), , "(string namespace, string method)" 
    "@brief Provides the name of the package the method belongs to\n\n"
    "@param namespace Class or namespace, such as Player\n"
    "@param method Name of the funciton to search for\n"
@@ -2452,7 +2452,7 @@ DefineConsoleFunction( getMethodPackage, const char*, ( const char* nameSpace, c
    return nse->mPackage;
 }
 
-DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varValue ), ("") , "(string varName)" 
+DefineEngineFunction( isDefined, bool, ( const char* varName, const char* varValue ), ("") , "(string varName)" 
    "@brief Determines if a variable exists and contains a value\n"
    "@param varName Name of the variable to search for\n"
    "@return True if the variable was defined in script, false if not\n"
@@ -2590,14 +2590,14 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( isCurrentScriptToolScript, bool, (), , "()" 
+DefineEngineFunction( isCurrentScriptToolScript, bool, (), , "()" 
    "Returns true if the calling script is a tools script.\n"
    "@hide")
 {
    return Con::isCurrentScriptToolScript();
 }
 
-DefineConsoleFunction( getModNameFromPath, const char *, ( const char* path ), , "(string path)" 
+DefineEngineFunction( getModNameFromPath, const char *, ( const char* path ), , "(string path)" 
             "@brief Attempts to extract a mod directory from path. Returns empty string on failure.\n\n"
             "@param File path of mod folder\n"
             "@note This is no longer relevant in Torque 3D (which does not use mod folders), should be deprecated\n"
@@ -2609,7 +2609,7 @@ DefineConsoleFunction( getModNameFromPath, const char *, ( const char* path ), ,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( pushInstantGroup, void, ( String group ),("") , "([group])" 
+DefineEngineFunction( pushInstantGroup, void, ( String group ),("") , "([group])" 
             "@brief Pushes the current $instantGroup on a stack "
             "and sets it to the given value (or clears it).\n\n"
             "@note Currently only used for editors\n"
@@ -2622,7 +2622,7 @@ DefineConsoleFunction( pushInstantGroup, void, ( String group ),("") , "([group]
       Con::pushInstantGroup();
 }
 
-DefineConsoleFunction( popInstantGroup, void, (), , "()" 
+DefineEngineFunction( popInstantGroup, void, (), , "()" 
             "@brief Pop and restore the last setting of $instantGroup off the stack.\n\n"
             "@note Currently only used for editors\n\n"
             "@ingroup Editors\n"
@@ -2633,7 +2633,7 @@ DefineConsoleFunction( popInstantGroup, void, (), , "()"
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileName ), (""), "([relativeFileName])" 
+DefineEngineFunction( getPrefsPath, const char *, ( const char* relativeFileName ), (""), "([relativeFileName])" 
             "@note Appears to be useless in Torque 3D, should be deprecated\n"
             "@internal")
 {
@@ -2646,31 +2646,28 @@ DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileNam
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( execPrefs, bool, 2, 4, "( string relativeFileName, bool noCalls=false, bool journalScript=false )"
-            "@brief Manually execute a special script file that contains game or editor preferences\n\n"
-            "@param relativeFileName Name and path to file from project folder\n"
-            "@param noCalls Deprecated\n"
-            "@param journalScript Deprecated\n"
-            "@return True if script was successfully executed\n"
-            "@note Appears to be useless in Torque 3D, should be deprecated\n"
-            "@ingroup Scripting")
+DefineEngineFunction(execPrefs, bool, (const char* relativeFileName, bool noCalls, bool journalScript),(false, false),
+   "@brief Manually execute a special script file that contains game or editor preferences\n\n"
+   "@param relativeFileName Name and path to file from project folder\n"
+   "@param noCalls Deprecated\n"
+   "@param journalScript Deprecated\n"
+   "@return True if script was successfully executed\n"
+   "@note Appears to be useless in Torque 3D, should be deprecated\n"
+   "@ingroup Scripting")
 {
-   const char *filename = Platform::getPrefsPath(argv[1]);
-   if(filename == NULL || *filename == 0)
+   if (relativeFileName == NULL || *relativeFileName == 0)
       return false;
 
    // Scripts do this a lot, so we may as well help them out
-   if(! Platform::isFile(filename) && ! Torque::FS::IsFile(filename))
+   if (!Platform::isFile(relativeFileName) && !Torque::FS::IsFile(relativeFileName))
       return true;
 
-   argv[0] = "exec";
-   argv[1] = filename;
-   return dAtob(Con::execute(argc, argv));
+   return Con::executeFile(relativeFileName, noCalls, journalScript);
 }
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( export, void, ( const char* pattern, const char* filename, bool append ), ( "", false ),
+DefineEngineFunction( export, void, ( const char* pattern, const char* filename, bool append ), ( "", false ),
    "Write out the definitions of all global variables matching the given name @a pattern.\n"
    "If @a fileName is not \"\", the variable definitions are written to the specified file.  Otherwise the "
    "definitions will be printed to the console.\n\n"
@@ -2723,7 +2720,7 @@ DefineEngineFunction( deleteVariables, void, ( const char* pattern ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( trace, void, ( bool enable ), ( true ),
+DefineEngineFunction( trace, void, ( bool enable ), ( true ),
    "Enable or disable tracing in the script code VM.\n\n"
    "When enabled, the script code runtime will trace the invocation and returns "
    "from all functions that are called and log them to the console. This is helpful in "
@@ -2739,7 +2736,7 @@ DefineConsoleFunction( trace, void, ( bool enable ), ( true ),
 
 #if defined(TORQUE_DEBUG) || !defined(TORQUE_SHIPPING)
 
-DefineConsoleFunction( debug, void, (),,
+DefineEngineFunction( debug, void, (),,
    "Drops the engine into the native C++ debugger.\n\n"
    "This function triggers a debug break and drops the process into the IDE's debugger.  If the process is not "
    "running with a debugger attached it will generate a runtime error on most platforms.\n\n"

+ 2 - 2
Engine/source/console/consoleLogger.cpp

@@ -225,7 +225,7 @@ void ConsoleLogger::log( const char *consoleLine )
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( ConsoleLogger, attach, bool, (), , "() Attaches the logger to the console and begins writing to file"
+DefineEngineMethod( ConsoleLogger, attach, bool, (), , "() Attaches the logger to the console and begins writing to file"
            "@tsexample\n"
            "// Create the logger\n"
            "// Will automatically start writing to testLogging.txt with normal priority\n"
@@ -247,7 +247,7 @@ DefineConsoleMethod( ConsoleLogger, attach, bool, (), , "() Attaches the logger
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( ConsoleLogger, detach, bool, (), , "() Detaches the logger from the console and stops writing to file"
+DefineEngineMethod( ConsoleLogger, detach, bool, (), , "() Detaches the logger from the console and stops writing to file"
            "@tsexample\n"
            "// Create the logger\n"
            "// Will automatically start writing to testLogging.txt with normal priority\n"

+ 23 - 0
Engine/source/console/consoleObject.h

@@ -662,6 +662,29 @@ public:
       // Finally, do any class specific initialization...
       T::initPersistFields();
       T::consoleInit();
+
+      EnginePropertyTable::Property* props = new EnginePropertyTable::Property[sg_tempFieldList.size()];
+
+      for (int i = 0; i < sg_tempFieldList.size(); ++i)
+      {
+         EnginePropertyTable::Property prop;
+         prop.mDocString = sg_tempFieldList[i].pFieldDocs;
+         prop.mName = sg_tempFieldList[i].pFieldname;
+         prop.mNumElements = sg_tempFieldList[i].elementCount;
+         prop.mFlags = 0;
+         if (sg_tempFieldList[i].type == StartGroupFieldType)
+            prop.mFlags |= EnginePropertyGroupBegin;
+         if (sg_tempFieldList[i].type == EndGroupFieldType)
+            prop.mFlags |= EnginePropertyGroupEnd;
+         prop.mType = sg_tempFieldList[i].type;
+
+         props[i] = prop;
+      }
+
+      _smPropertyTable = EnginePropertyTable(sg_tempFieldList.size(), props);
+      smPropertyTable = _smPropertyTable;
+
+      const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable;
  
       // Let the base finish up.
       AbstractClassRep::init();

+ 1 - 1
Engine/source/console/consoleXMLExport.cpp

@@ -314,7 +314,7 @@ namespace Con {
 }; // namespace Con
 
 
-DefineConsoleFunction( consoleExportXML, const char*, (), ,"Exports console definition XML representation" )
+DefineEngineFunction( consoleExportXML, const char*, (), ,"Exports console definition XML representation" )
 {
    Con::XMLExport xmlExport;
    String xml;

+ 89 - 72
Engine/source/console/engineAPI.h

@@ -26,6 +26,10 @@
 #include <tuple>
 #include <utility>
 
+#ifndef _FIXEDTUPLE_H_
+#include "fixedTuple.h"
+#endif
+
 #ifndef _CONSOLETYPES_H_
 #include "console/consoleTypes.h"
 #endif
@@ -347,6 +351,8 @@ struct _EngineTrampoline< R( ArgTs ... ) >
 {
    typedef std::tuple<ArgTs ...> Args;
    std::tuple<ArgTs ...> argT;
+   typedef fixed_tuple<ArgTs ...> FixedArgs;
+   fixed_tuple<ArgTs ...> fixedArgT;
 };
 
 template< typename T >
@@ -365,6 +371,7 @@ struct _EngineFunctionTrampoline< R(ArgTs...) > : public _EngineFunctionTrampoli
 private:
    using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >;
    using ArgsType = typename Super::Args;
+   using FixedArgsType = typename Super::FixedArgs;
    
    template<size_t ...> struct Seq {};
    template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
@@ -374,6 +381,11 @@ private:
    static R dispatchHelper(typename Super::FunctionType fn, const ArgsType& args, Seq<I...>)  {
       return R( fn(std::get<I>(args) ...) );
    }
+   
+   template<size_t ...I>
+   static R dispatchHelper(typename Super::FunctionType fn, const FixedArgsType& args, Seq<I...>)  {
+      return R( fn(fixed_tuple_accessor<I>::get(args) ...) );
+   }
 
    using SeqType = typename Gens<sizeof...(ArgTs)>::type;
 public:
@@ -381,6 +393,11 @@ public:
    {
       return dispatchHelper(fn, args, SeqType());
    }
+
+   static R jmp(typename Super::FunctionType fn, const FixedArgsType& args )
+   {
+      return dispatchHelper(fn, args, SeqType());
+   }
 };
 
 // Trampolines for engine methods
@@ -398,6 +415,7 @@ struct _EngineMethodTrampoline< Frame, R(ArgTs ...) > : public _EngineMethodTram
 private:
    using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >;
    using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args;
+   using FixedArgsType = typename Super::FixedArgs;
    
    template<size_t ...> struct Seq {};
    template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
@@ -408,6 +426,11 @@ private:
       return R( f._exec(std::get<I>(args) ...) );
    }
    
+   template<size_t ...I>
+   static R dispatchHelper(Frame f, const FixedArgsType& args, Seq<I...>)  {
+      return R( f._exec(fixed_tuple_accessor<I>::get(args) ...) );
+   }
+   
    using SeqType = typename Gens<sizeof...(ArgTs)>::type;
 public:
    static R jmp( typename Frame::ObjectType* object, const ArgsType& args )
@@ -417,6 +440,14 @@ public:
       f.object = object;
       return dispatchHelper(f, args, SeqType());
    }
+
+   static R jmp( typename Frame::ObjectType* object, const FixedArgsType& args )
+   {
+      
+      Frame f;
+      f.object = object;
+      return dispatchHelper(f, args, SeqType());
+   }
 };
 
 /// @}
@@ -683,7 +714,7 @@ public:
 #define DefineEngineFunction( name, returnType, args, defaultArgs, usage )                                                       \
    static inline returnType _fn ## name ## impl args;                                                                            \
    TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name                                                         \
-      ( _EngineFunctionTrampoline< returnType args >::Args a )                                                                   \
+      ( _EngineFunctionTrampoline< returnType args >::FixedArgs a )                                                              \
    {                                                                                                                             \
       _CHECK_ENGINE_INITIALIZED( name, returnType );                                                                             \
       return EngineTypeTraits< returnType >::ReturnValue(                                                                        \
@@ -702,7 +733,7 @@ public:
       ( void* ) &fn ## name,                                                                                                     \
       0                                                                                                                          \
    );                                                                                                                            \
-   static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )       \
+   static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )   \
    {                                                                                                                             \
       return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk(                \
          argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs                                                            \
@@ -737,7 +768,7 @@ public:
 
 #define _DefineMethodTrampoline( className, name, returnType, args ) \
    TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \
-      fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::Args a )   \
+      fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::FixedArgs a )\
    {                                                                                                                                            \
       _CHECK_ENGINE_INITIALIZED( className::name, returnType );                                                                                 \
       return EngineTypeTraits< returnType >::ReturnValue(                                                                                       \
@@ -820,7 +851,7 @@ public:
 #define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage )                                              \
    static inline returnType _fn ## className ## name ## impl args;                                                                     \
    TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name                                             \
-      ( _EngineFunctionTrampoline< returnType args >::Args a )                                                                         \
+      ( _EngineFunctionTrampoline< returnType args >::FixedArgs a )                                                                    \
    {                                                                                                                                   \
       _CHECK_ENGINE_INITIALIZED( className::name, returnType );                                                                        \
       return EngineTypeTraits< returnType >::ReturnValue(                                                                              \
@@ -855,76 +886,62 @@ public:
       );                                                                                                                               \
    static inline returnType _fn ## className ## name ## impl args
 
-
-// Convenience macros to allow defining functions that use the new marshalling features
-// while being only visible in the console interop.  When we drop the console system,
-// these macros can be removed and all definitions that make use of them can be removed
-// as well.
-#define DefineConsoleFunction( name, returnType, args, defaultArgs, usage )                                                      \
-   static inline returnType _fn ## name ## impl args;                                                                            \
-   static _EngineFunctionDefaultArguments< void args > _fn ## name ## DefaultArgs defaultArgs;                                   \
-   static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )       \
+#  define DefineEngineStringlyVariadicFunction(name,returnType,minArgs,maxArgs,usage) \
+   static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValueRef *argv);                                  \
+   TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name                                                         \
+      (S32 argc, const char** argv)                                                                                              \
    {                                                                                                                             \
-      return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk(                \
-         argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs                                                            \
-      ) );                                                                                                                       \
-   }                                                                                                                             \
-   static ConsoleFunctionHeader _ ## name ## header                                                                              \
-      ( #returnType, #args, #defaultArgs );                                                                                      \
-   static ConsoleConstructor                                                                                                     \
-      _ ## name ## obj( NULL, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## name ## caster ), usage,          \
-         _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs,                       \
-         _EngineConsoleThunk< 1, returnType args >::NUM_ARGS,                                                                    \
-         false, &_ ## name ## header                                                                                             \
+      _CHECK_ENGINE_INITIALIZED( name, returnType );                                                                             \
+      StringStackConsoleWrapper args(argc, argv);                                                                                \
+      return EngineTypeTraits< returnType >::ReturnValue(                                                                        \
+         _fn ## name ## impl(NULL, args.count(), args)                                                                           \
       );                                                                                                                         \
-   static inline returnType _fn ## name ## impl args
+   }                                                                                                                             \
+   static _EngineFunctionDefaultArguments< void (S32 argc, const char** argv) > _fn ## name ## DefaultArgs;                      \
+   static EngineFunctionInfo _fn ## name ## FunctionInfo(                                                                        \
+      #name,                                                                                                                     \
+      &_SCOPE<>()(),                                                                                                             \
+      usage,                                                                                                                     \
+      #returnType " " #name "(S32 argc, const char** argv)",                                                                     \
+      "fn" #name,                                                                                                                \
+      TYPE< returnType (S32 argc, const char** argv) >(),                                                                        \
+      &_fn ## name ## DefaultArgs,                                                                                               \
+      ( void* ) &fn ## name,                                                                                                     \
+      0                                                                                                                          \
+   );                                                                                                                            \
+   ConsoleConstructor cc_##name##_obj(NULL,#name,_fn ## name ## impl,usage,minArgs,maxArgs); \
+      returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv)
 
-#define DefineConsoleMethod( className, name, returnType, args, defaultArgs, usage )                                                            \
-   struct _ ## className ## name ## frame                                                                                                       \
-   {                                                                                                                                            \
-      typedef className ObjectType;                                                                                                             \
-      className* object;                                                                                                                        \
-      inline returnType _exec args const;                                                                                                       \
-   };                                                                                                                                           \
-   static _EngineFunctionDefaultArguments< _EngineMethodTrampoline< _ ## className ## name ## frame, void args >::FunctionType >                \
-      _fn ## className ## name ## DefaultArgs defaultArgs;                                                                                      \
-   static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv )  \
-   {                                                                                                                                            \
-      _ ## className ## name ## frame frame;                                                                                                    \
-      frame.object = static_cast< className* >( object );                                                                                       \
-      return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 2, returnType args >::thunk(                               \
-         argc, argv, &_ ## className ## name ## frame::_exec, &frame, _fn ## className ## name ## DefaultArgs                                   \
-      ) );                                                                                                                                      \
-   }                                                                                                                                            \
-   static ConsoleFunctionHeader _ ## className ## name ## header                                                                                \
-      ( #returnType, #args, #defaultArgs );                                                                                                     \
-   static ConsoleConstructor                                                                                                                    \
-      className ## name ## obj( #className, #name,                                                                                              \
-         _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage,                                        \
-         _EngineConsoleThunk< 2, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs,                                      \
-         _EngineConsoleThunk< 2, returnType args >::NUM_ARGS,                                                                                   \
-         false, &_ ## className ## name ## header                                                                                               \
-      );                                                                                                                                        \
-   returnType _ ## className ## name ## frame::_exec args const
+#  define DefineEngineStringlyVariadicMethod(className, name,returnType,minArgs,maxArgs,usage)                                   \
+   static inline returnType _fn ## className ## _ ## name ## impl (className* object, S32 argc, ConsoleValueRef* argv);          \
+   TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name                                       \
+      (className* object, S32 argc, const char** argv)                                                                           \
+   {                                                                                                                             \
+      _CHECK_ENGINE_INITIALIZED( name, returnType );                                                                             \
+      StringStackConsoleWrapper args(argc, argv);                                                                                \
+      return EngineTypeTraits< returnType >::ReturnValue(                                                                        \
+         _fn ## className ## _ ## name ## impl(object, args.count(), args)                                                       \
+      );                                                                                                                         \
+   }                                                                                                                             \
+   static _EngineFunctionDefaultArguments< void (className* object, S32 argc, const char** argv) > _fn ## className ## _ ## name ## DefaultArgs;   \
+   static EngineFunctionInfo _fn ## className ## _ ## name ## FunctionInfo(                                                      \
+      #name,                                                                                                                     \
+      &_SCOPE<>()(),                                                                                                             \
+      usage,                                                                                                                     \
+      #returnType " " #name "(SimObject* object, S32 argc, const char** argv)",                                                  \
+      "fn" #className "_" #name,                                                                                                 \
+      TYPE< returnType (SimObject* object, S32 argc, const char** argv) >(),                                                     \
+      &_fn ## className ## _ ## name ## DefaultArgs,                                                                             \
+      ( void* ) &fn ## className ## _ ## name,                                                                                   \
+      0                                                                                                                          \
+   );                                                                                                                            \
+   returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) {                             \
+      AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" );                  \
+      conmethod_return_##returnType ) _fn ## className ## _ ## name ## impl(static_cast<className*>(object),argc,argv);          \
+   };                                                                                                                            \
+   ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage,minArgs,maxArgs);    \
+   static inline returnType _fn ## className ## _ ## name ## impl(className *object, S32 argc, ConsoleValueRef *argv)
 
-#define DefineConsoleStaticMethod( className, name, returnType, args, defaultArgs, usage )                                             \
-   static inline returnType _fn ## className ## name ## impl args;                                                                     \
-   static _EngineFunctionDefaultArguments< void args > _fn ## className ## name ## DefaultArgs defaultArgs;                            \
-   static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\
-   {                                                                                                                                   \
-      return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk(                      \
-         argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs                                        \
-      ) );                                                                                                                             \
-   }                                                                                                                                   \
-   static ConsoleFunctionHeader _ ## className ## name ## header                                                                       \
-      ( #returnType, #args, #defaultArgs, true );                                                                                      \
-   static ConsoleConstructor                                                                                                           \
-      _ ## className ## name ## obj( #className, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage, \
-         _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs,                             \
-         _EngineConsoleThunk< 1, returnType args >::NUM_ARGS,                                                                          \
-         false, &_ ## className ## name ## header                                                                                      \
-      );                                                                                                                               \
-   static inline returnType _fn ## className ## name ## impl args
 
 
 // The following three macros are only temporary.  They allow to define engineAPI functions using the framework
@@ -934,7 +951,7 @@ public:
 #define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage )                                                    \
    static inline returnType _fn ## name ## impl args;                                                                            \
    TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name                                                         \
-      ( _EngineFunctionTrampoline< returnType args >::Args a )                                                                   \
+      ( _EngineFunctionTrampoline< returnType args >::FixedArgs a )                                                              \
    {                                                                                                                             \
       _CHECK_ENGINE_INITIALIZED( name, returnType );                                                                             \
       return EngineTypeTraits< returnType >::ReturnValue(                                                                        \
@@ -981,7 +998,7 @@ public:
 #define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage )                                           \
    static inline returnType _fn ## className ## name ## impl args;                                                                     \
    TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name                                             \
-      ( _EngineFunctionTrampoline< returnType args >::Args a )                                                                         \
+      ( _EngineFunctionTrampoline< returnType args >::FixedArgs a )                                                                    \
    {                                                                                                                                   \
       _CHECK_ENGINE_INITIALIZED( className::name, returnType );                                                                        \
       return EngineTypeTraits< returnType >::ReturnValue(                                                                              \

+ 8 - 1
Engine/source/console/engineFunctions.h

@@ -25,6 +25,10 @@
 
 #include <tuple>
 
+#ifndef _FIXEDTUPLE_H_
+#include "fixedTuple.h"
+#endif
+
 #ifndef _ENGINEEXPORTS_H_
    #include "console/engineExports.h"
 #endif
@@ -94,6 +98,7 @@ template<typename ...ArgTs>
 struct _EngineFunctionDefaultArguments< void(ArgTs...) > : public EngineFunctionDefaultArguments
 {
    template<typename T> using DefVST = typename EngineTypeTraits<T>::DefaultArgumentValueStoreType;
+   fixed_tuple<DefVST<ArgTs>  ...> mFixedArgs;
    std::tuple<DefVST<ArgTs>  ...> mArgs;
 private:
    using SelfType = _EngineFunctionDefaultArguments< void(ArgTs...) >;
@@ -130,7 +135,9 @@ private:
 public:
    template<typename ...TailTs> _EngineFunctionDefaultArguments(TailTs ...tail)
    : EngineFunctionDefaultArguments({sizeof...(TailTs)}), mArgs(SelfType::tailInit(tail...))
-   {}
+   {
+      fixed_tuple_mutator<void(DefVST<ArgTs>...), void(DefVST<ArgTs>...)>::copy(mArgs, mFixedArgs);
+   }
 };
 
 #pragma pack( pop )

+ 6 - 0
Engine/source/console/engineTypeInfo.h

@@ -231,6 +231,9 @@ class EnginePropertyTable
 
          /// Combination of EnginePropertyFlags.
          U32 mFlags;
+
+         /// Type-id of the property
+         U32 mType;
          
          /// Return the name of the property.
          const char* getName() const { return mName; }
@@ -255,6 +258,9 @@ class EnginePropertyTable
          
          ///
          bool hideInInspectors() const { return ( mFlags & EnginePropertyHideInInspectors ); }
+
+         /// Return the type-id of the property.
+         U32 getType() const { return mType; }
       };
       
    protected:

+ 3 - 3
Engine/source/console/engineTypes.h

@@ -236,16 +236,16 @@ template< typename T >
 struct _EngineStructTypeTraits
 {
    typedef T Type;
-   typedef const T& ValueType;
+   typedef const T ValueType;
    typedef void SuperType;
    
    // Structs get passed in as pointers and passed out as full copies.
-   typedef T* ArgumentValueType;
+   typedef T ArgumentValueType;
    typedef T ReturnValueType;
    typedef T DefaultArgumentValueStoreType;
 
    typedef ReturnValueType ReturnValue;
-   static ValueType ArgumentToValue( ArgumentValueType val ) { return *val; }
+   static ValueType ArgumentToValue( ArgumentValueType val ) { return val; }
 
    static const EngineTypeInfo* const TYPEINFO;
 };

+ 383 - 359
Engine/source/console/engineXMLExport.cpp

@@ -35,32 +35,32 @@
 /// actually having to access them directly in the DLL as native entities.
 
 
-static void exportScope( const EngineExportScope* scope, SimXMLDocument* xml, bool addNode = false );
+static void exportScope(const EngineExportScope* scope, SimXMLDocument* xml, bool addNode = false);
 
 
-static String getTypeName( const EngineTypeInfo* type )
+static String getTypeName(const EngineTypeInfo* type)
 {
-   if( !type )
+   if (!type)
    {
-      static String sVoid( "void" );
+      static String sVoid("void");
       return sVoid;
    }
-      
+
    return type->getFullyQualifiedExportName();
 }
 
-static const char* getDocString( const EngineExport* exportInfo )
+static const char* getDocString(const EngineExport* exportInfo)
 {
-   if( !exportInfo->getDocString() )
+   if (!exportInfo->getDocString())
       return "";
-   
+
    return exportInfo->getDocString();
 }
 
 template< typename T >
-inline T getArgValue( const EngineFunctionDefaultArguments* defaultArgs, U32 offset )
+inline T getArgValue(const EngineFunctionDefaultArguments* defaultArgs, U32 offset)
 {
-   return *reinterpret_cast< const T* >( defaultArgs->getArgs() + offset );
+   return *reinterpret_cast< const T* >(defaultArgs->getArgs() + offset);
 }
 
 
@@ -71,14 +71,14 @@ static const char* sExportFilterList[] =
    "Console", // Console namespace
 };
 
-static bool isExportFiltered( const EngineExport* exportInfo )
+static bool isExportFiltered(const EngineExport* exportInfo)
 {
    String qualifiedName = exportInfo->getFullyQualifiedExportName();
-   
-   for( U32 i = 0; i < ( sizeof( sExportFilterList ) / sizeof( sExportFilterList[ 0 ] ) ); ++ i )
-      if( qualifiedName.compare( sExportFilterList[ i ] ) == 0 )
+
+   for (U32 i = 0; i < (sizeof(sExportFilterList) / sizeof(sExportFilterList[0])); ++i)
+      if (qualifiedName.compare(sExportFilterList[i]) == 0)
          return true;
-         
+
    return false;
 }
 
@@ -90,248 +90,248 @@ static bool isExportFiltered( const EngineExport* exportInfo )
 //-----------------------------------------------------------------------------
 
 /// Helper to parse argument names out of a prototype string.
-static Vector< String > parseFunctionArgumentNames( const EngineFunctionInfo* function )
+static Vector< String > parseFunctionArgumentNames(const EngineFunctionInfo* function)
 {
    Vector< String > argNames;
-   
+
    const char* prototype = function->getPrototypeString();
-   if( !prototype )
+   if (!prototype)
       return argNames;
-      
-   const U32 prototypeLength = dStrlen( prototype );
-   const char* prototypeEnd = &prototype[ prototypeLength ];
+
+   const U32 prototypeLength = dStrlen(prototype);
+   const char* prototypeEnd = &prototype[prototypeLength];
    const char* ptr = prototypeEnd - 1;
-   
+
    // Search for right parenthesis.
-   while( ptr >= prototype && *ptr != ')' )
-      ptr --;
-      
-   if( ptr < prototype )
+   while (ptr >= prototype && *ptr != ')')
+      ptr--;
+
+   if (ptr < prototype)
       return argNames;
-   ptr --;
-   
-   while( ptr >= prototype && *ptr != '(' )
+   ptr--;
+
+   while (ptr >= prototype && *ptr != '(')
    {
       // Skip back over spaces.
-      
-      while( ptr >= prototype && dIsspace( *ptr ) )
-         ptr --;
-      if( ptr < prototype )
+
+      while (ptr >= prototype && dIsspace(*ptr))
+         ptr--;
+      if (ptr < prototype)
          return argNames;
-         
+
       // Parse out name.
-      
+
       const char* end = ptr + 1;
-      while( ptr > prototype && dIsalnum( *ptr ) )
-         ptr --;
+      while (ptr > prototype && dIsalnum(*ptr))
+         ptr--;
       const char* start = ptr + 1;
-               
+
       // Skip back over spaces.
 
-      while( ptr >= prototype && dIsspace( *ptr ) )
-         ptr --;
-         
+      while (ptr >= prototype && dIsspace(*ptr))
+         ptr--;
+
       // If we're sure we don't have just a type name without an
       // argument name, copy out the argument name name. 
 
-      if( ptr >= prototype && *ptr != ',' && *ptr != '(' && end > start )
-         argNames.push_front( String( start, end - start ) );
+      if (ptr >= prototype && *ptr != ',' && *ptr != '(' && end > start)
+         argNames.push_front(String(start, end - start));
       else
-         argNames.push_front( "" );
-      
+         argNames.push_front("");
+
       // Skip back to comma or opening parenthesis.
-      
+
       U32 parenNestingCount = 0;
-      while( ptr >= prototype )
+      while (ptr >= prototype)
       {
-         if( *ptr == ')' )
-            parenNestingCount ++;
-         else if( *ptr == '(' )
-            parenNestingCount --;
-         else if( *ptr == ',' && parenNestingCount == 0 )
+         if (*ptr == ')')
+            parenNestingCount++;
+         else if (*ptr == '(')
+            parenNestingCount--;
+         else if (*ptr == ',' && parenNestingCount == 0)
          {
-            ptr --;
+            ptr--;
             break;
          }
-         else if( *ptr == '(' && parenNestingCount == 0 )
+         else if (*ptr == '(' && parenNestingCount == 0)
             break;
-            
-         ptr --;
+
+         ptr--;
       }
    }
-   
+
    // Add 'this' parameter if this is a method.
-      
-   if( dStrncmp( prototype, "virtual ", sizeof( "virtual " ) - 1 ) == 0 )
-      argNames.push_front( "this" );
+
+   if (dStrncmp(prototype, "virtual ", sizeof("virtual ") - 1) == 0)
+      argNames.push_front("this");
 
    return argNames;
 }
 
 //-----------------------------------------------------------------------------
 
-static String getDefaultArgumentValue( const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 offset )
+static String getDefaultArgumentValue(const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 offset)
 {
    String value;
    const EngineFunctionDefaultArguments* defaultArgs = function->getDefaultArguments();
-   
-   switch( type->getTypeKind() )
+
+   switch (type->getTypeKind())
    {
-      case EngineTypeKindPrimitive:
-      {
-         #define PRIMTYPE( tp )                                               \
+   case EngineTypeKindPrimitive:
+   {
+#define PRIMTYPE( tp )                                               \
             if( TYPE< tp >() == type )                                        \
             {                                                                 \
                tp val = getArgValue< tp >( defaultArgs, offset );             \
                value = String::ToString( val );                               \
             }
-            
-         PRIMTYPE( bool );
-         PRIMTYPE( S8 );
-         PRIMTYPE( U8 );
-         PRIMTYPE( S32 );
-         PRIMTYPE( U32 );
-         PRIMTYPE( F32 );
-         PRIMTYPE( F64 );
-         
-         //TODO: for now we store string literals in ASCII; needs to be sorted out
-         if( TYPE< const char* >() == type )
-         {
-            const char* val = getArgValue< const char* >( defaultArgs, offset );
-            value = val;
-         }
-            
-         #undef PRIMTYPE
-         break;
-      }
-         
-      case EngineTypeKindEnum:
-      {
-         S32 val = getArgValue< S32 >( defaultArgs, offset );
-         AssertFatal( type->getEnumTable(), "engineXMLExport - Enum type without table!" );
-         
-         const EngineEnumTable& table = *( type->getEnumTable() );
-         const U32 numValues = table.getNumValues();
-         
-         for( U32 i = 0; i < numValues; ++ i )
-            if( table[ i ].getInt() == val )
-            {
-               value = table[ i ].getName();
-               break;
-            }
-               
-         break;
-      }
 
-      case EngineTypeKindBitfield:
-      {
-         S32 val = getArgValue< S32 >( defaultArgs, offset );
-         AssertFatal( type->getEnumTable(), "engineXMLExport - Bitfield type without table!" );
-         
-         const EngineEnumTable& table = *( type->getEnumTable() );
-         const U32 numValues = table.getNumValues();
-         
-         bool isFirst = true;
-         for( U32 i = 0; i < numValues; ++ i )
-            if( table[ i ].getInt() & val )
-            {
-               if( !isFirst )
-                  value += '|';
-                  
-               value = table[ i ].getName();
-               isFirst = false;
-            }
+      PRIMTYPE(bool);
+      PRIMTYPE(S8);
+      PRIMTYPE(U8);
+      PRIMTYPE(S32);
+      PRIMTYPE(U32);
+      PRIMTYPE(F32);
+      PRIMTYPE(F64);
 
-         break;
-      }
-      
-      case EngineTypeKindStruct:
+      //TODO: for now we store string literals in ASCII; needs to be sorted out
+      if (TYPE< const char* >() == type)
       {
-         //TODO: struct type default argument values
-         break;
-      }
-         
-      case EngineTypeKindClass:
-      case EngineTypeKindFunction:
-      {
-         // For these two kinds, we support "null" as the only valid
-         // default value.
-         
-         const void* ptr = getArgValue< const void* >( defaultArgs, offset );
-         if( !ptr )
-            value = "null";
-         break;
+         const char* val = reinterpret_cast<const char*>(defaultArgs->getArgs() + offset);
+         value = val;
       }
-      
-      default:
-         break;
+
+#undef PRIMTYPE
+      break;
    }
-   
+
+   case EngineTypeKindEnum:
+   {
+      S32 val = getArgValue< S32 >(defaultArgs, offset);
+      AssertFatal(type->getEnumTable(), "engineXMLExport - Enum type without table!");
+
+      const EngineEnumTable& table = *(type->getEnumTable());
+      const U32 numValues = table.getNumValues();
+
+      for (U32 i = 0; i < numValues; ++i)
+         if (table[i].getInt() == val)
+         {
+            value = table[i].getName();
+            break;
+         }
+
+      break;
+   }
+
+   case EngineTypeKindBitfield:
+   {
+      S32 val = getArgValue< S32 >(defaultArgs, offset);
+      AssertFatal(type->getEnumTable(), "engineXMLExport - Bitfield type without table!");
+
+      const EngineEnumTable& table = *(type->getEnumTable());
+      const U32 numValues = table.getNumValues();
+
+      bool isFirst = true;
+      for (U32 i = 0; i < numValues; ++i)
+         if (table[i].getInt() & val)
+         {
+            if (!isFirst)
+               value += '|';
+
+            value = table[i].getName();
+            isFirst = false;
+         }
+
+      break;
+   }
+
+   case EngineTypeKindStruct:
+   {
+      //TODO: struct type default argument values
+      break;
+   }
+
+   case EngineTypeKindClass:
+   case EngineTypeKindFunction:
+   {
+      // For these two kinds, we support "null" as the only valid
+      // default value.
+
+      const void* ptr = getArgValue< const void* >(defaultArgs, offset);
+      if (!ptr)
+         value = "null";
+      break;
+   }
+
+   default:
+      break;
+   }
+
    return value;
 }
 
 //-----------------------------------------------------------------------------
 
-static void exportFunction( const EngineFunctionInfo* function, SimXMLDocument* xml )
+static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* xml)
 {
-   if( isExportFiltered( function ) )
+   if (isExportFiltered(function))
       return;
-      
-   xml->pushNewElement( "EngineFunction" );
-      
-      xml->setAttribute( "name", function->getExportName() );
-      xml->setAttribute( "returnType", getTypeName( function->getReturnType() ) );
-      xml->setAttribute( "symbol", function->getBindingName() );
-      xml->setAttribute( "isCallback", function->isCallout() ? "1" : "0" );
-      xml->setAttribute( "isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0" );
-      xml->setAttribute( "docs", getDocString( function ) );
-      
-      xml->pushNewElement( "arguments" );
-      
-         const U32 numArguments = function->getNumArguments();
-         const U32 numDefaultArguments = ( function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0 );
-         const U32 firstDefaultArg = numArguments - numDefaultArguments;
-         
-         Vector< String > argumentNames = parseFunctionArgumentNames( function );
-         const U32 numArgumentNames = argumentNames.size();
-         
-         // Accumulated offset in function argument frame vector.
-         U32 argFrameOffset = 0;
-         
-         for( U32 i = 0; i < numArguments; ++ i )
-         {
-            xml->pushNewElement( "EngineFunctionArgument" );
-            const EngineTypeInfo* type = function->getArgumentType( i );
-            AssertFatal( type != NULL, "exportFunction - Argument cannot have type void!" );
-            
-            String argName;
-            if( i < numArgumentNames )
-               argName = argumentNames[ i ];
-               
-            xml->setAttribute( "name", argName );
-            xml->setAttribute( "type", getTypeName( type ) );
-            
-            if( i >= firstDefaultArg )
-            {
-               String defaultValue = getDefaultArgumentValue( function, type, argFrameOffset );
-               xml->setAttribute( "defaultValue", defaultValue );
-            }
 
-            xml->popElement();
-            
-            if( type->getTypeKind() == EngineTypeKindStruct )
-               argFrameOffset += type->getInstanceSize();
-            else
-               argFrameOffset += type->getValueSize();
-               
-            #ifdef _PACK_BUG_WORKAROUNDS
-            if( argFrameOffset % 4 > 0 )
-               argFrameOffset += 4 - ( argFrameOffset % 4 );
-            #endif
-         }
-         
+   xml->pushNewElement("EngineFunction");
+
+   xml->setAttribute("name", function->getExportName());
+   xml->setAttribute("returnType", getTypeName(function->getReturnType()));
+   xml->setAttribute("symbol", function->getBindingName());
+   xml->setAttribute("isCallback", function->isCallout() ? "1" : "0");
+   xml->setAttribute("isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0");
+   xml->setAttribute("docs", getDocString(function));
+
+   xml->pushNewElement("arguments");
+
+   const U32 numArguments = function->getNumArguments();
+   const U32 numDefaultArguments = (function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0);
+   const U32 firstDefaultArg = numArguments - numDefaultArguments;
+
+   Vector< String > argumentNames = parseFunctionArgumentNames(function);
+   const U32 numArgumentNames = argumentNames.size();
+
+   // Accumulated offset in function argument frame vector.
+   U32 argFrameOffset = 0;
+
+   for (U32 i = 0; i < numArguments; ++i)
+   {
+      xml->pushNewElement("EngineFunctionArgument");
+      const EngineTypeInfo* type = function->getArgumentType(i);
+      AssertFatal(type != NULL, "exportFunction - Argument cannot have type void!");
+
+      String argName;
+      if (i < numArgumentNames)
+         argName = argumentNames[i];
+
+      xml->setAttribute("name", argName);
+      xml->setAttribute("type", getTypeName(type));
+
+      if (i >= firstDefaultArg)
+      {
+         String defaultValue = getDefaultArgumentValue(function, type, argFrameOffset);
+         xml->setAttribute("defaultValue", defaultValue);
+      }
+
       xml->popElement();
-         
+
+      if (type->getTypeKind() == EngineTypeKindStruct)
+         argFrameOffset += type->getInstanceSize();
+      else
+         argFrameOffset += type->getValueSize();
+
+#ifdef _PACK_BUG_WORKAROUNDS
+      if (argFrameOffset % 4 > 0)
+         argFrameOffset += 4 - (argFrameOffset % 4);
+#endif
+   }
+
+   xml->popElement();
+
    xml->popElement();
 }
 
@@ -343,148 +343,172 @@ static void exportFunction( const EngineFunctionInfo* function, SimXMLDocument*
 
 //-----------------------------------------------------------------------------
 
-static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
+static void exportType(const EngineTypeInfo* type, SimXMLDocument* xml)
 {
    // Don't export anonymous types.
-   if( !type->getTypeName()[ 0 ] )
+   if (!type->getTypeName()[0])
       return;
-      
-   if( isExportFiltered( type ) )
+
+   if (isExportFiltered(type))
       return;
-      
+
    const char* nodeName = NULL;
-   switch( type->getTypeKind() )
+   switch (type->getTypeKind())
    {
-      case EngineTypeKindPrimitive:
-         nodeName = "EnginePrimitiveType";
-         break;
-         
-      case EngineTypeKindEnum:
-         nodeName = "EngineEnumType";
-         break;
-         
-      case EngineTypeKindBitfield:
-         nodeName = "EngineBitfieldType";
-         break;
-         
-      case EngineTypeKindStruct:
-         nodeName = "EngineStructType";
-         break;
-         
-      case EngineTypeKindClass:
-         nodeName = "EngineClassType";
-         break;
-      
-      default:
-         return;
+   case EngineTypeKindPrimitive:
+      nodeName = "EnginePrimitiveType";
+      break;
+
+   case EngineTypeKindEnum:
+      nodeName = "EngineEnumType";
+      break;
+
+   case EngineTypeKindBitfield:
+      nodeName = "EngineBitfieldType";
+      break;
+
+   case EngineTypeKindStruct:
+      nodeName = "EngineStructType";
+      break;
+
+   case EngineTypeKindClass:
+      nodeName = "EngineClassType";
+      break;
+
+   default:
+      return;
    }
-   
-   xml->pushNewElement( nodeName );
-
-      xml->setAttribute( "name", type->getTypeName() );
-      xml->setAttribute( "size", String::ToString( type->getInstanceSize() ) );
-      xml->setAttribute( "isAbstract", type->isAbstract() ? "1" : "0" );
-      xml->setAttribute( "isInstantiable", type->isInstantiable() ? "1" : "0" );
-      xml->setAttribute( "isDisposable", type->isDisposable() ? "1" : "0" );
-      xml->setAttribute( "isSingleton", type->isSingleton() ? "1" : "0" );
-      xml->setAttribute( "docs", getDocString( type ) );
-      
-      if( type->getSuperType() )
-         xml->setAttribute( "superType", getTypeName( type->getSuperType() ) );
-      
-      if( type->getEnumTable() )
+
+   xml->pushNewElement(nodeName);
+
+   xml->setAttribute("name", type->getTypeName());
+   xml->setAttribute("size", String::ToString(type->getInstanceSize()));
+   xml->setAttribute("isAbstract", type->isAbstract() ? "1" : "0");
+   xml->setAttribute("isInstantiable", type->isInstantiable() ? "1" : "0");
+   xml->setAttribute("isDisposable", type->isDisposable() ? "1" : "0");
+   xml->setAttribute("isSingleton", type->isSingleton() ? "1" : "0");
+   xml->setAttribute("docs", getDocString(type));
+
+   if (type->getSuperType())
+      xml->setAttribute("superType", getTypeName(type->getSuperType()));
+
+   if (type->getEnumTable())
+   {
+      xml->pushNewElement("enums");
+
+      const EngineEnumTable& table = *(type->getEnumTable());
+      const U32 numValues = table.getNumValues();
+
+      for (U32 i = 0; i < numValues; ++i)
       {
-         xml->pushNewElement( "enums" );
-         
-            const EngineEnumTable& table = *( type->getEnumTable() );
-            const U32 numValues = table.getNumValues();
-            
-            for( U32 i = 0; i < numValues; ++ i )
-            {
-               xml->pushNewElement( "EngineEnum" );
-               
-                  xml->setAttribute( "name", table[ i ].getName() );
-                  xml->setAttribute( "value", String::ToString( table[ i ].getInt() ) );
-                  xml->setAttribute( "docs", table[ i ].getDocString() ? table[ i ].getDocString() : "" );
-                  
-               xml->popElement();
-            }
-            
+         xml->pushNewElement("EngineEnum");
+
+         xml->setAttribute("name", table[i].getName());
+         xml->setAttribute("value", String::ToString(table[i].getInt()));
+         xml->setAttribute("docs", table[i].getDocString() ? table[i].getDocString() : "");
+
          xml->popElement();
       }
-      else if( type->getFieldTable() )
+
+      xml->popElement();
+   }
+   else if (type->getFieldTable())
+   {
+      xml->pushNewElement("fields");
+
+      const EngineFieldTable& table = *(type->getFieldTable());
+      const U32 numFields = table.getNumFields();
+
+      for (U32 i = 0; i < numFields; ++i)
       {
-         xml->pushNewElement( "fields" );
-         
-            const EngineFieldTable& table = *( type->getFieldTable() );
-            const U32 numFields = table.getNumFields();
-            
-            for( U32 i = 0; i < numFields; ++ i )
-            {
-               const EngineFieldTable::Field& field = table[ i ];
-               
-               xml->pushNewElement( "EngineField" );
-               
-                  xml->setAttribute( "name", field.getName() );
-                  xml->setAttribute( "type", getTypeName( field.getType() ) );
-                  xml->setAttribute( "offset", String::ToString( field.getOffset() ) );
-                  xml->setAttribute( "indexedSize", String::ToString( field.getNumElements() ) );
-                  xml->setAttribute( "docs", field.getDocString() ? field.getDocString() : "" );
-               
-               xml->popElement();
-            }
-         
+         const EngineFieldTable::Field& field = table[i];
+
+         xml->pushNewElement("EngineField");
+
+         xml->setAttribute("name", field.getName());
+         xml->setAttribute("type", getTypeName(field.getType()));
+         xml->setAttribute("offset", String::ToString(field.getOffset()));
+         xml->setAttribute("indexedSize", String::ToString(field.getNumElements()));
+         xml->setAttribute("docs", field.getDocString() ? field.getDocString() : "");
+
          xml->popElement();
       }
-      else if( type->getPropertyTable() )
+
+      xml->popElement();
+   }
+   else if (type->getPropertyTable())
+   {
+      xml->pushNewElement("properties");
+
+      const EnginePropertyTable& table = *(type->getPropertyTable());
+      const U32 numProperties = table.getNumProperties();
+      U32 groupNestingDepth = 0;
+
+      for (U32 i = 0; i < numProperties; ++i)
       {
-         xml->pushNewElement( "properties" );
-         
-            const EnginePropertyTable& table = *( type->getPropertyTable() );
-            const U32 numProperties = table.getNumProperties();
-            U32 groupNestingDepth = 0;
-            
-            for( U32 i = 0; i < numProperties; ++ i )
+         const EnginePropertyTable::Property& property = table[i];
+
+         if (property.isGroupBegin())
+         {
+            groupNestingDepth++;
+            xml->pushNewElement("EnginePropertyGroup");
+
+            xml->setAttribute("name", property.getName());
+            xml->setAttribute("indexedSize", String::ToString(property.getNumElements()));
+            xml->setAttribute("docs", property.getDocString() ? property.getDocString() : "");
+
+            xml->pushNewElement("properties");
+         }
+         else if (property.isGroupEnd())
+         {
+            groupNestingDepth--;
+            xml->popElement();
+            xml->popElement();
+         }
+         else
+         {
+            if (property.getType() == AbstractClassRep::StartArrayFieldType
+               || property.getType() == AbstractClassRep::EndArrayFieldType) {
+               continue;
+            }
+            xml->pushNewElement("EngineProperty");
+
+            xml->setAttribute("name", property.getName());
+            xml->setAttribute("indexedSize", String::ToString(property.getNumElements()));
+            xml->setAttribute("isConstant", property.isConstant() ? "1" : "0");
+            xml->setAttribute("isTransient", property.isTransient() ? "1" : "0");
+            xml->setAttribute("isVisible", property.hideInInspectors() ? "0" : "1");
+            xml->setAttribute("docs", property.getDocString() ? property.getDocString() : "");
+
+
+            const bool isDeprecated = (property.getType() == AbstractClassRep::DeprecatedFieldType);
+
+            if (isDeprecated)
             {
-               const EnginePropertyTable::Property& property = table[ i ];
-               
-               if( property.isGroupBegin() )
-               {
-                  groupNestingDepth ++;
-                  xml->pushNewElement( "EnginePropertyGroup" );
-                  
-                     xml->setAttribute( "name", property.getName() );
-                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
-                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
-                     
-                     xml->pushNewElement( "properties" );
-               }
-               else if( property.isGroupEnd() )
+               xml->setAttribute("type", "deprecated");
+            }
+            else
+            {
+               ConsoleBaseType *cbt = ConsoleBaseType::getType(property.getType());
+               if (cbt != NULL)
                {
-                  groupNestingDepth --;
-                  xml->popElement();
-                  xml->popElement();
+                  xml->setAttribute("type", cbt->getTypeClassName());
                }
                else
                {
-                  xml->pushNewElement( "EngineProperty" );
-                  
-                     xml->setAttribute( "name", property.getName() );
-                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
-                     xml->setAttribute( "isConstant", property.isConstant() ? "1" : "0" );
-                     xml->setAttribute( "isTransient", property.isTransient() ? "1" : "0" );
-                     xml->setAttribute( "isVisible", property.hideInInspectors() ? "0" : "1" );
-                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
-                  
-                  xml->popElement();
+                  xml->setAttribute("type", "unknown");
                }
             }
-         
-         AssertFatal( !groupNestingDepth, "exportType - Property group nesting mismatch!" );
-         xml->popElement();
-      }      
-      exportScope( type, xml );
-      
+
+            xml->popElement();
+         }
+      }
+
+      AssertFatal(!groupNestingDepth, "exportType - Property group nesting mismatch!");
+      xml->popElement();
+   }
+   exportScope(type, xml);
+
    xml->popElement();
 }
 
@@ -496,63 +520,63 @@ static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
 
 //-----------------------------------------------------------------------------
 
-static void exportScope( const EngineExportScope* scope, SimXMLDocument* xml, bool addNode )
+static void exportScope(const EngineExportScope* scope, SimXMLDocument* xml, bool addNode)
 {
-   if( addNode )
+   if (addNode)
    {
-      if( isExportFiltered( scope ) )
+      if (isExportFiltered(scope))
          return;
-         
-      xml->pushNewElement( "EngineExportScope" );
-      
-         xml->setAttribute( "name", scope->getExportName() );
-         xml->setAttribute( "docs", getDocString( scope ) );
+
+      xml->pushNewElement("EngineExportScope");
+
+      xml->setAttribute("name", scope->getExportName());
+      xml->setAttribute("docs", getDocString(scope));
    }
 
    // Dump all contained exports.
-   
-   xml->pushNewElement( "exports" );
-   
-      for( const EngineExport* exportInfo = scope->getExports(); exportInfo != NULL; exportInfo = exportInfo->getNextExport() )
+
+   xml->pushNewElement("exports");
+
+   for (const EngineExport* exportInfo = scope->getExports(); exportInfo != NULL; exportInfo = exportInfo->getNextExport())
+   {
+      switch (exportInfo->getExportKind())
       {
-         switch( exportInfo->getExportKind() )
-         {
-            case EngineExportKindScope:
-               exportScope( static_cast< const EngineExportScope* >( exportInfo ), xml, true );
-               break;
-               
-            case EngineExportKindFunction:
-               exportFunction( static_cast< const EngineFunctionInfo* >( exportInfo ), xml );
-               break;
-               
-            case EngineExportKindType:
-               exportType( static_cast< const EngineTypeInfo* >( exportInfo ), xml );
-               break;
-               
-            default:
-               break;
-         }
+      case EngineExportKindScope:
+         exportScope(static_cast< const EngineExportScope* >(exportInfo), xml, true);
+         break;
+
+      case EngineExportKindFunction:
+         exportFunction(static_cast< const EngineFunctionInfo* >(exportInfo), xml);
+         break;
+
+      case EngineExportKindType:
+         exportType(static_cast< const EngineTypeInfo* >(exportInfo), xml);
+         break;
+
+      default:
+         break;
       }
-      
+   }
+
    xml->popElement();
-   
-   if( addNode )
+
+   if (addNode)
       xml->popElement();
 }
 
 //-----------------------------------------------------------------------------
 
-DefineEngineFunction( exportEngineAPIToXML, SimXMLDocument*, (),,
+DefineEngineFunction(exportEngineAPIToXML, SimXMLDocument*, (), ,
    "Create a XML document containing a dump of the entire exported engine API.\n\n"
    "@return A SimXMLDocument containing a dump of the engine's export information or NULL if the operation failed.\n\n"
-   "@ingroup Console" )
+   "@ingroup Console")
 {
    SimXMLDocument* xml = new SimXMLDocument;
    xml->registerObject();
-   Sim::getRootGroup()->addObject( xml );
+   Sim::getRootGroup()->addObject(xml);
    xml->addHeader();
-   
-   exportScope( EngineExportScope::getGlobalScope(), xml, true );
-   
+
+   exportScope(EngineExportScope::getGlobalScope(), xml, true);
+
    return xml;
-}
+}

+ 4 - 4
Engine/source/console/fieldBrushObject.cpp

@@ -123,7 +123,7 @@ static char* suppressSpaces(const char* in_pname)
 //-----------------------------------------------------------------------------
 // Query Groups.
 //-----------------------------------------------------------------------------
-DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n"
+DefineEngineMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n"
                                                                 "@param simObject Object to query static-field groups on.\n"
                                                              "@return Space-seperated static-field group list.")
 {
@@ -191,7 +191,7 @@ DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* sim
 //-----------------------------------------------------------------------------
 // Query Fields.
 //-----------------------------------------------------------------------------
-DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n"
+DefineEngineMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n"
                                                                 "@param simObject Object to query static-fields on.\n"
                                                                 "@param groupList groups to filter static-fields against.\n"
                                                              "@return Space-seperated static-field list.")
@@ -366,7 +366,7 @@ DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* sim
 //-----------------------------------------------------------------------------
 // Copy Fields.
 //-----------------------------------------------------------------------------
-DefineConsoleMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n"
+DefineEngineMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n"
                                                         "@param simObject Object to copy static-fields from.\n"
                                                         "@param fieldList fields to filter static-fields against.\n"
                                                      "@return No return value.")
@@ -500,7 +500,7 @@ void FieldBrushObject::copyFields( SimObject* pSimObject, const char* fieldList
 //-----------------------------------------------------------------------------
 // Paste Fields.
 //-----------------------------------------------------------------------------
-DefineConsoleMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n"
+DefineEngineMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n"
                                                         "@param simObject Object to paste static-fields to.\n"
                                                      "@return No return value.")
 {

+ 153 - 0
Engine/source/console/fixedTuple.h

@@ -0,0 +1,153 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2012 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#ifndef _FIXEDTUPLE_H_
+#define _FIXEDTUPLE_H_
+/// @name Fixed-layout tuple definition
+/// These structs and templates serve as a way to pass arguments from external 
+/// applications and into the T3D console system.
+/// They work as std::tuple, but they ensure a standardized fixed memory 
+/// layout. Allowing for unmanaged calls with these tuples as the parameter 
+/// lists.
+///
+/// The implementation is from a SO solution:
+/// https://codereview.stackexchange.com/a/52279
+/// As out use-case is pretty simple, this code could probably be simplified by 
+/// stripping out a lot of extra functionality. But eh.
+///
+/// @{
+
+template <typename ...Ts>
+struct fixed_tuple;
+
+template <typename T, typename ...Ts>
+struct fixed_tuple<T, Ts...>
+{
+   T first;
+   fixed_tuple<Ts...> rest;
+
+   fixed_tuple() = default;
+   template <class U, class...Us, class = typename ::std::enable_if<!::std::is_base_of<fixed_tuple, typename ::std::decay<U>::type>::value>::type>
+   fixed_tuple(U&& u, Us&&...tail) :
+      first(::std::forward<U>(u)),
+      rest(::std::forward<Us>(tail)...) {}
+};
+
+template <typename T>
+struct fixed_tuple<T>
+{
+   T first;
+
+   fixed_tuple() = default;
+   template <class U, class = typename ::std::enable_if<!::std::is_base_of<fixed_tuple, typename ::std::decay<U>::type>::value>::type>
+   fixed_tuple(U&& u) :
+      first(::std::forward<U>(u)) {}
+};
+
+template <>
+struct fixed_tuple<> {};
+
+
+template < ::std::size_t i, class T>
+struct fixed_tuple_element;
+
+template < ::std::size_t i, class T, class... Ts>
+struct fixed_tuple_element<i, fixed_tuple<T, Ts...> >
+   : fixed_tuple_element<i - 1, fixed_tuple<Ts...> >
+{};
+
+template <class T, class... Ts>
+struct fixed_tuple_element<0, fixed_tuple<T, Ts...> >
+{
+   using type = T;
+};
+
+template < ::std::size_t i>
+struct fixed_tuple_accessor
+{
+   template <class... Ts>
+   static inline typename fixed_tuple_element<i, fixed_tuple<Ts...> >::type & get(fixed_tuple<Ts...> & t)
+   {
+      return fixed_tuple_accessor<i - 1>::get(t.rest);
+   }
+
+   template <class... Ts>
+   static inline const typename fixed_tuple_element<i, fixed_tuple<Ts...> >::type & get(const fixed_tuple<Ts...> & t)
+   {
+      return fixed_tuple_accessor<i - 1>::get(t.rest);
+   }
+};
+
+template <>
+struct fixed_tuple_accessor<0>
+{
+   template <class... Ts>
+   static inline typename fixed_tuple_element<0, fixed_tuple<Ts...> >::type & get(fixed_tuple<Ts...> & t)
+   {
+      return t.first;
+   }
+
+   template <class... Ts>
+   static inline const typename fixed_tuple_element<0, fixed_tuple<Ts...> >::type & get(const fixed_tuple<Ts...> & t)
+   {
+      return t.first;
+   }
+};
+
+template< typename T1, typename T2 >
+struct fixed_tuple_mutator {};
+
+template<typename... Tdest, typename... Tsrc>
+struct fixed_tuple_mutator<void(Tdest...), void(Tsrc...)>
+{
+   template<std::size_t I = 0>
+   static inline typename std::enable_if<I == sizeof...(Tsrc), void>::type
+      copy_r_t_l(fixed_tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
+   { }
+
+   template<std::size_t I = 0>
+   static inline typename std::enable_if<I < sizeof...(Tsrc), void>::type
+      copy_r_t_l(fixed_tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
+   {
+      fixed_tuple_accessor<I + (sizeof...(Tdest)-sizeof...(Tsrc))>::get(dest) = fixed_tuple_accessor<I>::get(src);
+      copy_r_t_l<I + 1>(src, dest);
+   }
+
+   template<std::size_t I = 0>
+   static inline typename std::enable_if<I == sizeof...(Tsrc), void>::type
+      copy(std::tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
+   { }
+
+   template<std::size_t I = 0>
+   static inline typename std::enable_if<I < sizeof...(Tsrc), void>::type
+      copy(std::tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
+   {
+      fixed_tuple_accessor<I>::get(dest) = std::get<I>(src);
+      copy<I + 1>(src, dest);
+   }
+};
+
+
+/// @}
+
+
+#endif // !_FIXEDTUPLE_H_

+ 13 - 13
Engine/source/console/persistenceManager.cpp

@@ -2190,14 +2190,14 @@ void PersistenceManager::deleteObjectsFromFile(const char* fileName)
    clearAll();
 }
 
-DefineConsoleMethod( PersistenceManager, deleteObjectsFromFile, void, ( const char * fileName ), , "( fileName )"
+DefineEngineMethod( PersistenceManager, deleteObjectsFromFile, void, ( const char * fileName ), , "( fileName )"
               "Delete all of the objects that are created from the given file." )
 {
    // Delete Objects.
    object->deleteObjectsFromFile( fileName );
 }
 
-DefineConsoleMethod( PersistenceManager, setDirty, void,  ( const char * objName, const char * fileName ), (""), "(SimObject object, [filename])"
+DefineEngineMethod( PersistenceManager, setDirty, void,  ( const char * objName, const char * fileName ), (""), "(SimObject object, [filename])"
               "Mark an existing SimObject as dirty (will be written out when saveDirty() is called).")
 {
    SimObject *dirtyObject = NULL;
@@ -2226,7 +2226,7 @@ DefineConsoleMethod( PersistenceManager, setDirty, void,  ( const char * objName
    }
 }
 
-DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objName ), , "(SimObject object)"
+DefineEngineMethod( PersistenceManager, removeDirty, void, ( const char * objName ), , "(SimObject object)"
               "Remove a SimObject from the dirty list.")
 {
    SimObject *dirtyObject = NULL;
@@ -2243,7 +2243,7 @@ DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objNa
       object->removeDirty(dirtyObject);
 }
 
-DefineConsoleMethod( PersistenceManager, isDirty, bool, ( const char * objName ), , "(SimObject object)"
+DefineEngineMethod( PersistenceManager, isDirty, bool, ( const char * objName ), , "(SimObject object)"
               "Returns true if the SimObject is on the dirty list.")
 {
    SimObject *dirtyObject = NULL;
@@ -2262,19 +2262,19 @@ DefineConsoleMethod( PersistenceManager, isDirty, bool, ( const char * objName )
    return false;
 }
 
-DefineConsoleMethod( PersistenceManager, hasDirty, bool, (), , "()"
+DefineEngineMethod( PersistenceManager, hasDirty, bool, (), , "()"
               "Returns true if the manager has dirty objects to save." )
 {
    return object->hasDirty();
 }
 
-DefineConsoleMethod( PersistenceManager, getDirtyObjectCount, S32, (), , "()"
+DefineEngineMethod( PersistenceManager, getDirtyObjectCount, S32, (), , "()"
               "Returns the number of dirty objects." )
 {
    return object->getDirtyList().size();
 }
 
-DefineConsoleMethod( PersistenceManager, getDirtyObject, S32, (S32 index), , "( index )"
+DefineEngineMethod( PersistenceManager, getDirtyObject, S32, (S32 index), , "( index )"
               "Returns the ith dirty object." )
 {
    if ( index < 0 || index >= object->getDirtyList().size() )
@@ -2290,7 +2290,7 @@ DefineConsoleMethod( PersistenceManager, getDirtyObject, S32, (S32 index), , "(
    return ( dirtyObject.getObject() ) ? dirtyObject.getObject()->getId() : 0;
 }
 
-DefineConsoleMethod( PersistenceManager, listDirty, void, (), , "()"
+DefineEngineMethod( PersistenceManager, listDirty, void, (), , "()"
               "Prints the dirty list to the console.")
 {
    const PersistenceManager::DirtyList dirtyList = object->getDirtyList();
@@ -2318,13 +2318,13 @@ DefineConsoleMethod( PersistenceManager, listDirty, void, (), , "()"
    }
 }
 
-DefineConsoleMethod( PersistenceManager, saveDirty, bool, (), , "()"
+DefineEngineMethod( PersistenceManager, saveDirty, bool, (), , "()"
               "Saves all of the SimObject's on the dirty list to their respective files.")
 {
    return object->saveDirty();
 }
 
-DefineConsoleMethod( PersistenceManager, saveDirtyObject, bool, (const char * objName), , "(SimObject object)"
+DefineEngineMethod( PersistenceManager, saveDirtyObject, bool, (const char * objName), , "(SimObject object)"
               "Save a dirty SimObject to it's file.")
 {
    SimObject *dirtyObject = NULL;
@@ -2342,13 +2342,13 @@ DefineConsoleMethod( PersistenceManager, saveDirtyObject, bool, (const char * ob
    return false;
 }
 
-DefineConsoleMethod( PersistenceManager, clearAll, void, (), , "()"
+DefineEngineMethod( PersistenceManager, clearAll, void, (), , "()"
               "Clears all the tracked objects without saving them." )
 {
    object->clearAll();
 }
 
-DefineConsoleMethod( PersistenceManager, removeObjectFromFile, void, (const char * objName, const char * filename),("") , "(SimObject object, [filename])"
+DefineEngineMethod( PersistenceManager, removeObjectFromFile, void, (const char * objName, const char * filename),("") , "(SimObject object, [filename])"
               "Remove an existing SimObject from a file (can optionally specify a different file than \
                the one it was created in.")
 {
@@ -2371,7 +2371,7 @@ DefineConsoleMethod( PersistenceManager, removeObjectFromFile, void, (const char
    }
 }
 
-DefineConsoleMethod( PersistenceManager, removeField, void, (const char * objName, const char * fieldName), , "(SimObject object, string fieldName)"
+DefineEngineMethod( PersistenceManager, removeField, void, (const char * objName, const char * fieldName), , "(SimObject object, string fieldName)"
               "Remove a specific field from an object declaration.")
 {
    SimObject *dirtyObject = NULL;

+ 14 - 16
Engine/source/console/scriptFilename.cpp

@@ -27,7 +27,7 @@
 #include "core/tSimpleHashTable.h"
 #include "core/strings/stringFunctions.h"
 #include "core/stringTable.h"
-#include "console/console.h"
+#include "console/engineAPI.h"
 #include "console/compiler.h"
 
 
@@ -342,28 +342,26 @@ bool collapseScriptFilename(char *filename, U32 size, const char *src)
 // Console Functions
 //-----------------------------------------------------------------------------
 
-ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)"
-            "@brief Grabs the full path of a specified file\n\n"
-            "@param filename Name of the local file to locate\n"
-            "@return String containing the full filepath on disk\n"
-            "@ingroup FileSystem")
+DefineEngineFunction(expandFilename, const char*, (const char* filename),,
+   "@brief Grabs the full path of a specified file\n\n"
+   "@param filename Name of the local file to locate\n"
+   "@return String containing the full filepath on disk\n"
+   "@ingroup FileSystem")
 {
-   TORQUE_UNUSED(argc);
    static const U32 bufSize = 1024;
-   char* ret = Con::getReturnBuffer( bufSize );
-   Con::expandScriptFilename(ret, bufSize, argv[1]);
+   char* ret = Con::getReturnBuffer(bufSize);
+   Con::expandScriptFilename(ret, bufSize, filename);
    return ret;
 }
 
-ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)"
-            "@brief Retrofits a filepath that uses old Torque style\n\n"
-            "@return String containing filepath with new formatting\n"
-            "@ingroup FileSystem")
+DefineEngineFunction(expandOldFilename, const char*, (const char* filename),,
+   "@brief Retrofits a filepath that uses old Torque style\n\n"
+   "@return String containing filepath with new formatting\n"
+   "@ingroup FileSystem")
 {
-   TORQUE_UNUSED(argc);
    static const U32 bufSize = 1024;
-   char* ret = Con::getReturnBuffer( bufSize );
-   Con::expandOldScriptFilename(ret, bufSize, argv[1]);
+   char* ret = Con::getReturnBuffer(bufSize);
+   Con::expandOldScriptFilename(ret, bufSize, filename);
    return ret;
 }
 

+ 13 - 13
Engine/source/console/sim.cpp

@@ -86,7 +86,7 @@ namespace Sim
 
 ConsoleFunctionGroupBegin ( SimFunctions, "Functions relating to Sim.");
 
-DefineConsoleFunction( nameToID, S32, (const char * objectName), ,"nameToID(object)")
+DefineEngineFunction( nameToID, S32, (const char * objectName), ,"nameToID(object)")
 {
    SimObject *obj = Sim::findObject(objectName);
    if(obj)
@@ -95,7 +95,7 @@ DefineConsoleFunction( nameToID, S32, (const char * objectName), ,"nameToID(obje
       return -1;
 }
 
-DefineConsoleFunction( isObject, bool, (const char * objectName), ,"isObject(object)")
+DefineEngineFunction( isObject, bool, (const char * objectName), ,"isObject(object)")
 {
    if (!dStrcmp(objectName, "0") || !dStrcmp(objectName, ""))
       return false;
@@ -133,7 +133,7 @@ ConsoleDocFragment _spawnObject1(
    "bool spawnObject(class [, dataBlock, name, properties, script]);"
 );
 
-DefineConsoleFunction( spawnObject, S32, (   const char * spawnClass
+DefineEngineFunction( spawnObject, S32, (   const char * spawnClass
                                          ,   const char * spawnDataBlock
                                          ,   const char * spawnName
                                          ,   const char * spawnProperties
@@ -149,39 +149,39 @@ DefineConsoleFunction( spawnObject, S32, (   const char * spawnClass
       return -1;
 }
 
-DefineConsoleFunction( cancel, void, (S32 eventId), ,"cancel(eventId)")
+DefineEngineFunction( cancel, void, (S32 eventId), ,"cancel(eventId)")
 {
    Sim::cancelEvent(eventId);
 }
 
-DefineConsoleFunction( cancelAll, void, (const char * objectId), ,"cancelAll(objectId): cancel pending events on the specified object.  Events will be automatically cancelled if object is deleted.")
+DefineEngineFunction( cancelAll, void, (const char * objectId), ,"cancelAll(objectId): cancel pending events on the specified object.  Events will be automatically cancelled if object is deleted.")
 {
    Sim::cancelPendingEvents(Sim::findObject(objectId));
 }
 
-DefineConsoleFunction( isEventPending, bool, (S32 scheduleId), ,"isEventPending(%scheduleId);")
+DefineEngineFunction( isEventPending, bool, (S32 scheduleId), ,"isEventPending(%scheduleId);")
 {
    return Sim::isEventPending(scheduleId);
 }
 
-DefineConsoleFunction( getEventTimeLeft, S32, (S32 scheduleId), ,"getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.")
+DefineEngineFunction( getEventTimeLeft, S32, (S32 scheduleId), ,"getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.")
 {
    return Sim::getEventTimeLeft(scheduleId);
 }
 
-DefineConsoleFunction( getScheduleDuration, S32, (S32 scheduleId), ,"getScheduleDuration(%scheduleId);" )
+DefineEngineFunction( getScheduleDuration, S32, (S32 scheduleId), ,"getScheduleDuration(%scheduleId);" )
 {
    S32 ret = Sim::getScheduleDuration(scheduleId);
    return ret;
 }
 
-DefineConsoleFunction( getTimeSinceStart, S32, (S32 scheduleId), ,"getTimeSinceStart(%scheduleId);" )
+DefineEngineFunction( getTimeSinceStart, S32, (S32 scheduleId), ,"getTimeSinceStart(%scheduleId);" )
 {
    S32 ret = Sim::getTimeSinceStart(scheduleId);
    return ret;
 }
 
-ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1...argN>)")
+DefineEngineStringlyVariadicFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1...argN>)")
 {
    U32 timeDelta = U32(dAtof(argv[1]));
    SimObject *refObject = Sim::findObject(argv[2]);
@@ -202,7 +202,7 @@ ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1
    return ret;
 }
 
-DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), ,
+DefineEngineFunction( getUniqueName, const char*, (const char * baseName), ,
    "( String baseName )\n"
    "@brief Returns a unique unused SimObject name based on a given base name.\n\n"
    "@baseName Name to conver to a unique string if another instance exists\n"
@@ -221,7 +221,7 @@ DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), ,
    return buffer;
 }
 
-DefineConsoleFunction( getUniqueInternalName, const char*, (const char * baseName, const char * setString, bool searchChildren), ,
+DefineEngineFunction( getUniqueInternalName, const char*, (const char * baseName, const char * setString, bool searchChildren), ,
    "( String baseName, SimSet set, bool searchChildren )\n"
    "@brief Returns a unique unused internal name within the SimSet/Group based on a given base name.\n\n"
    "@note Currently only used by editors\n"
@@ -246,7 +246,7 @@ DefineConsoleFunction( getUniqueInternalName, const char*, (const char * baseNam
    return buffer;
 }
 
-DefineConsoleFunction( isValidObjectName, bool, (const char * name), , "( string name )"
+DefineEngineFunction( isValidObjectName, bool, (const char * name), , "( string name )"
             "@brief Return true if the given name makes for a valid object name.\n\n"
             "@param name Name of object\n"
             "@return True if name is allowed, false if denied (usually because it starts with a number, _, or invalid character"

+ 3 - 3
Engine/source/console/simDatablock.cpp

@@ -428,7 +428,7 @@ void SimDataBlock::write(Stream &stream, U32 tabStop, U32 flags)
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimDataBlock, reloadOnLocalClient, void, (),,
+DefineEngineMethod( SimDataBlock, reloadOnLocalClient, void, (),,
    "Reload the datablock.  This can only be used with a local client configuration." )
 {
    // Make sure we're running a local client.
@@ -464,7 +464,7 @@ DefineConsoleMethod( SimDataBlock, reloadOnLocalClient, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( preloadClientDataBlocks, void, (),,
+DefineEngineFunction( preloadClientDataBlocks, void, (),,
    "Preload all datablocks in client mode.\n\n"
    "(Server parameter is set to false).  This will take some time to complete.")
 {
@@ -482,7 +482,7 @@ DefineConsoleFunction( preloadClientDataBlocks, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleFunction( deleteDataBlocks, void, (),,
+DefineEngineFunction( deleteDataBlocks, void, (),,
    "Delete all the datablocks we've downloaded.\n\n"
    "This is usually done in preparation of downloading a new set of datablocks, "
    "such as occurs on a mission change, but it's also good post-mission cleanup." )

+ 31 - 31
Engine/source/console/simObject.cpp

@@ -2271,7 +2271,7 @@ DefineEngineMethod( SimObject, dumpGroupHierarchy, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, isMethod, bool, ( const char* methodName ),,
+DefineEngineMethod( SimObject, isMethod, bool, ( const char* methodName ),,
    "Test whether the given method is defined on this object.\n"
    "@param The name of the method.\n"
    "@return True if the object implements the given method." )
@@ -2291,7 +2291,7 @@ DefineEngineMethod( SimObject, isChildOfGroup, bool, ( SimGroup* group ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getClassNamespace, const char*, (),,
+DefineEngineMethod( SimObject, getClassNamespace, const char*, (),,
    "Get the name of the class namespace assigned to this object.\n"
    "@return The name of the 'class' namespace." )
 {
@@ -2300,7 +2300,7 @@ DefineConsoleMethod( SimObject, getClassNamespace, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getSuperClassNamespace, const char*, (),,
+DefineEngineMethod( SimObject, getSuperClassNamespace, const char*, (),,
    "Get the name of the superclass namespace assigned to this object.\n"
    "@return The name of the 'superClass' namespace." )
 {
@@ -2309,7 +2309,7 @@ DefineConsoleMethod( SimObject, getSuperClassNamespace, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setClassNamespace, void, ( const char* name ),,
+DefineEngineMethod( SimObject, setClassNamespace, void, ( const char* name ),,
    "Assign a class namespace to this object.\n"
    "@param name The name of the 'class' namespace for this object." )
 {
@@ -2318,7 +2318,7 @@ DefineConsoleMethod( SimObject, setClassNamespace, void, ( const char* name ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setSuperClassNamespace, void, ( const char* name ),,
+DefineEngineMethod( SimObject, setSuperClassNamespace, void, ( const char* name ),,
    "Assign a superclass namespace to this object.\n"
    "@param name The name of the 'superClass' namespace for this object." )
 {
@@ -2345,7 +2345,7 @@ DefineEngineMethod( SimObject, setIsSelected, void, ( bool state ), ( true ),
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, isExpanded, bool, (),,
+DefineEngineMethod( SimObject, isExpanded, bool, (),,
    "Get whether the object has been marked as expanded. (in editor)\n"
    "@return True if the object is marked expanded." )
 {
@@ -2354,7 +2354,7 @@ DefineConsoleMethod( SimObject, isExpanded, bool, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setIsExpanded, void, ( bool state ), ( true ),
+DefineEngineMethod( SimObject, setIsExpanded, void, ( bool state ), ( true ),
    "Set whether the object has been marked as expanded. (in editor)\n"
    "@param state True if the object is to be marked expanded; false if not." )
 {
@@ -2363,7 +2363,7 @@ DefineConsoleMethod( SimObject, setIsExpanded, void, ( bool state ), ( true ),
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getFilename, const char*, (),,
+DefineEngineMethod( SimObject, getFilename, const char*, (),,
    "Returns the filename the object is attached to.\n"
    "@return The name of the file the object is associated with; usually the file the object was loaded from." )
 {
@@ -2372,7 +2372,7 @@ DefineConsoleMethod( SimObject, getFilename, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setFilename, void, ( const char* fileName ),,
+DefineEngineMethod( SimObject, setFilename, void, ( const char* fileName ),,
    "Sets the object's file name and path\n"
    "@param fileName The name of the file to associate this object with." )
 {
@@ -2381,7 +2381,7 @@ DefineConsoleMethod( SimObject, setFilename, void, ( const char* fileName ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getDeclarationLine, S32, (),,
+DefineEngineMethod( SimObject, getDeclarationLine, S32, (),,
    "Get the line number at which the object is defined in its file.\n\n"
    "@return The line number of the object's definition in script.\n"
    "@see getFilename()")
@@ -2418,7 +2418,7 @@ DefineEngineFunction( debugEnumInstances, void, ( const char* className, const c
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, assignFieldsFrom, void, ( SimObject* fromObject ),,
+DefineEngineMethod( SimObject, assignFieldsFrom, void, ( SimObject* fromObject ),,
    "Copy fields from another object onto this one.  The objects must "
    "be of same type. Everything from the object will overwrite what's "
    "in this object; extra fields in this object will remain. This "
@@ -2439,7 +2439,7 @@ DefineEngineMethod( SimObject, assignPersistentId, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getCanSave, bool, (),,
+DefineEngineMethod( SimObject, getCanSave, bool, (),,
    "Get whether the object will be included in saves.\n"
    "@return True if the object will be saved; false otherwise." )
 {
@@ -2448,7 +2448,7 @@ DefineConsoleMethod( SimObject, getCanSave, bool, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setCanSave, void, ( bool value ), ( true ),
+DefineEngineMethod( SimObject, setCanSave, void, ( bool value ), ( true ),
    "Set whether the object will be included in saves.\n"
    "@param value If true, the object will be included in saves; if false, it will be excluded." )
 {
@@ -2529,7 +2529,7 @@ DefineEngineMethod( SimObject, setHidden, void, ( bool value ), ( true ),
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, dumpMethods, ArrayObject*, (),,
+DefineEngineMethod( SimObject, dumpMethods, ArrayObject*, (),,
    "List the methods defined on this object.\n\n"
    "Each description is a newline-separated vector with the following elements:\n"
    "- Minimum number of arguments.\n"
@@ -2776,7 +2776,7 @@ DefineEngineMethod( SimObject, dump, void, ( bool detailed ), ( false ),
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, save, bool, ( const char* fileName, bool selectedOnly, const char* preAppendString ), ( false, "" ),
+DefineEngineMethod( SimObject, save, bool, ( const char* fileName, bool selectedOnly, const char* preAppendString ), ( false, "" ),
    "Save out the object to the given file.\n"
    "@param fileName The name of the file to save to."
    "@param selectedOnly If true, only objects marked as selected will be saved out.\n"
@@ -2808,7 +2808,7 @@ DefineEngineMethod( SimObject, getName, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getClassName, const char*, (),,
+DefineEngineMethod( SimObject, getClassName, const char*, (),,
    "Get the name of the C++ class which the object is an instance of.\n"
    "@return The name of the C++ class of the object." )
 {
@@ -2818,7 +2818,7 @@ DefineConsoleMethod( SimObject, getClassName, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, isField, bool, ( const char* fieldName ),,
+DefineEngineMethod( SimObject, isField, bool, ( const char* fieldName ),,
    "Test whether the given field is defined on this object.\n"
    "@param fieldName The name of the field.\n"
    "@return True if the object implements the given field." )
@@ -2828,7 +2828,7 @@ DefineConsoleMethod( SimObject, isField, bool, ( const char* fieldName ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getFieldValue, const char*, ( const char* fieldName, S32 index ), ( -1 ),
+DefineEngineMethod( SimObject, getFieldValue, const char*, ( const char* fieldName, S32 index ), ( -1 ),
    "Return the value of the given field on this object.\n"
    "@param fieldName The name of the field.  If it includes a field index, the index is parsed out.\n"
    "@param index Optional parameter to specify the index of an array field separately.\n"
@@ -2872,7 +2872,7 @@ DefineConsoleMethod( SimObject, getFieldValue, const char*, ( const char* fieldN
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setFieldValue, bool, ( const char* fieldName, const char* value, S32 index ), ( -1 ),
+DefineEngineMethod( SimObject, setFieldValue, bool, ( const char* fieldName, const char* value, S32 index ), ( -1 ),
    "Set the value of the given field on this object.\n"
    "@param fieldName The name of the field to assign to.  If it includes an array index, the index will be parsed out.\n"
    "@param value The new value to assign to the field.\n"
@@ -2919,7 +2919,7 @@ DefineConsoleMethod( SimObject, setFieldValue, bool, ( const char* fieldName, co
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getFieldType, const char*, ( const char* fieldName ),,
+DefineEngineMethod( SimObject, getFieldType, const char*, ( const char* fieldName ),,
    "Get the console type code of the given field.\n"
    "@return The numeric type code for the underlying console type of the given field." )
 {
@@ -2934,7 +2934,7 @@ DefineConsoleMethod( SimObject, getFieldType, const char*, ( const char* fieldNa
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, setFieldType, void, ( const char* fieldName, const char* type ),,
+DefineEngineMethod( SimObject, setFieldType, void, ( const char* fieldName, const char* type ),,
    "Set the console type code for the given field.\n"
    "@param fieldName The name of the dynamic field to change to type for.\n"
    "@param type The name of the console type.\n"
@@ -2945,7 +2945,7 @@ DefineConsoleMethod( SimObject, setFieldType, void, ( const char* fieldName, con
 
 //-----------------------------------------------------------------------------
 
-ConsoleMethod( SimObject, call, const char*, 3, 0, "( string method, string args... ) Dynamically call a method on an object.\n"
+DefineEngineStringlyVariadicMethod( SimObject, call, const char*, 3, 0, "( string method, string args... ) Dynamically call a method on an object.\n"
    "@param method Name of method to call.\n"
    "@param args Zero or more arguments for the method.\n"
    "@return The result of the method call." )
@@ -2974,7 +2974,7 @@ DefineEngineMethod( SimObject, getInternalName, const char*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, dumpClassHierarchy, void, (),,
+DefineEngineMethod( SimObject, dumpClassHierarchy, void, (),,
    "Dump the native C++ class hierarchy of this object's C++ class to the console." )
 {
    object->dumpClassHierarchy();
@@ -2982,7 +2982,7 @@ DefineConsoleMethod( SimObject, dumpClassHierarchy, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, isMemberOfClass, bool, ( const char* className ),,
+DefineEngineMethod( SimObject, isMemberOfClass, bool, ( const char* className ),,
    "Test whether this object is a member of the specified class.\n"
    "@param className Name of a native C++ class.\n"
    "@return True if this object is an instance of the given C++ class or any of its super classes." )
@@ -3004,7 +3004,7 @@ DefineConsoleMethod( SimObject, isMemberOfClass, bool, ( const char* className )
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, isInNamespaceHierarchy, bool, ( const char* name ),,
+DefineEngineMethod( SimObject, isInNamespaceHierarchy, bool, ( const char* name ),,
    "Test whether the namespace of this object is a direct or indirect child to the given namespace.\n"
    "@param name The name of a namespace.\n"
    "@return True if the given namespace name is within the namespace hierarchy of this object." )
@@ -3039,7 +3039,7 @@ DefineEngineMethod( SimObject, getGroup, SimGroup*, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, delete, void, (),,
+DefineEngineMethod( SimObject, delete, void, (),,
    "Delete and remove the object." )
 {
    object->deleteObject();
@@ -3047,7 +3047,7 @@ DefineConsoleMethod( SimObject, delete, void, (),,
 
 //-----------------------------------------------------------------------------
 
-ConsoleMethod( SimObject,schedule, S32, 4, 0, "( float time, string method, string args... ) Delay an invocation of a method.\n"
+DefineEngineStringlyVariadicMethod( SimObject,schedule, S32, 4, 0, "( float time, string method, string args... ) Delay an invocation of a method.\n"
    "@param time The number of milliseconds after which to invoke the method.  This is a soft limit.\n"
    "@param method The method to call.\n"
    "@param args The arguments with which to call the method.\n"
@@ -3067,7 +3067,7 @@ ConsoleMethod( SimObject,schedule, S32, 4, 0, "( float time, string method, stri
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getDynamicFieldCount, S32, (),,
+DefineEngineMethod( SimObject, getDynamicFieldCount, S32, (),,
    "Get the number of dynamic fields defined on the object.\n"
    "@return The number of dynamic fields defined on the object." )
 {
@@ -3081,7 +3081,7 @@ DefineConsoleMethod( SimObject, getDynamicFieldCount, S32, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getDynamicField, const char*, ( S32 index ),,
+DefineEngineMethod( SimObject, getDynamicField, const char*, ( S32 index ),,
    "Get a value of a dynamic field by index.\n"
    "@param index The index of the dynamic field.\n"
    "@return The value of the dynamic field at the given index or \"\"." )
@@ -3113,7 +3113,7 @@ DefineConsoleMethod( SimObject, getDynamicField, const char*, ( S32 index ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getFieldCount, S32, (),,
+DefineEngineMethod( SimObject, getFieldCount, S32, (),,
    "Get the number of static fields on the object.\n"
    "@return The number of static fields defined on the object." )
 {
@@ -3135,7 +3135,7 @@ DefineConsoleMethod( SimObject, getFieldCount, S32, (),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimObject, getField, const char*, ( S32 index ),,
+DefineEngineMethod( SimObject, getField, const char*, ( S32 index ),,
    "Retrieve the value of a static field by index.\n"
    "@param index The index of the static field.\n"
    "@return The value of the static field with the given index or \"\"." )

+ 0 - 1
Engine/source/console/simObject.h

@@ -455,7 +455,6 @@ class SimObject: public ConsoleObject, public TamlCallbacks
       {
          T* object = new T;
          object->incRefCount();
-         object->registerObject();
          return object;
       }
 

+ 1 - 1
Engine/source/console/simPersistSet.cpp

@@ -187,7 +187,7 @@ void SimPersistSet::addObject( SimObject* object )
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimPersistSet, resolvePersistentIds, void, (), , "() - Try to bind unresolved persistent IDs in the set." )
+DefineEngineMethod( SimPersistSet, resolvePersistentIds, void, (), , "() - Try to bind unresolved persistent IDs in the set." )
 {
    object->resolvePIDs();
 }

+ 7 - 23
Engine/source/console/simSet.cpp

@@ -895,15 +895,7 @@ DefineEngineMethod( SimSet, listObjects, void, (),,
 
 //-----------------------------------------------------------------------------
 
-DEFINE_CALLIN( fnSimSet_add, add, SimSet, void, ( SimSet* set, SimObject* object ),,,
-   "Add the given object to the set.\n"
-   "@param object An object." )
-{
-   if( object )
-      set->addObject( object );
-}
-
-ConsoleMethod( SimSet, add, void, 3, 0,
+DefineEngineStringlyVariadicMethod( SimSet, add, void, 3, 0,
    "( SimObject objects... ) Add the given objects to the set.\n"
    "@param objects The objects to add to the set." )
 {
@@ -919,15 +911,7 @@ ConsoleMethod( SimSet, add, void, 3, 0,
 
 //-----------------------------------------------------------------------------
 
-DEFINE_CALLIN( fnSimSet_remove, remove, SimSet, void, ( SimSet* set, SimObject* object ),,,
-   "Remove the given object from the set.\n"
-   "@param object An object." )
-{
-   if( object )
-      set->removeObject( object );
-}
-
-ConsoleMethod( SimSet, remove, void, 3, 0,
+DefineEngineStringlyVariadicMethod( SimSet, remove, void, 3, 0,
    "( SimObject objects... ) Remove the given objects from the set.\n"
    "@param objects The objects to remove from the set." )
 {
@@ -954,7 +938,7 @@ DefineEngineMethod( SimSet, clear, void, (),,
 //-----------------------------------------------------------------------------
 
 //UNSAFE; don't want this in the new API
-DefineConsoleMethod( SimSet, deleteAllObjects, void, (), , "() Delete all objects in the set." )
+DefineEngineMethod( SimSet, deleteAllObjects, void, (), , "() Delete all objects in the set." )
 {
    object->deleteAllObjects();
 }
@@ -970,7 +954,7 @@ DefineEngineMethod( SimSet, getRandom, SimObject*, (),,
 
 //-----------------------------------------------------------------------------
 
-ConsoleMethod( SimSet, callOnChildren, void, 3, 0,
+DefineEngineStringlyVariadicMethod( SimSet, callOnChildren, void, 3, 0,
    "( string method, string args... ) Call a method on all objects contained in the set.\n\n"
    "@param method The name of the method to call.\n"
    "@param args The arguments to the method.\n\n"
@@ -982,7 +966,7 @@ ConsoleMethod( SimSet, callOnChildren, void, 3, 0,
 
 //-----------------------------------------------------------------------------
 
-ConsoleMethod( SimSet, callOnChildrenNoRecurse, void, 3, 0,
+DefineEngineStringlyVariadicMethod( SimSet, callOnChildrenNoRecurse, void, 3, 0,
    "( string method, string args... ) Call a method on all objects contained in the set.\n\n"
    "@param method The name of the method to call.\n"
    "@param args The arguments to the method.\n\n"
@@ -1026,7 +1010,7 @@ DEFINE_CALLIN( fnSimSet_getCountRecursive, getCountRecursive, SimSet, U32, ( Sim
    return set->sizeRecursive();
 }
 
-DefineConsoleMethod( SimSet, getFullCount, S32, (), , "() Get the number of direct and indirect child objects contained in the set.\n"
+DefineEngineMethod( SimSet, getFullCount, S32, (), , "() Get the number of direct and indirect child objects contained in the set.\n"
    "@return The number of objects contained in the set as well as in other sets contained directly or indirectly in the set." )
 {
    return object->sizeRecursive();
@@ -1122,7 +1106,7 @@ DefineEngineMethod( SimSet, pushToBack, void, ( SimObject* obj ),,
 
 //-----------------------------------------------------------------------------
 
-DefineConsoleMethod( SimSet, sort, void, ( const char * callbackFunction ), , "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n"
+DefineEngineMethod( SimSet, sort, void, ( const char * callbackFunction ), , "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n"
    "@param callbackFunction Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." )
 {
    object->scriptSort( callbackFunction );

+ 1 - 1
Engine/source/console/telnetConsole.cpp

@@ -61,7 +61,7 @@ void TelnetConsole::destroy()
    TelConsole = NULL;
 }
 
-DefineConsoleFunction( telnetSetParameters, void, ( int port, const char* consolePass, const char* listenPass, bool remoteEcho ), ( false ),
+DefineEngineFunction( telnetSetParameters, void, ( int port, const char* consolePass, const char* listenPass, bool remoteEcho ), ( false ),
                 "@brief Initializes and open the telnet console.\n\n"
                 "@param port        Port to listen on for console connections (0 will shut down listening).\n"
                 "@param consolePass Password for read/write access to console.\n"

+ 3 - 3
Engine/source/console/telnetDebugger.cpp

@@ -113,7 +113,7 @@ MODULE_END;
 // BRKCLR file line - sent when a breakpoint cannot be moved to a breakable line on the client.
 //
 
-DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )"
+DefineEngineFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )"
                 "Open a debug server port on the specified port, requiring the specified password, "
             "and optionally waiting for the debug client to connect.\n"
             "@internal Primarily used for Torsion and other debugging tools")
@@ -124,14 +124,14 @@ DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password,
    }
 }
 
-DefineConsoleFunction( dbgIsConnected, bool, (), , "()"
+DefineEngineFunction( dbgIsConnected, bool, (), , "()"
                 "Returns true if a script debugging client is connected else return false.\n"
             "@internal Primarily used for Torsion and other debugging tools")
 {
    return TelDebugger && TelDebugger->isConnected();
 }
 
-DefineConsoleFunction( dbgDisconnect, void, (), , "()"
+DefineEngineFunction( dbgDisconnect, void, (), , "()"
                 "Forcibly disconnects any attached script debugging client.\n"
             "@internal Primarily used for Torsion and other debugging tools")
 {

+ 23 - 36
Engine/source/core/color.cpp

@@ -536,80 +536,67 @@ float LinearColorF::sSrgbToLinear[256] =
 #endif
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( getStockColorCount, S32, 1, 1, "() - Gets a count of available stock colors.\n"
-   "@return A count of available stock colors." )
+DefineEngineFunction(getStockColorCount, S32, (),,
+   "@brief Gets a count of available stock colors.\n"
+   "@return A count of available stock colors.")
 {
    return StockColor::getCount();
 }
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( getStockColorName, const char*, 2, 2,  "(stockColorIndex) - Gets the stock color name at the specified index.\n"
+DefineEngineFunction(getStockColorName, const char*, (S32 stockColorIndex),,
+   "@brief Gets the stock color name at the specified index.\n"
    "@param stockColorIndex The zero-based index of the stock color name to retrieve.\n"
-   "@return The stock color name at the specified index or nothing if the string is invalid." )
+   "@return The stock color name at the specified index or nothing if the string is invalid.")
 {
-   // Fetch stock color index.
-   const S32 stockColorIndex = dAtoi(argv[1]);
-
    // Fetch the color item.
-   const StockColorItem* pColorItem = StockColor::getColorItem( stockColorIndex );
+   const StockColorItem* pColorItem = StockColor::getColorItem(stockColorIndex);
 
    return pColorItem == NULL ? NULL : pColorItem->getColorName();
 }
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( isStockColor, bool, 2, 2,  "(stockColorName) - Gets whether the specified name is a stock color or not.\n"
+DefineEngineFunction(isStockColor, bool, (const char* stockColorName),,
+   "@brief Gets whether the specified name is a stock color or not.\n"
    "@param stockColorName - The stock color name to test for.\n"
-   "@return Whether the specified name is a stock color or not.\n" )
+   "@return Whether the specified name is a stock color or not.\n")
 {
-   // Fetch stock color name.
-   const char* pStockColorName = argv[1];
-
    // Return whether this is a stock color name or not.
-   return StockColor::isColor( pStockColorName );
+   return StockColor::isColor(stockColorName);
 }
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( getStockColorF, const char*, 2, 2, "(stockColorName) - Gets a floating-point-based stock color by name.\n"
+DefineEngineFunction(getStockColorF, LinearColorF, (const char* stockColorName),,
+   "@brief Gets a floating-point-based stock color by name.\n"
    "@param stockColorName - The stock color name to retrieve.\n"
-   "@return The stock color that matches the specified color name.  Returns nothing if the color name is not found.\n" )
+   "@return The stock color that matches the specified color name.  Returns nothing if the color name is not found.\n")
 {
-   // Fetch stock color name.
-   const char* pStockColorName = argv[1];
-
    // Return nothing if stock color name is invalid.
-   if ( !StockColor::isColor( pStockColorName ) )
+   if (!StockColor::isColor(stockColorName))
       return StringTable->EmptyString();
 
    // Fetch stock color.
-   const LinearColorF& color = StockColor::colorF( pStockColorName );
+   const LinearColorF& color = StockColor::colorF(stockColorName);
 
-   // Format stock color.
-   char* returnBuffer = Con::getReturnBuffer(256);
-   dSprintf(returnBuffer, 256, "%g %g %g %g", color.red, color.green, color.blue, color.alpha);
-   return(returnBuffer);
+   return color;
 }
 
 //-----------------------------------------------------------------------------
 
-ConsoleFunction( getStockColorI, const char*, 2, 2, "(stockColorName) - Gets a byte-based stock color by name.\n"
+DefineEngineFunction(getStockColorI, ColorI, (const char* stockColorName),,
+   "@brief Gets a byte-based stock color by name.\n"
    "@param stockColorName - The stock color name to retrieve.\n"
-   "@return The stock color that matches the specified color name.  Returns nothing if the color name is not found.\n" )
+   "@return The stock color that matches the specified color name.  Returns nothing if the color name is not found.\n")
 {
-   // Fetch stock color name.
-   const char* pStockColorName = argv[1];
-
    // Return nothing if stock color name is invalid.
-   if ( !StockColor::isColor( pStockColorName ) )
+   if (!StockColor::isColor(stockColorName))
       return StringTable->EmptyString();
 
    // Fetch stock color.
-   const ColorI& color = StockColor::colorI( pStockColorName );
+   const ColorI& color = StockColor::colorI(stockColorName);
 
-   // Format stock color.
-   char* returnBuffer = Con::getReturnBuffer(256);
-   dSprintf(returnBuffer, 256, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
-   return(returnBuffer);
+   return color;
 }

+ 1 - 1
Engine/source/core/dnet.cpp

@@ -50,7 +50,7 @@ static const char *packetTypeNames[] =
 //-----------------------------------------------------------------
 //-----------------------------------------------------------------
 //-----------------------------------------------------------------
-DefineConsoleFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)"
+DefineEngineFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)"
    "@brief Enables logging of the connection protocols\n\n"
    "When enabled a lot of network debugging information is sent to the console.\n"
    "@param enabled True to enable, false to disable\n"

+ 1 - 1
Engine/source/core/fileObject.cpp

@@ -484,7 +484,7 @@ static ConsoleDocFragment _FileObjectwriteObject2(
    "FileObject",
    "void writeObject( SimObject* object, string prepend);");
 
-DefineConsoleMethod( FileObject, writeObject, void,  (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)" 
+DefineEngineMethod( FileObject, writeObject, void,  (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)"
 			  "@hide")
 {
    SimObject* obj = Sim::findObject( simName );

+ 2 - 2
Engine/source/core/frameAllocator.cpp

@@ -21,7 +21,7 @@
 //-----------------------------------------------------------------------------
 
 #include "core/frameAllocator.h"
-#include "console/console.h"
+#include "console/engineAPI.h"
 
 U8*   FrameAllocator::smBuffer = NULL;
 U32   FrameAllocator::smWaterMark = 0;
@@ -30,7 +30,7 @@ U32   FrameAllocator::smHighWaterMark = 0;
 #ifdef TORQUE_DEBUG
 U32   FrameAllocator::smMaxFrameAllocation = 0;
 
-ConsoleFunction(getMaxFrameAllocation, S32, 1,1, "getMaxFrameAllocation();")
+DefineEngineFunction(getMaxFrameAllocation, S32, (),,"")
 {
    return FrameAllocator::getMaxFrameAllocation();
 }

+ 5 - 6
Engine/source/core/resourceManager.cpp

@@ -222,18 +222,17 @@ ResourceBase ResourceManager::nextResource()
 ConsoleFunctionGroupBegin(ResourceManagerFunctions, "Resource management functions.");
 
 
-ConsoleFunction(resourceDump, void, 1, 1, "()"
-				"@brief List the currently managed resources\n\n"
-				"Currently used by editors only, internal\n"
-				"@ingroup Editors\n"
-				"@internal")
+DefineEngineFunction(resourceDump, void, (),,
+   "@brief List the currently managed resources\n\n"
+   "Currently used by editors only, internal\n"
+   "@ingroup Editors\n"
+   "@internal")
 {
 #ifdef TORQUE_DEBUG
    ResourceManager::get().dumpToConsole();
 #endif
 }
 
-
 DefineEngineFunction( reloadResource, void, ( const char* path ),,
    "Force the resource at specified input path to be reloaded\n"
    "@param path Path to the resource to be reloaded\n\n"

+ 51 - 18
Engine/source/core/stream/bitStream.cpp

@@ -140,7 +140,7 @@ class HuffmanProcessor
 
    static HuffmanProcessor g_huffProcessor;
 
-   bool readHuffBuffer(BitStream* pStream, char* out_pBuffer);
+   bool readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen);
    bool writeHuffBuffer(BitStream* pStream, const char* out_pBuffer, S32 maxLen);
 };
 
@@ -488,24 +488,51 @@ void BitStream::readAffineTransform(MatrixF* matrix)
 
 void BitStream::writeQuat( const QuatF& quat, U32 bitCount )
 {
-   writeSignedFloat( quat.x, bitCount );
-   writeSignedFloat( quat.y, bitCount );
-   writeSignedFloat( quat.z, bitCount );
-   writeFlag( quat.w < 0.0f );
+   F32 quatVals[4] = { quat.x, quat.y, quat.z, quat.w };
+   bool flipQuat = (quatVals[0] < 0);
+   F32 maxVal = mFabs(quatVals[0]);
+   S32 idxMax = 0;
+
+   for (S32 i = 1; i < 4; ++i)
+   {
+      if (mFabs(quatVals[i]) > maxVal)
+      {
+         idxMax = i;
+         maxVal = mFabs(quatVals[i]);
+         flipQuat = (quatVals[i] < 0);
+      }
+   }
+   writeInt(idxMax, 2);
+
+   for (S32 i = 0; i < 4; ++i)
+   {
+      if (i == idxMax)
+         continue;
+      F32 curValue = (flipQuat ? -quatVals[i] : quatVals[i]) * (F32) M_SQRT2;
+      writeSignedFloat( curValue, bitCount );
+   }
 }
 
 void BitStream::readQuat( QuatF *outQuat, U32 bitCount )
 {
-   outQuat->x = readSignedFloat( bitCount );
-   outQuat->y = readSignedFloat( bitCount );
-   outQuat->z = readSignedFloat( bitCount );
-
-   outQuat->w = mSqrt( 1.0 - getMin(   mSquared( outQuat->x ) + 
-                                       mSquared( outQuat->y ) + 
-                                       mSquared( outQuat->z ),
-                                       1.0f ) );
-   if ( readFlag() )
-      outQuat->w = -outQuat->w;
+   F32 quatVals[4];
+   F32 sum = 0.0f;
+
+   S32 idxMax = readInt( 2 );
+   for (S32 i = 0; i < 4; ++i)
+   {
+      if (i == idxMax)
+         continue;
+      quatVals[i] = readSignedFloat( bitCount ) * M_SQRTHALF_F;
+      sum += quatVals[i] * quatVals[i];
+   }
+
+   if (sum > 1.0f)
+      quatVals[idxMax] = 1.0f;
+   else
+      quatVals[idxMax] = mSqrt(1.0f - sum);
+
+   outQuat->set(quatVals[0], quatVals[1], quatVals[2], quatVals[3]);
 }
 
 void BitStream::writeBits( const BitVector &bitvec )
@@ -667,12 +694,12 @@ void BitStream::readString(char buf[256])
       if(readFlag())
       {
          S32 offset = readInt(8);
-         HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset);
+         HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset, 256 - offset);
          dStrcpy(buf, stringBuffer, 256);
          return;
       }
    }
-   HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf);
+   HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf, 256);
    if(stringBuffer)
       dStrcpy(stringBuffer, buf, 256);
 }
@@ -812,13 +839,16 @@ S16 HuffmanProcessor::determineIndex(HuffWrap& rWrap)
    }
 }
 
-bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
+bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen=256)
 {
    if (m_tablesBuilt == false)
       buildTables();
 
    if (pStream->readFlag()) {
       S32 len = pStream->readInt(8);
+      if (len >= maxLen) {
+         len = maxLen;
+      }
       for (S32 i = 0; i < len; i++) {
          S32 index = 0;
          while (true) {
@@ -839,6 +869,9 @@ bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
    } else {
       // Uncompressed string...
       U32 len = pStream->readInt(8);
+      if (len >= maxLen) {
+         len = maxLen;
+      }
       pStream->read(len, out_pBuffer);
       out_pBuffer[len] = '\0';
       return true;

+ 4 - 4
Engine/source/core/stream/bitStream.h

@@ -207,18 +207,18 @@ public:
    void readAffineTransform(MatrixF*);
 
    /// Writes a quaternion in a lossy compressed format that
-   /// is ( bitCount * 3 ) + 1 bits in size.
+   /// is ( bitCount * 3 ) + 2 bits in size.
    ///
    /// @param quat The normalized quaternion to write.
-   /// @param bitCount The the storage space for the xyz component of
+   /// @param bitCount The the storage space for the packed components of
    ///                 the quaternion.
    ///
    void writeQuat( const QuatF& quat, U32 bitCount = 9 );
 
    /// Reads a quaternion written with writeQuat.
    ///
-   /// @param quat The normalized quaternion to write.
-   /// @param bitCount The the storage space for the xyz component of
+   /// @param quat The quaternion that was read.
+   /// @param bitCount The the storage space for the packed components of
    ///                 the quaternion.  Must match the bitCount at write.
    /// @see writeQuat
    ///

+ 2 - 2
Engine/source/core/stringBuffer.cpp

@@ -48,12 +48,12 @@
          void dumpAllStrings();
    };
 
-   DefineConsoleFunction( sbmDumpStats, void, (), , "()")
+   DefineEngineFunction( sbmDumpStats, void, (), , "()")
    {
       StringBufferManager::getManager().dumpStats();
    }
 
-   DefineConsoleFunction( sbmDumpStrings, void, (), , "()")
+   DefineEngineFunction( sbmDumpStrings, void, (), , "()")
    {
       StringBufferManager::getManager().dumpAllStrings();
    }

+ 1 - 1
Engine/source/core/util/str.cpp

@@ -480,7 +480,7 @@ static U32 sgStringInstances;
 
 
 #endif
-DefineConsoleFunction( dumpStringMemStats, void, (), , "()"
+DefineEngineFunction( dumpStringMemStats, void, (), , "()"
 				"@brief Dumps information about String memory usage\n\n"
 				"@ingroup Debugging\n"
 				"@ingroup Strings\n")

+ 1 - 1
Engine/source/environment/VolumetricFogRTManager.cpp

@@ -283,7 +283,7 @@ VolumetricFogRTManager* VolumetricFogRTManager::get()
    return gVolumetricFogRTManager;
 }
    
-DefineConsoleFunction(SetFogVolumeQuality, S32, (U32 new_quality), ,
+DefineEngineFunction(SetFogVolumeQuality, S32, (U32 new_quality), ,
 "@brief Resizes the rendertargets of the Volumetric Fog object.\n"
 "@params new_quality new quality for the rendertargets 1 = full size, 2 = halfsize, 3 = 1/3, 4 = 1/4 ...")
 {

+ 15 - 15
Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp

@@ -1185,67 +1185,67 @@ void GuiMeshRoadEditorCtrl::matchTerrainToRoad()
    // with the terrain underneath it.
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
 {
    object->deleteSelectedNode();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getMode, const char*, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getMode, const char*, (), , "" )
 {
    return object->getMode();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setMode, void, (const char * mode), , "setMode( String mode )" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setMode, void, (const char * mode), , "setMode( String mode )" )
 {
    String newMode = ( mode );
    object->setMode( newMode );
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, (), , "" )
 {
    return object->getNodeWidth();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
 {
    object->setNodeWidth( width );
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, (), , "" )
 {
    return object->getNodeDepth();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
 {
    object->setNodeDepth( depth );
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
 {
 
 	return object->getNodePosition();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
 {
 
    object->setNodePosition( pos );
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, Point3F, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getNodeNormal, Point3F, (), , "" )
 {
 
 	return object->getNodeNormal();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
 {
 
    object->setNodeNormal( normal );
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
 {
    if ( String::isEmpty(objName) )
       object->setSelectedRoad(NULL);
@@ -1257,7 +1257,7 @@ DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char *
    }
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
 {
    MeshRoad *road = object->getSelectedRoad();
    if ( !road )
@@ -1266,14 +1266,14 @@ DefineConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
    return road->getId();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, regenerate, void, (), , "" )
 {
    MeshRoad *road = object->getSelectedRoad();
    if ( road )
       road->regenerate();
 }
 
-DefineConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, (), , "" )
+DefineEngineMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, (), , "" )
 {
    object->matchTerrainToRoad();
 }

+ 14 - 14
Engine/source/environment/editors/guiRiverEditorCtrl.cpp

@@ -1393,66 +1393,66 @@ void GuiRiverEditorCtrl::_renderSelectedRiver( ObjectRenderInst *ri, SceneRender
    }
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, deleteNode, void, (), , "deleteNode()" )
+DefineEngineMethod( GuiRiverEditorCtrl, deleteNode, void, (), , "deleteNode()" )
 {
    object->deleteSelectedNode();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getMode, const char*, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getMode, const char*, (), , "" )
 {
    return object->getMode();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
+DefineEngineMethod( GuiRiverEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
 {
    String newMode = ( mode );
    object->setMode( newMode );
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getNodeWidth, F32, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getNodeWidth, F32, (), , "" )
 {
    return object->getNodeWidth();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
 {
    object->setNodeWidth( width );
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getNodeDepth, F32, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getNodeDepth, F32, (), , "" )
 {
    return object->getNodeDepth();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
 {
    object->setNodeDepth( depth );
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getNodePosition, Point3F, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getNodePosition, Point3F, (), , "" )
 {
 
 	return  object->getNodePosition();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
 {
    object->setNodePosition( pos );
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, Point3F, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getNodeNormal, Point3F, (), , "" )
 {
 
 	return object->getNodeNormal();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
 {
 
    object->setNodeNormal( normal );
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, (const char * objName), (""), "" )
+DefineEngineMethod( GuiRiverEditorCtrl, setSelectedRiver, void, (const char * objName), (""), "" )
 {
    if (dStrcmp( objName,"" )==0)
       object->setSelectedRiver(NULL);
@@ -1464,7 +1464,7 @@ DefineConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, (const char * o
    }
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" )
 {
    River *river = object->getSelectedRiver();
    if ( !river )
@@ -1473,7 +1473,7 @@ DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" )
    return river->getId();
 }
 
-DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" )
+DefineEngineMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" )
 {
    River *river = object->getSelectedRiver();
    if ( river )

+ 11 - 11
Engine/source/environment/editors/guiRoadEditorCtrl.cpp

@@ -1037,45 +1037,45 @@ void GuiRoadEditorCtrl::submitUndo( const UTF8 *name )
    undoMan->addAction( action );
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
+DefineEngineMethod( GuiRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
 {
    object->deleteSelectedNode();
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, getMode, const char*, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, getMode, const char*, (), , "" )
 {
    return object->getMode();
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
+DefineEngineMethod( GuiRoadEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
 {
    String newMode = ( mode );
    object->setMode( newMode );
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, getNodeWidth, F32, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, getNodeWidth, F32, (), , "" )
 {
    return object->getNodeWidth();
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
 {
    object->setNodeWidth( width );
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
 {
 
 	return object->getNodePosition();
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, ( Point3F pos ), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, setNodePosition, void, ( Point3F pos ), , "" )
 {
 
    object->setNodePosition( pos );
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, ( const char * pathRoad ), (""), "" )
+DefineEngineMethod( GuiRoadEditorCtrl, setSelectedRoad, void, ( const char * pathRoad ), (""), "" )
 {
    if (dStrcmp( pathRoad,"")==0 )
       object->setSelectedRoad(NULL);
@@ -1087,7 +1087,7 @@ DefineConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, ( const char * pa
    }
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
 {
    DecalRoad *road = object->getSelectedRoad();
    if ( road )
@@ -1096,12 +1096,12 @@ DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
    return NULL;
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedNode, S32, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, getSelectedNode, S32, (), , "" )
 {
    return object->getSelectedNode();
 }
 
-DefineConsoleMethod( GuiRoadEditorCtrl, deleteRoad, void, (), , "" )
+DefineEngineMethod( GuiRoadEditorCtrl, deleteRoad, void, (), , "" )
 {
    object->deleteSelectedRoad();
 }

+ 1 - 1
Engine/source/environment/skyBox.cpp

@@ -641,7 +641,7 @@ BaseMatInstance* SkyBox::_getMaterialInstance()
    return mMatInstance;
 }
 
-DefineConsoleMethod( SkyBox, postApply, void, (), , "")
+DefineEngineMethod( SkyBox, postApply, void, (), , "")
 {
 	object->inspectPostApply();
 }

+ 2 - 2
Engine/source/environment/sun.cpp

@@ -558,12 +558,12 @@ void Sun::_onUnselected()
    Parent::_onUnselected();
 }
 
-DefineConsoleMethod(Sun, apply, void, (), , "")
+DefineEngineMethod(Sun, apply, void, (), , "")
 {
    object->inspectPostApply();
 }
 
-DefineConsoleMethod(Sun, animate, void, ( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation ), , "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )")
+DefineEngineMethod(Sun, animate, void, ( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation ), , "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )")
 {
 
    object->animate(duration, startAzimuth, endAzimuth, startElevation, endElevation);

+ 1 - 1
Engine/source/forest/editor/forestBrushElement.cpp

@@ -187,7 +187,7 @@ bool ForestBrush::containsItemData( const ForestItemData *inData )
    return false;
 }
 
-DefineConsoleMethod( ForestBrush, containsItemData, bool, ( const char * obj ), , "( ForestItemData obj )" )
+DefineEngineMethod( ForestBrush, containsItemData, bool, ( const char * obj ), , "( ForestItemData obj )" )
 {
    ForestItemData *data = NULL;
    if ( !Sim::findObject( obj, data ) )

+ 1 - 1
Engine/source/forest/editor/forestBrushTool.cpp

@@ -682,7 +682,7 @@ bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, Vecto
    return true;
 }
 
-DefineConsoleMethod( ForestBrushTool, collectElements, void, (), , "" )
+DefineEngineMethod( ForestBrushTool, collectElements, void, (), , "" )
 {
    object->collectElements();
 }

+ 6 - 6
Engine/source/forest/editor/forestEditorCtrl.cpp

@@ -370,24 +370,24 @@ bool ForestEditorCtrl::isDirty()
    return foundDirty;   
 }
 
-DefineConsoleMethod( ForestEditorCtrl, updateActiveForest, void, (), , "()" )
+DefineEngineMethod( ForestEditorCtrl, updateActiveForest, void, (), , "()" )
 {
    object->updateActiveForest( true );
 }
 
-DefineConsoleMethod( ForestEditorCtrl, setActiveTool, void, ( const char * toolName ), , "( ForestTool tool )" )
+DefineEngineMethod( ForestEditorCtrl, setActiveTool, void, ( const char * toolName ), , "( ForestTool tool )" )
 {
    ForestTool *tool = dynamic_cast<ForestTool*>( Sim::findObject( toolName ) );
    object->setActiveTool( tool );
 }
 
-DefineConsoleMethod( ForestEditorCtrl, getActiveTool, S32, (), , "()" )
+DefineEngineMethod( ForestEditorCtrl, getActiveTool, S32, (), , "()" )
 {
    ForestTool *tool = object->getActiveTool();
    return tool ? tool->getId() : 0;
 }
 
-DefineConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj ), , "( ForestItemData obj )" )
+DefineEngineMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj ), , "( ForestItemData obj )" )
 {
    ForestItemData *db;
    if ( !Sim::findObject( obj, db ) )
@@ -396,12 +396,12 @@ DefineConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj
    object->deleteMeshSafe( db );   
 }
 
-DefineConsoleMethod( ForestEditorCtrl, isDirty, bool, (), , "" )
+DefineEngineMethod( ForestEditorCtrl, isDirty, bool, (), , "" )
 {
    return object->isDirty();
 }
 
-DefineConsoleMethod(ForestEditorCtrl, setActiveForest, void, (const char * obj), , "( Forest obj )")
+DefineEngineMethod(ForestEditorCtrl, setActiveForest, void, (const char * obj), , "( Forest obj )")
 {
    Forest *forestObject;
    if (!Sim::findObject(obj, forestObject))

+ 6 - 6
Engine/source/forest/editor/forestSelectionTool.cpp

@@ -563,32 +563,32 @@ void ForestSelectionTool::onUndoAction()
       mBounds.intersect( mSelection[i].getWorldBox() );
 }
 
-DefineConsoleMethod( ForestSelectionTool, getSelectionCount, S32, (), , "" )
+DefineEngineMethod( ForestSelectionTool, getSelectionCount, S32, (), , "" )
 {
    return object->getSelectionCount();
 }
 
-DefineConsoleMethod( ForestSelectionTool, deleteSelection, void, (), , "" )
+DefineEngineMethod( ForestSelectionTool, deleteSelection, void, (), , "" )
 {
    object->deleteSelection();
 }
 
-DefineConsoleMethod( ForestSelectionTool, clearSelection, void, (), , "" )
+DefineEngineMethod( ForestSelectionTool, clearSelection, void, (), , "" )
 {
    object->clearSelection();
 }
 
-DefineConsoleMethod( ForestSelectionTool, cutSelection, void, (), , "" )
+DefineEngineMethod( ForestSelectionTool, cutSelection, void, (), , "" )
 {
    object->cutSelection();
 }
 
-DefineConsoleMethod( ForestSelectionTool, copySelection, void, (), , "" )
+DefineEngineMethod( ForestSelectionTool, copySelection, void, (), , "" )
 {
    object->copySelection();
 }
 
-DefineConsoleMethod( ForestSelectionTool, pasteSelection, void, (), , "" )
+DefineEngineMethod( ForestSelectionTool, pasteSelection, void, (), , "" )
 {
    object->pasteSelection();
 }

+ 4 - 4
Engine/source/forest/forest.cpp

@@ -361,22 +361,22 @@ void Forest::saveDataFile( const char *path )
       mData->write( mDataFileName );
 }
 
-DefineConsoleMethod( Forest, saveDataFile, void, (const char * path), (""), "saveDataFile( [path] )" )
+DefineEngineMethod( Forest, saveDataFile, void, (const char * path), (""), "saveDataFile( [path] )" )
 {   
    object->saveDataFile( path );
 }
 
-DefineConsoleMethod(Forest, isDirty, bool, (), , "()")
+DefineEngineMethod(Forest, isDirty, bool, (), , "()")
 {
    return object->getData() && object->getData()->isDirty();
 }
 
-DefineConsoleMethod(Forest, regenCells, void, (), , "()")
+DefineEngineMethod(Forest, regenCells, void, (), , "()")
 {
    object->getData()->regenCells();
 }
 
-DefineConsoleMethod(Forest, clear, void, (), , "()" )
+DefineEngineMethod(Forest, clear, void, (), , "()" )
 {
    object->clear();
 }

+ 1 - 1
Engine/source/gfx/gfxDevice.cpp

@@ -1385,7 +1385,7 @@ DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
    return format;
 }
 
-DefineConsoleFunction(ResetGFX, void, (), , "forces the gbuffer to be reinitialized in cases of improper/lack of buffer clears.")
+DefineEngineFunction(ResetGFX, void, (), , "forces the gbuffer to be reinitialized in cases of improper/lack of buffer clears.")
 {
    GFX->beginReset();
 }

+ 1 - 1
Engine/source/gfx/gfxInit.cpp

@@ -523,7 +523,7 @@ DefineEngineStaticMethod( GFXInit, getAdapterModeCount, S32, ( S32 index ),,
    return adapters[index]->mAvailableModes.size();
 }
 
-DefineConsoleStaticMethod( GFXInit, getAdapterMode, String, ( S32 index, S32 modeIndex ),,
+DefineEngineStaticMethod( GFXInit, getAdapterMode, String, ( S32 index, S32 modeIndex ),,
    "Gets the details of the specified adapter mode.\n\n"
    "@param index Index of the adapter to query.\n"
    "@param modeIndex Index of the mode to get data from.\n"

+ 1 - 1
Engine/source/gfx/gl/gfxGLDevice.cpp

@@ -998,7 +998,7 @@ public:
 
 static GFXGLRegisterDevice pGLRegisterDevice;
 
-ConsoleFunction(cycleResources, void, 1, 1, "")
+DefineEngineFunction(cycleResources, void, (),, "")
 {
    static_cast<GFXGLDevice*>(GFX)->zombify();
    static_cast<GFXGLDevice*>(GFX)->resurrect();

+ 1 - 1
Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp

@@ -86,7 +86,7 @@ protected:
 
 GFXProfiler<GLTimer> gfxProfiler;
 
-DefineConsoleFunction(printGFXGLTimers, void,(), ,"")
+DefineEngineFunction(printGFXGLTimers, void,(), ,"")
 {
    gfxProfiler.printTimes();
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff