Skip to content

Commit 6a3ce4a

Browse files
fix: draw ext 3D offset issue (v2.1.1)
1 parent 2a9dacc commit 6a3ce4a

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

extensions/pl_draw_ext.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,6 +4397,7 @@ pl_draw_submit_3d_drawlist(plDrawList3D* ptDrawlist, plRenderEncoder* ptEncoder,
43974397
};
43984398
PL_LOG_DEBUG_API_F(gptLog, uLogChannelDrawBackend, "Grow \"%s\" %u to %u frame %llu", tBufferDesc.pcDebugName, ptBufferInfo->uVertexBufferSize, (uint32_t)tBufferDesc.szByteSize, gptIO->ulFrameCount);
43994399
ptBufferInfo->uVertexBufferSize = (uint32_t)tBufferDesc.szByteSize;
4400+
ptBufferInfo->uVertexBufferOffset = 0;
44004401

44014402
ptBufferInfo->tVertexBuffer = pl__create_staging_buffer(&tBufferDesc, "3d draw vtx buffer", uFrameIdx);
44024403
}
@@ -4487,7 +4488,7 @@ pl_draw_submit_3d_drawlist(plDrawList3D* ptDrawlist, plRenderEncoder* ptEncoder,
44874488
};
44884489
PL_LOG_DEBUG_API_F(gptLog, uLogChannelDrawBackend, "Grow \"%s\" %u to %u frame %llu", tBufferDesc.pcDebugName, ptBufferInfo->uVertexBufferSize, (uint32_t)tBufferDesc.szByteSize, gptIO->ulFrameCount);
44894490
ptBufferInfo->uVertexBufferSize = (uint32_t)tBufferDesc.szByteSize;
4490-
4491+
ptBufferInfo->uVertexBufferOffset = 0;
44914492
ptBufferInfo->tVertexBuffer = pl__create_staging_buffer(&tBufferDesc, "draw vtx buffer", uFrameIdx);
44924493
}
44934494

