Yep,
Quadmap generation is now done. Sector mesh generation from quadmap is also done. Build function is done. Continue build function is done.
heres a little extract from both dlls to show the difference in cleanness.
New:
// =========================
// === BT CONTINUE BUILD ===
// =========================
EXPORT int BT_ContinueBuild(unsigned long ObjectID,unsigned long PhyObjectID)
{
//Set Current function
BT_Main.CurrentFunction=C_BT_FUNCTION_CONTINUEBUILD;
//Variables
s_BT_Sector* Sector;
int Progress=0;
//Check that its building
if(BT_Main.Building)
{
//Check that objectid is valid
if(!ObjectID>0)
BT_Intern_Error(C_BT_ERROR_OBJECTIDILLEGAL);
//Get sector
Sector=&BT_terrain[BT_Main.CurrentBuildTerrain].Sector[BT_Main.CurrentBuildSector];
//Set sector object IDs
Sector->ObjectID=ObjectID;
Sector->PhyObjectID=PhyObjectID;
//Build
if(BT_Main.BuildType)
{ // Rebuild
//TODO: ADD REBUILD CODE
}else{ //Firstbuild
BT_Intern_BuildSector(Sector);
}
//Do some stuff to the objects
dbCalculateObjectBounds(Sector->ObjectID);
dbExcludeObjectOn(Sector->ObjectID);
if(Sector->PhyObjectID)
dbExcludeObjectOn(Sector->PhyObjectID);
//Set Current values
BT_Main.CurrentBuildRow=Sector->Row;
BT_Main.CurrentBuildColumn=Sector->Column;
//Increase sector number
BT_Main.CurrentBuildSector++;
//Get the progress
if(BT_Main.CurrentBuildSector==BT_terrain[BT_Main.CurrentBuildTerrain].Sectors)
{
Progress=-1;
BT_Main.Building=0;
}else{
Progress=int(BT_Main.CurrentBuildSector/BT_terrain[BT_Main.CurrentBuildTerrain].Sectors*100);
}
}
return Progress;
}
// === END FUNCTION ===
Old:
//***** 'ut_continuebuild' ****************************************************
//+**** ================== ****************************************************
int ut_continuebuild ( unsigned long object, unsigned long phyobject )
{
unsigned long terrain = 0;
unsigned long sectornum = 0;
unsigned long row = 0;
unsigned long column = 0;
unsigned long freememblock = 0;
unsigned long sector = 0;
int progress = 0;
float sectors_flt = 0;
float progress_flt = 0;
//Variables
//Find useful variables
terrain = ut_main.build.terrain;
sectornum = ut_main.build.currentsector + ut_terrain_arr[terrain].firstsector;
//Update sector number
ut_main.build.currentsector++;
//Update row and column
if ( ut_main.build.currentrow == ut_terrain_arr[terrain].split || ut_main.build.currentrow > ut_terrain_arr[terrain].split ) {
ut_main.build.currentcolumn++;
ut_main.build.currentrow = 0;
}
row = ut_main.build.currentrow;
column = ut_main.build.currentcolumn;
//Work out if the sector is excluded
ut_sector_arr[sectornum].excluded = ut_intern_getsectorexcluded( terrain, row, column );
//Work out if the sector exists
ut_sector_arr[sectornum].exists = 1 - ut_sector_arr[sectornum].excluded;
//If the sector is not excluded
if ( ut_sector_arr[sectornum].excluded == 0 ) {
//Set useful variables
ut_sector_arr[sectornum].objnum = object;
ut_sector_arr[sectornum].phyobjnum = phyobject;
ut_sector_arr[sectornum].currentlodlevel = 1;
//Work out the position
ut_sector_arr[sectornum].xpos = ut_terrain_arr[terrain].sectorsize / 2.0 + column * ut_terrain_arr[terrain].sectorsize;
ut_sector_arr[sectornum].zpos = ut_terrain_arr[terrain].sectorsize / 2.0 + row * ut_terrain_arr[terrain].sectorsize;
//Set the location
ut_sector_arr[sectornum].column = column;
ut_sector_arr[sectornum].row = row;
//Make the sector
ut_intern_createsector( sectornum );
//Correct sector height to make LOD more accurate
ut_intern_correctsectorheight( sectornum );
//Calculate the bounds for Frustum Culling
dbCalculateObjectBounds( ut_sector_arr[sectornum].objnum );
//Hide the object
dbExcludeObjectOn( ut_sector_arr[sectornum].objnum );
}
//Update the current row
ut_main.build.currentrow++;
//If the sector is not excluded
if ( ut_sector_arr[sectornum].excluded == 0 ) {
//Position the sector
dbPositionObject( ut_sector_arr[sectornum].objnum, ut_sector_arr[sectornum].xpos, ut_sector_arr[sectornum].ypos, ut_sector_arr[sectornum].zpos );
//Position the physics object (if it exists)
if ( ut_sector_arr[sectornum].phyobjnum ) {
dbPositionObject( ut_sector_arr[sectornum].phyobjnum, ut_sector_arr[sectornum].xpos, 0, ut_sector_arr[sectornum].zpos );
dbExcludeObjectOn( ut_sector_arr[sectornum].phyobjnum );
}
//If the texturemode is "BlitzTerrain" then texture it with the detailmap
if ( ut_terrain_arr[terrain].texmode == 0 ) {
if ( ut_terrain_arr[terrain].detailimg ) {
dbTextureObject( ut_sector_arr[sectornum].objnum, ut_terrain_arr[terrain].detailimg );
}
}
//If the texturemode is "Advanced Terrain"
if ( ut_terrain_arr[terrain].texmode == 1 ) {
//================================================================================================================================================
//======================= TODO ADVANCED TERRAIN CODE =============================================================================================
//================================================================================================================================================
//texture object UT_Sector(sectornum).objnum,0,UT_Terrain(terrain).textureimg
//texture object UT_Sector(sectornum).objnum,1,UT_Terrain(terrain).detailimg
if ( ut_terrain_arr[terrain].textureimg ) {
dbSetBlendMappingOn( ut_sector_arr[sectornum].objnum, 0, ut_terrain_arr[terrain].textureimg, 10, 4 );
}
if ( ut_terrain_arr[terrain].detailimg ) {
dbSetBlendMappingOn( ut_sector_arr[sectornum].objnum, 1, ut_terrain_arr[terrain].detailimg, 11, 4 );
}
}
//Set default edge LOD values to stop the LOD system updating the edges randomly
sector = sectornum;
ut_sector_arr[sector].loda.toplod = 1;
ut_sector_arr[sector].lodb.toplod = 2;
ut_sector_arr[sector].lodc.toplod = 3;
ut_sector_arr[sector].lodd.toplod = 4;
ut_sector_arr[sector].lode.toplod = 5;
ut_sector_arr[sector].lodf.toplod = 6;
ut_sector_arr[sector].lodg.toplod = 7;
ut_sector_arr[sector].loda.rightlod = 1;
ut_sector_arr[sector].lodb.rightlod = 2;
ut_sector_arr[sector].lodc.rightlod = 3;
ut_sector_arr[sector].lodd.rightlod = 4;
ut_sector_arr[sector].lode.rightlod = 5;
ut_sector_arr[sector].lodf.rightlod = 6;
ut_sector_arr[sector].lodg.rightlod = 7;
ut_sector_arr[sector].loda.bottomlod = 1;
ut_sector_arr[sector].lodb.bottomlod = 2;
ut_sector_arr[sector].lodc.bottomlod = 3;
ut_sector_arr[sector].lodd.bottomlod = 4;
ut_sector_arr[sector].lode.bottomlod = 5;
ut_sector_arr[sector].lodf.bottomlod = 6;
ut_sector_arr[sector].lodg.bottomlod = 7;
ut_sector_arr[sector].loda.leftlod = 1;
ut_sector_arr[sector].lodb.leftlod = 2;
ut_sector_arr[sector].lodc.leftlod = 3;
ut_sector_arr[sector].lodd.leftlod = 4;
ut_sector_arr[sector].lode.leftlod = 5;
ut_sector_arr[sector].lodf.leftlod = 6;
ut_sector_arr[sector].lodg.leftlod = 7;
//Set the original position of the sector
ut_sector_arr[sectornum].origxpos = ut_sector_arr[sectornum].xpos;
ut_sector_arr[sectornum].origypos = ut_sector_arr[sectornum].ypos;
ut_sector_arr[sectornum].origzpos = ut_sector_arr[sectornum].zpos;
}
//Check if the build is finnished
if ( sectornum == ut_terrain_arr[terrain].firstsector + ut_terrain_arr[terrain].sectors - 1 ) {
ut_terrain_arr[terrain].built = 1;
return -1;
}
//Calculate the progress
sectors_flt = ut_terrain_arr[terrain].sectors;
progress_flt = ut_main.build.currentsector / sectors_flt;
progress = int( progress_flt * 100.0 );
return progress;
}
I hope this wont put you off blitzterrain 1.05. just as a reminder, the above old code does the job very well and is bug free. It only means that building will be faster in 1.06.
The old code was generated by a dba - cpp converter, the new code has been handwritten by me
.
I have moved alot of the sector generation into the build function, and that takes 16ms to load a terrain with the extra code included.
Texturing is in my todo list.