Sfoglia il codice sorgente

- Added support for RectI, RectF & b2AAAA to schema.
- Added support for Scene.Controllers to schema.
- Scehema now adds static fields in reverse order so that root type is last.

MelvMay-GG 12 anni fa
parent
commit
dbfae3e930

+ 64 - 1
engine/source/2d/scene/Scene.cc

@@ -5350,7 +5350,7 @@ const char* Scene::getPickModeDescription( Scene::PickMode pickMode )
 
 //-----------------------------------------------------------------------------
 
-static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+static void WriteJointsCustomTamlScehema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
 {
     char buffer[1024];
 
@@ -5425,6 +5425,69 @@ static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlEleme
     pDistanceJointElementC->LinkEndChild( pDistanceJointElementD );
 }
 
+//-----------------------------------------------------------------------------
+
+static void WriteControllersCustomTamlScehema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    char buffer[1024];
+
+    // Create controllers node element.
+    TiXmlElement* pControllersNodeElement = new TiXmlElement( "xs:element" );
+    dSprintf( buffer, sizeof(buffer), "%s.%s", pClassRep->getClassName(), controllerCustomNodeName );
+    pControllersNodeElement->SetAttribute( "name", buffer );
+    pControllersNodeElement->SetAttribute( "minOccurs", 0 );
+    pControllersNodeElement->SetAttribute( "maxOccurs", 1 );
+    pParentElement->LinkEndChild( pControllersNodeElement );
+    
+    // Create complex type.
+    TiXmlElement* pControllersNodeComplexTypeElement = new TiXmlElement( "xs:complexType" );
+    pControllersNodeElement->LinkEndChild( pControllersNodeComplexTypeElement );
+    
+    // Create choice element.
+    TiXmlElement* pControllersNodeChoiceElement = new TiXmlElement( "xs:choice" );
+    pControllersNodeChoiceElement->SetAttribute( "minOccurs", 0 );
+    pControllersNodeChoiceElement->SetAttribute( "maxOccurs", "unbounded" );
+    pControllersNodeComplexTypeElement->LinkEndChild( pControllersNodeChoiceElement );
+
+    // Fetch the scene controller type.
+    AbstractClassRep* pPickingSceneControllerType = AbstractClassRep::findClassRep( "PickingSceneController" );
+    AbstractClassRep* pGroupedSceneControllerType = AbstractClassRep::findClassRep( "GroupedSceneController" );
+
+    // Sanity!
+    AssertFatal( pPickingSceneControllerType != NULL, "Scene::WriteControllersCustomTamlScehema() - Cannot find the PickingSceneController type." );
+    AssertFatal( pGroupedSceneControllerType != NULL, "Scene::WriteControllersCustomTamlScehema() - Cannot find the GroupedSceneController type." );
+
+    // Add choice members.
+    for ( AbstractClassRep* pChoiceType = AbstractClassRep::getClassList(); pChoiceType != NULL; pChoiceType = pChoiceType->getNextClass() )
+    {
+        // Skip if not derived from either of the scene controllers.
+        if ( !pChoiceType->isClass( pPickingSceneControllerType ) && !pChoiceType->isClass( pGroupedSceneControllerType ) )
+            continue;
+
+        // Add choice member.
+        TiXmlElement* pChoiceMemberElement = new TiXmlElement( "xs:element" );
+        pChoiceMemberElement->SetAttribute( "name", pChoiceType->getClassName() );
+        dSprintf( buffer, sizeof(buffer), "%s_Type", pChoiceType->getClassName() );
+        pChoiceMemberElement->SetAttribute( "type", buffer );
+        pControllersNodeChoiceElement->LinkEndChild( pChoiceMemberElement );
+    }
+}
+
+//-----------------------------------------------------------------------------
+
+static void WritePreloadsCustomTamlScehema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+}
+
+//-----------------------------------------------------------------------------
+
+static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    WriteJointsCustomTamlScehema( pClassRep, pParentElement );
+    WriteControllersCustomTamlScehema( pClassRep, pParentElement );
+    WritePreloadsCustomTamlScehema( pClassRep, pParentElement );
+}
+
 //------------------------------------------------------------------------------
 
 IMPLEMENT_CONOBJECT_CHILDREN_SCHEMA(Scene, WriteCustomTamlSchema);

