We have a WINNAR here. I did what I was talking about in my last post and made a way to keep track of values that changed often and to just automatically save them every once in a while. Basically, I made an Axiom Item for storing Vectors and Quaternions, then I created a new type of attribute for the MV3D datastore, which specifies that the value of that attribute is to be stored via an Axiom Item class. Since the only place that position/rotation is stored for objects is in the ODE body, I also made that attribute type able to use a getter/setter function to get/set the value to store.
Then from there, I added another option to them to specify that you want the attribute persisted automatically at regular intervals. If that’s on, it gets added to a list that the datastore keeps and every 15 seconds (currently), it stores the value again. It also automatically stores the value when the object it’s in is stored or when the store is closed. This seems to work great. It gave me a scare when I first got it working though–
Synced 480 autoStore objects in 19.34 seconds
Yeah, that was bad. But then I realized that I didn’t have it running in a transaction. I also added the smarts to it so that it doesn’t store a value if it hasn’t changed. That leads me to:
2008-05-31 00:09:43-0400 [-] Synced 6480 autoStore objects in 0.09 seconds
That was with not much changing.. Here’s two with about 800 objects all moving:
2008-05-31 00:00:04-0400 [-] Synced 9720 autoStore objects in 0.23 seconds
2008-05-31 00:00:17-0400 [-] Synced 9720 autoStore objects in 0.28 seconds
Those are all perfectly fine and don’t interrupt the server enough for it to be noticed (especially the 0.09 second value– the server only updates every 0.05 seconds).
There are a couple of bugs that I noticed, though. When the octree based area saves itself (which happens when something passes between nodes), it takes a while. Most likely, it’s saving way more data than it needs to, though. Also, (and this seems like it was a bug before I started messing with the datastores) after loading up a world, the physics is a little off from what the client expects. My theory is that there is some value for biped movement speed that isn’t being persisted or something isn’t being put in the right bucket when loaded.
All in all, though, I’m feeling pretty good about this.