Notifications
Clear all

[Closed] Deepcopy dynamic array

I have a dynamic array of a mesh’s vertices that I create like so:


     Point3* verts = new Point3[numOfVerts]
     for (int i=0;i<numOfVerts;++i){
     	.... stuff ....
     	 verts[i] = Point3(x,y,z);
     }
     
 I then modify the vertices in the vert array and add it to a temporary dynamic array that I create in the same fashion.

     for (int i=0;i<iterations;++i){
    	Point3* tmp = new Point3[numOfVerts]
    		for (int j=0;j<numOfVerts;++j){
    		.... modify vertices ....
    		tmp[j] = Point3(x,y,z);
    	}
  	// Now I need to deepcopy tmp and overwrite verts
  
  	// Attempt 1:
  	// verts = tmp; Doesn't work
  
  	// Attempt 2:
  	// delete[] verts
  	// verts = new int[numOfVerts];
  	// for (j=0;j<numOfVerts;++j]{
  	//	  verts[j] = tmp[j]
  	// } Doesn't work
  
  	// Attempt 3:
  	// std::copy(tmp, tmp+numOfVerts, verts) Doesn't work
  
    	delete[] tmp;
    }
     
In maxscript, it was like so:
verts = deepcopy tmp
How can I do this in C++?

Thanks.