About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Toggle physics and Navmesh creation
Author Message
Zervox Offline
Silver Supporter

Post: #1
Toggle physics and Navmesh creation
I would like to request the possibility to be able to disable the automatic navmesh and physics mesh generation until I need it(either through lock-unlock calls or a toggle button in the editor).
It would allow for faster terrain generation through the editor interface and possibly the heightmap import functionality, as it is now atleast with the Editor Interface for each area I submit the generation of navmeshes and physics mesh is exponentialialy increasing build times due to calling change on one area will tell all the 8 neighboring areas to rebuild navmesh making my tool either suddenly time out or have to wait a large time before the editor starts processing the other areas.
04-06-2015 12:41 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #2
RE: Toggle physics and Navmesh creation
Agreed. Also, the option to completely remove the navmesh?
04-06-2015 01:03 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #3
RE: Toggle physics and Navmesh creation
(04-06-2015 01:03 PM)Tottel Wrote:  Agreed. Also, the option to completely remove the navmesh?

+1
04-06-2015 01:32 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Toggle physics and Navmesh creation
I haven't touched the world building code in a while, but this is most likely what's happening:
-you start submitting areas through Editor Interface
-after a while the Editor will start processing some chunk of world areas that were modified in a block sized around 8x8 areas, only modified areas will be processed in that block
-if you submit all remaining areas by the time the Editor finishes processing the first block, then there should be no unnecessary work done by the editor world builder
04-06-2015 10:02 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #5
RE: Toggle physics and Navmesh creation
(04-06-2015 10:02 PM)Esenthel Wrote:  I haven't touched the world building code in a while, but this is most likely what's happening:
-you start submitting areas through Editor Interface
-after a while the Editor will start processing some chunk of world areas that were modified in a block sized around 8x8 areas, only modified areas will be processed in that block
-if you submit all remaining areas by the time the Editor finishes processing the first block, then there should be no unnecessary work done by the editor world builder

Yet it still does, I generate 24x24 heightmaps really quickly, it still isn't enough to prevent the editor from starting to stall for 20 minutes or more(it stalls from the first area I put in). to me it seems the submit will always tell neighbors to update navmeshes, no matter the timeframe.
(This post was last modified: 04-06-2015 10:13 PM by Zervox.)
04-06-2015 10:11 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Toggle physics and Navmesh creation
Hello,

This is the modified tutorial from Tutorials project, and creates 32x32 areas
Code:
/******************************************************************************

   This tutorial will present how to create a new world, and set some terrain in it.

/******************************************************************************/
Edit.EditorInterface EI;
bool ok;
/******************************************************************************/
void InitPre()
{
   EE_INIT();
}
/******************************************************************************/
bool Init()
{
   // connect to a running instance of the Editor
   Str message; if(!EI.connect(message))Exit(message);

   // create new world element in the project
   UID world_id=EI.newWorld("Programatic World");
   if(!world_id.valid())Exit("Creating world failed");

   int terrain_res=EI.worldTerrainRes(world_id); if(terrain_res<=0)Exit("Invalid terrain resolution");

   // set heightmap
   Image height;
   height.createSoft(terrain_res, terrain_res, 1, IMAGE_F32);
   REPD(y, height.h())
   REPD(x, height.w())height.pixelF(x, y, Random(0, 10)); // random value from 0 to 10 meters
   height.blur(4, true); // blur the image

   // setting terrain requires specifying a material, so let's look for one in the project
   UID material_id=UIDZero;
   Memc<Edit.Elm> elms; EI.getElms(elms); REPA(elms)if(elms[i].type==Edit.ELM_MTRL && elms[i].name=="grass"){material_id=elms[i].id; break;}
   if(!material_id.valid())Exit("Not found any material to use");

   // set terrain
   flt t=Time.curTime();
   REPD(x, 32)
   REPD(y, 32)ok=EI.worldTerrainSetHeight(world_id, VecI2(x, y), height, material_id);
   Exit(S+(Time.curTime()-t));

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   return true;
}
/******************************************************************************/
void Draw()
{
   D.clear(BLACK);
   D.text(Rect(Vec2(0)), ok ? "A new world has been created in the root of the project\nPlease open it to see it" : "Setting terrain failed");
}
/******************************************************************************/

The tutorial itself finishes in 21 seconds.
And the Editor finishes building the world 1-2 minutes after that.

Everything works as expected.
04-08-2015 02:40 AM
Find all posts by this user Quote this message in a reply
Post Reply