diff --git a/examples/CommonInterfaces/CommonFileIOInterface.h b/examples/CommonInterfaces/CommonFileIOInterface.h index e41faf78a..beb25edd6 100644 --- a/examples/CommonInterfaces/CommonFileIOInterface.h +++ b/examples/CommonInterfaces/CommonFileIOInterface.h @@ -22,7 +22,7 @@ struct CommonFileIOInterface virtual bool findResourcePath(const char* fileName, char* resourcePathOut, int resourcePathMaxNumBytes)=0; virtual char* readLine(int fileHandle, char* destBuffer, int numBytes)=0; virtual int getFileSize(int fileHandle)=0; - + virtual void enableFileCaching(bool enable) = 0; }; #endif //COMMON_FILE_IO_INTERFACE_H \ No newline at end of file diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index bba891478..6c8e8c496 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -8004,6 +8004,7 @@ bool PhysicsServerCommandProcessor::processSendPhysicsParametersCommand(const st if (clientCmd.m_updateFlags & SIM_PARAM_ENABLE_FILE_CACHING) { b3EnableFileCaching(clientCmd.m_physSimParamArgs.m_enableFileCaching); + m_data->m_pluginManager.getFileIOInterface()->enableFileCaching(clientCmd.m_physSimParamArgs.m_enableFileCaching!=0); } SharedMemoryStatus& serverCmd = serverStatusOut; diff --git a/examples/SharedMemory/plugins/fileIOPlugin/fileIOPlugin.cpp b/examples/SharedMemory/plugins/fileIOPlugin/fileIOPlugin.cpp index 9e53b9f77..3d3183ef3 100644 --- a/examples/SharedMemory/plugins/fileIOPlugin/fileIOPlugin.cpp +++ b/examples/SharedMemory/plugins/fileIOPlugin/fileIOPlugin.cpp @@ -283,6 +283,11 @@ struct InMemoryFileIO : public CommonFileIOInterface } return 0; } + + virtual void enableFileCaching(bool enable) + { + (void)enable; + } }; struct WrapperFileIO : public CommonFileIOInterface @@ -292,10 +297,12 @@ struct WrapperFileIO : public CommonFileIOInterface WrapperFileHandle m_wrapperFileHandles[B3_MAX_FILEIO_INTERFACES]; InMemoryFileIO m_cachedFiles; + bool m_enableFileCaching; WrapperFileIO() :CommonFileIOInterface(0,0), - m_numWrapperInterfaces(0) + m_numWrapperInterfaces(0), + m_enableFileCaching(true) { for (int i=0;ifileClose(childHandle); break; } @@ -525,6 +535,15 @@ struct WrapperFileIO : public CommonFileIOInterface return numBytes; } + virtual void enableFileCaching(bool enable) + { + m_enableFileCaching = enable; + if (!enable) + { + m_cachedFiles.clearCache(); + } + } + }; diff --git a/examples/SharedMemory/plugins/fileIOPlugin/zipFileIO.h b/examples/SharedMemory/plugins/fileIOPlugin/zipFileIO.h index a0e8fe00f..8c195c8f9 100644 --- a/examples/SharedMemory/plugins/fileIOPlugin/zipFileIO.h +++ b/examples/SharedMemory/plugins/fileIOPlugin/zipFileIO.h @@ -252,5 +252,10 @@ struct ZipFileIO : public CommonFileIOInterface } return size; } - + + virtual void enableFileCaching(bool enable) + { + (void)enable; + } + }; diff --git a/examples/Utils/b3BulletDefaultFileIO.h b/examples/Utils/b3BulletDefaultFileIO.h index b4cf20c4b..fa972de01 100644 --- a/examples/Utils/b3BulletDefaultFileIO.h +++ b/examples/Utils/b3BulletDefaultFileIO.h @@ -186,6 +186,11 @@ struct b3BulletDefaultFileIO : public CommonFileIOInterface } return size; } + + virtual void enableFileCaching(bool enable) + { + (void) enable; + } }; #endif //B3_BULLET_DEFAULT_FILE_IO_H diff --git a/examples/pybullet/examples/fileIOPlugin.py b/examples/pybullet/examples/fileIOPlugin.py new file mode 100644 index 000000000..99a5bac62 --- /dev/null +++ b/examples/pybullet/examples/fileIOPlugin.py @@ -0,0 +1,20 @@ +import pybullet as p +import time + +p.connect(p.GUI) +fileIO = p.loadPlugin("fileIOPlugin") +if (fileIO>=0): + p.executePluginCommand(fileIO, "pickup.zip", [p.AddFileIOAction, p.ZipFileIO]) + objs= p.loadSDF("pickup/model.sdf") + dobot =objs[0] + p.changeVisualShape(dobot,-1,rgbaColor=[1,1,1,1]) + +else: + print("fileIOPlugin is disabled.") + + +p.setPhysicsEngineParameter(enableFileCaching=False) + +while (1): + p.stepSimulation() + time.sleep(1./240.) \ No newline at end of file diff --git a/examples/pybullet/examples/pickup.zip b/examples/pybullet/examples/pickup.zip new file mode 100644 index 000000000..a3b24573f Binary files /dev/null and b/examples/pybullet/examples/pickup.zip differ