Browse Source

B3DImporter: Add unique_to_array helper function

Turo Lamminen 7 năm trước cách đây
mục cha
commit
30ae14fae9
1 tập tin đã thay đổi với 15 bổ sung0 xóa
  1. 15 0
      code/B3DImporter.cpp

+ 15 - 0
code/B3DImporter.cpp

@@ -267,6 +267,21 @@ T *B3DImporter::to_array( const vector<T> &v ){
     return p;
     return p;
 }
 }
 
 
+
+// ------------------------------------------------------------------------------------------------
+template<class T>
+T **unique_to_array( vector<std::unique_ptr<T> > &v ){
+    if( v.empty() ) {
+        return 0;
+    }
+    T **p = new T*[ v.size() ];
+    for( size_t i = 0; i < v.size(); ++i ){
+        p[i] = v[i].release();
+    }
+    return p;
+}
+
+
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 void B3DImporter::ReadTEXS(){
 void B3DImporter::ReadTEXS(){
     while( ChunkSize() ){
     while( ChunkSize() ){