+ 55 - 37
engine/source/2d/sceneobject/SceneObject.cc

@@ -4099,36 +4099,14 @@ const char* SceneObject::getDstBlendFactorDescription(const GLenum factor)
 
 //-----------------------------------------------------------------------------
 
-static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+static void WriteCircleCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
 {
-    char buffer[1024];
-
-    // Create shapes node element.
-    TiXmlElement* pShapesNodeElement = new TiXmlElement( "xs:element" );
-    dSprintf( buffer, sizeof(buffer), "%s.%s", pClassRep->getClassName(), shapeCustomNodeName );
-    pShapesNodeElement->SetAttribute( "name", buffer );
-    pShapesNodeElement->SetAttribute( "minOccurs", 0 );
-    pShapesNodeElement->SetAttribute( "maxOccurs", 1 );
-    pParentElement->LinkEndChild( pShapesNodeElement );
-    
-    // Create complex type.
-    TiXmlElement* pShapesNodeComplexTypeElement = new TiXmlElement( "xs:complexType" );
-    pShapesNodeElement->LinkEndChild( pShapesNodeComplexTypeElement );
-    
-    // Create choice element.
-    TiXmlElement* pShapesNodeChoiceElement = new TiXmlElement( "xs:choice" );
-    pShapesNodeChoiceElement->SetAttribute( "minOccurs", 0 );
-    pShapesNodeChoiceElement->SetAttribute( "maxOccurs", "unbounded" );
-    pShapesNodeComplexTypeElement->LinkEndChild( pShapesNodeChoiceElement );
-
-    // ********************************************************************************
-    // Create Circle
-    // ********************************************************************************
+    // Create circle element.
     TiXmlElement* pCircleElement = new TiXmlElement( "xs:element" );
     pCircleElement->SetAttribute( "name", circleTypeName );
     pCircleElement->SetAttribute( "minOccurs", 0 );
     pCircleElement->SetAttribute( "maxOccurs", 1 );
-    pShapesNodeChoiceElement->LinkEndChild( pCircleElement );
+    pParentElement->LinkEndChild( pCircleElement );
 
     // Create complex type Element.
     TiXmlElement* pCircleComplexTypeElement = new TiXmlElement( "xs:complexType" );
@@ -4197,15 +4175,18 @@ static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlEleme
     pCircleElementD = new TiXmlElement( "xs:minInclusive" );
     pCircleElementD->SetAttribute( "value", "0" );
     pCircleElementC->LinkEndChild( pCircleElementD );
+}
 
-    // ********************************************************************************
-    // Create Polygon
-    // ********************************************************************************
+//-----------------------------------------------------------------------------
+
+static void WritePolygonCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    // Create polygon element.
     TiXmlElement* pPolygonElement = new TiXmlElement( "xs:element" );
     pPolygonElement->SetAttribute( "name", polygonTypeName );
     pPolygonElement->SetAttribute( "minOccurs", 0 );
     pPolygonElement->SetAttribute( "maxOccurs", 1 );
-    pShapesNodeChoiceElement->LinkEndChild( pPolygonElement );
+    pParentElement->LinkEndChild( pPolygonElement );
 
     // Create complex type Element.
     TiXmlElement* pPolygonComplexTypeElement = new TiXmlElement( "xs:complexType" );
@@ -4265,15 +4246,18 @@ static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlEleme
     pPolygonElementD = new TiXmlElement( "xs:minInclusive" );
     pPolygonElementD->SetAttribute( "value", "0" );
     pPolygonElementC->LinkEndChild( pPolygonElementD );
+}
 
-    // ********************************************************************************
-    // Create Chain
-    // ********************************************************************************
+//-----------------------------------------------------------------------------
+
+static void WriteChainCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    // Create chain element.
     TiXmlElement* pChainElement = new TiXmlElement( "xs:element" );
     pChainElement->SetAttribute( "name", chainTypeName );
     pChainElement->SetAttribute( "minOccurs", 0 );
     pChainElement->SetAttribute( "maxOccurs", 1 );
-    pShapesNodeChoiceElement->LinkEndChild( pChainElement );
+    pParentElement->LinkEndChild( pChainElement );
 
     // Create complex type Element.
     TiXmlElement* pChainComplexTypeElement = new TiXmlElement( "xs:complexType" );
