Skip to content

Commit 5e1d911

Browse files
WIP 0
1 parent 4925422 commit 5e1d911

File tree

3 files changed

+380
-431
lines changed

3 files changed

+380
-431
lines changed

editor/app.c

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -297,61 +297,67 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
297297

298298
#if 1
299299

300-
for(uint32_t i = 5; i < 7; i++)
300+
plTerrainTileInfo atTiles[8 * 8] = {0};
301+
302+
plTerrainHeightMapInfo tInfo =
303+
{
304+
// .iTreeDepth = 6,
305+
.iTreeDepth = 9,
306+
.fRadius = 1737400.0f,
307+
.bEllipsoid = true,
308+
.b3dErrorCalc = true,
309+
.pcOutputFile = "moon.chu",
310+
.fMaxHeight = 14052.0f,
311+
.fMinHeight = -18256.0f,
312+
.fMaxBaseError = 10.0f,
313+
.fMetersPerPixel = 100.0f, // 4096
314+
.tCenter = {0},
315+
.atTiles = atTiles,
316+
.uSize = 28800
317+
// .uSize = 4096 * 1
318+
};
319+
320+
321+
for(uint32_t i = 0; i < 8; i++)
301322
{
302-
for(uint32_t j = 5; j < 7; j++)
323+
for(uint32_t j = 0; j < 8; j++)
303324
{
304-
char* sbNameBuffer0 = NULL;
305-
char* sbNameBuffer1 = NULL;
306-
pl_sb_sprintf(sbNameBuffer0, "../data/moon_%u_%u.png", i, j);
307-
pl_sb_sprintf(sbNameBuffer1, "moon_%u_%u.chu", i, j);
308-
plTerrainHeightMapInfo tInfo =
309-
{
310-
.iTreeDepth = 6,
311-
.fRadius = 1737400.0f,
312-
.bEllipsoid = true,
313-
.b3dErrorCalc = true,
314-
.pcHeightMapFile = sbNameBuffer0,
315-
.pcOutputFile = sbNameBuffer1,
316-
.fMaxHeight = 14052.0f,
317-
.fMinHeight = -18256.0f,
318-
// .fMaxBaseError = 324.0f,
319-
.fMaxBaseError = 10.0f,
320-
.fMetersPerPixel = 100.0f, // 4096
321-
.tCenter = {
322-
.x = -1440000.0f + (float)i * 409600.0f + 409600.0f * 0.5f,
323-
.z = -1440000.0f + (float)j * 409600.0f + 409600.0f * 0.5f
324-
}
325-
};
326-
327-
gptProfile->begin_frame();
328-
gptProfile->begin_sample(0, "FRAME");
329-
if(!gptFile->exists(tInfo.pcOutputFile))
330-
{
331-
gptProfile->begin_sample(0, "process_heightmap");
332-
gptTerrainProcessor->process_heightmap(tInfo);
333-
gptProfile->end_sample(0);
334-
}
325+
char* sbNameBuffer = NULL;
326+
pl_sb_sprintf(sbNameBuffer, "../data/moon_%u_%u.png", i, j);
327+
328+
strncpy(atTiles[tInfo.uTileCount].acHeightMapFile, sbNameBuffer, 256);
329+
atTiles[tInfo.uTileCount].fMinHeight = tInfo.fMinHeight;
330+
atTiles[tInfo.uTileCount].fMaxHeight = tInfo.fMaxHeight;
331+
atTiles[tInfo.uTileCount].uXOffset = 4096 * i;
332+
atTiles[tInfo.uTileCount].uYOffset = 4096 * j;
333+
tInfo.uTileCount++;
334+
pl_sb_free(sbNameBuffer);
335+
}
336+
}
335337

336-
gptProfile->begin_sample(0, "load_chunk_file");
337-
gptTerrain->load_chunk_file(ptAppData->ptTerrain, tInfo.pcOutputFile);
338-
gptProfile->end_sample(0);
338+
gptProfile->begin_frame();
339+
gptProfile->begin_sample(0, "FRAME");
340+
if(!gptFile->exists(tInfo.pcOutputFile))
341+
{
342+
gptProfile->begin_sample(0, "process_heightmap");
343+
gptTerrainProcessor->process_heightmap(tInfo);
344+
gptProfile->end_sample(0);
345+
}
339346

340-
gptProfile->end_sample(0);
341-
gptProfile->end_frame();
347+
gptProfile->begin_sample(0, "load_chunk_file");
348+
gptTerrain->load_chunk_file(ptAppData->ptTerrain, tInfo.pcOutputFile);
349+
gptProfile->end_sample(0);
342350

343-
uint32_t uSampleCount = 0;
344-
plProfileCpuSample* ptSamples = gptProfile->get_last_frame_samples(0, &uSampleCount);
351+
gptProfile->end_sample(0);
352+
gptProfile->end_frame();
345353

346-
const char* acSpaceBuffer = " ";
347-
// for(uint32_t j = 0; j < uSampleCount; j++)
348-
// {
349-
// printf("%s %s: %0.6f\n", &acSpaceBuffer[39 - ptSamples[j]._uDepth], ptSamples[j].pcName, ptSamples[j].dDuration);
350-
// }
354+
uint32_t uSampleCount = 0;
355+
plProfileCpuSample* ptSamples = gptProfile->get_last_frame_samples(0, &uSampleCount);
351356

352-
pl_sb_free(sbNameBuffer0);
353-
pl_sb_free(sbNameBuffer1);
354-
}
357+
const char* acSpaceBuffer = " ";
358+
for(uint32_t j = 0; j < uSampleCount; j++)
359+
{
360+
printf("%s %s: %0.6f\n", &acSpaceBuffer[39 - ptSamples[j]._uDepth], ptSamples[j].pcName, ptSamples[j].dDuration);
355361
}
356362

357363
#else

0 commit comments

Comments
 (0)