[HELP NEEDED ]Little change from stl::map -> 2d arrays

[HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 19 Apr 2012, 10:09

As I will try to pull via git what I have done so far with the code, let me summarize what's done ; I don't understand every inch of OD code so far so some help and discussion welcome :D

I try switching from typedef std::map<std::pair<int, int> , Tile*> TileMap_t; --> Tile** , when it would become C -style 2d array allocated dynamiclly .


Basicly we have something like @@GameEntity.h
//! \brief Function that implements code for the removal from the map
virtual void deleteYourself ();


Now as the Tiles are no longer keep in the stl::map container ; we need to rethink the lifecycle of the Tile.
I don't understand why is there need for Tile delete in the Gameplay , nor why it is not Update of and object ( like say , Tile might be reclaimed , lost it's Room on top of it , have removed the Ground etc. ) . So far the method looks like :

case RenderRequest::deleteTile:
{
Tile* curTile = static_cast<Tile*> (renderRequest.p);
delete curTile;
break;
}
Which of course does not suite new code , it might be something like :


case RenderRequest::deleteTile:
{
Tile* curTile = static_cast<Tile*> (renderRequest.p);
~curTile();
break;
}
and destructor might set to something ... yeah , what ? Is there a need of some subtype of Tile, say NULL_TILE ?

How does the Render in the old code handles the cases where are no apropriate Tile in stl::map for x, y positon ? Is it some Rock Tile or some other default one ?

That;s all for now :D ....
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 13 May 2012, 12:47

Well the Map board and tiles on it are displayed , but the whole game engine seems to be stalled down to 7 Fps.
I try to implement the frustrum tiles' culling by tracing the camera corners .
Almost done , .... don't know how to implement the Tile::show and Tile::hide methods. Will try later.
Current code in origin/tiles. Revisions and comments welcome.
btw After recalling c++ I don't attempt to call destrustors explicitly.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby oln » 15 May 2012, 22:16

Ogre should do the culling (actually it's probably done by OpenGL/D3D), I don't think doing any manual culling would make sense. (Though I could be wrong.)
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 19 May 2012, 10:16

Opengl does something like frustum culling but only for each primitive ( like triangle etc. ) at the end of the pipeline.
I just finished the basic culling algorithm , and it seems the improvment is significant. Animation of creatures does not work, cause of either to many removal of mutex 's or some other code spoil when switching from std:map -> C-arrays in MapLoad.* and GameMap.*.
Will push the code as I properly intend the code .

What is lacking is the culling for non-Tiles objects : mostly the Creture meshes and Rooms. They are loosly sparsed objects , ( far away ) so the chance of being put into current cameraView is very low . So some space partitioning tree would be the best, plus Creature is movable, ( so I Haven't heard about the dynamic PVS'es ). Hints welcome.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby oln » 19 May 2012, 11:22

Yep, I suppose you are correct. Space partitioning is probably a good idea.
There is https://code.google.com/p/ogre-paged/ , but I don't know how well that works with dynamic terrain.
I managed to break the creature animations once, then it was due to messing with the setPosition function, but I would guess that is not the issue this time.
Also, is it better to destroy the sceneNodes when culling (as is done now) or just hide them?
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 20 May 2012, 12:58

Creature::doTurn() it seems is never called. I cannot investigate properly with gdb , cause I cannot do my trick with two X servers on this laptophttp://forum.freegamedev.net/viewtopic.php?f=45&t=3026 Will try later.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby dusted » 21 May 2012, 21:58

I'm a glN00b, but I suggest you test the performance of simply constructing a vbo from the whole map each time a tile is changed (which is usually not every single frame), then simply draw that, you're usually able to push an incredible amount of geometry this way, the geometry will already be in videoram and the gfx card is free to optimise on this, and not render what is not shown, and it won't one call per til per frame for however it is being rendered now.

This is only a suggestion, and I do not know how it is already done. Peace. :)
User avatar
dusted
 
Posts: 83
Joined: 27 Feb 2010, 04:35

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 24 May 2012, 18:11

Finally its fixed, proper code is in branch tiles2 . Could someone start merging in with development ? Both branches needs proper code formatting first with .... maybe oln could find out finally his astyle config .
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 28 May 2012, 20:43

The same regards Creatures , what should I do before calling createMesh() and destroyMesh() for each creature ?
I suppose those are some mutexes, I could find on my own ... but OD's a team work , isn't it ?
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby oln » 28 May 2012, 21:39

I don't think you need to do anything before calling them.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 29 May 2012, 09:48

void GameMap:: toggleCreaturesVisibility(){
sem_wait(&creaturesLockSemaphore);
visibleCreatures = !visibleCreatures;
if(visibleCreatures ){
for( std::vector<Creature*>::iterator it = creatures.begin(); it != creatures.end(); it++){
if((*it)->isMeshExisting())
addAnimatedObject(*it);
(*it)->createMesh();
}
}
else{
for( std::vector<Creature*>::iterator it = creatures.begin(); it != creatures.end(); it++){
if((*it)->isMeshExisting())
removeAnimatedObject(*it);
(*it)->destroyMesh();

}
}
sem_post(&creaturesLockSemaphore);
}

-----------------------------------------------------------------------------------------------------------------------------
Causes Exception , assertion fails in Ogre::Singleton<ODFrameListener>::getSingleton ()

at
/usr/include/OGRE/OgreSingleton.h
What that has to do to mentioned function ? hmm ....


static T& getSingleton( void )
{ assert( ms_Singleton ); return ( *ms_Singleton ); }
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby oln » 29 May 2012, 11:55

I would guess the assertion means that the singleton is not initialised, though the only singleton that would be accessed in that class is RenderManager. Though again, have you tried just hiding the mesh/nodes, rather than destroying them?
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 31 May 2012, 15:26

Now I face the two coordinate world system , the one implied by Ogre , that is having the beginning in (0,0,0) coordinate and by C-Array of Tiles, having the begin co(mapSizeX/2, mapSizeY/2).
Now we must merge those two , that is choose one of them .
For example : Either by explicitly adding vectors at getTile, and setTile .
There are dozens of workouts , but thing is to choose the smartest one.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby oln » 31 May 2012, 16:12

I think we should just go with the easiest option, it should be easy to change later if we find out it's not ideal. If you have to fix the map file, use vectors, otherwise, start at (0,0).
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 31 May 2012, 17:17

how InputManager:xPos , and , yPos are modified ?
I cannot grep-out any references to them outside I-Manager.cpp.
EDIT: FOUND.
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [HELP NEEDED ]Little change from stl::map -> 2d arrays

Postby paul424 » 06 Jun 2012, 08:45

Why there are so many nodes assosiated with each Tile ?
I have noticed Level_%3i_%3i , Level_%3i_%3i_node , "Level_%3i_%3i_selection_indicator". Two of them are for meshes assosiated with digging.
Can't those meshes go into one Tile node ? I.e. Should I remove "Level_%3i_%3i_selection_indicator, Level_%3i_%3i .


Best would be third repo, or wiki like documentation site for documentation.
Cheers.
And may the force bring the new developers :D .
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Who is online

Users browsing this forum: No registered users and 1 guest