BGE: Adding support for the Cast Only material option.
authorMitchell Stokes <mogurijin@gmail.com>
Mon, 27 Jan 2014 03:28:26 +0000 (19:28 -0800)
committerMitchell Stokes <mogurijin@gmail.com>
Thu, 20 Mar 2014 06:57:49 +0000 (23:57 -0700)
Note: This does not add support for the option in the viewport.

source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
source/gameengine/Rasterizer/RAS_MaterialBucket.cpp

index 0ec54412485bf067ce6b823af26e4289377d5928..9eba103e7c03b3d9f958059b541640331f57e841 100644 (file)
@@ -611,6 +611,10 @@ static bool ConvertMaterial(
 
                // cast shadows?
                material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0;
+
+               // only shadows?
+               material->ras_mode |= ( mat->mode & MA_ONLYCAST )?ONLY_SHADOW:0;
+
                MTex *mttmp = 0;
                int valid_index = 0;
                
index be66e2ec84d0f4d699ed943bd5c3da50099a479a..83f9b601e0d1583e2cb8ab650d87c0a5bd7e44f7 100644 (file)
@@ -144,7 +144,8 @@ enum BL_ras_mode
        WIRE=64,
        CAST_SHADOW=128,
        TEX=256,
-       TWOSIDED=512
+       TWOSIDED=512,
+       ONLY_SHADOW=1024,
 };
 
 // -------------------------------------
index efaaed7b56752b9601162694da295469fccb82d9..68a71218b8c95e3007e963f2c595420b2e59cd5d 100644 (file)
@@ -110,6 +110,7 @@ void KX_BlenderMaterial::Initialize(
        m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0;
        m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0;
        m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0;
+       m_flag |= ((mMaterial->ras_mode & ONLY_SHADOW)!=0)? RAS_ONLYSHADOW: 0;
 
        // test the sum of the various modes for equality
        // so we can ether accept or reject this material
index 47e52318b3371436923adfe4b37b02de1f89e404..03f6e567771f751c390ea848be2c53c818d182fc 100644 (file)
@@ -282,6 +282,11 @@ bool RAS_IPolyMaterial::CastsShadows() const
        return (m_flag & RAS_CASTSHADOW) != 0;
 }
 
+bool RAS_IPolyMaterial::OnlyShadow() const
+{
+       return (m_flag & RAS_ONLYSHADOW) != 0;
+}
+
 bool RAS_IPolyMaterial::UsesObjectColor() const
 {
        return !(m_flag & RAS_BLENDERGLSL);
index 2db71c3a2fe9409323f222e83044f13dacd0f6ea..14223fc59bdb651561c5b45f85aa49c7c883672a 100644 (file)
@@ -61,7 +61,8 @@ enum MaterialProps
        RAS_NORMAL              =256,
        RAS_DEFMULTI    =512,
        RAS_BLENDERGLSL =1024,
-       RAS_CASTSHADOW  =2048
+       RAS_CASTSHADOW  =2048,
+       RAS_ONLYSHADOW  =4096,
 };
 
 /**
@@ -174,6 +175,7 @@ public:
        virtual bool            UsesLighting(RAS_IRasterizer *rasty) const;
        virtual bool            UsesObjectColor() const;
        virtual bool            CastsShadows() const;
+       virtual bool            OnlyShadow() const;
 
        virtual void            Replace_IScene(SCA_IScene *val) {} /* overridden by KX_BlenderMaterial */
 
index 0c715524218fe90f0e7cb83809e4679eba691442..4b5fc6510e0263b2a65e7967d43589d96c31476d 100644 (file)
@@ -587,6 +587,9 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I
        if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows())
                return false;
 
+       if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW && m_material->OnlyShadow())
+               return false;
+
        if (!rasty->SetMaterial(*m_material))
                return false;