Ticket #1771: no_preview_shadows_05222013.patch

File no_preview_shadows_05222013.patch, 3.0 KB (added by historic_bruno, 11 years ago)

new modified version of ericb's patch

  • source/graphics/Model.cpp

     
    602602            m_Props[i].m_Model->ToCModel()->AddFlagsRec(flags);
    603603}
    604604
     605void CModel::RemoveShadowsRec()
     606{
     607    m_Flags &= ~MODELFLAG_CASTSHADOWS;
     608
     609    m_Material.AddShaderDefine("DISABLE_RECEIVE_SHADOWS", "1");
     610
     611    for (size_t i = 0; i < m_Props.size(); ++i)
     612        if (m_Props[i].m_Model->ToCModel())
     613            m_Props[i].m_Model->ToCModel()->RemoveShadowsRec();
     614}
     615
    605616void CModel::SetMaterial(const CMaterial &material)
    606617{
    607618    m_Material = material;
  • source/graphics/Model.h

     
    118118    int GetFlags() const { return m_Flags; }
    119119    // add object flags, recursively through props
    120120    void AddFlagsRec(int flags);
     121    // remove shadow casting and receiving, recursively through props
     122    void RemoveShadowsRec();
    121123
    122124    // recurse down tree setting dirty bits
    123125    virtual void SetDirtyRec(int dirtyflags) {
  • source/simulation2/components/CCmpTemplateManager.cpp

     
    525525    if (out.GetChild("Entity").GetChild("Obstruction").IsOk())
    526526        CParamNode::LoadXMLString(out, "<Entity><Obstruction><Active>false</Active></Obstruction></Entity>");
    527527
     528    if (out.GetChild("Entity").GetChild("VisualActor").IsOk())
     529        CParamNode::LoadXMLString(out, "<Entity><VisualActor><DisableShadows/></VisualActor></Entity>");
     530
    528531    if (!corpse)
    529532    {
    530533        // Previews should always be visible in fog-of-war/etc
  • source/simulation2/components/CCmpVisualActor.cpp

     
    117117                    "<empty/>"
    118118                "</element>"
    119119            "</optional>"
     120            "<optional>"
     121                "<element name='DisableShadows' a:help='Used internally; if present, shadows will be disabled'>"
     122                    "<empty/>"
     123                "</element>"
     124            "</optional>"
    120125            "<element name='SilhouetteDisplay'>"
    121126                "<data type='boolean'/>"
    122127            "</element>"
     
    535540
    536541                if (paramNode.GetChild("SilhouetteDisplay").ToBool())
    537542                    modelFlags |= MODELFLAG_SILHOUETTE_DISPLAY;
    538 
    539543                if (paramNode.GetChild("SilhouetteOccluder").ToBool())
    540544                    modelFlags |= MODELFLAG_SILHOUETTE_OCCLUDER;
    541545
     
    544548                    modelFlags |= MODELFLAG_IGNORE_LOS;
    545549
    546550                model.ToCModel()->AddFlagsRec(modelFlags);
     551
     552                if (paramNode.GetChild("DisableShadows").IsOk())
     553                    model.ToCModel()->RemoveShadowsRec();
    547554            }
    548555
    549556            // Initialize the model's selection shape descriptor. This currently relies on the component initialization order; the