April 16, 2018 - lightsaberVR dailies - cutting joint chains

I had another productive run of 3 or 4 days which involved some intense dev sessions. During these sessions I've been mostly experimenting with copying components from one GameObject to another. This sounds like it should be an easy thing to do but I still haven't gotten it working.  The easy solution is instancing the first GameObject and then removing the components I don't want. But I've been trying to avoid instancing and destruction of classes of any kind to reduce garbage collection. What I'm doing specifically is when I'm cutting a rigidbody that is the connectedBody of another rigidbody I'm "moving" joints from one side of the cut to the other if the joint anchor belongs on the other side. Well, I got it working using the instancing method but I'll keep working on the copying/moving of components issue. The real tricky part is copying all of the properties from one to the other.

Somewhat related to my joint chain cutting issues has been the joint that anchors the object to the spawn platform. I had some pretty sloppy code one the platforms maintaining that joint causing other issues. So, I guess I cleaned that up as well.

One thing that had me tearing my hair out was really strange behavior of objects being anchored wrong or hanging in space. What I discovered was that after cutting a mesh I would accidentally leave behind a joint with a "missing" connectedBody. This alone caused major issues but it took me a long time to address the issue because I assumed it was harmless to leave them there. Removing those joints got rid of the strange behavior.

One more thing I added was the "chunks" HUD at the top of the screen. I wanted another HUD element to keep tabs on the usage of preallocated gameobjects. This was really impressive to look at when in previous videos I kept cutting up objects until the whole groundplane was covered in chunks. In this latest video I'm not even trying to test that extreme anymore but it was pretty impressive to maintain the illusion of persistent procedural meshes. I'll revisit this again soon.

Here's my latest update which I posted on Saturday, two days ago. It is probably the most stable build I've tested in over a month so I've taken time off from programming to catch up on other things.



"I've been super busy the past few days and haven't had time to upload videos I guess. Twice this week I've worked for hours only to discover that something I did completely screwed up the feel of the mechanic or created a huge mess. Both times I had to revert to code that was several hours old. But both times I ended up finding a much better solution in the end.
The main things that stood out in the latest update was the difficulty I'm having trying to copy joints of varying types from one gameObject to another. In the end what I'm doing is instancing the object and then deleting the ones I don't need from each side of the cut.The issue I have with doing things that way is that I'll end up allocating more memory at runtime instead of taking advantage of all of the pooled gameObjects I've preloaded. That's what I'm indicating in the HUD at the top of the screen. There are 256 chunks available but only a few are getting used when I'm cutting rigged gameObjects."



Here's an earlier update from Friday (the 13th!) where I was tried to max out the number of gameobjects in the pooled "chunks". Skip ahead to the 5 minute mark to see what that's like. And it's also an early look at the joint chains which was problematic. In retrospect this looks like a mess to me but that afternoon I was mildly satisfied with the results. Watching this right now it looks like the cuts aren't landing very well either. I'm finding this difficult to watch ;)


"In this build I had added the limited (and wonky) ability to maintain joint chains after a cut. I'm also testing how it feels to hit the "chunk" limit, i.e. max out the GameObjects pool for cut chunks. Using up the chunks would result in a "live" chunk being killed off and reused for the current cut. The trick is to maintain the illusion that all of the chunks are persistent by reusing the oldest one which is presumably buried in the bottom of the pile.
There's definitely a lot of odd behavior from the cut joint chains and especially the chunks that are anchored to the base."

Comments

Popular Posts