Sunday, November 22, 2015

Generated code

When two months ago I created generator for RTTI code I didn't realize how this one script will change so much in my programming style.

Right now I have already four of generators in my code base:
  1. RTTI - Generate part of my RTTI code.
  2. SID - Generate CStringID with already calculated hash
  3. Pimpl - Generate interface class.
  4. Enum - Generate toStringID, fromStringID functions.
So what changed for me after writing this one generator that make difference ? I try not to do monkey job. To show you how this improve my workflow let's look on generator I wrote today: Generator of Enumerator functions: toStringID, fromStringID.

This is simple problem where for some enumerators we want to have conversion from value to some verbose type. Some people may claim that this is not issue. You write functions once and they work. Later you just need to modify them when you do some changes in enum. This take like about half minute work 

... if we don't do mistake there. Then this is one extra compilation time. In some code base this can be counted in minutes. I would really love to see how much time of our programmers life we spending of stuff like that :) 

In my case I just have one macro: WR_ENUMGEN(EnumType, InvalidValue). Which look like this:
#   define WR_ENUMGEN(E, D)    \
        const CStringID&        toStringID(E a_value);                   \
        E                       fromStringID(const CStringIDa_value);
And is used like this:
    namespace EConstantsBuffers
        enum Enum
        typedef Enum Type;
The rest is generated :] So on top of this one line I just need to generate projects and that's all. No extra programmer steps to do. Thanks to that:

  • Adding/modifying of enumerators is simple
  • Generate code is easy to debug (what may be tricky with some macros).
  • Not slowing down my compilation. 
  • There is almost no place for any mistake  (always in sync with enum) .
  • There is unified code convention between enums.
  • Expanding of functionality need only modification of macro and/or generator.
So I don't know about you but personally with time I will probably use more and more generated code. I don't have a lot of spare time for monkey job I prefers to leave it for computers.


Thursday, November 12, 2015

Tools Design

Variable Set Editor - Main view
Continuation of previous post :] this time with real examples :D

Real tools design 

This may look like joke but this one window took me ~3 days to do. This include all it's features and communication:

Editor <-> Engine.

But this is reality. Creating good tools require time and I wasn't joking in Summary from previous post:
"As you can see creating of good tools is not easy. You often need go back and forth to create something really useful. You don't want to modify everything by scripts in which you can make easily mistake. Good tool will for sure save you a lot of work and return effort that you spend on it." 

Tuesday, November 10, 2015

Few words about tools design

Once again I will return to topic of tools. Mostly because right now this is the part of code I spend most of my time in. 

I will focus in this post on one dialog: Variables Set Editor This one dialog may sound simple but if you start thinking more about it it's really complex tool. 

So let's start with short description what Variables Sets are then lets move what we want achieve and in the end look on real implementation of this problem.

Variables Set

This is really simple system which allow you to specify some kind of properties. Right now I support only values of types: 

  • StringID
  • Float
  • Vec4.
Whole system may be use to store values like: life, attacks parameters, movement speed etc. In my case to this data have also access animation system which may request some kind of information which later may be use to control blends and generally its behavior.

Because this is simple list of variables you want to be able to have some kind of hierarchy. i.e:
NPC object contain [local set] which inherit values from [Clones set] which inherit values from [enemies set]. Change in inherited variables will be apply to all not override values. 

Dialog requirement

Short: You should be edit this stuff in nice UI.


Firs approach
Thanks to Qt designer this was really easy. As you can see on right everything look really nice you have section for name, you see right away type of variable are able to modify value and see what value you inherit :] If you want to add variable you using context menu (under Right Mouse Button). 

Of course this wouldn't be so easy if I ended here:P I forgot my dependencies list so I done small upgrade and finished :] Final result bellow:

Final dialog


As you can see creating of good tools is not easy. You often need go back and forth to create something really useful. You don't want to modify everything by scripts in which you can make easily mistake. Good tool will for sure save you a lot of work and return effort that you spend on it. And the tool you seen on screenshots are for sure not good one.

Saturday, October 24, 2015

7 Hours of hell

This will be story, my story based on true events.

Hour 0

