Browse Source

Merge branches 'doxygen' and 'downstream' of https://github.com/lilligreen/Torque2D into doxygen

lilligreen 12 years ago
parent
commit
a3b5f9619b
36 changed files with 2670 additions and 372 deletions
  1. 33 21
      engine/compilers/Xcode/Torque2D.xcodeproj/project.pbxproj
  2. 2 3
      engine/compilers/Xcode/Torque2D.xcodeproj/xcshareddata/xcschemes/Torque2D.xcscheme
  3. 29 2
      engine/compilers/Xcode/Torque2D/Config.xcconfig
  4. 2 0
      engine/source/2d/assets/ImageAsset.h
  5. 18 0
      engine/source/2d/assets/ImageAsset_ScriptBinding.h
  6. 1 1
      engine/source/2d/assets/ParticleAsset.cc
  7. 803 0
      engine/source/2d/assets/ParticleAssetEmitter_ScriptBinding.h
  8. 1 1
      engine/source/2d/assets/ParticleAssetField.cc
  9. 404 0
      engine/source/2d/assets/ParticleAsset_ScriptBinding.h
  10. 172 0
      engine/source/2d/controllers/PointForceController_ScriptBinding.h
  11. 1 0
      engine/source/2d/core/SpriteBatchItem.h
  12. 26 2
      engine/source/2d/core/SpriteBatchQuery.cc
  13. 1 0
      engine/source/2d/core/SpriteBatchQuery.h
  14. 2 29
      engine/source/2d/gui/SceneWindow.cc
  15. 0 2
      engine/source/2d/gui/SceneWindow.h
  16. 14 10
      engine/source/2d/sceneobject/CompositeSprite_ScriptBinding.h
  17. 4 4
      engine/source/2d/sceneobject/ImageFont.cc
  18. 5 5
      engine/source/2d/sceneobject/ImageFont.h
  19. 140 0
      engine/source/2d/sceneobject/ImageFont_ScriptBinding.h
  20. 6 6
      engine/source/2d/sceneobject/ParticlePlayer.cc
  21. 230 0
      engine/source/2d/sceneobject/ParticlePlayer_ScriptBinding.h
  22. 19 1
      engine/source/2d/sceneobject/SceneObject_ScriptBinding.h
  23. 1 1
      engine/source/2d/sceneobject/ShapeVector.h
  24. 76 27
      engine/source/audio/audio.cc
  25. 2 0
      engine/source/audio/audio.h
  26. 31 8
      engine/source/audio/audioBuffer.cc
  27. 6 3
      engine/source/audio/audio_ScriptBinding.cc
  28. 1 1
      engine/source/graphics/TextureManager.cc
  29. 10 1
      engine/source/io/fileSystem_ScriptBinding.cc
  30. 315 0
      engine/source/math/mConsoleFunctions.cc
  31. 20 0
      engine/source/math/mMathFn.h
  32. 6 1
      engine/source/persistence/SimXMLDocument.cpp
  33. 251 241
      engine/source/platformOSX/osxFont.mm
  34. 14 0
      engine/source/platformOSX/osxOpenGLDevice.mm
  35. 22 0
      engine/source/platformOSX/platformOSX.mm
  36. 2 2
      engine/source/platformWin32/winWindow.cc

+ 33 - 21
engine/compilers/Xcode/Torque2D.xcodeproj/project.pbxproj

@@ -54,7 +54,6 @@
 		8658B175165A7BFB0087ABC1 /* osxNetwork.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8658B172165A7BFB0087ABC1 /* osxNetwork.mm */; };
 		8658B176165A7BFB0087ABC1 /* osxString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8658B173165A7BFB0087ABC1 /* osxString.mm */; };
 		865A20CA16515B1E00527C44 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8BF1651518C002FE082 /* AppKit.framework */; };
-		865A20CB16515B1E00527C44 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 865A20C116515ACE00527C44 /* AVFoundation.framework */; };
 		865A20CC16515B1E00527C44 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8BC1651518C002FE082 /* Cocoa.framework */; };
 		865A20CD16515B1E00527C44 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8C01651518C002FE082 /* CoreData.framework */; };
 		865A20CE16515B1E00527C44 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 865A20C216515ACE00527C44 /* CoreFoundation.framework */; };
@@ -455,6 +454,7 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		04CC626B1795512500F9C119 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = ../../../../../../../System/Library/Frameworks/AVFoundation.framework; sourceTree = "<group>"; };
 		2A03300B165D1D2100E9CD70 /* unitTesting.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unitTesting.cc; path = ../../../source/testing/unitTesting.cc; sourceTree = "<group>"; };
 		2A03300C165D1D2100E9CD70 /* unitTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = unitTesting.h; path = ../../../source/testing/unitTesting.h; sourceTree = "<group>"; };
 		2A033010165D1D4100E9CD70 /* platformFileIoTests.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = platformFileIoTests.cc; path = ../../../source/testing/tests/platformFileIoTests.cc; sourceTree = "<group>"; };
@@ -560,7 +560,7 @@
 		8609FE3016556E5A004662ED /* osxThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxThread.mm; sourceTree = "<group>"; };
 		8609FE3216556F22004662ED /* osxFileDialogs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxFileDialogs.mm; sourceTree = "<group>"; };
 		8609FE351655716E004662ED /* osxPopupMenu.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxPopupMenu.mm; sourceTree = "<group>"; };
-		8609FE37165572EC004662ED /* osxFont.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxFont.mm; sourceTree = "<group>"; };
+		8609FE37165572EC004662ED /* osxFont.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 1; path = osxFont.mm; sourceTree = "<group>"; };
 		861CD8CE1678F6C200DAE1A0 /* fileDialog_ScriptBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fileDialog_ScriptBinding.h; sourceTree = "<group>"; };
 		861CD8CF1678F6C200DAE1A0 /* fileDialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileDialog.cc; sourceTree = "<group>"; };
 		864ECFEA1652795700012416 /* platform_ScriptBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_ScriptBinding.h; sourceTree = "<group>"; };
@@ -1437,7 +1437,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				865A20CA16515B1E00527C44 /* AppKit.framework in Frameworks */,
-				865A20CB16515B1E00527C44 /* AVFoundation.framework in Frameworks */,
 				865A20CC16515B1E00527C44 /* Cocoa.framework in Frameworks */,
 				865A20CD16515B1E00527C44 /* CoreData.framework in Frameworks */,
 				865A20CE16515B1E00527C44 /* CoreFoundation.framework in Frameworks */,
@@ -1901,6 +1900,7 @@
 		869FF8AD1651518C002FE082 = {
 			isa = PBXGroup;
 			children = (
+				04CC626B1795512500F9C119 /* AVFoundation.framework */,
 				8652F29F16C146CF00639EFE /* torque2d.icns */,
 				869FF8C21651518C002FE082 /* Torque2D */,
 				865A2351165188AF00527C44 /* platformOSX */,
@@ -3543,32 +3543,34 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = YES;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = TORQUE_SHIPPING;
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Shipping;
 		};
 		865A20AF165152EA00527C44 /* Shipping */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3577,6 +3579,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3590,9 +3593,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Shipping;
@@ -3601,14 +3605,14 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_OPTIMIZATION_LEVEL = 0;
@@ -3618,15 +3622,17 @@
 					"GTEST_USE_OWN_TR1_TUPLE=1",
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				ONLY_ACTIVE_ARCH = NO;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Debug;
 		};
@@ -3634,36 +3640,38 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = YES;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					TORQUE_RELEASE,
 					GTEST_OS_MAC,
 					"GTEST_USE_OWN_TR1_TUPLE=1",
 				);
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Release;
 		};
 		869FF8D71651518C002FE082 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3672,6 +3680,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3687,9 +3696,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)_DEBUG";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Debug;
@@ -3697,7 +3707,7 @@
 		869FF8D81651518C002FE082 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3706,6 +3716,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3721,9 +3732,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Release;

+ 2 - 3
engine/compilers/Xcode/Torque2D.xcodeproj/xcshareddata/xcschemes/Torque2D.xcscheme

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
    LastUpgradeVersion = "0460"
-   version = "1.3">
+   version = "1.8">
    <BuildAction
       parallelizeBuildables = "YES"
       buildImplicitDependencies = "YES">
@@ -44,8 +44,7 @@
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Debug"
-      ignoresPersistentStateOnLaunch = "NO"
+      buildConfiguration = "Release"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">
       <BuildableProductRunnable>

+ 29 - 2
engine/compilers/Xcode/Torque2D/Config.xcconfig

@@ -550,6 +550,33 @@ void ImageAsset::setCellHeight( const S32 cellheight )
     refreshAsset();
 }
 
+S32 ImageAsset::getExplicitCellWidth(const S32 cellIndex)
+{
+	if ( !getExplicitMode() )
+    {
+        // No, so warn.
+        Con::warnf( "ImageAsset() - Cannot perform explicit cell operation when not in explicit mode." );
+        return (0);
+    }
+    
+    ImageAsset::FrameArea::PixelArea thisCell = mExplicitFrames.at(cellIndex);
+    return(thisCell.mPixelWidth);
+
+}
+
+S32 ImageAsset::getExplicitCellHeight(const S32 cellIndex)
+{
+	if ( !getExplicitMode() )
+    {
+        // No, so warn.
+        Con::warnf( "ImageAsset() - Cannot perform explicit cell operation when not in explicit mode." );
+        return (0);
+	}
+	
+    ImageAsset::FrameArea::PixelArea thisCell = mExplicitFrames.at(cellIndex);
+    return(thisCell.mPixelHeight);
+
+}
 //------------------------------------------------------------------------------
 
 bool ImageAsset::clearExplicitCells( void )
@@ -999,7 +1026,7 @@ void ImageAsset::calculateImplicitMode( void )
     }
 
     // The cell height needs to be at maximum the image height!
-    if ( mCellHeight < 1 || mCellHeight > imageWidth )
+    if ( mCellHeight < 1 || mCellHeight > imageHeight )
     {
         // Warn.
         Con::warnf("ImageAsset::calculateImage() - Invalid Cell Height of %d.", mCellHeight );
@@ -1015,7 +1042,7 @@ void ImageAsset::calculateImplicitMode( void )
     }
 
     // The Cell Offset Y needs to be within the image.
-    if ( mCellOffsetY < 0 || mCellOffsetY >= imageWidth )
+    if ( mCellOffsetY < 0 || mCellOffsetY >= imageHeight )
     {
         // Warn.
         Con::warnf("ImageAsset::calculateImage() - Invalid Cell OffsetY of %d.", mCellOffsetY );

+ 2 - 0
engine/source/2d/assets/ImageAsset.h

@@ -202,9 +202,11 @@ public:
 
     void                    setCellWidth( const S32 cellWidth );
     inline S32              getCellWidth( void ) const						{ return mCellWidth; }
+    S32                     getExplicitCellWidth(const S32 cellIndex);
 
     void                    setCellHeight( const S32 cellheight );
     S32                     getCellHeight( void) const						{ return mCellHeight; }
+    S32                     getExplicitCellHeight(const S32 cellIndex);
 
     inline TextureHandle&   getImageTexture( void )                         { return mImageTextureHandle; }
     inline S32              getImageWidth( void ) const                     { return mImageTextureHandle.getWidth(); }

+ 18 - 0
engine/source/2d/assets/ImageAsset_ScriptBinding.h

@@ -253,6 +253,24 @@ ConsoleMethodWithDocs(ImageAsset, getCellWidth, ConsoleInt, 2, 2, ())
     return object->getCellWidth();
 }
 
