Browse Source

Merge branch 'development' of github.com:GarageGames/Torque2D into development

capnlove 12 years ago
parent
commit
9c74393

+ 14 - 0
engine/source/2d/core/SpriteBatch.cc

@@ -907,6 +907,9 @@ void SpriteBatch::setSpriteName( const char* pName )
     if ( findSpriteName( pName ) )
         return;
 
+    // Insert sprite name.
+    mSpriteNames.insert( StringTable->insert( pName ), mSelectedSprite );
+
     // Set name.
     mSelectedSprite->setName( pName );
 }
@@ -1224,6 +1227,17 @@ void SpriteBatch::onTamlCustomRead( const TamlCustomNode* pSpritesNode )
             // Yes, so insert into sprite positions.
             mSpritePositions.insert( logicalPosition, pSpriteBatchItem );
         }
+
+        // Fetch sprite name.
+        StringTableEntry spriteName = pSpriteBatchItem->getName();
+
+        // Did we get a sprite name?
+        if ( spriteName != StringTable->EmptyString )
+        {
+            // Yes, so insert into sprite names if it doesn't already exist.
+            if ( mSpriteNames.find( spriteName ) != mSpriteNames.end() ) 
+                mSpriteNames.insert( spriteName, mSelectedSprite );
+        }
     }
 }
 

+ 120 - 8
engine/source/collection/vector.h

@@ -79,7 +79,10 @@ class Vector
    U32         mLineAssociation;
 #endif
 
-   bool  resize(U32);
+   bool  resize(U32); // resizes, but does no construction/destruction
+   void  destroy(U32 start, U32 end);   ///< Destructs elements from <i>start</i> to <i>end-1</i>
+   void  construct(U32 start, U32 end); ///< Constructs elements from <i>start</i> to <i>end-1</i>
+   void  construct(U32 start, U32 end, const T* array);
   public:
    Vector(const U32 initialSize = 0);
    Vector(const U32 initialSize, const char* fileName, const U32 lineNum);
@@ -103,6 +106,8 @@ class Vector
    typedef S32    difference_type;
    typedef U32    size_type;
 
+   typedef difference_type (QSORT_CALLBACK *compare_func)(const T *a, const T *b);
+
    Vector<T>& operator=(const Vector<T>& p);
 
    iterator       begin();
@@ -112,6 +117,7 @@ class Vector
 
    S32 size() const;
    bool empty() const;
+   bool contains(const T&) const;
 
    void insert(iterator, const T&);
    void erase(iterator);
@@ -123,6 +129,9 @@ class Vector
 
    void push_front(const T&);
    void push_back(const T&);
+   U32 push_front_unique(const T&);
+   U32 push_back_unique(const T&);
+   S32 find_next( const T&, U32 start = 0 ) const;
    void pop_front();
    void pop_back();
 
@@ -146,7 +155,8 @@ class Vector
    U32  memSize() const;
    T*   address() const;
    U32  setSize(U32);
-   void increment(U32 = 1);
+   void increment( U32 = 1);
+   void increment(const T* array, U32 = 1);
    void decrement(U32 = 1);
    void insert(U32);
    void erase(U32);
@@ -154,7 +164,7 @@ class Vector
    void erase_fast(iterator);
    void clear();
    void compact();
-
+   void sort(compare_func f);
    T& first();
    T& last();
    const T& first() const;
@@ -246,6 +256,33 @@ template<class T> inline void Vector<T>::setFileAssociation(const char* file,
 }
 #endif
 
+template<class T> inline void  Vector<T>::destroy(U32 start, U32 end) // destroys from start to end-1
+{
+   // This check is a little generous as we can legitimately get (0,0) as
+   // our parameters... so it won't detect every invalid case but it does
+   // remain simple.
+   AssertFatal(start <= mElementCount && end <= mElementCount, "Vector<T>::destroy - out of bounds start/end.");
+
+   // destroys from start to end-1
+   while(start < end)
+      destructInPlace(&mArray[start++]);
+}
+
+template<class T> inline void  Vector<T>::construct(U32 start, U32 end) // destroys from start to end-1
+{
+   AssertFatal(start <= mElementCount && end <= mElementCount, "Vector<T>::construct - out of bounds start/end.");
+   while(start < end)
+      constructInPlace(&mArray[start++]);
+}
+
+template<class T> inline void  Vector<T>::construct(U32 start, U32 end, const T* array) // destroys from start to end-1
+{
+   AssertFatal(start <= mElementCount && end <= mElementCount, "Vector<T>::construct - out of bounds start/end.");
+    for (int i = 0; start + i < end; i++) {
+      constructInPlace(&mArray[start+i], &array[i]);
+    }
+}
+
 template<class T> inline U32 Vector<T>::memSize() const
 {
    return capacity() * sizeof(T);
@@ -265,18 +302,40 @@ template<class T> inline U32 Vector<T>::setSize(U32 size)
    return mElementCount;
 }
 
