瀏覽代碼

Selection Highlighting

Marc Chapman 8 年之前
父節點
當前提交
d4c2eeea98

+ 19 - 0
Engine/source/T3D/shapeBase.cpp

@@ -5013,3 +5013,22 @@ DefineEngineMethod( ShapeBase, getModelFile, const char *, (),,
    const char *fieldName = StringTable->insert( String("shapeFile") );
    return datablock->getDataField( fieldName, NULL );
 }
+
+void ShapeBase::setSelectionFlags(U8 flags)
+{
+   Parent::setSelectionFlags(flags);
+
+   if (!mShapeInstance || !isClientObject())  
+      return;  
+  
+   if (!mShapeInstance->ownMaterialList())  
+      return;  
+  
+   TSMaterialList* pMatList = mShapeInstance->getMaterialList();  
+   for (S32 j = 0; j < pMatList->size(); j++)   
+   {  
+      BaseMatInstance * bmi = pMatList->getMaterialInst(j);  
+      bmi->setSelectionHighlighting(needsSelectionHighlighting());  
+   }  
+}
+

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

@@ -1852,6 +1852,8 @@ public:
 protected:
    DECLARE_CALLBACK( F32, validateCameraFov, (F32 fov) );
 
+
+   virtual void setSelectionFlags(U8 flags);
 };
 
 

+ 21 - 0
Engine/source/T3D/tsStatic.cpp

@@ -375,6 +375,8 @@ bool TSStatic::_createShape()
 
    mShapeInstance = new TSShapeInstance( mShape, isClientObject() );
 
+   if (isClientObject())
+      mShapeInstance->cloneMaterialList();
    if( isGhost() )
    {
       // Reapply the current skin
@@ -1405,3 +1407,22 @@ void TSStatic::onStaticModified(const char* slotName, const char*newValue)
 
    set_special_typing();
 }
+
+void TSStatic::setSelectionFlags(U8 flags)
+{
+   Parent::setSelectionFlags(flags);
+
+   if (!mShapeInstance || !isClientObject())  
+      return;  
+  
+   if (!mShapeInstance->ownMaterialList())  
+      return;  
+  
+   TSMaterialList* pMatList = mShapeInstance->getMaterialList();  
+   for (S32 j = 0; j < pMatList->size(); j++)   
+   {  
+      BaseMatInstance * bmi = pMatList->getMaterialInst(j);  
+      bmi->setSelectionHighlighting(needsSelectionHighlighting());  
+   }  
+}
+

+ 1 - 0
Engine/source/T3D/tsStatic.h

@@ -254,6 +254,7 @@ public:
    Point2F        mGradientRange;
 private:
    void           set_special_typing();
+   virtual void setSelectionFlags(U8 flags);
 };
 
 typedef TSStatic::MeshType TSMeshType;

+ 5 - 0
Engine/source/materials/baseMatInstance.h

@@ -252,6 +252,11 @@ public:
 
    virtual const GFXStateBlockDesc &getUserStateBlock() const = 0;
 
+protected:
+   bool needsHighlighting;
+public:
+   bool needsSelectionHighlighting() { return needsHighlighting; };
+   void setSelectionHighlighting(bool flag) { needsHighlighting = flag; };
 };
 
 #endif /// _BASEMATINSTANCE_H_

+ 1 - 0
Engine/source/materials/matInstance.cpp

@@ -253,6 +253,7 @@ void MatInstance::construct()
    mIsForwardLit = false;
    mIsValid = false;
    mIsHardwareSkinned = false;
+   needsHighlighting = false;
 
    MATMGR->_track(this);
 }

+ 3 - 0
Engine/source/materials/sceneData.h

@@ -52,6 +52,9 @@ struct SceneData
       /// The deferred render bin.
       /// @RenderDeferredMgr
       DeferredBin,
+      /// The selection-highlight render bin.  
+      /// @afxRenderHighlightMgr  
+      HighlightBin,
    };
 
    /// This defines when we're rendering a special bin