diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2024-11-14 14:46:23 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2024-11-14 14:46:23 -0500 |
| commit | b2548ba4ce295fcd94a50123fb543fac2ef2bc33 (patch) | |
| tree | 444a32abb4a094c4fa2f7bc9a95aa86963ad4110 /editor | |
| parent | b1d926361b9d613ad712ad161f9a8b7ccab4551d (diff) | |
add pk.h and major pkmem refactor
Completely replaces the memory module with pkmem
pkmem is a newer implementation of the same
bucket memory structure.
Also includes replacing pkstr.h with pk.h's pkstr
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index b5a47cf..8c99096 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -18,6 +18,7 @@ #include "vendor/glm_include.hpp" #include "vendor/tinyfiledialogs//tinyfiledialogs.h" #include "window.hpp" +#include "vendor/pk.h" #include <GLFW/glfw3.h> #include <compare> @@ -88,7 +89,7 @@ glm::vec3 unproject(glm::vec3 windowCoords) { void PkeEditor_Tick(double delta) { if (shouldRunCurrentScene) { shouldRunCurrentScene = false; - auto *task = Pke_New<std::packaged_task<void()>>(); + auto *task = pk_new<std::packaged_task<void()>>(); new (task) std::packaged_task<void()>( [] { subProgramPid = fork(); if (subProgramPid == 0) { @@ -136,7 +137,7 @@ void PkeEditor_Tick(double delta) { } if (shouldOpenLoadSceneDialog) { shouldOpenLoadSceneDialog = false; - auto *task = Pke_New<std::packaged_task<void()>>(); + auto *task = pk_new<std::packaged_task<void()>>(); new (task) std::packaged_task<void()>( [] { const char * patterns[1] = {"*.pstf"}; char *selectedScene = tinyfd_openFileDialog(nullptr, "cafebabe.pstf", 1, patterns, "Pke Scene Text File", 0); @@ -151,7 +152,7 @@ void PkeEditor_Tick(double delta) { if (shouldOpenSaveSceneDialog) { shouldOpenSaveSceneDialog = false; - auto *task = Pke_New<std::packaged_task<void()>>(); + auto *task = pk_new<std::packaged_task<void()>>(); new (task) std::packaged_task<void()>( [] { const char * patterns[1] = {"*.pstf"}; char *selectedScene = tinyfd_saveFileDialog(nullptr, pkeSettings.rt.sceneName, 1, patterns, "Pke Scene Text File"); @@ -237,7 +238,7 @@ void PkeEditor_Tick(double delta) { } if (shouldCreateEntityType) { - EntityType *existingEntity = EntityType_FindByTypeCode(entityTypeToCreate.entityTypeCode); + EntityType *existingEntity = EntityType_FindByTypeCode(entityTypeToCreate.entityTypeCode.val); if (existingEntity == nullptr) { EntityType *newEntType = EntityType_Create(); @@ -657,23 +658,23 @@ void RecordImGuiEntityTypes() { ImGui::TableSetupColumn("Instances"); ImGui::TableHeadersRow(); - PkeHandleBucketIndex_T cameraBucketCount = EntityType_GetBucketCount(); - for (PkeHandleBucketIndex_T b = 0; b < cameraBucketCount; ++b) { - PkeHandleItemIndex_T count; + pk_handle_bucket_index_T cameraBucketCount = EntityType_GetBucketCount(); + for (pk_handle_bucket_index_T b = 0; b < cameraBucketCount; ++b) { + pk_handle_item_index_T count; auto *entityTypes = EntityType_GetEntityTypes(b, count); ImGui::PushID(b); - for (PkeHandleItemIndex_T i = 0; i < count; ++i) { + for (pk_handle_item_index_T i = 0; i < count; ++i) { const auto &et = entityTypes[i]; if (et.handle == EntityHandle_MAX) continue; ImGui::PushID(i); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - ImGui::Text("0x%016lX", et.handle.hash); + ImGui::Text("0x%08X 0x%08X", et.handle.bucketIndex, et.handle.itemIndex); ImGui::TableSetColumnIndex(1); ImGui::Text("%*.*s", 0, (int)AssetKeyLength, et.modelAssetKey); ImGui::TableSetColumnIndex(2); - ImGui::Text("%s", et.entityTypeCode); + ImGui::Text("%s", et.entityTypeCode.val); ImGui::TableSetColumnIndex(3); ImGui::Text("count: %li", et.detailsCount); ImGui::TableSetColumnIndex(4); @@ -749,10 +750,10 @@ void RecordImGuiCameras() { } ImGui::EndDisabled(); ImGui::TableSetColumnIndex(1); - ImGui::Text("0x%016lX", cam.handle.hash); + ImGui::Text("0x%08X 0x%08X", cam.handle.bucketIndex, cam.handle.itemIndex); ImGui::TableSetColumnIndex(2); if (cam.phys.targetInst != nullptr) { - ImGui::Text("0x%016lX", cam.phys.targetInst->entHandle.hash); + ImGui::Text("0x%08X 0x%08X", cam.phys.targetInst->entHandle.bucketIndex, cam.phys.targetInst->entHandle.itemIndex); } else { ImGui::Text("0x%p", cam.phys.targetInst); } @@ -931,9 +932,9 @@ void RecordImGuiModalCreateEntityType() { // TODO this needs to be an array strncpy(entityTypeToCreate.details[0].textureAssetKey, apssTexture.safeKey, AssetKeyLength); - char *sEntityTypeCode = Pke_New<char>(strlen(entityTypeCode) + 1); + char *sEntityTypeCode = pk_new<char>(strlen(entityTypeCode) + 1); strncpy(sEntityTypeCode, entityTypeCode, 31); - entityTypeToCreate.entityTypeCode = sEntityTypeCode; + entityTypeToCreate.entityTypeCode.val = sEntityTypeCode; shouldCreateEntityType = true; @@ -1080,7 +1081,7 @@ void RecordImGui_CompInstPos(bool readonly, CompInstance *component) { rot.getEulerZYX(eul.z, eul.y, eul.x); eul = glm::degrees(eul); - ImGui::Text("InstanceHandle: 0x%016lX", component->instanceHandle.hash); + ImGui::Text("InstanceHandle: 0x%08X 0x%08X", component->instanceHandle.bucketIndex, component->instanceHandle.itemIndex); changed = ImGui::InputScalar("Instance Index", ImGuiDataType_U64, &component->index, nullptr, nullptr, nullptr, ImGuiInputTextFlags_ReadOnly) || changed; changed = ImGui::InputScalarN("pos", ImGuiDataType_Float, &pos, 3, nullptr, nullptr, nullptr, inputTextFlags) || changed; changed = ImGui::InputScalarN("rot (eul)", ImGuiDataType_Float, &eul, 3, nullptr, nullptr, nullptr, inputTextFlags) || changed; @@ -1179,12 +1180,12 @@ void BuildDirRecursive(const std::filesystem::directory_entry &de, fsEntry *dirF auto fullPath = std::filesystem::absolute(de.path()); auto len = strlen(fullPath.c_str()); // TODO leaky - entry.path = Pke_New<char>(len + 1); + entry.path = pk_new<char>(len + 1); memset(entry.path, '\0', len + 1); memcpy(entry.path, fullPath.c_str(), len); len = strlen(fullPath.filename().c_str()); // TODO leaky - entry.name = Pke_New<char>(len + 1); + entry.name = pk_new<char>(len + 1); memset(entry.name, '\0', len + 1); memcpy(entry.name, fullPath.filename().c_str(), len); @@ -1340,7 +1341,7 @@ void PkeEditor_Init() { PkeInputSet debugControlsSet; debugControlsSet.title = "debug-editor-controls"; debugControlsSet.actionCount = 13; - debugControlsSet.actions = Pke_New<PkeInputAction>(debugControlsSet.actionCount); + debugControlsSet.actions = pk_new<PkeInputAction>(debugControlsSet.actionCount); debugControlsSet.actions[0].name = dbgCtrl_CameraLeft; debugControlsSet.actions[0].primaryHash = PkeInputEventMask { |