-template<class T> inline void Vector<T>::increment(U32 delta)
+template<class T> inline void Vector<T>::increment( U32 delta)
 {
+    U32 count = mElementCount;
+    if ((mElementCount += delta) > mArraySize)
+        resize(mElementCount);
+    construct(count, mElementCount);
+}
+
+template<class T> inline void Vector<T>::increment(const T* array, U32 delta)
+{
+   U32 count = mElementCount;
    if ((mElementCount += delta) > mArraySize)
       resize(mElementCount);
+    construct(count, mElementCount, array);
 }
 
 template<class T> inline void Vector<T>::decrement(U32 delta)
 {
+   AssertFatal(mElementCount != 0, "Vector<T>::decrement - cannot decrement zero-length vector.");
+
+   const U32 count = mElementCount;
+
+   // Determine new count after decrement...
+   U32 newCount = mElementCount;
    if (mElementCount > delta)
-      mElementCount -= delta;
+      newCount -= delta;
    else
-      mElementCount = 0;
+      newCount = 0;
+
+   // Destruct removed items...
+   destroy(newCount, count);
+
+   // Note new element count.
+   mElementCount = newCount;
 }
 
 template<class T> inline void Vector<T>::insert(U32 index)
@@ -349,6 +408,12 @@ template<class T> inline void Vector<T>::compact()
    resize(mElementCount);
 }
 
+typedef int (QSORT_CALLBACK *qsort_compare_func)(const void *, const void *);
+
+template<class T> inline void Vector<T>::sort(compare_func f)
+{
+   qsort(address(), size(), sizeof(T), (qsort_compare_func) f);
+}
 
 //-----------------------------------------------------------------------------
 
@@ -438,8 +503,55 @@ template<class T> inline void Vector<T>::push_front(const T& x)
 
 template<class T> inline void Vector<T>::push_back(const T& x)
 {
-   increment();
-   mArray[mElementCount - 1] = x;
+   increment(&x);
+//   mArray[mElementCount - 1] = x;
+}
+
+template<class T> inline U32 Vector<T>::push_front_unique(const T& x)
+{
+   S32 index = find_next(x);
+
+   if (index == -1)
+   {
+      index = 0;
+
+      insert(index);
+      mArray[index] = x;
+   }
+
+   return index;
+}
+
+template<class T> inline U32 Vector<T>::push_back_unique(const T& x)
+{
+   S32 index = find_next(x);
+
+   if (index == -1)
+   {
+      increment(&x);
+      index = mElementCount - 1;
+   }
+
+   return index;
+}
+
+template<class T> inline S32 Vector<T>::find_next( const T& x, U32 start ) const
+{
+   S32 index = -1;
+
+   if (start < mElementCount)
+   {
+      for (U32 i = start; i < mElementCount; i++)
+      {
+         if (mArray[i] == x)
+         {
+            index = i;
+            break;
+         }
+      }
+   }
+
+   return index;
 }
 
 template<class T> inline void Vector<T>::pop_front()

+ 0 - 5
engine/source/persistence/taml/tamlXmlWriter.cc

@@ -170,11 +170,6 @@ void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const Taml
         dSprintf( extendedElementNameBuffer, sizeof(extendedElementNameBuffer), "%s.%s", pXmlElement->Value(), pCustomNode->getNodeName() );
         StringTableEntry extendedElementName = StringTable->insert( extendedElementNameBuffer );
 
-        if ( dStricmp(pCustomNode->getNodeName(), "controllers") == 0 )
-        {
-            S32 a = 0;
-        }
-
         // Create element.
         TiXmlElement* pExtendedPropertyElement = new TiXmlElement( extendedElementName );
 

+ 7 - 0
engine/source/platform/platformMemory.h

@@ -49,6 +49,13 @@ template <class T> inline T* constructInPlace(T* p, const T* copy)
    return new(p) T(*copy);
 }
 
+
+template< class T >
+inline T* constructArrayInPlace( T* p, U32 num )
+{
+    return new ( p ) T[ num ];
+}
+
 //------------------------------------------------------------------------------
 
 template <class T> inline void destructInPlace(T* p)

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

@@ -631,7 +631,7 @@ struct WinMessage
    UINT message;
    WPARAM wParam;
    LPARAM lParam;
-
+   WinMessage() {};
    WinMessage(UINT m, WPARAM w, LPARAM l) : message(m), wParam(w), lParam(l) {}
 };
 

+ 1 - 1
modules/AppCore/1/main.cs

@@ -33,7 +33,7 @@ function AppCore::create( %this )
     
     // Set the canvas color
     Canvas.BackgroundColor = "CornflowerBlue";
-    Canvas.UseBackgroundColor = false;
+    Canvas.UseBackgroundColor = true;
     
     // Initialize audio
     initializeOpenAL();

+ 5 - 5
modules/Sandbox/1/scripts/toolbox.cs