Recently I start using project generator not only to generate makes, projects and solutions but also to generate some code. Because of that from time to time I need to run one python script. This is not big problem but I decided to make my life easier and add button in Visual Studio 2010 (I'm working slowly on progression to new one) which will trigger this task. Sound simple right ? 

Tuesday, October 20, 2015

My biggest problem: I try to do things right ...

In last weeks I done a lot of work on animation system. In the same time I did not code too much of it. Right now I still struggle with some basic thing: edition of blend tree. And this is not that I'm not able to code it. It just my current prototype fell somehow wrong.

I don't like forcing myself to do stuff. If I do this is the worst possible situation. Code will be messy without any clean goals and in the end it will feel somehow wrong each time there will be need of modifying it.

To not loose time I do other things completely unrelated to animation system. Leaving this problem hanging somewhere in "background". When I have time I try to find in my head a way to improve my design of editor to make my changes nicer. When I will know how I want to do it I will just sit down and code it: quicker, better and with a lot more fun.

Of course some may see all of this as excuse for not doing stuff I should :] And if somebody saying that it just mean that he don't know what programming is about. 

This is not about writing code this is about resolving problems. Code is just medium which allow us to present our solution to other people.


Tuesday, September 29, 2015

Namespaces hell

Welcome in namespace hell. In this place you will find annoying code and the best part: it is on demand. So lets start another topic base on one of my horror stories which ended with hours spend to straight things up.

But let's start from begin. This words probably don't mean a lot for you: s2d, s3d, world2d. world3d, fs, sound, physics, math, navmesh, utility, resources, game, editor, lba, wre, wr.

Personally I know them really well. All of this are namespaces that I used or using in my code. This is collection from 7 years of development and they are probably not all of them. When I start writing engine I wanted to do stuff right. So I created modules which then I encapsulate in namespaces. This was naive and stupid because I ended with annoying code. Who want to write physics::CPhysics for physics class? This is duplicated information. But well with time I got smarter and removed most of them using simple method : Find and replace all.

This was my first sin. After this operation I left with code where you could find stuff like this:

namesace wre
    class A : public wre::class B

The second sin is my mistake of using prefixes for basics types and functions which were outside of namespace. So I had wrVec3, wrQuat, wrMtx44 and functions with similar convention. Why I call it sin ? Because I ended with inconsistent code standard which is not something good and create really a lot of issue. For what you use prefix for what namespace?

So right now I'm decided to clean all of my past mistakes. There will be only one simple convention. Everything will be in one main namespace wr (stands for White Rabbit) and helpers wr::math. I will cleanup naming convention, remove prefixes and put everything related to engine in this namespace.

If somebody think that namespace is useless in he can always use : 

using namespace wr; 

to remove need of using it explicit. I think that this change will only result in simpler and easier to understand code. But well there are no sure things.

What do you think about namespaces ? You would recommend them or rather burn them using fire ?


Sunday, September 27, 2015

Commit comments

Now that I thought about this is interesting topic:

How your comments for commits look like?

In my case you probably think that they are poor because I do project myself. But here I will surprise you (and myself to) because most of the time I do full summary what I done in given change list. So bellow you will find few of my comments from different commits across last 3 years (I use not modified git logs) :

* 13/11/2012

* 25/02/2013

* 30/12/2013

* 05/09/2014

* 21/09/2015

I really like my current form because its simple and easy to understand. Especially with my tendency to submit multi issue change lists. I need to do something about this because this may save me a lot of troubles later. But sometimes you just starting one thing which require something else and before you notice you have overlapping changes. 

What is yours format of check-in comments. ?


Sunday, September 20, 2015

Animation System Changes: Part 1

After weeks of work (probably I could even say months) and hundred resolved tasks and bugs new animation system finally start working ;] Check final effect:

If you think that it is look no different from my old animations then you are almost right :D Currently this new system have even less functionality than old one. Because of that I needed to disable big part of gameplay.

Was it worth it ? 

Short version: I think that: YES. 

Saturday, September 19, 2015

Playing games and Dreams

Normally I don't play too much games but there are days when I just want to relax and play. Sometimes even a little too much for one day but well this have it's charm (till the next day when you need to wake up).

This week I finished playing PS3 Uncharted games and Zone of the Enders. I feel inspired by their style. I really liked Uncharted 2 graphics would it be cool if Little Big Adventure remake had this level of graphics :D Well I need to return to development I still need do few things to make dreams became true.

Tuesday, September 15, 2015

RTTI: Changes for better

As some of you may know White Rabbit Engine use it's own Run Time Type Information system. And well like with everything else sometimes come time when you need to upgrade stuff. Recently I had another occasion to do iteration over this system.

In this post I will try to give you a little bit insight how m RTTI look is engine, what changed and what are plans for future. But well let's start from begin.