I create big modification for this solution, where speed 3x increase.
Can use it with physical engine, LOD, apod.
This solution use more tiles, this tiles are moved when camera move to heir border and are draw only visible tiles.
more about this solution and code for download is here:
http://magicresurection.ic.cz/index.php ... 4&Itemid=2
new new tile engine
Hi turican, I am glad you have found some use of my terrain node.
Your modification is interesting. There are some things I don't understand however.
Function which controls if mesh needs to be updated is this (look at last if() ):
function which actulay perform test is isSectorOnScreen(TlTSector* sctr)
Your modification is interesting. There are some things I don't understand however.
I think you refer here to proces when visible terrain mesh is updated from data arrays. Update however does not happen every frame. It happen only when told to ...mostly when camera move certain distance.This engine in ever farme copy tarrain to one tile and shis tile is rendered.
Copy in every frames is not good, In huge terrain take any FPS.
Function which controls if mesh needs to be updated is this (look at last if() ):
Code: Select all
// set rendered mesh position relative to terrain
void ShTlTerrainSceneNode::setMeshPosition(core::vector2d<s32> pos)
{
// correct if out of terrain bounds
if(pos.X < 0) pos.X = 0;
if(pos.Y < 0) pos.Y = 0;
if(pos.X > (s32)(Size.Width - MeshSize.Width)) pos.X = (s32)(Size.Width - MeshSize.Width);
if(pos.Y > (s32)(Size.Height - MeshSize.Height)) pos.Y = (s32)(Size.Height - MeshSize.Height);
// update
if(pos.X > MeshPosition.X + ShStep || pos.X < MeshPosition.X - ShStep ||
pos.Y > MeshPosition.Y + ShStep || pos.Y < MeshPosition.Y - ShStep)
{
MeshPosition = pos;
update();
}
}
Do you mean more tiles or more sectors?Create more tile with some LOD and when camera move to borders tile, last tile move before first.
Not all tiles are rendered. Every frame there is test if sector (mesh buffer) is on screen. If it is not its tiles are not rendered. Test happen in void ShTlTerrainSceneNode::render()Next optimalization is change from rendering all tiles:
...
To only tiles in view:
...
Code: Select all
// test if sectors are vissible
for(u32 j=0; j<Sector.height(); j++)
for(u32 i=0; i<Sector.width(); i++)
if( isSectorOnScreen( &Sector(i,j) ) ) Sector(i,j).isVissible = true;
else Sector(i,j).isVissible = false;
Hi arras.
Update every frame - my mistake, I disremember how it works
Do you mean more tiles or more sectors?
-yes, better name is sectors. Big tiles include small tiles.
Not all tiles are rendered
-I have old code, and here no function isSectorOnScreen:
virtual void render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(buffer->Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList
(&buffer->Vertices[0], buffer->getVertexCount(),
&buffer->Indices[0], buffer->getIndexCount()/3 );
}
Can give me link to actual code?
I make any repair my code and cleaning(camera not as parameter), cleaning parts where no terrain code and push to my pages.
Small tune increase fps about 5%, too.
Update every frame - my mistake, I disremember how it works
Do you mean more tiles or more sectors?
-yes, better name is sectors. Big tiles include small tiles.
Not all tiles are rendered
-I have old code, and here no function isSectorOnScreen:
virtual void render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(buffer->Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList
(&buffer->Vertices[0], buffer->getVertexCount(),
&buffer->Indices[0], buffer->getIndexCount()/3 );
}
Can give me link to actual code?
I make any repair my code and cleaning(camera not as parameter), cleaning parts where no terrain code and push to my pages.
Small tune increase fps about 5%, too.
Code is here:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=20940
May be you are using old TlTerrainNode.
isSectorOnScreen() is private member:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=20940
May be you are using old TlTerrainNode.
isSectorOnScreen() is private member:
Code: Select all
class ShTlTerrainSceneNode : public scene::ISceneNode
{
....
// return true if sector is on screen
virtual bool isSectorOnScreen(TlTSector* sctr);
// update vertices of sector
virtual void updateVertices(TlTSector §or);
// update 2nd texture layer
virtual void updateTexture(u32* p, TlTSector §or);
// return true if 3d line colide with tile
virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d<f32> line,
core::vector3df &outIntersection);
public:
...