Pārlūkot izejas kodu

Implement 'Clear' function on StateRecorderImpl (#722)

* Implement 'Clear' function on StateRecorderImpl. Allows for clearing the state and re-recording on the same string iostream with same underlying buffer.
Jonathan B 1 gadu atpakaļ
vecāks
revīzija
4fa4946bbc

+ 6 - 0
Jolt/Physics/StateRecorderImpl.cpp

@@ -18,6 +18,12 @@ void StateRecorderImpl::Rewind()
 	mStream.seekg(0, std::stringstream::beg);
 }
 
+void StateRecorderImpl::Clear()
+{
+	mStream.clear();
+	mStream.str({});
+}
+
 void StateRecorderImpl::ReadBytes(void *outData, size_t inNumBytes)
 {
 	if (IsValidating())

+ 3 - 0
Jolt/Physics/StateRecorderImpl.h

@@ -22,6 +22,9 @@ public:
 	/// Rewind the stream for reading
 	void				Rewind();
 
+	/// Clear the stream for reuse
+	void				Clear();
+
 	/// Read a string of bytes from the binary stream
 	virtual void		ReadBytes(void *outData, size_t inNumBytes) override;