@@ -215,15 +215,15 @@ function toggleToolbox(%make)
 function BackgroundColorSelectList::onSelect(%this)
 {           
     // Fetch the index.
-    $activeSceneColor = %this.getSelected();
+    $activeBackgroundColor = %this.getSelected();
  
     // Finish if the sandbox scene is not available.
     if ( !isObject(SandboxScene) )
         return;
             
     // Set the scene color.
-    SandboxScene.BackgroundColor = getStockColorName($activeSceneColor);
-    SandboxScene.UseBackgroundColor = true;
+    Canvas.BackgroundColor = getStockColorName($activeBackgroundColor);
+    Canvas.UseBackgroundColor = true;
 }
 
 //-----------------------------------------------------------------------------
@@ -296,8 +296,8 @@ function updateToolboxOptions()
         return;
         
     // Set the scene color.
-    SandboxScene.BackgroundColor = getStockColorName($activeSceneColor);
-    SandboxScene.UseBackgroundColor = true;        
+    Canvas.BackgroundColor = getStockColorName($activeBackgroundColor);
+    Canvas.UseBackgroundColor = true;        
        
     // Set option.
     if ( $pref::Sandbox::metricsOption )

+ 1 - 1
tools/TexturePacker/T2DMIT/exporter.xml

@@ -29,7 +29,7 @@
     </files>
 
     <!-- target framework supports trimming -->
-    <supportsTrimming>true</supportsTrimming>
+    <supportsTrimming>false</supportsTrimming>
 
     <!-- target framework supports rotated sprites -->
     <supportsRotation>false</supportsRotation>

+ 1 - 1
tools/TexturePacker/T2DMIT/template.asset.taml

@@ -1,6 +1,6 @@
 <ImageAsset
     AssetName="{{texture.trimmedName}}"
-    ImageFile="@assetFile=#{{texture.fullName}}">	
+    ImageFile="@assetFile={{texture.fullName}}">	
 	<ImageAsset.Cells>
 		{% for sprite in allSprites %}<Cell Offset="{{sprite.frameRect.x}} {{sprite.frameRect.y}}" Width="{{sprite.frameRect.width}}" Height="{{sprite.frameRect.height}}"/>
 		{% endfor %}

+ 0 - 0
tools/VisualStudioVisualizer/VisualStudioVisualizer.txt → tools/VisualStudioVisualizer/VS2010/VisualStudioVisualizer.txt


+ 13 - 0
tools/VisualStudioVisualizer/VS2012/ReadMe.txt

@@ -0,0 +1,13 @@
+Debug Visualizers for Torque 2D.
+
+Type visualizers for C++ types are specified in .natvis files. A natvis file is simply an xml file (with .natvis extension) that contains visualization rules for one or more types. At the start of each debugging session, Visual Studio processes any natvis files it can find in the following locations:
+
+    -         %VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers (requires admin access)
+    -         %USERPROFILE%\My Documents\Visual Studio 2012\Visualizers\
+    -         VS extension folders
+	
+
+More information can be found here:
+
+http://blogs.msdn.com/b/vcblog/archive/2012/07/12/10329460.aspx
+http://code.msdn.microsoft.com/Writing-type-visualizers-2eae77a2

+ 10 - 0
tools/VisualStudioVisualizer/VS2012/T2D_AssetPtrT.natvis

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
+    <Type Name="AssetPtr&lt;*&gt;">
+		<DisplayString Condition="mpAsset.mObj==0">Empty Asset Reference</DisplayString>
+		<DisplayString>{{Module = {((AssetBase*)(mpAsset.mObj))-&gt;mpAssetDefinition-&gt;mpModuleDefinition-&gt;mModuleId} AssetName = {((AssetBase*)(mpAsset.mObj))-&gt;mpAssetDefinition-&gt;mAssetName} AssetType = {((AssetBase*)(mpAsset.mObj))-&gt;mpAssetDefinition-&gt;mAssetType}}}</DisplayString>
+		<Expand> 
+			<ExpandedItem Condition="mpAsset.mObj!=0">($T1*)(mpAsset.mObj)</ExpandedItem> 
+		</Expand> 		
+    </Type>
+</AutoVisualizer>

+ 13 - 0
tools/VisualStudioVisualizer/VS2012/T2D_VectorT.natvis

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
+    <Type Name="Vector&lt;*&gt;">
+		<DisplayString Condition="mElementCount==0">Empty Vector</DisplayString>
+		<DisplayString>{{ Size = {mElementCount}, Capacity = {mArraySize}, Memory = {mArraySize*sizeof($T1)} bytes }}</DisplayString>
+		<Expand> 
+			<ArrayItems> 
+				<Size>mElementCount</Size> 
+				<ValuePointer>mArray</ValuePointer> 
+			</ArrayItems> 
+		</Expand> 		
+    </Type>
+</AutoVisualizer>