diff options
Diffstat (limited to 'editor/editor.cpp')
| -rw-r--r-- | editor/editor.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 48e5cc1..17a2913 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -189,6 +189,15 @@ void PkeEditor_Tick(double delta) { } else { sprintf(file_path, "%.16s", editor_mstr.active_scene->name); } + int len = strlen(file_path); + if (strstr(file_path, ".pstf") == nullptr && len < 251) { + file_path[len+0] = '.'; + file_path[len+1] = 'p'; + file_path[len+2] = 's'; + file_path[len+3] = 't'; + file_path[len+4] = 'f'; + file_path[len+5] = '\0'; + } pke_editor_scene_save(file_path); shouldRebuildProjectDir = true; } @@ -1093,19 +1102,22 @@ void RecordImGuiAssets() { } void RecordImGuiCameras() { - CompInstance *activeInst = nullptr; - // CompInstance *activeTargetInst = nullptr; + CompInstance *active_inst = nullptr; if (!ImGui::Begin("Cameras")) { ImGui::End(); return; } - activeInst = ECS_GetInstance(ActiveCamera->phys.instHandle); - // activeTargetInst = ECS_GetInstance(ActiveCamera->phys.targetInstHandle); + active_inst = ECS_GetInstance(ActiveCamera->phys.instHandle); if (ImGui::Button("Create")) { InstPos instPos{}; instPos.mass = 1.f; - activeInst->bt.motionState->getWorldTransform(instPos.posRot); - instPos.scale = activeInst->bt.rigidBody->getCollisionShape()->getLocalScaling(); + if (active_inst == nullptr) { + instPos.posRot.setIdentity(); + instPos.scale = btVector3(1, 1, 1); + } else { + active_inst->bt.motionState->getWorldTransform(instPos.posRot); + instPos.scale = active_inst->bt.rigidBody->getCollisionShape()->getLocalScaling(); + } auto &cam = PkeCamera_Register(pk_uuid_zed, instPos); cam.phys.targetInstHandle = ActiveCamera->phys.targetInstHandle; cam.type = ActiveCamera->type; @@ -1168,8 +1180,13 @@ void RecordImGuiCameras() { if (ImGui::Button("Update Position")) { InstPos instPos{}; instPos.mass = 1.f; - activeInst->bt.motionState->getWorldTransform(instPos.posRot); - instPos.scale = activeInst->bt.rigidBody->getCollisionShape()->getLocalScaling(); + if (active_inst == nullptr) { + NullCameraInstance.bt.motionState->getWorldTransform(instPos.posRot); + instPos.scale = NullCameraInstance.bt.rigidBody->getCollisionShape()->getLocalScaling(); + } else { + active_inst->bt.motionState->getWorldTransform(instPos.posRot); + instPos.scale = active_inst->bt.rigidBody->getCollisionShape()->getLocalScaling(); + } CompInstance *camInst = ECS_GetInstance(cam.phys.instHandle); ECS_UpdateInstance(camInst, instPos, true); } |