+ConsoleMethod(ImageAsset, getExplicitCellWidth, S32, 3,3, "(CellIndex) Gets the CELL width in Explicit Mode.\n"
+                                                                        "@return the specified CELL width.")
+{
+	    // Fetch cell index.
+    const S32 cellIndex = dAtoi( argv[2] );
+
+    return(object->getExplicitCellWidth(cellIndex));
+}
+
+ConsoleMethod(ImageAsset, getExplicitCellHeight, S32, 3,3, "(CellIndex) Gets the CELL height in Explicit Mode.\n"
+                                                                        "@return the specified CELL height.")
+{
+	    // Fetch cell index.
+    const S32 cellIndex = dAtoi( argv[2] );
+
+    return(object->getExplicitCellHeight(cellIndex));
+
+}
 //-----------------------------------------------------------------------------
 
 /*! Sets the CELL height.

+ 1 - 1
engine/source/2d/assets/ParticleAsset.cc

@@ -130,7 +130,7 @@ ParticleAsset::ParticleAsset() :
     VECTOR_SET_ASSOCIATION( mEmitters );  
 
     // Initialize particle fields.
-    mParticleFields.addField( mParticleLifeScale.getBase(), "LifeScale", 1000.0f, 0.0f, 100.0f, 1.0f );
+    mParticleFields.addField( mParticleLifeScale.getBase(), "LifetimeScale", 1000.0f, 0.0f, 100.0f, 1.0f );
     mParticleFields.addField( mQuantityScale.getBase(), "QuantityScale", 1000.0f, 0.0f, 100.0f, 1.0f );
     mParticleFields.addField( mSizeXScale.getBase(), "SizeXScale", 1000.0f, 0.0f, 100.0f, 1.0f );
     mParticleFields.addField( mSizeYScale.getBase(), "SizeYScale", 1000.0f, 0.0f, 100.0f, 1.0f );

+ 803 - 0
engine/source/2d/assets/ParticleAssetEmitter_ScriptBinding.h

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 //-----------------------------------------------------------------------------
 // Copyright (c) 2013 GarageGames, LLC
 //
@@ -824,3 +825,805 @@ ConsoleMethodWithDocs(ParticleAssetEmitter, getValueScale, ConsoleFloat, 2, 2, (
 }
 
 ConsoleMethodGroupEndWithDocs(ParticleAssetEmitter)
+=======
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/// Particle emitter accessors.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getOwner, const char*, 2, 2,    "() Gets the asset owner of the emitter.\n"
+                                                                    "@return The asset owner of the emitter or nothing if no owner assigned." )
+{
+    // Fetch the owner.
+    ParticleAsset* pParticleAsset = object->getOwner();
+
+    return pParticleAsset == NULL ? StringTable->EmptyString : pParticleAsset->getIdString();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setEmitterName, void, 3, 3,     "(emitterName) Sets the name of the emitter.\n"
+                                                                    "@param emitterName The name to set the emitter to.\n"
+                                                                    "@return No return value." )
+{
+    object->setEmitterName( argv[2] );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getEmitterName, const char*, 2, 2,  "() Gets the name of the emitter.\n"
+                                                                        "@return The name of the emitter." )
+{
+    return object->getEmitterName();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setEmitterType, void, 3, 3,     "(emitterType) Sets the type of the emitter.\n"
+                                                                    "@param emitterType The type to set the emitter.  Either 'POINT', 'LINE', 'BOX' or 'DISK', 'ELLIPSE' or 'TORUS'.\n"
+                                                                    "An emitter-type of 'POINT' creates the particles at the position of the particle asset.\n"
+                                                                    "An emitter-type of 'LINE' creates the particles along a line defined by the particle width.\n"
+                                                                    "An emitter-type of 'BOX' creates the particles within the dimensions defined by the particle size.\n"
+                                                                    "An emitter-type of 'DISK' creates the particles within a disk with radii defined by the particle size.\n"
+                                                                    "An emitter-type of 'ELLIPSE' creates the particles on an ellipse with the radii defined by the particle size.\n"
+                                                                    "An emitter-type of 'TORUS' creates the particles within a torus with a maximum and minimum radii defined by the particle width and height respectively.\n"
+                                                                    "@return No return value." )
+{
+    object->setEmitterType( ParticleAssetEmitter::getEmitterTypeEnum(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getEmitterType, const char*, 2, 2,  "() Gets the type of the emitter.\n"
+                                                                        "@return The type of the emitter." )
+{
+    return ParticleAssetEmitter::getEmitterTypeDescription( object->getEmitterType() );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setEmitterOffset, void, 3, 4,   "(float X / float Y) - Offsets the position of the emitter relative to the effect or player position.\n"
+                                                                    "@return No return value.")
+{
+    // Grab the element count.
+    U32 elementCount =Utility::mGetStringElementCount(argv[2]);
+    
+    // ("positionX positionY")
+    if ( (elementCount == 2) && (argc < 4) )
+    {
+        object->setEmitterOffset( Vector2( argv[2] ) );
+        return;
+    }
+    
+    // (positionX, positionY)
+    if ( (elementCount == 1) && (argc > 3) )
+    {
+        object->setEmitterOffset( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
+        return;
+    }
+    
+    // Warn.
+    Con::warnf( "ParticleAssetEmitter::setEmitterOffset() - Invalid number of parameters!" );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getEmitterOffset, const char*, 2, 2,    "Gets the emitter offset position.\n"
+                                                                            "@return (float x/float y) The offset of the emitter relative to the effect or player position.")
+{
+    return object->getEmitterOffset().scriptThis();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setEmitterSize, void, 3, 4, "(float width / float height) - Sets the emitter size.\n"
+                                                                "@param width The width of the emitter.\n"
+                                                                "@param height The height of the emitter.\n"
+                                                                "@return No return value.")
+{
+    F32 width, height;
+    
+    const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
+    
+    // ("width height")
+    if ((elementCount == 2) && (argc == 3))
+    {
+        width = dAtof(Utility::mGetStringElement(argv[2], 0));
+        height = dAtof(Utility::mGetStringElement(argv[2], 1));
+    }
+    
+    // (width, [height])
+    else if (elementCount == 1)
+    {
+        width = dAtof(argv[2]);
+        
+        if (argc > 3)
+            height = dAtof(argv[3]);
+        else
+            height = width;
+    }
+    
+    // Invalid
+    else
+    {
+        Con::warnf("ParticleAssetEmitter::setEmitterSize() - Invalid number of parameters!");
+        return;
+    }
+    
+    // Set Size.
+    object->setEmitterSize(Vector2(width, height));
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getEmitterSize, const char*, 2, 2,  "Gets the emitter size.\n"
+                                                                        "@return (float width/float height) The width and height of the emitter.")
+{
+    return object->getEmitterSize().scriptThis();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setEmitterAngle, void, 3, 3,    "(float angle) - Sets the emitter angle.\n"
+                                                                    "@param angle The angle of the emitter."
+                                                                    "@return No return value.")
+{
+    // Set Rotation.
+    object->setEmitterAngle( mDegToRad( dAtof(argv[2]) ) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getEmitterAngle, F32, 2, 2, "() Gets the emitter angle.\n"
+                                                                "@return (float angle) The emitter's current angle.")
+{
+    // Return angle.
+    return mRadToDeg( object->getEmitterAngle());
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setFixedAspect, void, 3, 3,     "(fixedAspect) Sets the emitter to used a fixed-aspect for particles.\n"
+                                                                    "@param fixedAspect Whether to use a fixed-aspect or not.\n"
+                                                                    "@return No return value." )
+{
+    object->setFixedAspect( dAtob(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getFixedAspect, bool, 2, 2,     "() Gets whether the emitter uses a fixed-aspect for particles or not.\n"
+                                                                    "@return Whether the emitter uses a fixed-aspect for particles or not." )
+{
+    return object->getFixedAspect();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setFixedForceAngle, void, 3, 3, "(fixedForceAngle) Sets the emitter fixed-force angle for particles.\n"
+                                                                    "@param fixedForceAngle The fixed-force angle for particles.\n"
+                                                                    "@return No return value." )
+{
+    object->setFixedForceAngle( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getFixedForceAngle, F32, 2, 2,  "() Gets the emitter fixed-force angle for particles.\n"
+                                                                    "@return The fixed-force angle for particles." )
+{
+    return object->getFixedForceAngle();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setOrientationType, void, 3, 3,     "(orientationType) Sets the orientation-type of the emitter.\n"
+                                                                        "@param orientationType The orientation-type to set the emitter to.  Either 'FIXED', 'ALIGNED' or 'RANDOM'.\n"
+                                                                        "An orientation-type of 'FIXED' causes the particles to be orientation at a fixed angle.\n"
+                                                                        "An orientation-type of 'ALIGNED' causes the particles to be orientation at the current emission angle.\n"
+                                                                        "An orientation-type of 'RANDOM' causes the particles to be orientation at a fixed angle.\n"
+                                                                        "@return No return value." )
+{
+    object->setOrientationType( ParticleAssetEmitter::getOrientationTypeEnum(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getOrientationType, const char*, 2, 2,  "() Gets the orientation-type of the emitter.\n"
+                                                                            "@return The orientation-type of the emitter." )
+{
+    return ParticleAssetEmitter::getOrientationTypeDescription( object->getOrientationType() );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setKeepAligned, void, 3, 3,     "(keepAligned) Sets whether to keep emitted particles aligned or not."
+                                                                    "@keepAligned Whether to keep emitted particles aligned or not.\n"
+                                                                    "@return No return value." )
+{
+    object->setKeepAligned( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getKeepAligned, bool, 2, 2, "() Gets whether to keep emitted particles aligned or not.\n"
+                                                                "@return Whether to keep emitted particles aligned or not." )
+{
+    return object->getKeepAligned();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setAlignedAngleOffset, void, 3, 3,  "(alignAngleOffset) Sets the aligned angle offset.\n"
+                                                                        "@param alignAngleOffset The aligned angle offset.\n"
+                                                                        "@return No return value." )
+{
+    object->setAlignedAngleOffset( dAtof(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getAlignedAngleOffset, F32, 2, 2,  "() Gets the aligned angle offset.\n"
+                                                                        "@return The aligned angle offset." )
+{
+    return object->getAlignedAngleOffset();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setRandomAngleOffset, void, 3, 3, "(randomAngle) - Set Random-Orientation Angle-Offset.")
+{
+    object->setRandomAngleOffset( dAtof(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getRandomAngleOffset, F32, 2, 2, "Get Random-Orientation Angle-Offset.")
+{
+    return object->getRandomAngleOffset();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setRandomArc, void, 3, 3, "(randomArc) - Set Random-Orientation Arc.")
+{
+    object->setRandomArc( dAtof(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getRandomArc, F32, 2, 2, "Get Random-Orientation Arc.")
+{
+    return object->getRandomArc();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setFixedAngleOffset, void, 3, 3, "(randomAngle) - Set Fixed-Orientation Angle-Offset.")
+{
+    object->setFixedAngleOffset( dAtof(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getFixedAngleOffset, F32, 2, 2, "Get Fixed-Orientation Angle-Offset.")
+{
+    return object->getFixedAngleOffset();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setPivotPoint, void, 3, 4, "(pivotX / pivotY) - Set the Pivot-Point.")
+{
+    // Grab the element count.
+    U32 elementCount =Utility::mGetStringElementCount(argv[2]);
+
+    // ("pivotX pivotY")
+    if ( (elementCount == 2) && (argc < 4) )
+    {
+        object->setPivotPoint( Vector2( argv[2] ) );
+        return;
+    }
+
+    // (pivotX, pivotY)
+    if ( (elementCount == 1) && (argc > 3) )
+    {
+        object->setPivotPoint( Vector2( dAtof(argv[2]), dAtof(argv[3]) ) );
+        return;
+    }
+
+    // Warn.
+    Con::warnf( "ParticleAssetEmitter::setPivotPoint() - Invalid number of parameters!" );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getPivotPoint, const char*, 2, 2, "Get Pivot-Point.")
+{
+    return object->getPivotPoint().scriptThis();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setLinkEmissionRotation, void, 3, 3, "(linkEmissionRotation) - Set Link-Emission-Rotation Flag.")
+{
+    object->setLinkEmissionRotation( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getLinkEmissionRotation, bool, 2, 2, "Get Link-Emission-Rotation Flag.")
+{
+    return object->getLinkEmissionRotation();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setIntenseParticles, void, 3, 3, "(intenseParticles) - Set Intense-Particles Flag.")
+{
+    object->setIntenseParticles( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getIntenseParticles, bool, 2, 2, "Get Intense-Particles Flag.")
+{
+    return object->getIntenseParticles();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setSingleParticle, void, 3, 3, "(singleParticle) - Set Single-Particle Flag.")
+{
+    // Set Single Particle.
+    object->setSingleParticle( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getSingleParticle, bool, 2, 2, "Get Single-Particle Flag.")
+{
+    return object->getSingleParticle();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setAttachPositionToEmitter, void, 3, 3, "(attachPositionToEmitter) - Set Attach-Position-To-Emitter Flag.")
+{
+    object->setAttachPositionToEmitter( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getAttachPositionToEmitter, bool, 2, 2, "Get Attach-Position-To-Emitter Flag.")
+{
+    return object->getAttachPositionToEmitter();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setAttachRotationToEmitter, void, 3, 3, "(attachRotationToEmitter) - Set Attach-Rotation-To-Emitter Flag.")
+{
+    object->setAttachRotationToEmitter( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getAttachRotationToEmitter, bool, 2, 2, "Get Attach-Rotation-To-Emitter Flag.")
+{
+    return object->getAttachRotationToEmitter();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setOldestInFront, void, 3, 3,   "(oldestInFront) Sets whether to render particles as oldest on front or not.\n"
+                                                                    "@param oldestInFront Whether to render particles as oldest on front or not.\n"
+                                                                    "@return No return value." )
+{
+    object->setOldestInFront( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getOldestInFront, bool, 2, 2,   "() Gets whether to render particles as oldest on front or not.\n"
+                                                                    "@return Whether to render particles as oldest on front or not." )
+{
+    return object->getOldestInFront();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setImage, bool, 3, 4,   "(imageAssetId, [frame]) Sets the emitter to use the specified image asset Id and optional frame.\n"
+                                                            "@param imageAssetId The image asset Id to use.\n"
+                                                            "@param frame The frame of the image asset Id to use.  Optional.\n"
+                                                            "@return Whether the operation was successful or not." )
+{
+    // Fetch the frame.
+    const U32 frame = argc >= 4 ? dAtoi(argv[3]) : 0;
+
+    return object->setImage( argv[2], frame );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getImage, const char*, 2, 2,    "() Gets the asset Id of the image asset assigned to the emitter.\n"
+                                                                    "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
+{
+    return object->getImage();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setImageFrame, bool, 3, 3,   "(frame) Sets the emitter to use the specified image frame.\n"
+                                                                "@param frame The frame of the image to use..\n"
+                                                                "@return Whether the operation was successful or not." )
+{
+    return object->setImageFrame( dAtoi(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getImageFrame, S32, 2, 2,    "() Gets the asset Id of the image asset assigned to the emitter.\n"
+                                                                    "@return The asset Id of the image asset assigned to the emitter or nothing if no image is assigned." )
+{
+    return object->getImageFrame();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setRandomImageFrame, void, 3, 3,    "(randomImageFrame) Disables the Frame field and uses a random frame from the specified ImageAsset.\n"
+                                                                        "@param randomImageFrame Whether to use a random image frame or not.\n"
+                                                                        "@return No return value." )
+{
+    object->setRandomImageFrame( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getRandomImageFrame, bool, 2, 2,    "() Gets whether a random frame from the specified ImageAsset is being used or not.\n"
+                                                                        "@return Whether to use a random image frame or not." )
+{
+    return object->getRandomImageFrame();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setAnimation, bool, 3, 3,   "(animationAssetId) Sets the emitter to use the specified animation asset Id.\n"
+                                                                "@param animationAssetId The animation asset Id to use.\n"
+                                                                "@return Whether the operation was successful or not." )
+{
+    return object->setAnimation( argv[2] );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getAnimation, const char*, 2, 2,    "() Gets the asset Id of the animation asset assigned to the emitter.\n"
+                                                                        "@return The asset Id of the animation asset assigned to the emitter or nothing if no animation is assigned." )
+{
+    return object->getAnimation();
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setBlendMode, void, 3, 3,   "(blendMode) Sets whether to use render blending or not.\n"
+                                                                "@param blendMode Whether to use render blending or not.\n"
+                                                                "@return No return value." )
+{
+    object->setBlendMode( dAtob(argv[2]) );
+}
+
+//------------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getBlendMode, bool, 2, 2,   "() Gets whether to use render blending or not.\n"
+                                                                "@return Whether to use render blending or not." )
+{
+    return object->getBlendMode();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setSrcBlendFactor, void, 3, 3,  "(srcBlend) - Sets the source blend factory.\n"
+                                                                    "@param srcBlend The source blend factor.\n"
+                                                                    "@return No return Value.")
+{
+    // Fetch source blend factor.
+    const  GLenum blendFactor = SceneObject::getSrcBlendFactorEnum(argv[2]);
+
+    object->setSrcBlendFactor( blendFactor );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getSrcBlendFactor, const char*, 2, 2,   "() - Gets the source render blend factor.\n"
+                                                                            "@return (srcBlend) The source render blend factor.")
+{
+   return SceneObject::getSrcBlendFactorDescription(object->getSrcBlendFactor());
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setDstBlendFactor, void, 3, 3,  "(dstBlend) - Sets the destination render blend factor.\n"
+                                                                    "@param dstBlend The destination render blend factor.\n"
+                                                                    "@return No return Value.")
+{
+    // Fetch destination blend factor.
+    const GLenum blendFactor = SceneObject::getDstBlendFactorEnum(argv[2]);
+
+    object->setDstBlendFactor( blendFactor );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getDstBlendFactor, const char*, 2, 2,   "() - Gets the destination render blend factor.\n"
+                                                                            "@return (dstBlend) The destination render blend factor.")
+{
+   return SceneObject::getDstBlendFactorDescription(object->getDstBlendFactor());
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setAlphaTest, void, 3, 3,   "(float alpha) - Set the render alpha test threshold.\n"
+                                                                "@param alpha The alpha test threshold in the range of 0.0 to 1.0.  Less than zero to disable alpha testing.\n"
+                                                                "@return No return value." )
+
+{
+    object->setAlphaTest(dAtof(argv[2]));
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getAlphaTest, F32, 2, 2,    "() - Gets the render alpha test threshold.\n"
+                                                                "@return The render alpha test threshold in the range of 0.0f to 1.0.  Less than zero represents disabled alpha testing.")
+{
+    return object->getAlphaTest();
+}
+
+
+//-----------------------------------------------------------------------------
+/// Particle emitter fields.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getSelectableFieldCount, S32, 2, 2, "() Gets the number of available selectable fields.\n"
+                                                                        "@return The number of available selectable fields." )
+{
+    return object->getParticleFields().getFields().size();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getSelectableFieldName, const char*, 3, 3, "(fieldIndex) Gets the selectable field at the specified index.\n"
+                                                                                "@return The selectable field name at the specified index." )
+{
+    // Fetch the field hash.
+    const ParticleAssetFieldCollection::typeFieldHash& fieldHash = object->getParticleFields().getFields();
+
+    // Fetch the index.
+    S32 fieldIndex = dAtoi( argv[2] );
+
+    // Is the field index valid?
+    if ( fieldIndex >= 0 && fieldIndex < (S32)fieldHash.size() )
+    {
+        // Yes, but because the fields are in a hash-table, we'll have to iterate and get O(index).
+        for( ParticleAssetFieldCollection::typeFieldHash::const_iterator fieldItr = fieldHash.begin(); fieldItr != fieldHash.end(); ++fieldItr, --fieldIndex )
+        {
+            // Skip if this is not the field index we're looking for?
+            if ( fieldIndex != 0 )
+                continue;
+
+            // Found it so return the field name.
+            return fieldItr->value->getFieldName();
+        }
+    }
+
+
+    // Warn.
+    Con::warnf( "ParticleAssetEmitter::getSelectableFieldName() - Index '%d' is out of range.", fieldIndex );
+
+    return StringTable->EmptyString;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, selectField, bool, 3, 3,   "(fieldName) Select the specified field by its name.\n"
+                                                                "@param fieldName The field name to use for the selection.  Use an empty name to deselect to stop accidental changes.\n"
+                                                            "@return Whether the field was successfully selected or not.")
+{
+    return object->getParticleFields().selectField( argv[2] ) != NULL;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, deselectField, void, 2, 2,  "() Deselect any selected field.  If no field is selected then nothing happens.\n"
+                                                                "@return No return value.")
+{
+    object->getParticleFields().deselectField();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getSelectedField, const char*, 2, 2,   "() Gets the selected field name or nothing if no field is selected.\n"
+                                                                    "@return The selected field name or nothing if no fields is selected.")
+{
+    // Get the selected field.
+    const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
+
+    return pParticleAssetField == NULL ? StringTable->EmptyString : pParticleAssetField->getFieldName();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setSingleDataKey, S32, 3, 3,    "(value) Sets a single data-key at time-zero with the specified value.  All existing keys are cleared.\n"
+                                                                    "@param value The value to set the key to.\n"
+                                                                    "@return Returns the index of the new data-key (always zero) or -1 on failure.")
+{
+    return object->getParticleFields().setSingleDataKey( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, addDataKey, S32, 4, 4,  "(time, value) Add Data-Key to Graph.\n"
+                                                            "@param time The key time.\n"
+                                                            "@param value The value at specified time\n"
+                                                            "@return Returns the index of the new data-key or -1 on failure.")
+{
+    return object->getParticleFields().addDataKey( dAtof(argv[2]), dAtof(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, removeDataKey, bool, 3, 3,  "(keyIndex) Remove the data-key from the field.\n"
+                                                                "@param keyIndex The index of the data-key you want to remove.\n"
+                                                                "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().removeDataKey( dAtoi(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, clearDataKeys, bool, 2, 2,  "() Clears all data-key(s) from the field.\n"
+                                                                "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().clearDataKeys();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setDataKeyValue, bool, 4, 4,    "(keyIndex, value) Set data-key value for the field.\n"
+                                                                    "@param keyIndex The index of the key to be modified.\n"
+                                                                    "@param value The value to change the key to.\n"
+                                                                    "@return Whether the operation was successful or not.")
+{
+   // Set Data Key.
+   return object->getParticleFields().setDataKey( dAtoi(argv[2]), dAtof(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getDataKeyCount, S32, 2, 2,     "() Gets the data-key count.\n"
+                                                                    "@return The number of data-keys in the currently selected field or -1 if no field is selected.")
+{
+   // Get Data Key Count.
+   return object->getParticleFields().getDataKeyCount();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getDataKey, const char*, 3, 3,  "(keyIndex) Gets the data-key at the specified index from the field.\n"
+                                                                    "@param keyIndex The index of the data-key to be retrieved.\n"
+                                                                    "@return The data-key comprising both the time and value or nothing if the key is invalid.")
+{
+   // Fetch the key index.
+   const S32 keyIndex = dAtoi(argv[2]);
+
+   // Fetch the data-key.
+   const ParticleAssetField::DataKey dataKey = object->getParticleFields().getDataKey( keyIndex );
+
+   // Finish if the data-key is bad.
+   if ( dataKey == ParticleAssetField::BadDataKey )
+       return StringTable->EmptyString;
+
+   // Create Returnable Buffer.
+   char* pBuffer = Con::getReturnBuffer(32);
+
+   // Format Buffer.
+   dSprintf(pBuffer, 32, "%f %f", dataKey.mTime, dataKey.mValue );
+
+   // Return buffer.
+   return pBuffer;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getMinValue, F32, 2, 2,     "() Get the minimum value for the field.\n"
+                                                                "@return The minimum value for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMinValue();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getMaxValue, F32, 2, 2,     "() Get the maximum value for the field.\n"
+                                                                "@return The maximum value for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMaxValue();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getMinTime, F32, 2, 2,      "() Get the minimum time for the field.\n"
+                                                                "@return The minimum time for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMinTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getMaxTime, F32, 2, 2,      "() Get the maximum time for the field.\n"
+                                                                "@return The maximum time for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMaxTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getFieldValue, F32, 3, 3,   "(time) Get the fields' value at the specified time.\n"
+                                                                "@param time The time to sample the field value at.\n"
+                                                                "@return The fields' value at the specified time or always 0.0 if no field is selected.")
+{
+   return object->getParticleFields().getFieldValue( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setRepeatTime, bool, 3, 3,  "(repeatTime) Sets the time period to repeat (cycle) the fields' values at.\n"
+                                                                "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().setRepeatTime( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getRepeatTime, F32, 2, 2,   "() Gets the time period that the fields' value repeat (cycle) at.\n"
+                                                                "@return The time period that the fields' value repeat (cycle) at.\n" )
+{
+   return object->getParticleFields().getRepeatTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, setValueScale, bool, 3, 3,  "(valueScale) Set the scaling of field values retrieved from the field.  This does not alter the actual data-key values.\n"
+                                                                "@param valueScale The scale for field values retrieved from the field.\n"
+                                                                "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().setValueScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAssetEmitter, getValueScale, F32, 2, 2,   "() Gets the scaling of field values' retrieved from the field.\n"
+                                                                "@return The scaling of field values' retrieved from the field." )
+{
+   return object->getParticleFields().getValueScale();
+}
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24

+ 1 - 1
engine/source/2d/assets/ParticleAssetField.cc

@@ -543,7 +543,7 @@ void ParticleAssetField::onTamlCustomWrite( TamlCustomNode* pCustomNode )
         const DataKey& dataKey = mDataKeys[index];
 
         // Add a key node.
-        TamlCustomNode* pKeyNode = pCustomNode->addNode( particleAssetFieldDataKeyName );
+        TamlCustomNode* pKeyNode = pAssetField->addNode( particleAssetFieldDataKeyName );
 
         // Add key fields.
         pKeyNode->addField( particleAssetFieldDataKeyTimeName, dataKey.mTime );

+ 404 - 0
engine/source/2d/assets/ParticleAsset_ScriptBinding.h

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 //-----------------------------------------------------------------------------
 // Copyright (c) 2013 GarageGames, LLC
 //
@@ -469,3 +470,406 @@ ConsoleMethodWithDocs(ParticleAsset, moveEmitter, ConsoleVoid, 4, 4, (fromEmitte
 }
 
 ConsoleMethodGroupEndWithDocs(ParticleAsset)
+=======
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/// Particle asset accessors.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setLifeMode, void, 3, 3,   "(lifeMode) Sets the life-mode of the particle effect.\n"
+                                                        "@param lifeMode The life-mode of the particle effect (either INFINITE, CYCLE, KILL or STOP.\n"
+                                                        "A life-mode of INFINITE causes the particle effect to last forever.\n"
+                                                        "A life-mode of CYCLE causes the particle effect to restart playing when its specified 'lifetime' has been reached.\n"
+                                                        "A life-mode of KILL causes the particle effect to be deleted when its specified 'lifetime' has been reached.\n"
+                                                        "A life-mode of STOP causes the particle effect to stop playing (but not be deleted) when its specified lifetime has been reached.\n"
+                                                        "@return No return value.")
+{
+    object->setLifeMode( ParticleAsset::getParticleAssetLifeModeEnum( argv[2] ) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod( ParticleAsset, getLifeMode, const char*, 2, 2,   "() - Gets the life-mode of the particle effect.\n"
+                                                                "@return The life-mode of the particle effect." )
+{
+    return ParticleAsset::getParticleAssetLifeModeDescription( object->getLifeMode() );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setLifetime, void, 3, 3,   "(lifeTime) Sets the lifetime of the particle effect.\n"
+                                                        "@param lifeTime The lifetime of the particle effect.  This is used according to the 'lifeMode' setting.\n"
+                                                        "@return No return value." )
+{
+    object->setLifetime( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getLifetime, F32, 2, 2,    "() Gets the lifetime of the particle effect.\n"
+                                                        "@return The lifetime of the particle effect." )
+{
+    return object->getLifetime();
+}
+
+//-----------------------------------------------------------------------------
+/// Particle asset fields.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getSelectableFieldCount, S32, 2, 2,    "() Gets the number of available selectable fields.\n"
+                                                                    "@return The number of available selectable fields." )
+{
+    return object->getParticleFields().getFields().size();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getSelectableFieldName, const char*, 3, 3, "(fieldIndex) Gets the selectable field at the specified index.\n"
+                                                                        "@return The selectable field name at the specified index." )
+{
+    // Fetch the field hash.
+    const ParticleAssetFieldCollection::typeFieldHash& fieldHash = object->getParticleFields().getFields();
+
+    // Fetch the index.
+    S32 fieldIndex = dAtoi( argv[2] );
+
+    // Is the field index valid?
+    if ( fieldIndex >= 0 && fieldIndex < (S32)fieldHash.size() )
+    {
+        // Yes, but because the fields are in a hash-table, we'll have to iterate and get O(index).
+        for( ParticleAssetFieldCollection::typeFieldHash::const_iterator fieldItr = fieldHash.begin(); fieldItr != fieldHash.end(); ++fieldItr, --fieldIndex )
+        {
+            // Skip if this is not the field index we're looking for?
+            if ( fieldIndex != 0 )
+                continue;
+
+            // Found it so return the field name.
+            return fieldItr->value->getFieldName();
+        }
+    }
+
+
+    // Warn.
+    Con::warnf( "ParticleAsset::getSelectableFieldName() - Index '%d' is out of range.", fieldIndex );
+
+    return StringTable->EmptyString;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, selectField, bool, 3, 3,   "(fieldName) Select the specified field by its name.\n"
+                                                        "@param fieldName The field name to use for the selection.  Use an empty name to deselect to stop accidental changes.\n"
+                                                        "@return Whether the field was successfully selected or not.")
+{
+    return object->getParticleFields().selectField( argv[2] ) != NULL;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, deselectField, void, 2, 2, "() Deselect any selected field.  If no field is selected then nothing happens.\n"
+                                                        "@return No return value.")
+{
+    object->getParticleFields().deselectField();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getSelectedField, const char*, 2, 2,  "() Gets the selected field name or nothing if no field is selected.\n"
+                                                            "@return The selected field name or nothing if no fields is selected.")
+{
+    // Get the selected field.
+    const ParticleAssetField* pParticleAssetField = object->getParticleFields().getSelectedField();
+
+    return pParticleAssetField == NULL ? StringTable->EmptyString : pParticleAssetField->getFieldName();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setSingleDataKey, S32, 3, 3,   "(value) Sets a single data-key at time-zero with the specified value.  All existing keys are cleared.\n"
+                                                            "@param value The value to set the key to.\n"
+                                                            "@return Returns the index of the new data-key (always zero) or -1 on failure.")
+{
+    return object->getParticleFields().setSingleDataKey( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, addDataKey, S32, 4, 4, "(time, value) Add Data-Key to Graph.\n"
+                                                    "@param time The key time.\n"
+                                                    "@param value The value at specified time\n"
+                                                    "@return Returns the index of the new data-key or -1 on failure.")
+{
+    return object->getParticleFields().addDataKey( dAtof(argv[2]), dAtof(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, removeDataKey, bool, 3, 3, "(keyIndex) Remove the data-key from the field.\n"
+                                                        "@param keyIndex The index of the data-key you want to remove.\n"
+                                                        "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().removeDataKey( dAtoi(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, clearDataKeys, bool, 2, 2,     "() Clears all data-key(s) from the field.\n"
+                                                            "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().clearDataKeys();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setDataKeyValue, bool, 4, 4, "(keyIndex, value) Set data-key value for the field.\n"
+                                                          "@param keyIndex The index of the key to be modified.\n"
+                                                          "@param value The value to change the key to.\n"
+                                                          "@return Whether the operation was successful or not.")
+{
+   // Set Data Key.
+   return object->getParticleFields().setDataKey( dAtoi(argv[2]), dAtof(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getDataKeyCount, S32, 2, 2,    "() Gets the data-key count.\n"
+                                                            "@return The number of data-keys in the currently selected field or -1 if no field is selected.")
+{
+   // Get Data Key Count.
+   return object->getParticleFields().getDataKeyCount();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getDataKey, const char*, 3, 3, "(keyIndex) Gets the data-key at the specified index from the field.\n"
+                                                            "@param keyIndex The index of the data-key to be retrieved.\n"
+                                                            "@return The data-key comprising both the time and value or nothing if the key is invalid.")
+{
+   // Fetch the key index.
+   const S32 keyIndex = dAtoi(argv[2]);
+
+   // Fetch the data-key.
+   const ParticleAssetField::DataKey dataKey = object->getParticleFields().getDataKey( keyIndex );
+
+   // Finish if the data-key is bad.
+   if ( dataKey == ParticleAssetField::BadDataKey )
+       return StringTable->EmptyString;
+
+   // Create Returnable Buffer.
+   char* pBuffer = Con::getReturnBuffer(32);
+
+   // Format Buffer.
+   dSprintf(pBuffer, 32, "%f %f", dataKey.mTime, dataKey.mValue );
+
+   // Return buffer.
+   return pBuffer;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getMinValue, F32, 2, 2,    "() Get the minimum value for the field.\n"
+                                                        "@return The minimum value for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMinValue();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getMaxValue, F32, 2, 2,    "() Get the maximum value for the field.\n"
+                                                        "@return The maximum value for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMaxValue();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getMinTime, F32, 2, 2,     "() Get the minimum time for the field.\n"
+                                                        "@return The minimum time for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMinTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getMaxTime, F32, 2, 2,     "() Get the maximum time for the field.\n"
+                                                        "@return The maximum time for the field or always 0.0 if no field is selected." )
+{
+   return object->getParticleFields().getMaxTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getFieldValue, F32, 3, 3,  "(time) Get the fields' value at the specified time.\n"
+                                                        "@param time The time to sample the field value at.\n"
+                                                        "@return The fields' value at the specified time or always 0.0 if no field is selected.")
+{
+   return object->getParticleFields().getFieldValue( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setRepeatTime, bool, 3, 3, "(repeatTime) Sets the time period to repeat (cycle) the fields' values at.\n"
+                                                        "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().setRepeatTime( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getRepeatTime, F32, 2, 2,  "() Gets the time period that the fields' value repeat (cycle) at.\n"
+                                                        "@return The time period that the fields' value repeat (cycle) at.\n" )
+{
+   return object->getParticleFields().getRepeatTime();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, setValueScale, bool, 3, 3, "(valueScale) Set the scaling of field values retrieved from the field.  This does not alter the actual data-key values.\n"
+                                                        "@param valueScale The scale for field values retrieved from the field.\n"
+                                                        "@return Whether the operation was successful or not.")
+{
+   return object->getParticleFields().setValueScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getValueScale, F32, 2, 2,  "() Gets the scaling of field values' retrieved from the field.\n"
+                                                        "@return The scaling of field values' retrieved from the field." )
+{
+   return object->getParticleFields().getValueScale();
+}
+
+//-----------------------------------------------------------------------------
+/// Emitter asset methods.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, createEmitter, const char*, 2, 2,  "() - Creates and add a new emitter.\n"
+                                                                "@return The new emitter that was added or 0 if failed.")
+{
+    // Find the emitter.
+    ParticleAssetEmitter* pEmitter = object->createEmitter();
+
+    return pEmitter == NULL ? StringTable->EmptyString : pEmitter->getIdString();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, addEmitter, bool, 3, 3,    "(emitterId) - Adds an existing emitter.\n"
+                                                        "@param emitterId The emitter to add.\n"
+                                                        "@return On success it returns the ID of the emitter, or 0 if failed.")
+{
+    // Find the emitter.
+    ParticleAssetEmitter* pEmitter = Sim::findObject<ParticleAssetEmitter>( argv[2] );
+
+    // Did we find the emitter?
+    if ( pEmitter == NULL )
+    {
+        // No, so warn.
+        Con::warnf( "ParticleAsset::addEmitter() - Could not find the emitter '%s'.", argv[2] );
+        return false;
+    }
+
+    return object->addEmitter(pEmitter);
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, removeEmitter, bool, 3, 4, "(emitterId, [bool deleteEmitter]) - Removes an emitter.\n"
+                                                        "@param emitterId The emitter to remove.\n"
+                                                        "@return No return value.")
+{
+    // Find the emitter.
+    ParticleAssetEmitter* pEmitter = Sim::findObject<ParticleAssetEmitter>( argv[2] );
+
+    // Did we find the emitter?
+    if ( pEmitter == NULL )
+    {
+        // No, so warn.
+        Con::warnf( "ParticleAsset::removeEmitter() - Could not find the emitter '%s'.", argv[2] );
+        return false;
+    }
+
+    bool deleteEmitter = true;
+    if (argc > 3)
+        deleteEmitter = dAtob(argv[3]);
+
+    // Remove the emitter.
+    object->removeEmitter( pEmitter, deleteEmitter );
+
+    return true;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, clearEmitters, void, 2, 2, "() Clear all the emitters.\n"
+                                                        "@return No return Value.")
+{
+   // Clear Emitters.
+   object->clearEmitters();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getEmitterCount, S32, 2, 2,    "() Gets the emitter count.\n"
+                                                            "@return Returns the number of emitters as an integer.")
+{
+   // Get Emitter Count.
+   return object->getEmitterCount();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, getEmitter, S32, 3, 3,     "(emitterIndex) Gets the emitter at the specified index.\n"
+                                                        "@param emitterIndex The index for the desired emitter\n"
+                                                        "@return The emitter or 0 if not found.")
+{
+   // Get the emitter.
+   ParticleAssetEmitter* pEmitter = object->getEmitter( dAtoi(argv[2]) );
+
+   return pEmitter == NULL ? 0 : pEmitter->getId();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, findEmitter, S32, 3, 3,    "(emitterName) Finds the emitter by its name.\n"
+                                                        "@param emitterName The name of the desired emitter.\n"
+                                                        "@return The emitter or 0 if not found.")
+{
+   // Find the emitter.
+   ParticleAssetEmitter* pEmitter = object->findEmitter( argv[2] );
+
+   return pEmitter == NULL ? 0 : pEmitter->getId();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticleAsset, moveEmitter, void, 4, 4, "(fromEmitterIndex, toEmitterIndex) Moves the emitter order.\n"
+              "@param fromEmitterIndex The source index of the emitter to move.\n"
+              "@param toEmitterIndex The destination index to move the emitter to.\n"
+              "@return No return value.")
+{
+   // Move Emitter Object.
+   object->moveEmitter( dAtoi(argv[2]), dAtoi(argv[3]) );
+}
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24

+ 172 - 0
engine/source/2d/controllers/PointForceController_ScriptBinding.h

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 //-----------------------------------------------------------------------------
 // Copyright (c) 2013 GarageGames, LLC
 //
@@ -198,3 +199,174 @@ ConsoleMethodWithDocs(PointForceController, getTrackedObject, ConsoleString, 2,
 } 
 
 ConsoleMethodGroupEndWithDocs(PointForceController)
+=======
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setPosition, void, 3, 4,    "(float x, float y) - Sets the position of the force center.\n"
+                                                                "@param x The position along the horizontal axis.\n"
+                                                                "@param y The position along the vertical axis.\n"
+                                                                "@return No return value.")
+{
+    // The new position.
+    b2Vec2 position;
+
+    // Elements in the first argument.
+    U32 elementCount = Utility::mGetStringElementCount(argv[2]);
+
+    // ("x y")
+    if ((elementCount == 2) && (argc == 3))
+        position = Utility::mGetStringElementVector(argv[2]);
+
+    // (x, y)
+    else if ((elementCount == 1) && (argc == 4))
+        position.Set(dAtof(argv[2]), dAtof(argv[3]));
+
+    // Invalid
+    else
+    {
+        Con::warnf("PointForceController::setPosition() - Invalid number of parameters!");
+        return;
+    }
+
+    // Set Position.
+    object->setPosition(position);
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getPosition, const char*, 2, 2,    "() Gets the position of the force center.\n"
+                                                                                "@return (float x/float y) The x and y (horizontal and vertical) position of the force center.")
+{
+    // Get position.
+    return object->getPosition().scriptThis();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setRadius, void, 3, 3,       "(radius) - Sets the radius of the point force to use.\n"
+                                                                "@param radius The radius of the point force to use.\n"
+                                                                "@return No return value.")
+{
+    object->setRadius( dAtof(argv[2]) );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getRadius, F32, 2, 2,        "() Gets the radius of the point force being used.\n"
+                                                                "@return The radius of the point force being used.")
+{
+    return object->getRadius();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setForce, void, 3, 3,       "(force) - Sets the point force to use.\n"
+                                                                "@param force The point force to use.\n"
+                                                                "@return No return value.")
+{
+    object->setForce( dAtof(argv[2]) );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getForce, F32, 2, 2,        "() Gets the point force being used.\n"
+                                                                "@return The point force being used.")
+{
+    return object->getForce();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setLinearDrag, void, 3, 3,  "(linearDrag) - Sets the linear drag coefficient (0.0 to 1.0).\n"
+                                                                "@param linearDrag The linear drag coefficient\n"
+                                                                "@return No return value.")
+{
+    object->setLinearDrag( dAtof(argv[2]) );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getLinearDrag, F32, 2, 2,   "() Gets the linear drag coefficient.\n"
+                                                                "@return The linear drag coefficient.")
+{
+    return object->getLinearDrag();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setAngularDrag, void, 3, 3, "(angularDrag) - Sets the angular drag coefficient (0.0 to 1.0).\n"
+                                                                "@param angularDrag The angular drag coefficient\n"
+                                                                "@return No return value.")
+{
+    object->setAngularDrag( dAtof(argv[2]) );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getAngularDrag, F32, 2, 2,  "() Gets the angular drag coefficient.\n"
+                                                                "@return The angular drag coefficient.")
+{
+    return object->getAngularDrag();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setNonLinear, void, 3, 3,   "(nonLinear) - Sets whether to apply the force non-linearly (using the inverse square law) or linearly.\n"
+                                                                "@param nonLinear whether to apply the force non-linearly (using the inverse square law) or linearly.\n"
+                                                                "@return No return value.")
+{
+    object->setNonLinear( dAtob(argv[2]) );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getNonLinear, bool, 2, 2,  "() Gets whether to apply the force non-linearly (using the inverse square law) or linearly.\n"
+                                                                "@return Whether to apply the force non-linearly (using the inverse square law) or linearly.")
+{
+    return object->getNonLinear();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, setTrackedObject, void, 3, 3,   "(sceneObject) - Sets a scene object from which the position will be tracked.\n"
+                                                                    "@param sceneObject The scene object from which the position will be tracked.  An empty string will stop tracking.\n"
+                                                                    "@return No return value.")
+{
+    // Find the scene object.
+    SceneObject* pSceneObject = Sim::findObject<SceneObject>( argv[2] );
+
+    object->setTrackedObject( pSceneObject );
+} 
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(PointForceController, getTrackedObject, const char*, 2, 2,    "() - Gets the scene object from which the position will be tracked.\n"
+                                                                            "@return The scene object from which the position will be tracked or an empty string if nothing is being tracked.")
+{
+    // Fetch the scene object.
+    SceneObject* pSceneObject = object->getTrackedObject();
+
+    return pSceneObject == NULL ? NULL : pSceneObject->getIdString();
+} 
+
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24

+ 1 - 0
engine/source/2d/core/SpriteBatchItem.h

@@ -291,6 +291,7 @@ public:
 
     virtual void copyTo( SpriteBatchItem* pSpriteBatchItem ) const;
 
+    inline const Vector2* getLocalOOBB( void ) const { return mLocalOOBB; }
     inline const Vector2* getRenderOOBB( void ) const { return mRenderOOBB; }
 
     void prepareRender( SceneRenderRequest* pSceneRenderRequest, const U32 batchTransformId );

+ 26 - 2
engine/source/2d/core/SpriteBatchQuery.cc

@@ -81,6 +81,30 @@ bool SpriteBatchQuery::update( SpriteBatchItem* pSpriteBatchItem, const b2AABB&
 
 //-----------------------------------------------------------------------------
 
+U32 SpriteBatchQuery::queryOOBB( const b2AABB& aabb, b2PolygonShape& oobb, const bool targetOOBB )
+{
+  // This function is used exclusively when picking rectangular areas using CompositeSprite's pickArea ConsoleMethod
+  // For rendering, SpriteBatchQuery::queryArea is used instead
+
+  // Debug Profiling.
+    PROFILE_SCOPE(SpriteBatchQuery_QueryArea);
+
+    mMasterQueryKey++;
+
+    // Flag as not a ray-cast query result.
+    mIsRaycastQueryResult = false;
+
+  mComparePolygonShape.Set(oobb.m_vertices,4);
+  mComparePolygonShape.m_centroid = oobb.m_centroid;
+
+    mCompareTransform.SetIdentity();
+    mCheckOOBB = targetOOBB;
+    Query( this, aabb );
+    mCheckOOBB = false;
+
+    return getQueryResultsCount();
+}
+
 U32 SpriteBatchQuery::queryArea( const b2AABB& aabb, const bool targetOOBB )
 {
     // Debug Profiling.
@@ -195,7 +219,7 @@ bool SpriteBatchQuery::QueryCallback( S32 proxyId )
     {
             // Fetch the shapes render OOBB.
         b2PolygonShape oobb;
-        oobb.Set( pSpriteBatchItem->getRenderOOBB(), 4);
+        oobb.Set( pSpriteBatchItem->getLocalOOBB(), 4);
 
         if ( mCheckPoint )
         {
@@ -237,7 +261,7 @@ F32 SpriteBatchQuery::RayCastCallback( const b2RayCastInput& input, S32 proxyId
     {
         // Fetch the shapes render OOBB.
         b2PolygonShape oobb;
-        oobb.Set( pSpriteBatchItem->getRenderOOBB(), 4);
+        oobb.Set( pSpriteBatchItem->getLocalOOBB(), 4);
         b2RayCastOutput rayOutput;
         if ( !oobb.RayCast( &rayOutput, mCompareRay, mCompareTransform, 0 ) )
             return true;

+ 1 - 0
engine/source/2d/core/SpriteBatchQuery.h

@@ -50,6 +50,7 @@ public:
 
     //// Spatial queries.
     U32             queryArea( const b2AABB& aabb, const bool targetOOBB );
+    U32             queryOOBB( const b2AABB& aabb, b2PolygonShape& oobb, const bool targetOOBB );
     U32             queryRay( const Vector2& point1, const Vector2& point2, const bool targetOOBB );
     U32             queryPoint( const Vector2& point, const bool targetOOBB );
  

+ 2 - 29
engine/source/2d/gui/SceneWindow.cc

@@ -576,42 +576,15 @@ F32 SceneWindow::interpolate( F32 from, F32 to, F32 delta )
 {
     // Linear.
     if ( mCameraInterpolationMode == LINEAR )
-        return linearInterpolate( from, to, delta );
+        return mLerp( from, to, delta );
     // Sigmoid.
     else if ( mCameraInterpolationMode == SIGMOID )
-        return sigmoidInterpolate( from, to, delta );
+        return mSmoothStep( from, to, delta );
     // Hmmm...
     else
         return from;
 }
 
-//-----------------------------------------------------------------------------
-
-F32 SceneWindow::linearInterpolate( F32 from, F32 to, F32 delta )
-{
-    // Clamp if we're over/under time.
-    if ( delta <= 0.0f )
-        return from;
-    else if ( delta >= 1.0f )
-        return to;
-
-    // Calculate resultant interpolation.
-    return ( from * ( 1.0f - delta ) ) + ( to * delta );
-}
-
-//-----------------------------------------------------------------------------
-
-F32 SceneWindow::sigmoidInterpolate( F32 from, F32 to, F32 delta )
-{
-    // Range Expand/Clamp Delta to (-1 -> +1).
-    delta = mClampF( (delta - 0.5f) * 2.0f, -1.0f, 1.0f );
-
-    // Calculate interpolator value using sigmoid function.
-    F32 sigmoid = mClampF ( 1.0f / (1.0f + mPow(2.718282f, -15.0f * delta)), 0.0f, 1.0f );
-
-    // Calculate resultant interpolation.
-    return ( from * ( 1.0f - sigmoid ) ) + ( to * sigmoid );
-}
 
 //-----------------------------------------------------------------------------
 

+ 0 - 2
engine/source/2d/gui/SceneWindow.h

@@ -270,8 +270,6 @@ public:
     void completeCameraMove( void );
     void undoCameraMove( const F32 interpolationTime );
     F32 interpolate( F32 from, F32 to, F32 delta );
-    F32 linearInterpolate( F32 from, F32 to, F32 delta );
-    F32 sigmoidInterpolate( F32 from, F32 to, F32 delta );
     void updateCamera( void );
 
     inline Vector2 getCameraRenderPosition( void )                      { calculateCameraView( &mCameraCurrent ); return mCameraCurrent.mDestinationArea.centre(); }

+ 14 - 10
engine/source/2d/sceneobject/CompositeSprite_ScriptBinding.h

@@ -1155,13 +1155,6 @@ ConsoleMethodWithDocs(CompositeSprite, pickArea, ConsoleString, 4, 6, (startx/y,
         return NULL;
     }
 
-    // Fetch the render transform.
-    const b2Transform& renderTransform = object->getRenderTransform();
-    
-    // Translate into local space.
-    v1 -= renderTransform.p;
-    v2 -= renderTransform.p;
-
     // Calculate normalized AABB.
     b2AABB aabb;
     aabb.lowerBound.x = getMin( v1.x, v2.x );
@@ -1169,11 +1162,22 @@ ConsoleMethodWithDocs(CompositeSprite, pickArea, ConsoleString, 4, 6, (startx/y,
     aabb.upperBound.x = getMax( v1.x, v2.x );
     aabb.upperBound.y = getMax( v1.y, v2.y );
 
-    // Rotate the AABB into local space.
-    CoreMath::mRotateAABB( aabb, -renderTransform.q.GetAngle(), aabb );
+	// Calculate local OOBB.
+    b2Vec2 localOOBB[4];
+    CoreMath::mAABBtoOOBB( aabb, localOOBB );
+    CoreMath::mCalculateInverseOOBB( localOOBB, object->getRenderTransform(), localOOBB );
+
+	// Calculate local AABB.
+    b2AABB localAABB;
+    CoreMath::mOOBBtoAABB( localOOBB, localAABB );
+  
+	// Convert OOBB to a PolygonShape
+    b2PolygonShape oobb_polygon;
+    oobb_polygon.Set(localOOBB, 4);
 
     // Perform query.
-    pSpriteBatchQuery->queryArea( aabb, true );
+    pSpriteBatchQuery->queryOOBB( localAABB, oobb_polygon, true );
+
 
     // Fetch result count.
     const U32 resultCount = pSpriteBatchQuery->getQueryResultsCount();

+ 4 - 4
engine/source/2d/sceneobject/ImageFont.cc

@@ -328,7 +328,7 @@ void ImageFont::setFontSize( const Vector2& size )
 
 //-----------------------------------------------------------------------------
 
-void ImageFont::setFontPadding( const U32 padding )
+void ImageFont::setFontPadding( const F32 padding )
 {
     mFontPadding = padding;
     calculateSpatials();
@@ -349,7 +349,7 @@ void ImageFont::calculateSpatials( void )
     }
 
     // Calculate total font padding.
-    const U32 totalFontPadding = (renderCharacters * mFontPadding) - mFontPadding;
+    const F32 totalFontPadding = (renderCharacters * mFontPadding) - mFontPadding;
 
     // Calculate total character size.
     const Vector2 totalFontSize( renderCharacters * mFontSize.x, mFontSize.y );
@@ -366,14 +366,14 @@ void ImageFont::calculateSpatials( void )
         case ALIGN_LEFT:
             {
                 // Size is twice the padded text width as we're aligning to the left from the position expanding rightwards.
-                setSize( totalPaddedTextSize * 2.0f );
+                setSize( totalPaddedTextSize.x * 2.0f, totalPaddedTextSize.y );
             }
             break;
 
         case ALIGN_RIGHT:
             {
                 // Size is twice the padded text width as we're aligning to the right from the position expanding leftwards.
-                setSize( totalPaddedTextSize * 2.0f );
+                setSize( totalPaddedTextSize.x * 2.0f, totalPaddedTextSize.y );
             }
             break;
 

+ 5 - 5
engine/source/2d/sceneobject/ImageFont.h

@@ -75,7 +75,7 @@ private:
 private:
     AssetPtr<ImageAsset>    mImageAsset;
     StringBuffer            mText;
-    U32                     mFontPadding;
+    F32                     mFontPadding;
     Vector2                 mFontSize;
     TextAlignment           mTextAlignment;
 
@@ -106,8 +106,8 @@ public:
     inline TextAlignment getTextAlignment( void ) const                     { return mTextAlignment; }
     void setFontSize( const Vector2& size );
     inline Vector2 getFontSize( void ) const                                { return mFontSize; }
-    void setFontPadding( const U32 padding );
-    inline U32 getFontPadding( void ) const                                 { return mFontPadding; }
+    void setFontPadding( const F32 padding );
+    inline F32 getFontPadding( void ) const                                 { return mFontPadding; }
 
     static TextAlignment getTextAlignmentEnum(const char* label);
     static const char* getTextAlignmentDescription(const TextAlignment alignment);
@@ -125,8 +125,8 @@ protected:
     static bool setTextAlignment( void* obj, const char* data );
     static bool writeTextAlignment( void* obj, StringTableEntry pFieldName ){return static_cast<ImageFont*>(obj)->getTextAlignment() != ImageFont::ALIGN_CENTER; }
     static bool setFontSize( void* obj, const char* data )                  { static_cast<ImageFont*>( obj )->setFontSize( Utility::mGetStringElementVector(data) ); return false; }
-    static bool writeFontSize( void* obj, StringTableEntry pFieldName )     { return static_cast<ImageFont*>(obj)->getFontSize().isEqual(Vector2::getOne()); }
-    static bool setFontPadding( void* obj, const char* data )               { static_cast<ImageFont*>( obj )->setFontPadding( dAtoi(data) ); return false; }
+	static bool writeFontSize( void* obj, StringTableEntry pFieldName )     { return static_cast<ImageFont*>(obj)->getFontSize().notEqual(Vector2::getOne()); }	
+    static bool setFontPadding( void* obj, const char* data )               { static_cast<ImageFont*>( obj )->setFontPadding( dAtof(data) ); return false; }
     static bool writeFontPadding( void* obj, StringTableEntry pFieldName )  { return static_cast<ImageFont*>(obj)->getFontPadding() != 0; }
 };
 

+ 140 - 0
engine/source/2d/sceneobject/ImageFont_ScriptBinding.h

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 //-----------------------------------------------------------------------------
 // Copyright (c) 2013 GarageGames, LLC
 //
@@ -159,3 +160,142 @@ ConsoleMethodWithDocs(ImageFont, getFontPadding, ConsoleInt, 2, 2, ())
 }
 
 ConsoleMethodGroupEndWithDocs(ImageFont)
+=======
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, setImage, bool, 3, 3,  "(imageAssetId) - Sets the image asset to use..\n"
+                                                "@param imageName The image asset to use.\n"
+                                                "@return Returns true on success.")
+{
+    // Set Image.
+    return object->setImage( argv[2] );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, getImage, const char*, 2, 2,   "() - Gets current image asset..\n"
+                                                        "@return The current image asset.")
+{
+    // Get Image.
+    return object->getImage();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, setText, void, 3, 3,   "(text) - Set the text to render.\n")
+{
+    object->setText(argv[2]);
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, getText, const char*, 2, 2,    "() - Gets the text being rendered.\n")
+{
+    return object->getText().getPtr8();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, setTextAlignment, void, 3, 3,  "(alignment) - Set the text alignment to 'left', 'center' or 'right'.\n"
+                                                        "@param alignment The text alignment of 'left', 'center' or 'right'.\n"
+                                                        "@return No return value.")
+{
+
+    object->setTextAlignment( ImageFont::getTextAlignmentEnum(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, getTextAlignment, const char*, 2, 2,   "() - Gets the text alignment.\n"
+                                                                "@return The text alignment of 'left', 'center' or 'right'.")
+{
+    return ImageFont::getTextAlignmentDescription(object->getTextAlignment());
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, setFontSize, void, 3, 4,   "(width, height) - Set the size of the font characters.\n"
+                                                    "@param width The width of a font character.\n"
+                                                    "@param height The height of a font character.\n"
+                                                    "@return No return value.")
+{
+    F32 width, height;
+
+    U32 elementCount = Utility::mGetStringElementCount(argv[2]);
+
+    // ("width height")
+    if ((elementCount == 2) && (argc == 3))
+    {
+        width = dAtof(Utility::mGetStringElement(argv[2], 0));
+        height = dAtof(Utility::mGetStringElement(argv[2], 1));
+    }
+
+    // (width, [height])
+    else if (elementCount == 1)
+    {
+        width = dAtof(argv[2]);
+
+        if (argc > 3)
+            height = dAtof(argv[3]);
+        else
+            height = width;
+    }
+    // Invalid
+    else
+    {
+        Con::warnf("ImageFont::setFontSize() - Invalid number of parameters!");
+        return;
+    }
+
+    // Set character size.
+    object->setFontSize(Vector2(width, height));
+
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, getFontSize, const char*, 2, 2,    "() - Gets the size of the font characters.\n"
+                                                            "@return The size of the font characters.")
+{
+    return object->getFontSize().scriptThis();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, setFontPadding, void, 3, 3,    "(padding) - Set the font padding.\n"
+                                                        "@param padding The space added in-between font characters.\n"
+                                                        "@return No return value.")
+{
+   // Set character padding.
+   object->setFontPadding( dAtof(argv[2]) );
+
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ImageFont, getFontPadding, F32, 2, 2,     "() - Gets the font padding.\n"
+                                                        "@return The font padding.")
+{
+    return object->getFontPadding();
+}
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24

+ 6 - 6
engine/source/2d/sceneobject/ParticlePlayer.cc

@@ -401,14 +401,10 @@ void ParticlePlayer::integrateObject( const F32 totalTime, const F32 elapsedTime
     // Fetch the particle life-mode.
     const ParticleAsset::LifeMode lifeMode = pParticleAsset->getLifeMode();
 
-    // Finish if the particle player is in "infinite" mode.
-    if ( lifeMode == ParticleAsset::INFINITE )
-        return;
-
     // Are we waiting for particles and there are non left?
     if ( mWaitingForParticles )
     {
-        // Yes, so are there any particles left?
+		// Yes, so are there any particles left?
         if ( activeParticleCount == 0 )
         {
             // No, so stop the player immediately.
@@ -418,6 +414,10 @@ void ParticlePlayer::integrateObject( const F32 totalTime, const F32 elapsedTime
         return;
     }
 
+	// Finish if the particle player is in "infinite" mode.
+    if ( lifeMode == ParticleAsset::INFINITE )
+        return;
+
     // Fetch the particle lifetime.
     const F32 lifetime = pParticleAsset->getLifetime();
 
@@ -793,7 +793,7 @@ bool ParticlePlayer::play( const bool resetParticles )
     {
         // Fetch the emitter node.
         EmitterNode* pEmitterNode = *emitterItr;
-
+		pEmitterNode->setPaused(false);
         // Reset the time since last generation.
         pEmitterNode->setTimeSinceLastGeneration( 0.0f );
     }

+ 230 - 0
engine/source/2d/sceneobject/ParticlePlayer_ScriptBinding.h

@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 //-----------------------------------------------------------------------------
 // Copyright (c) 2013 GarageGames, LLC
 //
@@ -235,3 +236,232 @@ ConsoleMethodWithDocs(ParticlePlayer, getEmitterVisible, ConsoleBool, 3, 3, (emi
 }
 
 ConsoleMethodGroupEndWithDocs(ParticlePlayer)
+=======
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setParticleAsset, void, 3, 3,     "(particleAssetId?) Sets the particle asset Id to play.\n"
+                                                                "@param particleAssetId The particle asset Id to play.\n"
+                                                                "@return No return value.")
+{
+    object->setParticle( argv[2] );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getParticleAsset, const char*, 2, 2,  "() Gets the particle asset Id.\n"
+                                                                    "@return The particle asset Id.")
+{
+    return object->getParticle();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setCameraIdleDistance, void, 3, 3,    "(idleDistance) Sets the distance from any camera when the particle player will become idle i.e. stop integrating and rendering.\n"
+                                                                    "@param pauseDistance The distance from any camera when the particle player will become idle i.e. stop integrating and rendering.\n"
+                                                                    "@return No return value.")
+{
+    object->setCameraIdleDistance( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getCameraIdleDistance, F32, 2, 2,     "() Gets the distance from any camera when the particle player will become idle i.e. stop integrating and rendering.\n"
+                                                                    "@return The distance from any camera when the particle player will become idle i.e. stop integrating and rendering.")
+{
+    return object->getCameraIdleDistance();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setParticleInterpolation, void, 3, 3,     "(bool status) Sets whether the intermediate world position, rotation, and size data points of particles between ticks are calculated.\n"
+                                                                        "@return No return value.")
+{
+    object->setParticleInterpolation( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getParticleInterpolation, F32, 2, 2,  "() Gets whether the intermediate world position, rotation, and size data points of particles between ticks are calculated.\n"
+                                                                    "@return (bool status) Whether interpolation is calculated or not.")
+{
+    return object->getParticleInterpolation();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setEmissionRateScale, void, 3, 3,     "(scale) Sets the scale for the particle player emission rate.\n"
+                                                                    "@param scale The scale for the particle player emission rate.\n"
+                                                                    "@return No return value.")
+{
+    object->setEmissionRateScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getEmissionRateScale, F32, 2, 2,     "() Gets the scale for the particle player emission rate.\n"
+                                                                    "@return The scale for the particle player emission rate.")
+{
+    return object->getEmissionRateScale();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setSizeScale, void, 3, 3,     "(scale) Sets the scale for the particle player particle sizes.\n"
+                                                            "@param scale The scale for the particle player particle sizes.\n"
+                                                            "@return No return value.")
+{
+    object->setSizeScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getSizeScale, F32, 2, 2,      "() Gets the scale for the particle player particle sizes.\n"
+                                                            "@return The scale for the particle player particle sizes.")
+{
+    return object->getSizeScale();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setForceScale, void, 3, 3,    "(scale) Sets the scale for the particle player forces.\n"
+                                                            "@param scale The scale for the particle player forces.\n"
+                                                            "@return No return value.")
+{
+    object->setForceScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getForceScale, F32, 2, 2,     "() Gets the scale for the particle player forces.\n"
+                                                            "@return The scale for the particle player forces.")
+{
+    return object->getForceScale();
+}
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setTimeScale, void, 3, 3,     "(scale) Sets the scale for the particle player particle lifetimes.\n"
+                                                            "@param scale The scale for the particle player particle lifetimes.\n"
+                                                            "@return No return value.")
+{
+    object->setTimeScale( dAtof(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getTimeScale, F32, 2, 2,  "() Gets the scale for the particle player particle lifetimes.\n"
+                                                        "@return The scale for the particle player particle lifetimes.")
+{
+    return object->getTimeScale();
+}
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, play, bool, 2, 3, "([resetParticles]) Starts the particle player playing.\n"
+                                                "@param resetParticles Whether to reset any existing particles before starting to play.  Default is true.\n"
+                                                "@return Returns true on success and false otherwise.")
+{
+    // Fetch the reset-particle flag.
+    const bool resetParticles = argc >= 3 ? dAtob(argv[2]) : true;
+
+    return object->play( resetParticles );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, stop, void, 2, 4, "([waitForParticles?, killEffect?]) - Stops the Particle Effect.\n"
+              "@param waitForParticles Whether or not the effect should wait until all of its particles have run their course, or just stop immediately and delete the particles (default true).\n"
+              "@param killEffect Whether or not the effect should be deleted after it has stopped (default false).\n"
+              "@return No return value.")
+{
+    // Fetch the wait-for-particles flag.
+   const bool waitForParticles = argc >= 3 ? dAtob(argv[2]) : true;
+
+   // Fetch the kill-effect flag.
+   const bool killEffect = argc >= 4 ? dAtob(argv[3]) : false;
+
+   // Stop playing.
+   object->stop( waitForParticles, killEffect );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getIsPlaying, bool, 2, 2, "() Gets whether the particle player is playing or not.\n"
+                                                        "@return Whether the particle player is playing or not." )
+{
+   return object->getIsPlaying();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setPaused, void, 3, 3,    "(paused?) Sets whether the particle player is paused or not.\n"
+                                                        "@param paused Whether the particle player is paused or not.\n"
+                                                        "@return No return value.")
+{
+    object->setPaused( dAtob(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getPaused, bool, 2, 2,    "() Gets whether the particle player is paused or not.\n"
+                                                        "@return Whether the particle player is paused or not.")
+{
+    return object->getPaused();
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setEmitterPaused, void, 4, 4, "(paused, emitterIndex) Sets whether the specified particle emitter is paused or not.\n"
+                                                            "@param paused Whether the specified particle emitter is paused or not.\n"
+                                                            "@param emitterIndex The index of the emitter to modify.\n"
+                                                            "@return No return value.")
+{
+    object->setEmitterPaused( dAtob(argv[2]), dAtoi(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getEmitterPaused, bool, 3, 3, "(emitterIndex) Gets whether the specified particle emitter is paused or not.\n"
+                                                            "@param emitterIndex The index of the emitter to modify.\n"
+                                                            "@return Whether the specified particle emitter is paused or not.")
+{
+    return object->getEmitterPaused( dAtob(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, setEmitterVisible, void, 4, 4,    "(visible, emitterIndex) Sets whether the specified particle emitter is visible or not.\n"
+                                                                "@param paused Whether the specified particle emitter is visible or not.\n"
+                                                                "@param emitterIndex The index of the emitter to modify.\n"
+                                                                "@return No return value.")
+{
+    object->setEmitterVisible( dAtob(argv[2]), dAtoi(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleMethod(ParticlePlayer, getEmitterVisible, bool, 3, 3,    "(emitterIndex) Gets whether the specified particle emitter is visible or not.\n"
+                                                                "@param emitterIndex The index of the emitter to modify.\n"
+                                                                "@return Whether the specified particle emitter is visible or not.")
+{
+    return object->getEmitterVisible( dAtob(argv[2]) );
+}
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24

+ 19 - 1
engine/source/2d/sceneobject/SceneObject_ScriptBinding.h

@@ -1994,6 +1994,7 @@ ConsoleMethodWithDocs(SceneObject, isRotateToComplete, ConsoleBool, 2, 2, ())
 
 //-----------------------------------------------------------------------------
 
+<<<<<<< HEAD
 /*! Applies a force at a world point.
     If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity.
     @param worldForceX/Y - The world force vector in Newtons (N).
@@ -2001,6 +2002,13 @@ ConsoleMethodWithDocs(SceneObject, isRotateToComplete, ConsoleBool, 2, 2, ())
     @return No return Value.
 */
 ConsoleMethodWithDocs(SceneObject, applyForce, ConsoleVoid, 4, 6, (worldForce X/Y, [worldPoint X/Y]))
