summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-05-29 16:11:37 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-05-29 16:11:37 -0400
commitd9dc3559296661249f9e5f1c3d0a8320cbf8fc29 (patch)
tree2a0203b676f15e8933960e786c8181354f73b121 /editor
parenta9bc23377bd9193cd3eb3ef2e91431d088d13d5d (diff)
pke: ecs: BucketContainer > pk_bkt_arr_t & cleanup
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 057152f..667508d 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -746,7 +746,7 @@ void RecordImGuiEntityTypes() {
ImGui::PushID(i);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
- ImGui::Text("0x%08X 0x%08X", et.handle.bucketIndex, et.handle.itemIndex);
+ ImGui::Text("0x%08X 0x%08X", et.handle.b, et.handle.i);
ImGui::TableSetColumnIndex(1);
ImGui::Text("%*.*s", 0, (int)AssetKeyLength, et.modelAssetKey);
ImGui::TableSetColumnIndex(2);
@@ -981,7 +981,7 @@ bool RecordImGui_GenerateMTSDFModal() {
auto *assets = AM_GetAssets(b, count);
for (pk_handle_item_index_T i = 0; i < count; ++i) {
const auto &asset = assets[i];
- if (asset.handle == EntityHandle_MAX)
+ if (asset.handle == AssetHandle_MAX)
continue;
if (!PK_HAS_FLAG(asset.type, PKE_ASSET_TYPE_FONT)) {
continue;
@@ -1077,7 +1077,7 @@ void RecordImGuiAssets() {
ImGui::PushID(b);
for (pk_handle_item_index_T i = 0; i < count; ++i) {
const auto &asset = assets[i];
- if (asset.handle == EntityHandle_MAX)
+ if (asset.handle == AssetHandle_MAX)
continue;
ImGui::PushID(i);
ImGui::TableNextRow();
@@ -1170,7 +1170,7 @@ void RecordImGuiCameras() {
}
ImGui::EndDisabled();
ImGui::TableSetColumnIndex(1);
- ImGui::Text("0x%08X 0x%08X", cam.handle.bucketIndex, cam.handle.itemIndex);
+ ImGui::Text("0x%08X 0x%08X", cam.handle.b, cam.handle.i);
ImGui::TableSetColumnIndex(2);
ImGui::Text(pk_uuid_printf_format, pk_uuid_printf_var(cam.phys.target_inst_uuid));
ImGui::TableSetColumnIndex(3);
@@ -1501,7 +1501,7 @@ void RecordImGui_CompInstPos(bool readonly, CompInstance *component) {
rot.getEulerZYX(eul.z, eul.y, eul.x);
eul = glm::degrees(eul);
- ImGui::Text("InstanceHandle: 0x%08X 0x%08X", component->instanceHandle.bucketIndex, component->instanceHandle.itemIndex);
+ ImGui::Text("InstanceHandle: 0x%08X 0x%08X", component->instanceHandle.b, component->instanceHandle.i);
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;
@@ -1538,7 +1538,7 @@ void RecordImGui_CompInstPos(bool readonly, CompInstance *component) {
PkeCamera_TargetInstance(ActiveCamera->camHandle, component);
}
ImGui::SameLine();
- ImGui::Text("Active Camera: 0x%08X 0x%08X", ActiveCamera->handle.bucketIndex, ActiveCamera->handle.itemIndex);
+ ImGui::Text("Active Camera: 0x%08X 0x%08X", ActiveCamera->handle.b, ActiveCamera->handle.i);
ImGui::EndDisabled();
if (changed) {
@@ -1680,27 +1680,30 @@ void RecordImGuiProjectBrowser() {
void RecordImGuiSceneBrowser() {
NULL_CHAR_ARR(text, 128);
- CompInstance *instances;
- EntityType *entType;
- pk_handle_bucket_index_T bucketCount, i;
- pk_handle_item_index_T itemCount, k;
+
if (!ImGui::Begin("SceneBrowser", &pkeSettings.editorSettings.isShowingSceneEditor)) {
ImGui::End();
return;
}
- bucketCount = ECS_GetInstances_BucketCount();
- for (i = 0; i < bucketCount; ++i) {
- instances = ECS_GetInstances(0, itemCount);
- for (k = 0; k < itemCount; ++k) {
- if (instances[k].instanceHandle == InstanceHandle_MAX) continue;
- entType = EntityType_FindByEntityHandle(instances[k].entHandle);
- sprintf(text, "%s: %08x %08x", entType != nullptr ? entType->entityTypeCode.val : "(no type)", instances[k].instanceHandle.bucketIndex, instances[k].instanceHandle.itemIndex);
- if (ImGui::Button(text)) {
- selectedEntity = &instances[k];
- }
+ using InstIterFn = pk_tmpln_1<void, CompInstance*, void*>;
+ InstIterFn inst_iter_cb{};
+ inst_iter_cb.func = [&text](CompInstance *arr_obj_data) {
+ // EntityType *entType = EntityType_FindByEntityHandle(arr_obj_data->entHandle);
+ EntityType *entType = NULL;
+ CompGrBinds *grBinds = ECS_GetGrBinds(arr_obj_data->grBindsHandle);
+ if (grBinds != NULL) {
+ entType = static_cast<EntityType*>(ECS_GetEntity(grBinds->entHandle));
}
- }
+ sprintf(text, "%08x %08x", arr_obj_data->instanceHandle.b, arr_obj_data->instanceHandle.i);
+ if (ImGui::Button(text)) {
+ selectedEntity = arr_obj_data;
+ }
+ ImGui::SameLine();
+ sprintf(text, "EntityType: %s", entType != nullptr ? entType->entityTypeCode.val : "(no type)");
+ ImGui::Text("%s", text);
+ };
+ pk_bkt_arr_iterate(ECS_GetInstances(), &InstIterFn::invoke, &inst_iter_cb);
ImGui::End();
}
@@ -1743,15 +1746,21 @@ void RecordImGuiSceneEditor() {
reset = true;
}
}
+ reset = reset || (entGrBinds.next == 0 && entInstances.next == 0);
if (reset) {
pk_arr_clear(&entGrBinds);
pk_arr_clear(&entInstances);
entType = nullptr;
}
- if (entGrBinds.next == 0)
- ECS_GetGrBinds(ECS_GetEntity(selectedEntity->entHandle), entGrBinds);
- if (entInstances.next == 0)
+ if (entGrBinds.next == 0) {
+ CompGrBinds *grBinds = ECS_GetGrBinds(selectedEntity->grBindsHandle);
+ if (grBinds != NULL) {
+ ECS_GetGrBinds(ECS_GetEntity(grBinds->entHandle), entGrBinds);
+ }
+ }
+ if (entInstances.next == 0) {
ECS_GetInstances(ECS_GetEntity(selectedEntity->entHandle), entInstances);
+ }
if (entGrBinds.next > 0) {
if (ImGui::Button("Create Instance")) {
Entity_Base *entity = ECS_GetEntity(selectedEntity->entHandle);
@@ -1767,7 +1776,7 @@ void RecordImGuiSceneEditor() {
} else {
ImGui::Text("%s: %s", "EntType: ", "Unknown");
}
- ImGui::Text("%s: %08x %08x", "Entity Handle: ", selectedEntity->entHandle.bucketIndex, selectedEntity->entHandle.itemIndex);
+ ImGui::Text("%s: %08x %08x", "Entity Handle: ", selectedEntity->entHandle.b, selectedEntity->entHandle.i);
for (int64_t i = 0; i < entGrBinds.next; ++i) {
RecordImGui_CompGrBinds(true, entGrBinds[i]);
}