#include <OSGMaterialMergeGraphOp.h>Go to the source code of this file.
Namespaces | |
| namespace | osg |
Functions | |
| template<typename T> | |
| T | next (T t) |
| bool | isEqual (const osg::FieldContainerPtr &a, const osg::FieldContainerPtr &b) |
| bool | equal (MaterialPtr a, MaterialPtr b) |
|
||||||||||
|
Definition at line 72 of file OSGMaterialMergeGraphOp.cpp.
|
|
||||||||||||
|
Definition at line 78 of file OSGMaterialMergeGraphOp.cpp. References osg::Field::getCardinality(), osg::TypeBase::getCName(), osg::FieldDescription::getCName(), osg::FieldContainerType::getFieldDescription(), osg::FieldContainerType::getNumFieldDescs(), osg::Field::getType(), osg::Field::getValueByStr(), osg::FieldDescription::isInternal(), osg::FieldType::MULTI_FIELD, osg::NullFC, and osg::FieldType::SINGLE_FIELD. Referenced by equal(). 00079 { 00080 using std::string; 00081 00082 // Compare the pointers. 00083 if(a == b) 00084 return true; 00085 00086 if(a == NullFC || b == NullFC) 00087 return false; 00088 00089 if(a->getType() != b->getType()) 00090 return false; 00091 00092 //printf("comparing: %s\n", a->getType().getName().str()); 00093 00094 const FieldContainerType &type = a->getType(); 00095 UInt32 fcount = type.getNumFieldDescs(); 00096 00097 for(UInt32 i=1;i <= fcount;++i) 00098 { 00099 const FieldDescription* fdesc = type.getFieldDescription(i); 00100 00101 if(fdesc->isInternal()) 00102 continue; 00103 00104 // ignore attachments 00105 if(strcmp(fdesc->getCName(), "attachments") == 0) 00106 continue; 00107 00108 Field *a_field = a->getField(i); 00109 Field *b_field = b->getField(i); 00110 00111 const FieldType &a_ftype = a_field->getType(); 00112 const FieldType &b_ftype = b_field->getType(); 00113 00114 //printf("comparing field %s\n", a_ftype.getCName()); 00115 00116 if(a_ftype != b_ftype) 00117 return false; 00118 00119 if(strstr(a_ftype.getCName(), "Ptr") == NULL) 00120 { 00121 // This would be nice but there is no virtual compare method :-( 00122 // if(*a_field != *b_field) 00123 // return false; 00124 00125 // This is very slow with multi fields!!!! 00126 string av, bv; 00127 a_field->getValueByStr(av); 00128 b_field->getValueByStr(bv); 00129 if(av != bv) 00130 return false; 00131 } 00132 else 00133 { 00134 if(a_field->getCardinality() == FieldType::SINGLE_FIELD) 00135 { 00136 if(!isEqual(((SFFieldContainerPtr *) a_field)->getValue(), 00137 ((SFFieldContainerPtr *) b_field)->getValue())) 00138 return false; 00139 } 00140 else if(a_field->getCardinality() == FieldType::MULTI_FIELD) 00141 { 00142 if(((MFFieldContainerPtr*)a_field)->size() != 00143 ((MFFieldContainerPtr*)b_field)->size()) 00144 return false; 00145 00146 for(UInt32 j=0;j < ((MFFieldContainerPtr*)a_field)->size();++j) 00147 { 00148 if(!isEqual((*(((MFFieldContainerPtr *)a_field)))[j], 00149 (*(((MFFieldContainerPtr *)b_field)))[j])) 00150 return false; 00151 } 00152 } 00153 } 00154 } 00155 return true; 00156 }
|
|
||||||||||||
|
Definition at line 159 of file OSGMaterialMergeGraphOp.cpp. References isEqual(). Referenced by osg::MaterialMergeGraphOp::traverse(), and osg::MultiDisplayWindow::updateViewport(). 00159 { 00160 // It's too bad Material::operator== doesn't work. 00161 //return *a == *b; 00162 return isEqual(a, b); 00163 }
|
1.4.3