+=======
+ConsoleMethod(SceneObject, applyForce, void, 3, 6,       "(worldForce X/Y, [worldPoint X/Y]) - Applies a force at a world point.\n"
+                                                            "If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity.\n"
+                                                            "@param worldForceX/Y - The world force vector in Newtons (N)."
+                                                            "@param worldPointX/Y - The world point where the force is applied.  If world point is not specified, the center of mass is used."
+                                                            "@return No return Value.")
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24
 {
     // World force.
     const U32 worldForceElementCount = Utility::mGetStringElementCount(argv[2]);
@@ -2028,6 +2036,7 @@ ConsoleMethodWithDocs(SceneObject, applyForce, ConsoleVoid, 4, 6, (worldForce X/
     {
         // Apply force.
         object->applyForce( worldForce );
+		return;
     }
 
     // World point.
@@ -2047,7 +2056,7 @@ ConsoleMethodWithDocs(SceneObject, applyForce, ConsoleVoid, 4, 6, (worldForce X/
     // Invalid
     else
     {
-        Con::warnf("Scene::applyForce() - Invalid number of parameters!");
+		Con::warnf("Scene::applyForce() - Invalid number of parameters!");
         return;
     }
 
@@ -2073,6 +2082,7 @@ ConsoleMethodWithDocs(SceneObject, applyTorque, ConsoleVoid, 3, 3, (torque))
 
 //-----------------------------------------------------------------------------
 
+<<<<<<< HEAD
 /*! Applies an impulse at a world point.
     This immediately modifies the linear velocity.  It also modifies the angular velocity if the point of application is not the center of mass.
     @param worldImpulse/Y - The world impulse vector in Newtons (N-seconds) or Kg-m/s.
@@ -2080,6 +2090,13 @@ ConsoleMethodWithDocs(SceneObject, applyTorque, ConsoleVoid, 3, 3, (torque))
     @return No return Value.
 */
 ConsoleMethodWithDocs(SceneObject, applyLinearImpulse, ConsoleVoid, 4, 6, (worldImpulse X/Y, [worldPoint X/Y]))
+=======
+ConsoleMethod(SceneObject, applyLinearImpulse, void, 3, 6,   "(worldImpulse X/Y, [worldPoint X/Y]) - Applies an impulse at a world point.\n"
+                                                                "This immediately modifies the linear velocity.  It also modifies the angular velocity if the point of application is not the center of mass.\n"
+                                                                "@param worldImpulse/Y - The world impulse vector in Newtons (N-seconds) or Kg-m/s."
+                                                                "@param worldPointX/Y - The world point where the force is applied.  If world point is not specified, the center of mass is used."
+                                                                "@return No return Value.")
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24
 {
     // World impulse.
     const U32 worldImpulseElementCount = Utility::mGetStringElementCount(argv[2]);
@@ -2107,6 +2124,7 @@ ConsoleMethodWithDocs(SceneObject, applyLinearImpulse, ConsoleVoid, 4, 6, (world
     {
         // Apply force.
         object->applyForce( worldImpulse );
+		return;
     }
 
     // World point.

+ 1 - 1
engine/source/2d/sceneobject/ShapeVector.h

@@ -117,7 +117,7 @@ protected:
     static bool writeFillColor( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mFillColor != ColorF(0.5f,0.5f,0.5f,1.0f); }
     static bool writeFillMode( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mFillMode == true; }
     static bool writeIsCircle( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mIsCircle == true; }
-    static bool writeCircleRadius( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mIsCircle != 1; }
+    static bool writeCircleRadius( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mCircleRadius != 1; }
 };
 
 #endif // _SHAPE_VECTOR_H_

+ 76 - 27
engine/source/audio/audio.cc

@@ -102,6 +102,7 @@ struct LoopingImage
 static F32 mMasterVolume = 1.f;           // traped from AL_LISTENER gain (miles has difficulties with 3d sources)
 
 static ALuint                 mSource[MAX_AUDIOSOURCES];                   // ALSources
+static ALint                  mResumePosition[MAX_AUDIOSOURCES];           // Ensures Pause resumes from the correct position
 static AUDIOHANDLE            mHandle[MAX_AUDIOSOURCES];                   // unique handles
 static Resource<AudioBuffer>  mBuffer[MAX_AUDIOSOURCES];                   // each of the playing buffers (needed for AudioThread)
 static F32                    mScore[MAX_AUDIOSOURCES];                    // for figuring out which sources to cull/uncull
@@ -580,6 +581,8 @@ static void alxSourcePlay(AudioStreamSource *streamSource)
    ALuint source = streamSource->mSource;
    Audio::Description& desc = streamSource->mDescription;
 
+   bool ret = streamSource->initStream();
+
    alSourcef(source, AL_GAIN, Audio::linearToDB(desc.mVolume * mAudioChannelVolumes[desc.mVolumeChannel] * mMasterVolume));
 //   alSourcei(source, AL_LOOPING, AL_FALSE);
    alSourcef(source, AL_PITCH, 1.f);
@@ -965,30 +968,17 @@ bool alxPause( AUDIOHANDLE handle )
 
     alSourcePause( mSource[index] );
 
-    ALenum error = 0;
-    if ( (error = alGetError()) == AL_NO_ERROR)
-        return true;
-    switch (error)
-    {
-        case AL_INVALID_NAME:
-            Con::errorf("alxPause - OpenAL AL_INVALID_NAME error code returned");
-            break;
-        case AL_INVALID_ENUM:
-            Con::errorf("alxPause - OpenAL AL_INVALID_ENUM error code returned");
-            break;
-        case AL_INVALID_VALUE:
-            Con::errorf("alxPause - OpenAL AL_INVALID_VALUE error code returned");
-            break;
-        case AL_INVALID_OPERATION:
-            Con::errorf("alxPause - OpenAL AL_INVALID_OPERATION error code returned");
-            break;
-        case AL_OUT_OF_MEMORY:
-            Con::errorf("alxPause - OpenAL AL_OUT_OF_MEMORY error code returned");
-            break;
-        default:
-            Con::errorf("alxPause - OpenAL has encountered a problem and won't tell us what it is.");
-    };
-    return false;
+    ALint state;
+	alGetSourcei(mSource[index], AL_SOURCE_STATE, &state);
+
+	if( state==AL_PAUSED)
+	{
+		mResumePosition[index] = -1;
+		return true;
+	}
+
+	alGetSourcei(mSource[index], AL_SAMPLE_OFFSET, &mResumePosition[index]);
+	return alxCheckError("alxPause()","alGetSourcei");
 }
 
 void alxUnPause( AUDIOHANDLE handle )
@@ -996,7 +986,18 @@ void alxUnPause( AUDIOHANDLE handle )
     if(handle == NULL_AUDIOHANDLE)
         return;
     
-    alxPlay( handle );
+	U32 index = alxFindIndex(handle);
+	ALuint source = mSource[index];
+
+	if( mResumePosition[index] != -1 )
+	{
+		alSourcei( source, AL_SAMPLE_OFFSET, mResumePosition[index]);
+		mResumePosition[index] = -1;
+	}
+	alxCheckError("alxUnPause()","alSourcei");
+
+	alSourcePlay( source );
+	alxCheckError("alxUnPause()","alSourcePlay");
 }
 //--------------------------------------------------------------------------
 void alxStop(AUDIOHANDLE handle)
@@ -1920,7 +1921,7 @@ void alxCloseHandles()
 
       ALint state = 0;
       alGetSourcei(mSource[i], AL_SOURCE_STATE, &state);
-      if(state == AL_PLAYING)
+      if(state == AL_PLAYING || state == AL_PAUSED)
          continue;
 
       if(!(mHandle[i] & AUDIOHANDLE_INACTIVE_BIT))
@@ -1979,6 +1980,11 @@ void alxUpdateScores(bool sourcesOnly)
          continue;
       }
 
+	  ALint state = 0;
+	  alGetSourcei(mSource[i], AL_SOURCE_STATE, &state);
+	  if(state==AL_PAUSED)
+		  continue;
+
       // grab the volume.. (not attenuated by master for score)
       F32 volume = mSourceVolume[i] * mAudioChannelVolumes[mType[i]];
 
@@ -2159,6 +2165,36 @@ ALuint alxGetWaveLen(ALuint buffer)
    return(len);
 }
 
+bool alxCheckError(const char* sourceFuncName, const char* alFuncName)
+{
+  ALenum errorVal = alGetError();
+  switch (errorVal)
+  {
+    case AL_NO_ERROR:
+      break;
+    case AL_INVALID_NAME:
+      Con::errorf("%s - %s OpenAL AL_INVALID_NAME error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_ENUM:
+      Con::errorf("%s - %s OpenAL AL_INVALID_ENUM error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_VALUE:
+      Con::errorf("%s - %s OpenAL AL_INVALID_VALUE error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_OPERATION:
+      Con::errorf("%s - %s OpenAL AL_INVALID_OPERATION error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_OUT_OF_MEMORY:
+      Con::errorf("%s - %s OpenAL AL_OUT_OF_MEMORY error code returned", sourceFuncName, alFuncName);
+      break;
+    default:
+      Con::errorf("%s - %s OpenAL has encountered a problem and won't tell us what it is. %d", errorVal, sourceFuncName, alFuncName);
+  };
+  if (errorVal == AL_NO_ERROR)
+    return true;
+  else
+    return false;
+}
 
 //--------------------------------------------------------------------------
 // Environment:
@@ -2531,9 +2567,22 @@ void OpenALShutdown()
       delete mLoopingFreeList.last();
       mLoopingFreeList.pop_back();
    }
+   
+   //clear error buffer
+   alGetError();
 
    for(U32 i = 0; i < MAX_AUDIOSOURCES; i++)
-      mBuffer[i] = 0;
+   {
+	   ALint tempbuff = 0;
+	   alGetSourcei( mSource[i], AL_BUFFER, &tempbuff);
+
+	   if (alIsBuffer(tempbuff) && tempbuff !=0)
+	   {
+		   ALuint buffer = tempbuff;
+		   alSourceUnqueueBuffers( mSource[i], 1, &buffer);
+		   alxCheckError("OpenALShutdown()","alSourceUnqueueBuffers");
+	   }
+   }
 
    alDeleteSources(mNumSources, mSource);
 

+ 2 - 0
engine/source/audio/audio.h

@@ -38,5 +38,7 @@
 //-Mat default sample rate, change as needed
 #define DEFAULT_SOUND_OUTPUT_RATE		44100
 
+bool alxCheckError(const char*, const char*);
+
 
 #endif  // _H_AUDIO_

+ 31 - 8
engine/source/audio/audioBuffer.cc

@@ -110,14 +110,37 @@ AudioBuffer::AudioBuffer(StringTableEntry filename)
 
 AudioBuffer::~AudioBuffer()
 {
-   if( malBuffer != 0 ) 
-   {
-     alGetError();
-     alDeleteBuffers( 1, &malBuffer );
-     ALenum error;
-     error = alGetError();
-     AssertWarn( error == AL_NO_ERROR, "AudioBuffer::~AudioBuffer() - failed to release buffer" );
-   }
+   if( alIsBuffer(malBuffer) )
+  {
+    alGetError();
+    alDeleteBuffers( 1, &malBuffer );
+
+    ALenum error;
+    error = alGetError();
+    AssertWarn( error == AL_NO_ERROR, "AudioBuffer::~AudioBuffer() - failed to release buffer" );
+    switch (error)
+    {
+      case AL_NO_ERROR:
+        break;
+      case AL_INVALID_NAME:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_NAME error code returned");
+        break;
+      case AL_INVALID_ENUM:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_ENUM error code returned");
+        break;
+      case AL_INVALID_VALUE:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_VALUE error code returned");
+        break;
+      case AL_INVALID_OPERATION:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_OPERATION error code returned");
+        break;
+      case AL_OUT_OF_MEMORY:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_OUT_OF_MEMORY error code returned");
+        break;
+      default:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL has encountered a problem and won't tell us what it is. %d", error);
+    };
+  }
 }
 
 //--------------------------------------

+ 6 - 3
engine/source/audio/audio_ScriptBinding.cc

@@ -92,6 +92,9 @@ static ALenum getEnum(const char * name, U32 flags)
       { "AL_CONE_INNER_ANGLE",            AL_CONE_INNER_ANGLE,             (Source|Get|Set|Int) },
       { "AL_CONE_OUTER_ANGLE",            AL_CONE_OUTER_ANGLE,             (Source|Get|Set|Int) },
       { "AL_LOOPING",                     AL_LOOPING,                      (Source|Get|Set|Int) },
+	  { "AL_SAMPLE_OFFSET",               AL_SAMPLE_OFFSET,                (Source|Get|Set|Int) },
+	  { "AL_SEC_OFFSET",                  AL_SEC_OFFSET,                   (Source|Get|Set|Int) },
+	  { "AL_BYTE_OFFSET",                 AL_BYTE_OFFSET,                  (Source|Get|Set|Int) },
       //{ "AL_STREAMING",                   AL_STREAMING,                    (Source|Get|Set|Int) },
       //{ "AL_BUFFER",                      AL_BUFFER,                       (Source|Get|Set|Int) },
 
@@ -366,7 +369,7 @@ ConsoleFunctionWithDocs(alxSourcei, ConsoleVoid, 4, 4, ( handle , ALEnum , value
       return;
    }
 
-   alxSourcei(dAtoi(argv[1]), e, dAtoi(argv[3]));
+   alxSourcei(dAtoi(argv[1]), e, static_cast<ALint>(dAtoi(argv[3])));
 }
 
 
@@ -436,9 +439,9 @@ ConsoleFunctionWithDocs(alxGetSourcei, ConsoleInt, 3, 3, ( handle , ALEnum ))
       return(0);
    }
 
-   S32 value;
+   ALint value;
    alxGetSourcei(dAtoi(argv[1]), e, &value);
-   return(value);
+   return(static_cast<S32>(value));
 }
 
 

+ 1 - 1
engine/source/graphics/TextureManager.cc

@@ -857,7 +857,7 @@ TextureObject *TextureManager::loadTexture(const char* pTextureKey, TextureHandl
 GBitmap *TextureManager::loadBitmap( const char* pTextureKey, bool recurse, bool nocompression )
 {
     char fileNameBuffer[512];
-    Platform::makeFullPathName( pTextureKey, fileNameBuffer, 512 );
+    Con::expandPath( fileNameBuffer, sizeof(fileNameBuffer), pTextureKey );
     GBitmap *bmp = NULL;
 
     // Loop through the supported extensions to find the file.

+ 10 - 1
engine/source/io/fileSystem_ScriptBinding.cc

@@ -648,9 +648,18 @@ ConsoleFunctionWithDocs(restartInstance, ConsoleVoid, 1, 1, ())
    Platform::postQuitMessage( 0 );
 }
 
+<<<<<<< HEAD:engine/source/io/fileSystem_ScriptBinding.cc
 /*! creates the path or path to the file name
 */
 ConsoleFunctionWithDocs( createPath, ConsoleBool, 2,2, (fileName or pathName))
+=======
+ConsoleFunction( createPath, bool, 2,2, "createPath(\"path\");  creates the path.  "
+                "Verifies all the elements in a path exists or creates them if they do not.  "
+                "Note that the path should end with a slash (/).  Otherwise, the last element in the path "
+                "will be assumed to be a filename and not a path component, and it will not be created.  "
+                "For example \"data/stage2/part1\" will verify or create \"data/stage2/\" and not \"part1\"."
+                )
+>>>>>>> 6e2964681666532c99f49535de98f93c3b6dfb24:engine/source/io/fileSystemFunctions.cpp
 {
    static char pathName[1024];
 
@@ -661,4 +670,4 @@ ConsoleFunctionWithDocs( createPath, ConsoleBool, 2,2, (fileName or pathName))
 
 ConsoleFunctionGroupEnd(FileSystem)
 
-/*! @} */ // group FileSystem
+/*! @} */ // group FileSystem

+ 315 - 0
engine/source/math/mConsoleFunctions.cc

@@ -0,0 +1,315 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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/console.h"
+#include "math/mMathFn.h"
+#include "math/mRandom.h"
+#include "string/stringUnit.h"
+
+ConsoleFunctionGroupBegin( GeneralMath, "General math functions. Use these whenever possible, as they'll run much faster than script equivalents.");
+
+ConsoleFunction( mSolveQuadratic, const char *, 4, 4, "(float a, float b, float c)"
+              "Solve a quadratic equation of form a*x^2 + b*x + c = 0.\n\n"
+              "@returns A triple, contanining: sol x0 x1. sol is the number of"
+              " solutions (being 0, 1, or 2), and x0 and x1 are the solutions, if any."
+              " Unused x's are undefined.")
+{
+   char * retBuffer = Con::getReturnBuffer(256);
+   F32 x[2];
+   U32 sol = mSolveQuadratic(dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3]), x);
+   dSprintf(retBuffer, 256, "%d %g %g", sol, x[0], x[1]);
+   return retBuffer;
+}
+
+ConsoleFunction( mSolveCubic, const char *, 5, 5, "(float a, float b, float c, float d)"
+              "Solve a cubic equation of form a*x^3 + b*x^2 + c*x + d = 0.\n\n"
+              "@returns A 4-tuple, contanining: sol x0 x1 x2. sol is the number of"
+              " solutions (being 0, 1, 2, or 3), and x0, x1, x2 are the solutions, if any."
+              " Unused x's are undefined.")
+{
+   char * retBuffer = Con::getReturnBuffer(256);
+   F32 x[3];
+   U32 sol = mSolveCubic(dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), x);
+   dSprintf(retBuffer, 256, "%d %g %g %g", sol, x[0], x[1], x[2]);
+   return retBuffer;
+}
+
+ConsoleFunction( mSolveQuartic, const char *, 6, 6, "(float a, float b, float c, float d, float e)"
+              "Solve a quartic equation of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.\n\n"
+              "@returns A 5-tuple, contanining: sol x0 x1 x2 x3. sol is the number of"
+              " solutions (ranging from 0-4), and x0, x1, x2 and x3 are the solutions, if any."
+              " Unused x's are undefined.")
+{
+   char * retBuffer = Con::getReturnBuffer(256);
+   F32 x[4];
+   U32 sol = mSolveQuartic(dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), dAtof(argv[5]), x);
+   dSprintf(retBuffer, 256, "%d %g %g %g %g", sol, x[0], x[1], x[2], x[3]);
+   return retBuffer;
+}
+
+ConsoleFunction( mFloor, S32, 2, 2, "( val ) Use the mFloor function to calculate the next lowest integer value from val.\n"
+                                                                "@param val A floating-point value.\n"
+                                                                "@return Returns an integer representing the next lowest integer from val.\n"
+                                                                "@sa mCeil")
+{
+   return (S32)mFloor(dAtof(argv[1]));
+}
+ConsoleFunction( mRound, F32, 2, 2, "(float v) Rounds a number. 0.5 is rounded up.\n"
+                "@param val A floating-point value\n"
+                "@return Returns the integer value closest to the given float")
+
+{
+   return mRound( dAtof(argv[1]) );
+}
+
+ConsoleFunction( mCeil, S32, 2, 2, "( val ) Use the mCeil function to calculate the next highest integer value from val.\n"
+                                                                "@param val A floating-point value.\n"
+                                                                "@return Returns an integer representing the next highest integer from val.\n"
+                                                                "@sa mFloor")
+{
+   return (S32)mCeil(dAtof(argv[1]));
+}
+
+
+ConsoleFunction( mFloatLength, const char *, 3, 3, "( val , numDecimals ) Use the mFloatLength function to limit the number of decimal places in val to numDecimals.\n"
+                                                                "@param val A floating-point value.\n"
+                                                                "@param numDecimals An integer between 0 and inf representing the number of decimal places to allow val to have.\n"
+                                                                "@return Returns a floating-point value equivalent to a truncated version of val, where the new version has numDecimals decimal places")
+{
+   char * outBuffer = Con::getReturnBuffer(256);
+   char fmtString[8] = "%.0f";
+   U32 precision = dAtoi(argv[2]);
+   if (precision > 9)
+      precision = 9;
+   fmtString[2] = '0' + precision;
+
+   dSprintf(outBuffer, 255, fmtString, dAtof(argv[1]));
+   return outBuffer;
+}
+
+//------------------------------------------------------------------------------
+ConsoleFunction( mAbs, F32, 2, 2, "( val ) Use the mAbs function to get the magnitude of val.\n"
+                                                                "@param val An integer or a floating-point value.\n"
+                                                                "@return Returns the magnitude of val")
+{
+   return(mFabs(dAtof(argv[1])));
+}
+
+ConsoleFunction( mSign, F32, 2, 2, "( val ) Use the mSign function to get the signum of a number.\n"
+                                                                "@param val An integer or a floating-point value.\n"
+                                                                "@return Returns +1 if the number is >= 0, or -1 if it's < 0")
+{
+   return(mFsign(dAtof(argv[1])));
+}
+
+ConsoleFunction( mSqrt, F32, 2, 2, "( val ) Use the mSqrt function to calculated the square root of val.\n"
+                                                                "@param val A numeric value.\n"
+                                                                "@return Returns the the squareroot of val")
+{
+   return(mSqrt(dAtof(argv[1])));
+}
+
+ConsoleFunction( mPow, F32, 3, 3, "( val , power ) Use the mPow function to calculated val raised to the power of power.\n"
+                                                                "@param val A numeric (integer or floating-point) value to be raised to a power.\n"
+                                                                "@param power A numeric (integer or floating-point) power to raise val to.\n"
+                                                                "@return Returns val^power")
+{
+   return(mPow(dAtof(argv[1]), dAtof(argv[2])));
+}
+
+ConsoleFunction( mLog, F32, 2, 2, "( val ) Use the mLog function to calculate the natural logarithm of val.\n"
+                                                                "@param val A numeric value.\n"
+                                                                "@return Returns the natural logarithm of val")
+{
+   return(mLog(dAtof(argv[1])));
+}
+
+ConsoleFunction( mSin, F32, 2, 2, "( val ) Use the mSin function to get the sine of the radian angle val.\n"
+                                                                "@param val A value between -3.14159 and 3.14159.\n"
+                                                                "@return Returns the sine of val. This value will be in the range [ -1.0 , 1.0 ].\n"
+                                                                "@sa mAsin")
+{
+   return(mSin(dAtof(argv[1])));
+}
+
+ConsoleFunction( mCos, F32, 2, 2, "( val ) Use the mCos function to get the cosine of the radian angle val.\n"
+                                                                "@param val A value between -3.14159 and 3.14159.\n"
+                                                                "@return Returns the cosine of val. This value will be in the range [ -1.0 , 1.0 ].\n"
+                                                                "@sa mAcos")
+{
+   return(mCos(dAtof(argv[1])));
+}
+
+ConsoleFunction( mTan, F32, 2, 2, "( val ) Use the mTan function to get the tangent of the radian angle val.\n"
+                                                                "@param val A value between -3.14159/2 and 3.14159/2.\n"
+                                                                "@return Returns the tangent of val. This value will be in the range [ -inf.0 , inf.0 ].\n"
+                                                                "@sa mAtan")
+{
+   return(mTan(dAtof(argv[1])));
+}
+
+ConsoleFunction( mAsin, F32, 2, 2, "( val ) Use the mAsin function to get the inverse sine of val in radians.\n"
+                                                                "@param val A value between -1.0 and 1.0 equal to the sine of some angle theta.\n"
+                                                                "@return Returns the inverse sine of val in radians. This value will be in the range [ - 3.14159/2 , 3.14159/2 ].\n"
+                                                                "@sa mSin")
+{
+   return(mAsin(dAtof(argv[1])));
+}
+
+ConsoleFunction( mAcos, F32, 2, 2, "( val ) Use the mAcos function to get the inverse cosine of val in radians.\n"
+                                                                "@param val A value between -1.0 and 1.0 equal to the cosine of some angle theta.\n"
+                                                                "@return Returns the inverse cosine of val in radians. This value will be in the range [ 0 , 3.14159 ].\n"
+                                                                "@sa mCos")
+{
+   return(mAcos(dAtof(argv[1])));
+}
+
+ConsoleFunction( mAtan, F32, 3, 3, "( val ) Use the mAtan function to get the inverse tangent of rise/run in radians.\n"
+                                                                "@param rise Vertical component of a line.\n"
+                                                                "@param run Horizontal component of a line.\n"
+                                                                "@return Returns the slope in radians (the arc-tangent) of a line with the given rise and run.\n"
+                                                                "@sa mTan")
+{
+   return(mAtan(dAtof(argv[1]), dAtof(argv[2])));
+}
+
+ConsoleFunction( mRadToDeg, F32, 2, 2, "( val ) Use the mRadToDeg function to convert radians to degrees.\n"
+                                                                "@param val A floating-point number representing some number of radians.\n"
+                                                                "@return Returns the equivalent of the radian value val in degrees.\n"
+                                                                "@sa mDegToRad")
+{
+   return(mRadToDeg(dAtof(argv[1])));
+}
+
+ConsoleFunction( mDegToRad, F32, 2, 2, "( val ) Use the mDegToRad function to convert degrees to radians.\n"
+                                                                "@param val A floating-point number representing some number of degrees.\n"
+                                                                "@return Returns the equivalent of the degree value val in radians.\n"
+                                                                "@sa mRadToDeg")
+{
+   return(mDegToRad(dAtof(argv[1])));
+}
+
+ConsoleFunction( mClamp, F32, 4, 4, "(float number, float min, float max) Clamp a value between two other values.\n"
+                "@param number A float value representing the number to clamp\n"
+                "@param min The lower bound\n"
+                "@param max The upper bound\n"
+                "@return A float value the is within the given range")
+{
+   F32 value = dAtof( argv[1] );
+   F32 min = dAtof( argv[2] );
+   F32 max = dAtof( argv[3] );
+   return mClampF( value, min, max );
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleFunction( mGetMin, F32, 3, 3, "(a, b) - Returns the Minimum of two values.")
+{
+   return getMin(dAtof(argv[1]), dAtof(argv[2]));
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleFunction( mGetMax, F32, 3, 3, "(a, b) - Returns the Maximum of two values.")
+{
+   return getMax(dAtof(argv[1]), dAtof(argv[2]));
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleFunction( bits, const char*, 2, 2, "Converts a list of bit-positions into a value." )
+{
+    // Calculate Element Count.
+    U32 elementCount = StringUnit::getUnitCount( argv[1], " \t\n" );
+
+    // Return nothing if there's no elements.
+    if ( elementCount < 1 )
+    {
+        // Error!
+        Con::printf("bits() - Invalid number of parameters!");
+        return "0";
+    }
+
+    // Reset Bit Value.
+    U32 bitValue = 0;
+
+    // Parse Bits.
+    for ( U32 n = 0; n < elementCount; n++ )
+    {
+        // Merge Bit Value.
+        bitValue |= (U32)BIT(dAtoi(StringUnit::getUnit(argv[1], n, " \t\n")));
+    }
+
+    // Create Returnable Buffer.
+    char* pBuffer = Con::getReturnBuffer(16);
+    // Format Output.
+    dSprintf( pBuffer, 16, "%u", bitValue );
+    // Return Buffer.
+    return pBuffer;
+}
+
+//-----------------------------------------------------------------------------
+
+ConsoleFunction( bit, const char*, 2, 2, "Converts a bit-position into a value." )
+{
+    // Create Returnable Buffer.
+    char* pBuffer = Con::getReturnBuffer(16);
+
+    // Format Output.
+    dSprintf( pBuffer, 16, "%u", U32(BIT(dAtoi(argv[1]))) );
+
+    // Return Buffer.
+    return pBuffer;
+}
+
+ConsoleFunction( bitInverse, const char*, 2, 2, "Returns the ones complement of a bit." )
+{
+    // Create Returnable Buffer.
+    char* pBuffer = Con::getReturnBuffer(16);
+
+    // Format Output.
+    dSprintf( pBuffer, 16, "%u", U32(~BIT(dAtoi(argv[1]))) );
+
+    // Return Buffer.
+    return pBuffer;
+}
+
+ConsoleFunction( addBitToMask, S32, 3, 3, "( mask, bit ) - Returns the mask with a bit added to it" )
+{
+   U32 mask;
+   dSscanf( argv[1], "%u", &mask );
+   U32 bit = BIT( dAtoi( argv[2] ) );
+   
+   return mask | bit;
+}
+
+ConsoleFunction( removeBitFromMask, S32, 3, 3, "( mask, bit ) - Returns the mask with a bit removed from it" )
+{
+   U32 mask;
+   dSscanf( argv[1], "%u", &mask );
+   U32 bit = BIT( dAtoi( argv[2] ) );
+   
+   return mask & ~bit;
+}
+
+ConsoleFunctionGroupEnd( GeneralMath );

+ 20 - 0
engine/source/math/mMathFn.h

@@ -325,6 +325,11 @@ inline F32 mFabs(const F32 val)
    return (F32) fabs(val);
 }
 
+inline F32 mFsign(const F32 val)
+{
+   return (F32) (val > 0 ? 1 : val < 0 ? -1 : 0);
+}
+
 inline F32 mFmod(const F32 val, const F32 mod)
 {
    return (F32) fmod(val, mod);
@@ -360,6 +365,21 @@ inline U32 mMulDiv(S32 a, S32 b, U32 c)
    return m_mulDivU32(a, b, c);
 }
 
+/// Template function for doing a linear interpolation between any two
+/// types which implement operators for scalar multiply and addition.
+template <typename T>
+inline T mLerp( const T &v1, const T &v2, F32 factor )
+{
+   factor = mClampF( factor, 0.0f, 1.0f);
+   return ( v1 * ( 1.0f - factor ) ) + ( v2 * factor );
+}
+
+template <typename T>
+inline T mSmoothStep( const T &v1, const T &v2, F32 factor)
+{
+   factor = mClampF( factor, 0.0f, 1.0f);
+   return mLerp(v1, v2, (factor*factor*(3.0f-2.0f*factor)));
+}
 
 inline F32 mSin(const F32 angle)
 {

+ 6 - 1
engine/source/persistence/SimXMLDocument.cpp

@@ -860,7 +860,12 @@ const char* SimXMLDocument::getData()
    if(!pNode)
       return "";
 
-   TiXmlText* text = pNode->FirstChild()->ToText();
+   TiXmlNode * firstChild =  pNode->FirstChild();
+
+   if(!firstChild)
+	   return "";
+
+   TiXmlText* text = firstChild->ToText();
    if( !text )
       return "";
 

+ 251 - 241
engine/source/platformOSX/osxFont.mm

@@ -1,242 +1,252 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2013 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.
-//-----------------------------------------------------------------------------
-
-#import "platform/platform.h"
-#import "platformOSX/platformOSX.h"
-#import "platformOSX/osxFont.h"
-#import "string/Unicode.h"
-
-//------------------------------------------------------------------------------
-
-PlatformFont* createPlatformFont( const char* name, U32 size, U32 charset )
-{
-    PlatformFont* pFont = new OSXFont();
-    
-    if ( pFont->create(name, size, charset) )
-        return pFont;
-    
-    delete pFont;
-    
-    return NULL;
-}
-
-//------------------------------------------------------------------------------
-
-void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts )
-{
-    // Fetch available fonts.
-    NSArray* availableFonts = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:0];
-
-    // Enumerate font names.
-    for (id fontName in availableFonts)
-    {
-        fonts.push_back( StringTable->insert( [fontName UTF8String] ) );
-    }
-
-    // Release font name.
-    [availableFonts release];
-}
-
-//------------------------------------------------------------------------------
-
-OSXFont::OSXFont()
-{
-    // Reset the rendering color-space.
-    mColorSpace = NULL;
-}
-
-//------------------------------------------------------------------------------
-
-OSXFont::~OSXFont()
-{
-    // Destroy the rendering color-space.
-    CGColorSpaceRelease( mColorSpace );
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::create( const char* name, U32 size, U32 charset )
-{
-    // Sanity!
-    AssertFatal( name != NULL, "Cannot create a NULL font name." );
-
-    // Generate compatible font name.
-    CFStringRef fontName = CFStringCreateWithCString( kCFAllocatorDefault, name, kCFStringEncodingUTF8 );
-
-    // Sanity!
-    if ( !fontName )
-    {
-        Con::errorf("Could not handle font name of '%s'.", name );
-        return false;
-    }
-
-    // Use Windows as a baseline (96 DPI) and adjust accordingly.
-    F32 scaledSize = size * (72.0f/96.0f);
-    scaledSize = mRound(scaledSize);
-
-    // Create the font reference.
-    mFontRef = CTFontCreateWithName( fontName, scaledSize, NULL );
-
-    // Sanity!
-    if ( !mFontRef )
-    {
-        Con::errorf( "Could not generate a font reference to font name '%s' of size '%d'", name, size );
-        return false;
-    }
-
-    // Fetch font metrics.
-    CGFloat ascent = CTFontGetAscent( mFontRef );
-    CGFloat descent = CTFontGetDescent( mFontRef );
-
-    // Set baseline.
-    mBaseline = (U32)mRound(ascent);
-
-    // Set height.
-    mHeight = (U32)mRound( ascent + descent );
-
-    // Create a gray-scale color-space.
-    mColorSpace = CGColorSpaceCreateDeviceGray();
-
-    // Return status.
-    return true;
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::isValidChar( const UTF8* str ) const
-{
-    // since only low order characters are invalid, and since those characters
-    // are single codeunits in UTF8, we can safely cast here.
-    return isValidChar((UTF16)*str);
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::isValidChar( const UTF16 character) const
-{
-    // We cut out the ASCII control chars here. Only printable characters are valid.
-    // 0x20 == 32 == space
-    if( character < 0x20 )
-        return false;
-    
-    return true;
-}
-
-//------------------------------------------------------------------------------
-
-PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF8 *str) const
-{
-    return getCharInfo( oneUTF32toUTF16(oneUTF8toUTF32(str,NULL)) );
-}
-
-//------------------------------------------------------------------------------
-
-PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF16 character) const
-{
-    // Declare and clear out the CharInfo that will be returned.
-    static PlatformFont::CharInfo characterInfo;
-    dMemset(&characterInfo, 0, sizeof(characterInfo));
-    
-    // prep values for GFont::addBitmap()
-    characterInfo.bitmapIndex = 0;
-    characterInfo.xOffset = 0;
-    characterInfo.yOffset = 0;
-
-    CGGlyph characterGlyph;
-    CGRect characterBounds;
-    CGSize characterAdvances;
-    UniChar unicodeCharacter = character;
-
-    // Fetch font glyphs.
-    if ( !CTFontGetGlyphsForCharacters( mFontRef, &unicodeCharacter, &characterGlyph, (CFIndex)1) )
-    {
-        // Sanity!
-        AssertFatal( false, "Cannot create font glyph." );
-    }
-
-    // Fetch glyph bounding box.
-    CTFontGetBoundingRectsForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterBounds, (CFIndex)1 );
-
-    // Fetch glyph advances.
-    CTFontGetAdvancesForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterAdvances, (CFIndex)1 );
-
-    // Set character metrics,
-    characterInfo.xOrigin = (S32)mRound( characterBounds.origin.x );
-    characterInfo.yOrigin = (S32)mRound( characterBounds.origin.y );
-    characterInfo.width = (U32)mCeil( characterBounds.size.width ) + 2;
-    characterInfo.height = (U32)mCeil( characterBounds.size.height ) + 2;
-    characterInfo.xIncrement = (S32)mRound( characterAdvances.width );
-
-    // Finish if character is undrawable.
-    if ( characterInfo.width == 0 && characterInfo.height == 0 )
-        return characterInfo;
-
-    // Clamp character minimum width.
-    if ( characterInfo.width == 0 )
-        characterInfo.width = 2;
-
-    if ( characterInfo.height == 0 )
-        characterInfo.height = 1;
-
-
-    // Allocate a bitmap surface.
-    const U32 bitmapSize = characterInfo.width * characterInfo.height;
-    characterInfo.bitmapData = new U8[bitmapSize];
-    dMemset(characterInfo.bitmapData, 0x00, bitmapSize);
-
-    // Create a bitmap context.
-    CGContextRef bitmapContext = CGBitmapContextCreate( characterInfo.bitmapData, characterInfo.width, characterInfo.height, 8, characterInfo.width, mColorSpace, kCGImageAlphaNone );
-
-    // Sanity!
-    AssertFatal( bitmapContext != NULL, "Cannot create font context." );
-
-    // Render font anti-aliased if font is arbitrarily small.
-    CGContextSetShouldAntialias( bitmapContext, true);
-    CGContextSetShouldSmoothFonts( bitmapContext, true);
-    CGContextSetRenderingIntent( bitmapContext, kCGRenderingIntentAbsoluteColorimetric);
-    CGContextSetInterpolationQuality( bitmapContext, kCGInterpolationNone);
-    CGContextSetGrayFillColor( bitmapContext, 1.0, 1.0);
-    CGContextSetTextDrawingMode( bitmapContext,  kCGTextFill);
-
-    // Draw glyph.
-    CGPoint renderOrigin;
-    renderOrigin.x = -characterInfo.xOrigin;
-    renderOrigin.y = -characterInfo.yOrigin;
-    CTFontDrawGlyphs( mFontRef, &characterGlyph, &renderOrigin, 1, bitmapContext );
-
- #if 0
-    Con::printf("Width:%f, Height:%f, OriginX:%f, OriginY:%f",
-            characterBounds.size.width,
-            characterBounds.size.height,
-            characterBounds.origin.x,
-            characterBounds.origin.y );
-#endif
-
-    // Adjust the y origin for the glyph size.
-    characterInfo.yOrigin += characterInfo.height;// + mHeight;
-
-    // Release the bitmap context.
-    CGContextRelease( bitmapContext );
-
-    // Return character information.
-    return characterInfo;
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 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.
+//-----------------------------------------------------------------------------
+ 
+#import "platform/platform.h"
+#import "platformOSX/platformOSX.h"
+#import "platformOSX/osxFont.h"
+#import "string/Unicode.h"
+
+//------------------------------------------------------------------------------
+
+PlatformFont* createPlatformFont( const char* name, U32 size, U32 charset )
+{
+    PlatformFont* pFont = new OSXFont();
+    
+    if ( pFont->create(name, size, charset) )
+        return pFont;
+    
+    delete pFont;
+    
+    return NULL;
+}
+
+//------------------------------------------------------------------------------
+
+void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts )
+{
+    // Fetch available fonts.
+    NSArray* availableFonts = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:0];
+
+    // Enumerate font names.
+    for (id fontName in availableFonts)
+    {
+        fonts.push_back( StringTable->insert( [fontName UTF8String] ) );
+    }
+
+    // Release font name.
+    [availableFonts release];
+}
+
+//------------------------------------------------------------------------------
+
+OSXFont::OSXFont()
+{
+    // Reset the rendering color-space.
+    mColorSpace = NULL;
+}
+
+//------------------------------------------------------------------------------
+
+OSXFont::~OSXFont()
+{
+    // Destroy the rendering color-space.
+    CGColorSpaceRelease( mColorSpace );
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::create( const char* name, U32 size, U32 charset )
+{
+    // Sanity!
+    AssertFatal( name != NULL, "Cannot create a NULL font name." );
+
+    // Generate compatible font name.
+    CFStringRef fontName = CFStringCreateWithCString( kCFAllocatorDefault, name, kCFStringEncodingUTF8 );
+
+    // Sanity!
+    if ( !fontName )
+    {
+        Con::errorf("Could not handle font name of '%s'.", name );
+        return false;
+    }
+
+    // Use Windows as a baseline (96 DPI) and adjust accordingly.
+    F32 scaledSize = size * (72.0f/96.0f);
+    scaledSize = mRound(scaledSize);
+
+    // Create the font reference.
+    mFontRef = CTFontCreateWithName( fontName, scaledSize, NULL );
+
+    // Sanity!
+    if ( !mFontRef )
+    {
+        Con::errorf( "Could not generate a font reference to font name '%s' of size '%d'", name, size );
+        return false;
+    }
+
+    // Fetch font metrics.
+    CGFloat ascent = CTFontGetAscent( mFontRef );
+    CGFloat descent = CTFontGetDescent( mFontRef );
+
+    // Set baseline.
+    mBaseline = (U32)mRound(ascent);
+
+    // Set height.
+    mHeight = (U32)mRound( ascent + descent );
+
+    // Create a gray-scale color-space.
+    mColorSpace = CGColorSpaceCreateDeviceGray();
+
+    // Return status.
+    return true;
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::isValidChar( const UTF8* str ) const
+{
+    // since only low order characters are invalid, and since those characters
+    // are single codeunits in UTF8, we can safely cast here.
+    return isValidChar((UTF16)*str);
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::isValidChar( const UTF16 character) const
+{
+    // We cut out the ASCII control chars here. Only printable characters are valid.
+    // 0x20 == 32 == space
+    if( character < 0x20 )
+        return false;
+    
+    return true;
+}
+
+//------------------------------------------------------------------------------
+
+PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF8 *str) const
+{
+    return getCharInfo( oneUTF32toUTF16(oneUTF8toUTF32(str,NULL)) );
+}
+
+//------------------------------------------------------------------------------
+
+PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF16 character) const
+{
+    // Declare and clear out the CharInfo that will be returned.
+    static PlatformFont::CharInfo characterInfo;
+    dMemset(&characterInfo, 0, sizeof(characterInfo));
+    
+    // prep values for GFont::addBitmap()
+    characterInfo.bitmapIndex = 0;
+    characterInfo.xOffset = 0;
+    characterInfo.yOffset = 0;
+
+    CGGlyph characterGlyph;
+    CGRect characterBounds;
+    CGSize characterAdvances;
+    UniChar unicodeCharacter = character;
+
+    // Fetch font glyphs.
+    if ( !CTFontGetGlyphsForCharacters( mFontRef, &unicodeCharacter, &characterGlyph, (CFIndex)1) )
+    {
+        // Sanity!
+        AssertFatal( false, "Cannot create font glyph." );
+    }
+
+    // Fetch glyph bounding box.
+    CTFontGetBoundingRectsForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterBounds, (CFIndex)1 );
+
+    // Fetch glyph advances.
+    CTFontGetAdvancesForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterAdvances, (CFIndex)1 );
+
+    // Set character metrics,
+    characterInfo.xOrigin = (S32)mRound( characterBounds.origin.x );
+    characterInfo.yOrigin = (S32)mRound( characterBounds.origin.y );
+    characterInfo.width = (U32)mCeil( characterBounds.size.width ) + 2;
+    characterInfo.height = (U32)mCeil( characterBounds.size.height ) + 2;
+    characterInfo.xIncrement = (S32)mRound( characterAdvances.width );
+
+    // Finish if character is undrawable.
+    if ( characterInfo.width == 0 && characterInfo.height == 0 )
+        return characterInfo;
+
+    // Clamp character minimum width.
+    if ( characterInfo.width == 0 )
+        characterInfo.width = 2;
+
+    if ( characterInfo.height == 0 )
+        characterInfo.height = 1;
+
+
+    // Allocate a bitmap surface.
+    const U32 bitmapSize = characterInfo.width * characterInfo.height;
+    characterInfo.bitmapData = new U8[bitmapSize];
+    dMemset(characterInfo.bitmapData, 0x00, bitmapSize);
+
+    // Create a bitmap context.
+    CGContextRef bitmapContext = CGBitmapContextCreate( characterInfo.bitmapData, characterInfo.width, characterInfo.height, 8, characterInfo.width, mColorSpace, kCGImageAlphaNone );
+
+    // Sanity!
+    AssertFatal( bitmapContext != NULL, "Cannot create font context." );
+
+    // Render font anti-aliased if font is arbitrarily small.
+    CGContextSetShouldAntialias( bitmapContext, true);
+    CGContextSetShouldSmoothFonts( bitmapContext, true);
+    CGContextSetRenderingIntent( bitmapContext, kCGRenderingIntentAbsoluteColorimetric);
+    CGContextSetInterpolationQuality( bitmapContext, kCGInterpolationNone);
+    CGContextSetGrayFillColor( bitmapContext, 1.0, 1.0);
+    CGContextSetTextDrawingMode( bitmapContext,  kCGTextFill);
+
+    // Draw glyph. 
+    CGPoint renderOrigin;
+    renderOrigin.x = -characterInfo.xOrigin;
+    renderOrigin.y = -characterInfo.yOrigin;
+    
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+    CTFontDrawGlyphs( mFontRef, &characterGlyph, &renderOrigin, 1, bitmapContext );
+#else
+    CGFontRef cgFont = CTFontCopyGraphicsFont(mFontRef, NULL);
+    CGContextSetFont(bitmapContext, cgFont);
+    CGContextSetFontSize(bitmapContext, CTFontGetSize(mFontRef));
+    CGContextShowGlyphsAtPositions(bitmapContext, &characterGlyph, &renderOrigin, 1);
+    CFRelease(cgFont);
+#endif
+    
+     
+ #if 0
+    Con::printf("Width:%f, Height:%f, OriginX:%f, OriginY:%f",
+            characterBounds.size.width,
+            characterBounds.size.height,
+            characterBounds.origin.x,
+            characterBounds.origin.y );
+#endif
+
+    // Adjust the y origin for the glyph size.
+    characterInfo.yOrigin += characterInfo.height;// + mHeight;
+
+    // Release the bitmap context.
+    CGContextRelease( bitmapContext );
+
+    // Return character information.
+    return characterInfo;
 }

