Bad Creature Class ...

Bad Creature Class ...

Postby paul424 » 03 Apr 2014, 10:12

For people who designed the Creature class : it seems very bad that you have decoupled animationState from creatureAction, may I know reason for this ?
Now modifing a little that class without breaking invariants is very hard -- the Animations are lost in some cases.
Should I start fixing this , so the animationState is hardwired to creatureAction ( and vice versa) ... ?
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Bad Creature Class ...

Postby Bertram » 03 Apr 2014, 10:58

Hi Paul,

it seems very bad that you have decoupled animationState from creatureAction, may I know reason for this ?

I didn't write the first code but for being the guy that spent a lot of time on it earlier when removing some code complexity there (and the use of gotos...),
I would say that decoupling the animation from the action logic is a good thing at least for it permits to have the same animation for several actions, for instance, or easily change/add/remove the action used for a given animation and vice-versa.

Also, in game programming more than anything else, you should alway try to decouple the update logic (here the action decision logic) from the rendering code (the animation logic). So, without any strong reason to do what you want to do, I'd say: Don't do it.

Now, can I know what are reasons you want to change things there?

Best regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Bad Creature Class ...

Postby paul424 » 03 Apr 2014, 11:49

I wanted to add a new creatureAction : rotate . So they rotate , right or left , before changing direction ...
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Bad Creature Class ...

Postby Bertram » 03 Apr 2014, 15:27

Ah, I see.

You have the "idle" and "walkToTile" actions, AFAIK.
To me, the rotation logic should be part of the creature movement logic, so that when you ask a creature to got somewhere it either rotate or walk according to its current position and direction of the next node it wants to reach.
I've seen those functions that may need an upgrade according to what you want to do, for instance (and it seems they aren't linked to the creature action code after all):

void MovableGameEntity::faceToward(int x, int y)
https://github.com/Bertram25/OpenDungeo ... y.cpp#L133

(The loop that updates the creatures positions and directions)
https://github.com/Bertram25/OpenDungeo ... r.cpp#L408

I hope it will help you.

Best regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Bad Creature Class ...

Postby paul424 » 03 Apr 2014, 17:44

From the far look it might be look so , but it's not the >>rotation step << is deeply sunken into machinery of OD .

{l Code}: {l Select All Code}
bool Creature::handleSleepAction()
{
    Tile* myTile = positionTile();
    if (mHomeTile == NULL)
    {
        popAction();
        return false;
    }

    if (myTile != mHomeTile)
    {
        // Walk to the the home tile.
        std::list<Tile*> tempPath = getGameMap()->path(myTile, mHomeTile, mDefinition->getTilePassability());
        getGameMap()->cutCorners(tempPath, mDefinition->getTilePassability());
        if (setWalkPath(tempPath, 2, false))
        {
            setAnimationState("Walk");
            popAction();
            pushAction(CreatureAction::walkToTile);
            return false;
        }
    }
    else
    {
        // We are at the home tile so sleep.
        setAnimationState("Sleep");
        mAwakeness += 4.0;
        if (mAwakeness > 100.0)
        {
            mAwakeness = 100.0;
            popAction();
        }
    }
    return false;
}


Only now I noticed that setAnimationState should be placed in handleXYZAction.
The rules are more ezoteric ... it doesn't say under what circumstances we should trigger animation change ... that's why I don't like this part of code ....
Seems they need to have like spinSpeed, according to which there is spin rotation done in every frame.
Naah looks like best would be to return to clean state onto development. At least I know how to start that ....
Bertram , if you would like to chat and code via Skype or other voice chat I would appreciate it ....
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Bad Creature Class ...

Postby Bertram » 03 Apr 2014, 22:31

Hi Paul,

I wish I had some time so we could happily chat a bit. I just have very few spare-time at the moment and this week-end is unfortunately full for me already.
Hopefully next week?

But it seems you got a point. There seems to be animation steps set at different functions levels and that's not for the best. I wonder what would be better, though.
If you got an idea, feel free to tell, but please don't push unfinished things on development, as we're trying to stabilize the beast for the next release.
Other than that, I'm quite eager to see how you want to fix that. :)

Regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Bad Creature Class ...

Postby Bertram » 06 Apr 2014, 08:38

And so you reverted one of my patches without any explanation:
http://sourceforge.net/p/opendungeons/g ... bf62f3e8d/

Paul, why?? Is it possible for you to act less bluntly?
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Bad Creature Class ...

Postby paul424 » 06 Apr 2014, 10:32

OK I reverted the revert . I experimented with revert and pushed that by choice.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Bad Creature Class ...

Postby Bertram » 06 Apr 2014, 15:36

OK I reverted the revert . I experimented with revert and pushed that by choice.

??? This last sentence looks just insane to me.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Bad Creature Class ...

Postby paul424 » 06 Apr 2014, 17:36

I was sure revert reverts all the commits down to specified hash , instead it just provides >> anti-commit << of that particular git commit package, regardless how deep in repo is commit pointed by that hash .,... , ok let me revert the commits with rotate creatures ...
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: Bad Creature Class ...

Postby Bertram » 07 Apr 2014, 08:23

Well, whatever you do, don't push things you're not sure of. We are here to help in those cases.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Who is online

Users browsing this forum: No registered users and 1 guest