Archived
1
Fork 0

Fix some cutscene bugs

This commit is contained in:
redstrate 2021-10-12 10:26:40 -04:00
parent 7a526a4cab
commit 8ea112e26c
2 changed files with 20 additions and 16 deletions

View file

@ -102,24 +102,27 @@ void CommonEditor::update(float deltaTime) {
platform::capture_mouse(willCaptureMouse); platform::capture_mouse(willCaptureMouse);
if(willCaptureMouse) { if(willCaptureMouse) {
yaw += engine->get_input()->get_value("lookX") * 50.0f * deltaTime; if(engine->get_scene() != nullptr && !engine->get_scene()->get_all<Camera>().empty()) {
pitch += engine->get_input()->get_value("lookY") * 50.0f * deltaTime;
const float speed = 7.00f; yaw += engine->get_input()->get_value("lookX") * 50.0f * deltaTime;
pitch += engine->get_input()->get_value("lookY") * 50.0f * deltaTime;
prism::float3 forward, right; const float speed = 7.00f;
forward = normalize(angle_axis(yaw, prism::float3(0, 1, 0)) * angle_axis(pitch, prism::float3(1, 0, 0)) * prism::float3(0, 0, 1));
right = normalize(angle_axis(yaw, prism::float3(0, 1, 0)) * prism::float3(1, 0, 0));
float movX = engine->get_input()->get_value("movementX"); prism::float3 forward, right;
float movY = engine->get_input()->get_value("movementY"); forward = normalize(angle_axis(yaw, prism::float3(0, 1, 0)) * angle_axis(pitch, prism::float3(1, 0, 0)) * prism::float3(0, 0, 1));
right = normalize(angle_axis(yaw, prism::float3(0, 1, 0)) * prism::float3(1, 0, 0));
auto [obj, cam] = engine->get_scene()->get_all<Camera>()[0]; float movX = engine->get_input()->get_value("movementX");
float movY = engine->get_input()->get_value("movementY");
engine->get_scene()->get<Transform>(obj).position += right * movX * speed * deltaTime; auto [obj, cam] = engine->get_scene()->get_all<Camera>()[0];
engine->get_scene()->get<Transform>(obj).position += forward * -movY * speed * deltaTime;
engine->get_scene()->get<Transform>(obj).rotation = angle_axis(yaw, prism::float3(0, 1, 0)) * angle_axis(pitch, prism::float3(1, 0, 0)); engine->get_scene()->get<Transform>(obj).position += right * movX * speed * deltaTime;
engine->get_scene()->get<Transform>(obj).position += forward * -movY * speed * deltaTime;
engine->get_scene()->get<Transform>(obj).rotation = angle_axis(yaw, prism::float3(0, 1, 0)) * angle_axis(pitch, prism::float3(1, 0, 0));
}
} }
doing_viewport_input = willCaptureMouse; doing_viewport_input = willCaptureMouse;
@ -925,7 +928,7 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene, const prism::flo
texture_create_info.width = thumbnail_resolution; texture_create_info.width = thumbnail_resolution;
texture_create_info.height = thumbnail_resolution; texture_create_info.height = thumbnail_resolution;
texture_create_info.format = GFXPixelFormat::RGBA8_UNORM; texture_create_info.format = GFXPixelFormat::RGBA8_UNORM;
texture_create_info.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled; texture_create_info.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
auto final_texture = gfx->create_texture(texture_create_info); auto final_texture = gfx->create_texture(texture_create_info);
@ -1085,7 +1088,7 @@ void CommonEditor::load_thumbnail_cache() {
info.width = thumbnail_resolution; info.width = thumbnail_resolution;
info.height = thumbnail_resolution; info.height = thumbnail_resolution;
info.format = GFXPixelFormat::RGBA8_UNORM; info.format = GFXPixelFormat::RGBA8_UNORM;
info.usage = GFXTextureUsage::Sampled; info.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
GFXTexture* texture = engine->get_gfx()->create_texture(info); GFXTexture* texture = engine->get_gfx()->create_texture(info);

View file

@ -425,7 +425,8 @@ void CutsceneEditor::drawUI() {
ImGui::End(); ImGui::End();
if(ImGui::Begin("Viewport")) { if(ImGui::Begin("Viewport")) {
drawViewport(engine->get_scene()); if(currentShot != nullptr && currentShot->scene != nullptr)
drawViewport(currentShot->scene);
} }
ImGui::End(); ImGui::End();