+ 14 - 0
engine/source/platformOSX/osxOpenGLDevice.mm

@@ -285,7 +285,21 @@ bool osxOpenGLDevice::setScreenMode( U32 width, U32 height, U32 bpp, bool fullSc
     }
     else
     {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        [[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask] ;
+        
+        // Calculate the actual center
+        CGFloat x = ([[NSScreen mainScreen] frame].size.width - width) / 2;
+        CGFloat y = ([[NSScreen mainScreen] frame].size.height - height) / 2;
+        
+        // Create a rect to send to the window
+        NSRect newFrame = NSMakeRect(x, y, width, height);
+        
+        // Send message to the window to resize/relocate
+        [[platState window] setFrame:newFrame display:YES animate:NO];
+#else
         [[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask];
+#endif
     }
     
     [[platState torqueView] createContextWithPixelFormat:pixelFormat];

+ 22 - 0
engine/source/platformOSX/platformOSX.mm

@@ -146,11 +146,33 @@ static osxPlatState * tempSharedPlatState = nil;
         
         // Get the new position of the title bar
         barOffset -= frame.size.height;
+        
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        
+        // Update the frame of the torqueView to match the window
+        frame = NSMakeRect([_window frame].origin.x, [_window frame].origin.y, width, height);
+        NSRect viewFrame = NSMakeRect(0, 0, frame.size.width, frame.size.height);
+        [_torqueView setFrame:viewFrame];
+        [_torqueView updateContext];
+#endif
     }
     else
     {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        
+        NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
+        // Update the frame of the torqueView to match the window
+        NSRect viewFrame = NSMakeRect(0, 0, mainDisplayRect.size.width, mainDisplayRect.size.height);
+        [_torqueView setFrame:viewFrame];
+        [_torqueView updateContext];
+        
+        // Otherwise, just go straight full screen
+        [_torqueView enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
+        
+#else
         // Otherwise, just go straight full screen
         [_window toggleFullScreen:self];
+#endif
     }
     
     // Update the frame of the torqueView to match the window

+ 2 - 2
engine/source/platformWin32/winWindow.cc

@@ -1494,9 +1494,9 @@ void Platform::init()
 //--------------------------------------
 void Platform::shutdown()
 {
-   sgQueueEvents = false;
-
+   sgQueueEvents = false;   
    setMouseLock( false );
+   Audio::OpenALShutdown();
    Video::destroy();
    Input::destroy();
    WinConsole::destroy();