Browse Source

- Fixed-up a recent bad merge and implemented stubs for missing functionality. The baton has been passed back now... :)

MelvMay-GG 12 years ago
parent
commit
0ed914b

+ 23 - 86
engine/source/2d/scene/Scene.cc

@@ -68,10 +68,6 @@ SimObjectPtr<Scene> Scene::LoadingScene = NULL;
 
 //------------------------------------------------------------------------------
 
-IMPLEMENT_CONOBJECT_CHILDREN(Scene);
-
-//------------------------------------------------------------------------------
-
 static ContactFilter mContactFilter;
 
 // Scene counter.
@@ -101,7 +97,6 @@ static StringTableEntry jointRevoluteMotorMaxTorqueName   = StringTable->insert(
 static StringTableEntry jointWeldNodeName                 = StringTable->insert( "Weld" );
 static StringTableEntry jointWeldFrequencyName            = jointDistanceFrequencyName;
 static StringTableEntry jointWeldDampingRatioName         = jointDistanceDampingRatioName;
-static StringTableEntry jointRevoluteMotorMaxTorqueName;
 
 static StringTableEntry jointWheelNodeName                = StringTable->insert( "Wheel" );
 static StringTableEntry jointWheelWorldAxisName           = StringTable->insert( "WorldAxis" );
@@ -113,7 +108,6 @@ static StringTableEntry jointWheelDampingRatioName        = jointDistanceDamping
 static StringTableEntry jointFrictionNodeName             = StringTable->insert( "Friction" );
 static StringTableEntry jointFrictionMaxForceName         = StringTable->insert( "MaxForce" );
 static StringTableEntry jointFrictionMaxTorqueName        = jointRevoluteMotorMaxTorqueName;
-static StringTableEntry jointWheelDampingRatioName;
 
 static StringTableEntry jointPrismaticNodeName            = StringTable->insert( "Prismatic" );
 static StringTableEntry jointPrismaticWorldAxisName       = jointWheelWorldAxisName;
@@ -138,7 +132,7 @@ static StringTableEntry jointTargetDampingRatioName       = jointDistanceDamping
 static StringTableEntry jointMotorNodeName                = StringTable->insert( "Motor" );
 static StringTableEntry jointMotorLinearOffsetName        = StringTable->insert( "LinearOffset" );
 static StringTableEntry jointMotorAngularOffsetName       = StringTable->insert( "AngularOffset" );
-static StringTableEntry jointTargetNodeName;
+
 static StringTableEntry jointMotorMaxForceName            = jointFrictionMaxForceName;
 static StringTableEntry jointMotorMaxTorqueName           = jointRevoluteMotorMaxTorqueName;
 static StringTableEntry jointMotorCorrectionFactorName    = StringTable->insert( "CorrectionFactor" );
@@ -179,79 +173,6 @@ Scene::Scene() :
     mRenderCallback(false),
     mSceneIndex(0)
 {
-    // Initialize Taml property names.
-    if ( !tamlPropertiesInitialized )
-    {
-        jointCustomNodeName               = StringTable->insert( "Joints" );
-        jointCollideConnectedName         = StringTable->insert( "CollideConnected" );
-        jointLocalAnchorAName             = StringTable->insert( "LocalAnchorA" );
-        jointLocalAnchorBName             = StringTable->insert( "LocalAnchorB" );
-
-        jointDistanceNodeName             = StringTable->insert( "Distance" );
-        jointDistanceLengthName           = StringTable->insert( "Length" );
-        jointDistanceFrequencyName        = StringTable->insert( "Frequency" );
-        jointDistanceDampingRatioName     = StringTable->insert( "DampingRatio" );
-
-        jointRopeNodeName                 = StringTable->insert( "Rope" );
-        jointRopeMaxLengthName            = StringTable->insert( "MaxLength" );
-
-        jointRevoluteNodeName             = StringTable->insert( "Revolute" );
-        jointRevoluteLimitLowerAngleName  = StringTable->insert( "LowerAngle" );
-        jointRevoluteLimitUpperAngleName  = StringTable->insert( "UpperAngle" );
-        jointRevoluteMotorSpeedName       = StringTable->insert( "MotorSpeed" );
-        jointRevoluteMotorMaxTorqueName   = StringTable->insert( "MaxTorque" );
-
-        jointWeldNodeName                 = StringTable->insert( "Weld" );
-        jointWeldFrequencyName            = jointDistanceFrequencyName;
-        jointWeldDampingRatioName         = jointDistanceDampingRatioName;
-
-        jointWheelNodeName                = StringTable->insert( "Wheel" );
-        jointWheelWorldAxisName           = StringTable->insert( "WorldAxis" );
-        jointWheelMotorSpeedName          = StringTable->insert( "MotorSpeed" );
-        jointWheelMotorMaxTorqueName      = jointRevoluteMotorMaxTorqueName;
-        jointWheelFrequencyName           = jointDistanceFrequencyName;
-        jointWheelDampingRatioName        = jointDistanceDampingRatioName;
-
-        jointFrictionNodeName             = StringTable->insert( "Friction" );
-        jointFrictionMaxForceName         = StringTable->insert( "MaxForce" );
-        jointFrictionMaxTorqueName        = jointRevoluteMotorMaxTorqueName;
-
-        jointPrismaticNodeName            = StringTable->insert( "Prismatic" );
-        jointPrismaticWorldAxisName       = jointWheelWorldAxisName;
-        jointPrismaticLimitLowerTransName = StringTable->insert( "LowerTranslation" );
-        jointPrismaticLimitUpperTransName = StringTable->insert( "UpperTranslation" );
-        jointPrismaticMotorSpeedName      = jointRevoluteMotorSpeedName;
-        jointPrismaticMotorMaxForceName   = jointFrictionMaxForceName;
-
-        jointPulleyNodeName               = StringTable->insert( "Pulley" );
-        jointPulleyGroundAnchorAName      = StringTable->insert( "GroundAnchorA" );
-        jointPulleyGroundAnchorBName      = StringTable->insert( "GroundAnchorB" );
-        jointPulleyLengthAName            = StringTable->insert( "LengthA" );
-        jointPulleyLengthBName            = StringTable->insert( "LengthB" );
-        jointPulleyRatioName              = StringTable->insert( "Ratio" );
-
-        jointTargetNodeName               = StringTable->insert( "Target" );
-        jointTargetWorldTargetName        = StringTable->insert( "WorldTarget" );
-        jointTargetMaxForceName           = StringTable->insert( jointFrictionMaxForceName );
-        jointTargetFrequencyName          = jointDistanceFrequencyName;
-        jointTargetDampingRatioName       = jointDistanceDampingRatioName;
-
-        jointMotorNodeName                = StringTable->insert( "Motor" );
-        jointMotorLinearOffsetName        = StringTable->insert( "LinearOffset" );
-        jointMotorAngularOffsetName       = StringTable->insert( "AngularOffset" );
-        jointMotorMaxForceName            = jointFrictionMaxForceName;
-        jointMotorMaxTorqueName           = jointRevoluteMotorMaxTorqueName;
-        jointMotorCorrectionFactorName    = StringTable->insert( "CorrectionFactor" );
-
-        controllerCustomNodeName	      = StringTable->insert( "Controllers" );
-
-        assetPreloadNodeName              = StringTable->insert( "AssetPreloads" );
-        assetNodeName                     = StringTable->insert( "Asset" );
-
-        // Flag as initialized.
-        tamlPropertiesInitialized = true;
-    }
-
     // Set Vector Associations.
     VECTOR_SET_ASSOCIATION( mSceneObjects );
     VECTOR_SET_ASSOCIATION( mDeleteRequests );
@@ -577,16 +498,16 @@ void Scene::dispatchBeginContactCallbacks( void )
         const F32 tangentImpulse2 = tickContact.mTangentImpulses[1];
 
         // Format objects.
-        char* pSceneObjectABuffer = Con::getArgBuffer( 8 );
-        char* pSceneObjectBBuffer = Con::getArgBuffer( 8 );
-        dSprintf( pSceneObjectABuffer, 8, "%d", pSceneObjectA->getId() );
-        dSprintf( pSceneObjectBBuffer, 8, "%d", pSceneObjectB->getId() );
+        char sceneObjectABuffer[16];
+        char sceneObjectBBuffer[16];
+        dSprintf( sceneObjectABuffer, sizeof(sceneObjectABuffer), "%d", pSceneObjectA->getId() );
+        dSprintf( sceneObjectBBuffer, sizeof(sceneObjectBBuffer), "%d", pSceneObjectB->getId() );
 
         // Format miscellaneous information.
-        char* pMiscInfoBuffer = Con::getArgBuffer(128);
+        char miscInfoBuffer[128];
         if ( pointCount == 2 )
         {
-            dSprintf(pMiscInfoBuffer, 128,
+            dSprintf(miscInfoBuffer, sizeof(miscInfoBuffer),
                 "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
                 shapeIndexA, shapeIndexB,
                 normal.x, normal.y,
@@ -2236,6 +2157,22 @@ bool Scene::getRevoluteJointMotor(
 
 //-----------------------------------------------------------------------------
 
+F32 Scene::getRevoluteJointAngle( const U32 jointId )
+{
+    // MM: These are for Simon to fill-in!
+    return 0.0f;
+}
+
+//-----------------------------------------------------------------------------
+
+F32	Scene::getRevoluteJointSpeed( const U32 jointID )
+{
+    // MM: These are for Simon to fill-in!
+    return 0.0f;
+}
+
+//-----------------------------------------------------------------------------
+
 S32 Scene::createWeldJoint(
         const SceneObject* pSceneObjectA, const SceneObject* pSceneObjectB,
         const b2Vec2& localAnchorA, const b2Vec2& localAnchorB,

+ 4 - 5
engine/source/2d/scene/Scene.h

@@ -442,6 +442,10 @@ public:
                                 bool& enableMotor,
                                 F32& motorSpeed,
                                 F32& maxMotorTorque );
+
+	F32                     getRevoluteJointAngle( const U32 jointId );
+	F32						getRevoluteJointSpeed( const U32 jointId );
+
     /// Weld joint.
     S32                     createWeldJoint(
                                 const SceneObject* pSceneObjectA, const SceneObject* pSceneObjectB,
@@ -619,11 +623,6 @@ public:
 
     F32                     getMotorJointMaxTorque( const U32 jointId );
 
-	/// Misc Joint Utilities - 19-03-13 - capnlove
-
-	F32                     getRevoluteJointAngle(const U32 jointID);
-	F32						getRevoluteJointSpeed(const U32 jointID);
-
     /// Debug and metrics.
     inline void             setDebugOn( const U32 debugMask )           { mDebugMask |= debugMask; }
     inline void             setDebugOff( const U32 debugMask )          { mDebugMask &= ~debugMask; }

+ 26 - 37
engine/source/2d/scene/Scene_ScriptBinding.h

@@ -965,6 +965,32 @@ ConsoleMethod(Scene, getRevoluteJointMotor, const char*, 3, 3,  "(jointId) Gets
 
 //-----------------------------------------------------------------------------
 
+ConsoleMethod(Scene, getRevoluteJointAngle, F32, 3, 3,      "(jointId) Gets the current angle of a revolute joint.\n"
+                                                            "@param jointId The Id of the joint to use.\n"
+                                                            "@return Returns the joint angle." )
+{
+    // Fetch joint Id.
+    const S32 jointId = dAtoi(argv[2]);
+
+    // Access joint.
+	return object->getRevoluteJointAngle( jointId );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(Scene, getRevoluteJointSpeed, F32, 3, 3,  "(jointId) Gets the current speed of a revolute joint.\n"
+                                                        "@param jointId The Id of the joint to use.\n"
+                                                        "@return Returns the joint speed as Angular Velocity" )
+{
+    // Fetch joint Id.
+    const S32 jointId = dAtoi(argv[2]);
+
+    // Access joint.
+	return object->getRevoluteJointSpeed( jointId );
+}
+
+//-----------------------------------------------------------------------------
+
 ConsoleMethod(Scene, createWeldJoint, S32, 4, 11,       "(sceneObjectA, sceneObjectB, [localAnchorA X/Y], [localAnchorB X/Y], [frequency], [dampingRatio], [collideConnected]) Creates a weld joint.\n"
                                                                 "@param sceneObjectA The first scene object to connect to the joint.  Use an empty string to indicate the Scene ground body.\n"
                                                                 "@param sceneObjectB The second scene object to connect to the joint.  Use an empty string to indicate the Scene ground body.\n"
@@ -3353,40 +3379,3 @@ ConsoleMethod(Scene, create, const char*, 3, 3, "(type) Creates the specified sc
     return pSceneObject == NULL ? NULL : pSceneObject->getIdString();
 }
 
-ConsoleMethod(Scene, getRevoluteJointAngle, const char*, 3, 3,  "(jointId) Gets the current angle of a revolute joint.\n"
-                                                                        "@param jointId The Id of the joint to use.\n"
-                                                                    "@return Returns the joint angle in degrees (not Rad" )
-{
-    // Fetch joint Id.
-    const S32 jointId = dAtoi(argv[2]);
-
-    // Args.
-    F32 currentAngle;
-
-    // Access joint.
-	currentAngle = object->getRevoluteJointAngle( jointId);
-    
-    // Format output.
-    char* pBuffer = Con::getReturnBuffer(64);
-    dSprintf( pBuffer, 64, "%g", mRadToDeg(currentAngle) );
-    return pBuffer;
-}
-
-ConsoleMethod(Scene, getRevoluteJointSpeed, const char*, 3, 3,  "(jointId) Gets the current speed of a revolute joint.\n"
-                                                                        "@param jointId The Id of the joint to use.\n"
-                                                                    "@return Returns the joint speed as Angular Velocity" )
-{
-    // Fetch joint Id.
-    const S32 jointId = dAtoi(argv[2]);
-
-    // Args.
-    F32 angularVel;
-
-    // Access joint.
-	angularVel = object->getRevoluteJointSpeed( jointId);
-    
-    // Format output.
-    char* pBuffer = Con::getReturnBuffer(64);
-    dSprintf( pBuffer, 64, "%g", angularVel);
-    return pBuffer;
-}