diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-21 15:46:46 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-21 15:46:46 -0400 |
| commit | ef37d054dfe5812efa9eefb4b9b18621fdabac25 (patch) | |
| tree | 713042c875004da0058bf5813c4b2b736b6c4ed3 /src/serialization-camera.cpp | |
| parent | a066448effaa9a56c049136067a73ba0156f65d3 (diff) | |
pke: first-pass serializing ui and font renders
Diffstat (limited to 'src/serialization-camera.cpp')
| -rw-r--r-- | src/serialization-camera.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/serialization-camera.cpp b/src/serialization-camera.cpp index 0183e29..714ea2c 100644 --- a/src/serialization-camera.cpp +++ b/src/serialization-camera.cpp @@ -10,7 +10,12 @@ #include "vendor-glm-include.hpp" -void pke_serialize_camera(srlztn_serialize_helper *h, const PkeCamera *cam) { +bool pke_serialize_camera(srlztn_serialize_helper *h, const PkeCamera *cam) { + assert(h != nullptr); + assert(cam != nullptr); + if (PK_HAS_FLAG(cam->entity_flags, ENTITY_FLAG_DO_NOT_SERIALIZE)) { + return false; + } PkeCamera c{}; if (cam->uuid != pk_uuid_zed && cam->uuid != pk_uuid_max) { h->o << SRLZTN_CAMERA_UUID << cam->uuid << std::endl; @@ -46,13 +51,10 @@ void pke_serialize_camera(srlztn_serialize_helper *h, const PkeCamera *cam) { BulletToGlm(rot, quat_rot); BulletToGlm(scale, glm_scale); pke_serialize_inst_pos(h, glm_pos, quat_rot, glm_scale); + return true; } -bool FindFirstInstanceHandle(void *handle, void *mapping) { - srlztn_instance_mapping *inst_mapping = reinterpret_cast<srlztn_instance_mapping *>(mapping); - return inst_mapping->serialized_uuid == *reinterpret_cast<pk_uuid *>(handle); -} -void pke_deserialize_camera(srlztn_deserialize_helper *h) { +bool pke_deserialize_camera(srlztn_deserialize_helper *h) { PK_STN_RES stn_res = PK_STN_RES(0); PkeCamera cam{}; cam.type = PKE_CAMERA_TYPE_PERSPECTIVE; @@ -70,7 +72,7 @@ void pke_deserialize_camera(srlztn_deserialize_helper *h) { uint32_t targetInstanceIndex = -1; if (target_uuid != pk_uuid_zed) { - targetInstanceIndex = pk_arr_find_first_index(&h->mapping, &target_uuid, FindFirstInstanceHandle); + targetInstanceIndex = pk_arr_find_first_index(&h->mapping, &target_uuid, srlztn_mapping_find_first_handle_by_uuid); if (targetInstanceIndex == uint32_t(-1)) { fprintf(stderr, "[pke_deserialize_camera] Camera has target instance uuid '" pk_uuid_printf_format "', but failed to find target instance.", pk_uuid_printf_var(target_uuid)); } @@ -95,7 +97,7 @@ void pke_deserialize_camera(srlztn_deserialize_helper *h) { if (rCam.isPrimary == true) { ActiveCamera = &rCam; } - return; + return true; } if (pke_deserialize_inst_pos(h, pos, quat_rot, scale)) { continue; @@ -139,4 +141,5 @@ void pke_deserialize_camera(srlztn_deserialize_helper *h) { continue; } } + return false; } |