@@ -4808,7 +4809,7 @@ pl__get_3d_pipeline(plRenderPassHandle tRenderPass, uint32_t uMSAASampleCount, p
48084809
.tFragmentShader = gptShader->load_glsl("pl_draw_3d.frag", "main", NULL, NULL),
48094810
.tVertexShader = gptShader->load_glsl("pl_draw_3d_line.vert", "main", NULL, NULL),
48104811
.tGraphicsState = {
4811-
.ulDepthWriteEnabled = tFlags & PL_DRAW_FLAG_DEPTH_WRITE,
4812+
.ulDepthWriteEnabled = tFlags & PL_DRAW_FLAG_DEPTH_WRITE ? 1 : 0,
48124813
.ulDepthMode = tFlags & PL_DRAW_FLAG_DEPTH_TEST ? (tFlags & PL_DRAW_FLAG_REVERSE_Z_DEPTH ? PL_COMPARE_MODE_GREATER : PL_COMPARE_MODE_LESS) : PL_COMPARE_MODE_ALWAYS,
48134814
.ulCullMode = ulCullMode,
48144815
.ulWireframe = 0,

extensions/pl_draw_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern "C" {
5353
// [SECTION] apis
5454
//-----------------------------------------------------------------------------
5555

56-
#define plDrawI_version {2, 1, 0}
56+
#define plDrawI_version {2, 1, 1}
5757

5858
//-----------------------------------------------------------------------------
5959
// [SECTION] includes

internal/sandbox/app.c

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const plGraphicsI* gptGfx = NULL;
9292
const plToolsI* gptTools = NULL;
9393
const plEcsI* gptEcs = NULL;
9494
const plCameraI* gptCamera = NULL;
95+
const plCameraEcsI* gptCameraEcs = NULL;
9596
const plModelLoaderI* gptModelLoader = NULL;
9697
const plJobI* gptJobs = NULL;
9798
const plDrawI* gptDraw = NULL;
@@ -413,7 +414,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
413414
gptEcs->initialize((plEcsInit){0});
414415
gptRendererEcs->register_system();
415416
gptScript->register_ecs_system();
416-
gptCamera->register_ecs_system();
417+
gptCameraEcs->register_ecs_system();
417418
gptAnimation->register_ecs_system();
418419
gptMesh->register_ecs_system();
419420
gptPhysics->register_ecs_system();
@@ -519,7 +520,7 @@ pl_app_resize(plWindow* ptWindow, plAppData* ptAppData)
519520
{
520521
plIO* ptIO = gptIO->get_io();
521522
if(ptAppData->tTestWorld.ptScene)
522-
gptCamera->set_aspect((plCamera*)gptEcs->get_component(ptAppData->ptComponentLibrary, gptCamera->get_ecs_type_key(), ptAppData->tTestWorld.tMainCamera), ptIO->tMainViewportSize.x / ptIO->tMainViewportSize.y);
523+
gptCamera->set_aspect((plCamera*)gptEcs->get_component(ptAppData->ptComponentLibrary, gptCameraEcs->get_ecs_type_key(), ptAppData->tTestWorld.tMainCamera), ptIO->tMainViewportSize.x / ptIO->tMainViewportSize.y);
523524
ptAppData->bResize = true;
524525
gptStarter->resize();
525526
}
@@ -554,7 +555,7 @@ pl_app_update(plAppData* ptAppData)
554555
// update statistics
555556
gptShaderVariant->update_stats();
556557

557-
plCamera* ptCamera = (plCamera*)gptEcs->get_component(ptAppData->ptComponentLibrary, gptCamera->get_ecs_type_key(), ptAppData->tTestWorld.tMainCamera);
558+
plCamera* ptCamera = (plCamera*)gptEcs->get_component(ptAppData->ptComponentLibrary, gptCameraEcs->get_ecs_type_key(), ptAppData->tTestWorld.tMainCamera);
558559

559560
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~selection stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
560561

@@ -588,7 +589,7 @@ pl_app_update(plAppData* ptAppData)
588589
gptEcs->run_transform_update_system(ptAppData->ptComponentLibrary);
589590
gptEcs->run_hierarchy_update_system(ptAppData->ptComponentLibrary);
590591
gptRendererEcs->run_light_update_system(ptAppData->ptComponentLibrary);
591-
gptCamera->run_ecs(ptAppData->ptComponentLibrary);
592+
gptCameraEcs->run_ecs(ptAppData->ptComponentLibrary);
592593
gptAnimation->run_inverse_kinematics_update_system(ptAppData->ptComponentLibrary);
593594
gptRendererEcs->run_skin_update_system(ptAppData->ptComponentLibrary);
594595
gptRendererEcs->run_object_update_system(ptAppData->ptComponentLibrary);
@@ -766,6 +767,34 @@ pl__show_init_window(plAppData* ptAppData)
766767
gptStarter->deactivate_msaa();
767768

768769
gptRendererEditor->rebuild_scene_bvh(ptAppData->tTestWorld.ptScene);
770+
771+
#if 0
772+
plCommandBuffer* ptCmdBuffer = gptStarter->get_temporary_command_buffer();
773+
774+
plTerrainProcessTileInfo tTile = {
775+
.iTreeDepth = 6,
776+
.fMaxHeight = 2000.0f,
777+
.fMinHeight = -40.0f,
778+
.fMaxBaseError = 3.0f,
779+
.tCenter = {0}
780+
};
781+
plTerrainProcessInfo tTerrainInfo = {
782+
.fMetersPerPixel = 20.0f,
783+
.uHorizontalTiles = 1,
784+
.uVerticalTiles = 1,
785+
.uSize = 4096,
786+
.uTileCount = 1,
787+
.atTiles = &tTile
788+
};
789+
790+
sprintf(tTile.acOutputFile, "/cache/mountains.chu");
791+
sprintf(tTile.acHeightMapFile, "/assets/core/textures/mountains.png");
792+
793+
gptTerrain->process(&tTerrainInfo);
794+
ptAppData->ptTerrain = gptRendererTerrain->create(ptCmdBuffer, &tTerrainInfo);
795+
gptStarter->submit_temporary_command_buffer(ptCmdBuffer);
796+
gptRendererTerrain->set(ptAppData->tTestWorld.ptScene, ptAppData->ptTerrain);
797+
#endif
769798
}
770799
}
771800

@@ -1225,6 +1254,7 @@ pl__load_apis(plApiRegistryI* ptApiRegistry)
12251254
gptTools = pl_get_api_latest(ptApiRegistry, plToolsI);
12261255
gptEcs = pl_get_api_latest(ptApiRegistry, plEcsI);
12271256
gptCamera = pl_get_api_latest(ptApiRegistry, plCameraI);
1257+
gptCameraEcs = pl_get_api_latest(ptApiRegistry, plCameraEcsI);
12281258
gptRenderer = pl_get_api_latest(ptApiRegistry, plRendererI);
12291259
gptJobs = pl_get_api_latest(ptApiRegistry, plJobI);
12301260
gptModelLoader = pl_get_api_latest(ptApiRegistry, plModelLoaderI);
@@ -1369,37 +1399,6 @@ pl__verify_scene(plAppData* ptAppData, const char* pcPath)
13691399
return bResult;
13701400
}
13711401

1372-
1373-
1374-
#if 0
1375-
plCommandBuffer* ptCmdBuffer = gptStarter->get_temporary_command_buffer();
1376-
1377-
plTerrainProcessTileInfo tTile = {
1378-
.iTreeDepth = 6,
1379-
.fMaxHeight = 2000.0f,
1380-
.fMinHeight = -40.0f,
1381-
.fMaxBaseError = 3.0f,
1382-
.tCenter = {0}
1383-
};
1384-
plTerrainProcessInfo tTerrainInfo = {
1385-
.fMetersPerPixel = 20.0f,
1386-
.uHorizontalTiles = 1,
1387-
.uVerticalTiles = 1,
1388-
.uSize = 4096,
1389-
.uTileCount = 1,
1390-
.atTiles = &tTile
1391-
};
1392-
1393-
sprintf(tTile.acOutputFile, "/assets/mountains.chu");
1394-
sprintf(tTile.acHeightMapFile, "/assets/mountains.png");
1395-
1396-
gptTerrain->process(&tTerrainInfo);
1397-
ptAppData->ptTerrain = gptRendererTerrain->create(ptCmdBuffer, &tTerrainInfo);
1398-
gptStarter->submit_temporary_command_buffer(ptCmdBuffer);
1399-
gptRendererTerrain->set(ptAppData->ptScene, ptAppData->ptTerrain);
1400-
#endif
1401-
// }
1402-
14031402
void
14041403
pl__show_ui_demo_window(plAppData* ptAppData)
14051404
{

0 commit comments

Comments
 (0)