@@ -4347,15 +4331,18 @@ static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlEleme
     pChainElementD = new TiXmlElement( "xs:minInclusive" );
     pChainElementD->SetAttribute( "value", "0" );
     pChainElementC->LinkEndChild( pChainElementD );
+}
 
-    // ********************************************************************************
-    // Create Edge
-    // ********************************************************************************
+//-----------------------------------------------------------------------------
+
+static void WriteEdgeCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    // Create edge element.
     TiXmlElement* pEdgeElement = new TiXmlElement( "xs:element" );
     pEdgeElement->SetAttribute( "name", edgeTypeName );
     pEdgeElement->SetAttribute( "minOccurs", 0 );
     pEdgeElement->SetAttribute( "maxOccurs", 1 );
-    pShapesNodeChoiceElement->LinkEndChild( pEdgeElement );
+    pParentElement->LinkEndChild( pEdgeElement );
 
     // Create complex type Element.
     TiXmlElement* pEdgeComplexTypeElement = new TiXmlElement( "xs:complexType" );
@@ -4431,4 +4418,35 @@ static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlEleme
 
 //-----------------------------------------------------------------------------
 
+static void WriteCustomTamlSchema( const AbstractClassRep* pClassRep, TiXmlElement* pParentElement )
+{
+    char buffer[1024];
+
+    // Create shapes node element.
+    TiXmlElement* pShapesNodeElement = new TiXmlElement( "xs:element" );
+    dSprintf( buffer, sizeof(buffer), "%s.%s", pClassRep->getClassName(), shapeCustomNodeName );
+    pShapesNodeElement->SetAttribute( "name", buffer );
+    pShapesNodeElement->SetAttribute( "minOccurs", 0 );
+    pShapesNodeElement->SetAttribute( "maxOccurs", 1 );
+    pParentElement->LinkEndChild( pShapesNodeElement );
+    
+    // Create complex type.
+    TiXmlElement* pShapesNodeComplexTypeElement = new TiXmlElement( "xs:complexType" );
+    pShapesNodeElement->LinkEndChild( pShapesNodeComplexTypeElement );
+    
+    // Create choice element.
+    TiXmlElement* pShapesNodeChoiceElement = new TiXmlElement( "xs:choice" );
+    pShapesNodeChoiceElement->SetAttribute( "minOccurs", 0 );
+    pShapesNodeChoiceElement->SetAttribute( "maxOccurs", "unbounded" );
+    pShapesNodeComplexTypeElement->LinkEndChild( pShapesNodeChoiceElement );
+
+    // Write collision shapes.
+    WriteCircleCustomTamlSchema( pClassRep, pShapesNodeChoiceElement );
+    WritePolygonCustomTamlSchema( pClassRep, pShapesNodeChoiceElement );
+    WriteChainCustomTamlSchema( pClassRep, pShapesNodeChoiceElement );
+    WriteEdgeCustomTamlSchema( pClassRep, pShapesNodeChoiceElement );
+}
+
+//-----------------------------------------------------------------------------
+
 IMPLEMENT_CONOBJECT_SCHEMA(SceneObject, WriteCustomTamlSchema);

+ 60 - 3
engine/source/persistence/taml/taml.cc

@@ -922,6 +922,45 @@ bool Taml::generateTamlSchema( const char* pFilename )
     pPoint2IElementB->SetAttribute( "value", "[-]?[0-9]* [-]?[0-9]*" );   
     pPoint2IElementA->LinkEndChild( pPoint2IElementB );
 
