Sunday 26 October 2008

PsybrusEd Progress...

A few more days go by, a few more lines of code are written. I've mostly spent the week focusing on getting actions working correctly in the editor. As much as I wanted to put these into Python, theres still issues to resolve with the global interpreter lock so the actions may be updated from the engine's thread. This could probably be done by ticking the engine over when input events happen, rather than run it totally on a seperate thread, but that I'll wait for now.

Since the actions went in, so did undo and redo. Actually simpler than I first expected to implement! Just store an action history list, give them virtual undo/redo, and call these when an undo or redo is invoked! I'm going down the route of cloning objects when an action is performed on them, that way we can get back the exact object that we just modified, rather than transforming it back or whatever, potentially having errors creep in later on. Another advantage of doing this is the fact I can get away with writing one lump of code for undo and redo, and it work on any object:

   79 BcBool ActCsgBase::undo()

   80 {

   81     // Remove all added objects, and readd all removed ones again.

   82     ObjPtrList::iterator Iter;

   83 

   84     Iter = AddedObjects_.begin();

   85     while( Iter != AddedObjects_.end() )

   86     {

   87         ObjManagerState::pInstance()->removeObject( (*Iter) );

   88         ++Iter;

   89     }

   90 

   91     Iter = RemovedObjects_.begin();

   92     while( Iter != RemovedObjects_.end() )

   93     {

   94         ObjManagerState::pInstance()->addObject( (*Iter) );

   95         ++Iter;

   96     }

   97     return BcTrue;

   98 }


Save/load had also been 'sort of' implemented. This will be due an overhaul to use XML soon, rather than serialising the binary data of every object. Currently this is fine for me for quickly testing without rebuilding scenes to check out something! Probably going to be going down the LibXML route, rather than write my own library on this one, however one of my major concerns is file sizes will get pretty large, especially if I plan to save out undos and redos to preserve the users workspace.

Next task for me, sadly, is starting to do more of the GUI stuff, and tidying up the CSG operations so the world is stored as one object containing all the convex shapes, and operations as objects so they can be modified on the fly. Should have possibly done this from the beginning, but I wanted to get something quickly up and running to test out the CSG library to the full!

Anyways, a screenshot of it in its current state showing off 3 new lovely orthographic viewports:

No comments: