@@ -210,37 +210,38 @@ void ofxVisualProgramming::update(){
210210
211211 }
212212
213- // left to right computing order
214- leftToRightIndexOrder.clear ();
215- for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
216- leftToRightIndexOrder.push_back (make_pair (static_cast <int >(floor (it->second ->getPos ().x )),it->second ->getId ()));
217- }
218- // sort the vector by it's pair first value (object X position)
219- sort (leftToRightIndexOrder.begin (),leftToRightIndexOrder.end ());
213+ if (!bLoadingNewPatch && !patchObjects.empty ()){
214+ // left to right computing order
215+ leftToRightIndexOrder.clear ();
216+ for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
217+ leftToRightIndexOrder.push_back (make_pair (static_cast <int >(floor (it->second ->getPos ().x )),it->second ->getId ()));
218+ }
219+ // sort the vector by it's pair first value (object X position)
220+ sort (leftToRightIndexOrder.begin (),leftToRightIndexOrder.end ());
220221
222+ ImGuiEx::ProfilerTask *pt = new ImGuiEx::ProfilerTask[leftToRightIndexOrder.size ()];
221223
222- ImGuiEx::ProfilerTask *pt = new ImGuiEx::ProfilerTask[leftToRightIndexOrder.size ()];
224+ for (unsigned int i=0 ;i<leftToRightIndexOrder.size ();i++){
225+ pt[i].color = profiler.cpuGraph .colors [static_cast <unsigned int >(i%16 )];
226+ pt[i].startTime = ofGetElapsedTimef ();
227+ pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _update" ;
228+ patchObjects[leftToRightIndexOrder[i].second ]->update (patchObjects,*engine);
229+ pt[i].endTime = ofGetElapsedTimef ();
223230
224- for (unsigned int i=0 ;i<leftToRightIndexOrder.size ();i++){
225- pt[i].color = profiler.cpuGraph .colors [static_cast <unsigned int >(i%16 )];
226- pt[i].startTime = ofGetElapsedTimef ();
227- pt[i].name = patchObjects[leftToRightIndexOrder[i].second ]->getName ()+ofToString (patchObjects[leftToRightIndexOrder[i].second ]->getId ())+" _update" ;
228- patchObjects[leftToRightIndexOrder[i].second ]->update (patchObjects,*engine);
229- pt[i].endTime = ofGetElapsedTimef ();
230-
231- // update scripts objects files map
232- ofFile tempsofp (patchObjects[leftToRightIndexOrder[i].second ]->getFilepath ());
233- string fileExt = ofToUpper (tempsofp.getExtension ());
234- if (fileExt == " LUA" || fileExt == " PY" || fileExt == " SH" || fileExt == " FRAG" ){
235- map<string,string>::iterator sofpIT = scriptsObjectsFilesPaths.find (tempsofp.getFileName ());
236- if (sofpIT == scriptsObjectsFilesPaths.end ()){
237- // not found, insert it
238- scriptsObjectsFilesPaths.insert ( pair<string,string>(tempsofp.getFileName (),tempsofp.getAbsolutePath ()) );
231+ // update scripts objects files map
232+ ofFile tempsofp (patchObjects[leftToRightIndexOrder[i].second ]->getFilepath ());
233+ string fileExt = ofToUpper (tempsofp.getExtension ());
234+ if (fileExt == " LUA" || fileExt == " PY" || fileExt == " SH" || fileExt == " FRAG" ){
235+ map<string,string>::iterator sofpIT = scriptsObjectsFilesPaths.find (tempsofp.getFileName ());
236+ if (sofpIT == scriptsObjectsFilesPaths.end ()){
237+ // not found, insert it
238+ scriptsObjectsFilesPaths.insert ( pair<string,string>(tempsofp.getFileName (),tempsofp.getAbsolutePath ()) );
239+ }
239240 }
240241 }
241- }
242242
243- profiler.cpuGraph .LoadFrameData (pt,leftToRightIndexOrder.size ());
243+ profiler.cpuGraph .LoadFrameData (pt,leftToRightIndexOrder.size ());
244+ }
244245
245246}
246247
@@ -1063,6 +1064,12 @@ void ofxVisualProgramming::newTempPatchFromFile(string patchFile){
10631064 ofFile fileToRead (patchFile);
10641065 ofFile newPatchFile (ofToDataPath (" temp/" +newFileName,true ));
10651066 ofFile::copyFromTo (fileToRead.getAbsolutePath (),newPatchFile.getAbsolutePath (),true ,true );
1067+
1068+ ofDirectory dataFolderOrigin;
1069+ dataFolderOrigin.listDir (fileToRead.getEnclosingDirectory ()+" /data/" );
1070+ std::filesystem::path tp = ofToDataPath (" temp/data/" ,true );
1071+ dataFolderOrigin.copyTo (tp,true ,true );
1072+
10661073 newFileCounter++;
10671074
10681075 currentPatchFile = newPatchFile.getAbsolutePath ();
0 commit comments