Sunday, March 18, 2012

More Cleanup

Hey Readers,

Sorry for the lack of updates, my wife and I just had a baby so I've been off work and therefore not doing any programming on the bus. Lots to update on though!

I added in context objects for all the major systems. This made all of the parameters I was passing into various objects a lot cleaner. Now an object just takes in the necessary contexts and has all the information it needs for construction.

I also cleaned up the movement code in the physics. After all the refactoring I was finding that the collision didn't quite work right. The character would get stuck all the time inside of walls. The trick was to separate out the collision into vertical and horizontal steps and also separate the collision response. Now everything's working great.

After that I decided it was time to start cleaning up all the bus in the editor and refine some of the features that I had stubbed in. The first thing I added was that if an object is selected and the user presses Ctrl-E it switches into the voxel editor mode with that objects voxel sprite.

Then I made some tweaks to the color palette. I set it up so that when the user enters voxel edit mode it loads all of the colors for that voxel sprite into the palette. I also fixed up the rgb sliders, now when the user selects a color the sliders auto adjust to the current color. Previously while they would adjust the color, the positions of the sliders didn't update to the current color.

I also changed the behaviour of saving for voxel sprites. Before when the user would press Ctrl-S it would save the currently edited voxel sprite as Sprite.spark in the base directory. Now it uses the metadata associated with the asset to get the proper filename so that it saves back to the right file. I should have done this ages ago, makes it a lot easier to iterate on art.

Another update was to the mouse raycast code. Before when selecting an object I would just iterate over the entire list of objects and as soon as I came across the first object that intersected with the mouse raycast I would break and make that object the currently selected. The problem with this is that the first object is not necessarily the closest object! So I changed it so that I build up a vector of selected object and then make the closest object to the camera the currently selected object.

The last thing I started putting in is functionality for copy and paste from the windows clipboard. I hooked up the platform specific code and now I'm starting to hook into the frontend code. I've stubbed in a UICopyPastable sprocket which any object that wants copy paste behaviour can use it.

No comments:

Post a Comment