~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osg/StateSet.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
        rhs_uitr != rhs._uniformList.end();
142
142
        ++rhs_uitr)
143
143
    {
144
 
    const std::string& name = rhs_uitr->first;
145
 
    const RefUniformPair& rup = rhs_uitr->second;
146
 
    Uniform* uni = copyop(rup.first.get());
147
 
    if (uni)
 
144
        const std::string& name = rhs_uitr->first;
 
145
        const RefUniformPair& rup = rhs_uitr->second;
 
146
        Uniform* uni = copyop(rup.first.get());
 
147
        if (uni)
148
148
        {
149
149
            _uniformList[name] = RefUniformPair(uni, rup.second);
150
150
            uni->addParent(this);
607
607
        ModeList::iterator lhs_mitr = _modeList.find(rhs_mitr->first);
608
608
        if (lhs_mitr!=_modeList.end())
609
609
        {
610
 
            if (!(lhs_mitr->second & StateAttribute::OVERRIDE)) 
 
610
            // take the rhs mode unless the lhs is override and the rhs is not protected 
 
611
            if (!(lhs_mitr->second & StateAttribute::OVERRIDE ) ||
 
612
                 (rhs_mitr->second & StateAttribute::PROTECTED)) 
611
613
            {
612
 
                // override isn't on in rhs, so overrite it with incomming
 
614
                // override isn't on in rhs, so override it with incoming
613
615
                // value.
614
616
                lhs_mitr->second = rhs_mitr->second;
615
617
            }
630
632
        AttributeList::iterator lhs_aitr = _attributeList.find(rhs_aitr->first);
631
633
        if (lhs_aitr!=_attributeList.end())
632
634
        {
633
 
            if (!(lhs_aitr->second.second & StateAttribute::OVERRIDE)) 
 
635
            // take the rhs attribute unless the lhs is override and the rhs is not protected 
 
636
            if (!(lhs_aitr->second.second & StateAttribute::OVERRIDE) ||
 
637
                 (rhs_aitr->second.second & StateAttribute::PROTECTED))
634
638
            {
635
 
                // override isn't on in rhs, so overrite it with incomming
 
639
                // override isn't on in rhs, so override it with incoming
636
640
                // value.
637
641
                if (lhs_aitr->second.first!=rhs_aitr->second.first)
638
642
                {
639
643
                    // new attribute so need to remove self from outgoing attribute
640
644
                    lhs_aitr->second.first->removeParent(this);
641
645
 
642
 
                    // override isn't on in rhs, so overrite it with incomming
 
646
                    // override isn't on in rhs, so override it with incoming
643
647
                    // value.
644
648
                    lhs_aitr->second = rhs_aitr->second;
645
649
                    lhs_aitr->second.first->addParent(this);
675
679
            ModeList::iterator lhs_mitr = lhs_modeList.find(rhs_mitr->first);
676
680
            if (lhs_mitr!=lhs_modeList.end())
677
681
            {
678
 
                if (!(lhs_mitr->second & StateAttribute::OVERRIDE)) 
 
682
                // take the rhs mode unless the lhs is override and the rhs is not protected 
 
683
                if (!(lhs_mitr->second & StateAttribute::OVERRIDE) ||
 
684
                     (rhs_mitr->second & StateAttribute::PROTECTED)) 
679
685
                {
680
 
                    // override isn't on in rhs, so overrite it with incomming
 
686
                    // override isn't on in rhs, so override it with incoming
681
687
                    // value.
682
688
                    lhs_mitr->second = rhs_mitr->second;
683
689
                }
705
711
            AttributeList::iterator lhs_aitr = lhs_attributeList.find(rhs_aitr->first);
706
712
            if (lhs_aitr!=lhs_attributeList.end())
707
713
            {
708
 
                if (!(lhs_aitr->second.second & StateAttribute::OVERRIDE)) 
 
714
                // take the rhs attribute unless the lhs is override and the rhs is not protected 
 
715
                if (!(lhs_aitr->second.second & StateAttribute::OVERRIDE) ||
 
716
                     (rhs_aitr->second.second & StateAttribute::PROTECTED)) 
709
717
                {
710
 
                    // override isn't on in rhs, so overrite it with incomming
 
718
                    // override isn't on in rhs, so override it with incoming
711
719
                    // value.
712
720
                    
713
721
                    if (lhs_aitr->second.first!=rhs_aitr->second.first)
739
747
        UniformList::iterator lhs_uitr = _uniformList.find(rhs_uitr->first);
740
748
        if (lhs_uitr!=_uniformList.end())
741
749
        {
742
 
            if (!(lhs_uitr->second.second & StateAttribute::OVERRIDE)) 
 
750
            // take the rhs uniform unless the lhs is override and the rhs is not protected 
 
751
            if (!(lhs_uitr->second.second & StateAttribute::OVERRIDE) ||
 
752
                 (rhs_uitr->second.second & StateAttribute::PROTECTED)) 
743
753
            {
744
 
                // override isn't on in rhs, so overrite it with incomming
 
754
                // override isn't on in rhs, so override it with incoming
745
755
                // value.
746
756
 
747
757
                if (lhs_uitr->second.first!=rhs_uitr->second.first)
1461
1471
        unsigned int                _unit;
1462
1472
};
1463
1473
 
 
1474
class RemoveAssociateModesHelper : public StateAttribute::ModeUsage
 
1475
{
 
1476
    public:
 
1477
        RemoveAssociateModesHelper(StateSet* stateset, unsigned int unit=0):
 
1478
            _stateset(stateset),
 
1479
            _unit(unit) {}
 
1480
            
 
1481
        virtual ~RemoveAssociateModesHelper() {}
 
1482
        
 
1483
        virtual void usesMode(StateAttribute::GLMode mode)
 
1484
        {
 
1485
            _stateset->removeMode(mode);
 
1486
        }
 
1487
        
 
1488
        virtual void usesTextureMode(StateAttribute::GLMode mode)
 
1489
        {
 
1490
           _stateset->removeTextureMode(_unit, mode);
 
1491
        }
 
1492
        
 
1493
       
 
1494
        
 
1495
        StateSet*                   _stateset;
 
1496
        unsigned int                _unit;
 
1497
};
 
1498
 
1464
1499
void StateSet::setAssociatedModes(const StateAttribute* attribute, StateAttribute::GLModeValue value)
1465
1500
{
1466
1501
    SetAssociateModesHelper helper(this,value);
1467
1502
    attribute->getModeUsage(helper);
1468
1503
}
1469
1504
 
 
1505
void StateSet::removeAssociatedModes(const StateAttribute* attribute)
 
1506
{
 
1507
    RemoveAssociateModesHelper helper(this);
 
1508
    attribute->getModeUsage(helper);
 
1509
}
 
1510
 
1470
1511
void StateSet::setAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute, StateAttribute::GLModeValue value)
1471
1512
{
1472
1513
    SetAssociateModesHelper helper(this,value,unit);
1473
1514
    attribute->getModeUsage(helper);
1474
1515
}
1475
1516
 
 
1517
void StateSet::removeAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute)
 
1518
{
 
1519
    RemoveAssociateModesHelper helper(this,unit);
 
1520
    attribute->getModeUsage(helper);
 
1521
}
 
1522
 
1476
1523
void StateSet::setAttribute(AttributeList& attributeList,StateAttribute *attribute, const StateAttribute::OverrideValue value)
1477
1524
{
1478
1525
    if (attribute)
1743
1790
        {
1744
1791
            // the number of callbacks has changed, need to pass this
1745
1792
            // on to parents so they know whether app traversal is
1746
 
            // reqired on this subgraph.
 
1793
            // required on this subgraph.
1747
1794
            for(ParentList::iterator itr =_parents.begin();
1748
1795
                itr != _parents.end();
1749
1796
                ++itr)
1788
1835
        {
1789
1836
            // the number of callbacks has changed, need to pass this
1790
1837
            // on to parents so they know whether app traversal is
1791
 
            // reqired on this subgraph.
 
1838
            // required on this subgraph.
1792
1839
            for(ParentList::iterator itr =_parents.begin();
1793
1840
                itr != _parents.end();
1794
1841
                ++itr)