+    // b2AABB.
+    TiXmlComment* pb2AABBComment = new TiXmlComment( "b2AABB Console Type" );
+    pSchemaElement->LinkEndChild( pb2AABBComment );
+    TiXmlElement* pb2AABBTypeElement = new TiXmlElement( "xs:simpleType" );
+    pb2AABBTypeElement->SetAttribute( "name", "b2AABB_ConsoleType" );
+    pSchemaElement->LinkEndChild( pb2AABBTypeElement );
+    TiXmlElement* pb2AABBElementA = new TiXmlElement( "xs:restriction" );
+    pb2AABBElementA->SetAttribute( "base", "xs:string" );
+    pb2AABBTypeElement->LinkEndChild( pb2AABBElementA );
+    TiXmlElement* pb2AABBElementB = new TiXmlElement( "xs:pattern" );
+    pb2AABBElementB->SetAttribute( "value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b" );   
+    pb2AABBElementA->LinkEndChild( pb2AABBElementB );   
+
+    // RectI.
+    TiXmlComment* pRectIComment = new TiXmlComment( "RectI Console Type" );
+    pSchemaElement->LinkEndChild( pRectIComment );
+    TiXmlElement* pRectITypeElement = new TiXmlElement( "xs:simpleType" );
+    pRectITypeElement->SetAttribute( "name", "RectI_ConsoleType" );
+    pSchemaElement->LinkEndChild( pRectITypeElement );
+    TiXmlElement* pRectIElementA = new TiXmlElement( "xs:restriction" );
+    pRectIElementA->SetAttribute( "base", "xs:string" );
+    pRectITypeElement->LinkEndChild( pRectIElementA );
+    TiXmlElement* pRectIElementB = new TiXmlElement( "xs:pattern" );
+    pRectIElementB->SetAttribute( "value", "[-]?[0-9]* [-]?[0-9]* [-]?[0-9]* [-]?[0-9]*" );   
+    pRectIElementA->LinkEndChild( pRectIElementB );
+
+    // RectF.
+    TiXmlComment* pRectFComment = new TiXmlComment( "RectF Console Type" );
+    pSchemaElement->LinkEndChild( pRectFComment );
+    TiXmlElement* pRectFTypeElement = new TiXmlElement( "xs:simpleType" );
+    pRectFTypeElement->SetAttribute( "name", "RectF_ConsoleType" );
+    pSchemaElement->LinkEndChild( pRectFTypeElement );
+    TiXmlElement* pRectFElementA = new TiXmlElement( "xs:restriction" );
+    pRectFElementA->SetAttribute( "base", "xs:string" );
+    pRectFTypeElement->LinkEndChild( pRectFElementA );
+    TiXmlElement* pRectFElementB = new TiXmlElement( "xs:pattern" );
+    pRectFElementB->SetAttribute( "value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b" );   
+    pRectFElementA->LinkEndChild( pRectFElementB );
+
     // AssetId.
     TiXmlComment* pAssetIdComment = new TiXmlComment( "AssetId Console Type" );
     pSchemaElement->LinkEndChild( pAssetIdComment );
@@ -1015,12 +1054,17 @@ bool Taml::generateTamlSchema( const char* pFilename )
             customSchemaFn( pType, pSequenceElement );
         }
 
-        // Iterate static fields.
+        // Fetch field list.
         const AbstractClassRep::FieldList& fields = pType->mFieldList;
-        for( AbstractClassRep::FieldList::const_iterator fieldItr = fields.begin(); fieldItr != fields.end(); ++fieldItr )
+
+        // Fetcj field count.
+        const S32 fieldCount = fields.size();
+
+        // Iterate static fields (in reverse as most types are organized from the root-fields up).
+        for( S32 index = fieldCount-1; index > 0; --index )
         {
             // Fetch field.
-            const AbstractClassRep::Field& field = *fieldItr;
+            const AbstractClassRep::Field& field = fields[index];
 
             // Skip if not a data field.
             if( field.type == AbstractClassRep::DepricatedFieldType ||
@@ -1081,6 +1125,7 @@ bool Taml::generateTamlSchema( const char* pFilename )
                 {
                     pFieldTypeDescription = "Vector2_ConsoleType";
                 }
+
                 else if( fieldType == TypePoint2F )
                 {
                     pFieldTypeDescription = "Point2F_ConsoleType";
@@ -1089,6 +1134,18 @@ bool Taml::generateTamlSchema( const char* pFilename )
                 {
                     pFieldTypeDescription = "Point2I_ConsoleType";
                 }
+                else if( fieldType == Typeb2AABB )
+                {
+                    pFieldTypeDescription = "b2AABB_ConsoleType";
+                }
+                else if( fieldType == TypeRectI )
+                {
+                    pFieldTypeDescription = "RectI_ConsoleType";
+                }
+                else if( fieldType == TypeRectF )
+                {
+                    pFieldTypeDescription = "RectF_ConsoleType";
+                }
                 else if(    fieldType == TypeAssetId ||
                             fieldType == TypeImageAssetPtr ||
                             fieldType == TypeAnimationAssetPtr ||