diff --git a/Geome3Dash/src/game/editor/CameraKeyframeEditorPopup.cpp b/Geome3Dash/src/game/editor/CameraKeyframeEditorPopup.cpp index 11d8875b..bb86c3df 100644 --- a/Geome3Dash/src/game/editor/CameraKeyframeEditorPopup.cpp +++ b/Geome3Dash/src/game/editor/CameraKeyframeEditorPopup.cpp @@ -185,9 +185,8 @@ namespace g3d return true; } - - void CameraKeyframeEditorPopup::onClose(CCObject* obj) { + if (ckel->keyframeBuffer.keyframes.empty()) { ckel->keyframeBuffer.setKeyframe(0, glm::vec3(0), glm::vec3(0)); } currentLevelData.keyframe = ckel->keyframeBuffer; setLevelData(LevelEditorLayer::get(), currentLevelData); this->setMouseEnabled(false); diff --git a/Geome3Dash/src/helper/CameraKeyframeBuffer.cpp b/Geome3Dash/src/helper/CameraKeyframeBuffer.cpp index b1826dd1..40fe7bee 100644 --- a/Geome3Dash/src/helper/CameraKeyframeBuffer.cpp +++ b/Geome3Dash/src/helper/CameraKeyframeBuffer.cpp @@ -20,7 +20,7 @@ namespace g3d } void CameraKeyframeBuffer::removeLastKeyframe() { - keyframes.pop_back(); + if (keyframes.size()) { keyframes.pop_back(); } } CameraKeyframe CameraKeyframeBuffer::getInterpolatedCameraKeyframe(float playersXpos) { diff --git a/Geome3Dash/src/transformer/SplineGameObjectTransformer.cpp b/Geome3Dash/src/transformer/SplineGameObjectTransformer.cpp index d22c2bc3..bd4484e1 100644 --- a/Geome3Dash/src/transformer/SplineGameObjectTransformer.cpp +++ b/Geome3Dash/src/transformer/SplineGameObjectTransformer.cpp @@ -8,7 +8,7 @@ namespace g3d void SplineGameObjectTransformer::transform(GameObjectModel* gom) { auto block = gom->getGameObject(); - auto data = spline->findClosestByLength(block->getPositionX() * *lengthScaleFactor); + auto data = spline->findClosestByLength(block->m_positionX * (*lengthScaleFactor)); auto pos = data.value; auto normal = glm::normalize(spline->normal(data.t)); @@ -30,7 +30,7 @@ namespace g3d glm::quat rotationQuat = glm::quat_cast(rotationMatrix); glm::vec3 eulerDegrees = glm::degrees(glm::eulerAngles(rotationQuat * firstRotationQuat)); - gom->setPosition(pos + (normal * (*lengthScaleFactor) * (block->getPositionY() - 110))); + gom->setPosition(pos + (normal * (*lengthScaleFactor) * (static_cast(block->m_positionY) - 110))); gom->setRotation(eulerDegrees); gom->setScale(glm::vec3( 0.5 * (block->m_startFlipX ? -1 : 1) * (*lengthScaleFactor) * 30, diff --git a/Geome3Dash/src/transformer/SplinePlayerObjectTransformer.cpp b/Geome3Dash/src/transformer/SplinePlayerObjectTransformer.cpp index c33d7c21..08b875e4 100644 --- a/Geome3Dash/src/transformer/SplinePlayerObjectTransformer.cpp +++ b/Geome3Dash/src/transformer/SplinePlayerObjectTransformer.cpp @@ -9,15 +9,15 @@ namespace g3d { if (auto pom = dynamic_cast(gom)) { - auto block = gom->getGameObject(); - auto data = spline->findClosestByLength(block->getPositionX() * *lengthScaleFactor); + auto player = pom->getPlayerObject(); + auto data = spline->findClosestByLength(player->m_position.x * (*lengthScaleFactor)); auto pos = data.value; auto normal = glm::normalize(spline->normal(data.t)); auto tangent = glm::normalize(spline->tangent(data.t)); glm::vec3 side(1.f, 0.f, 0.f); - float normalDeltaAngle = glm::radians(block->getRotation()); + float normalDeltaAngle = glm::radians(player->getRotation()); glm::quat firstRotationQuat = glm::angleAxis(normalDeltaAngle, side); @@ -34,11 +34,11 @@ namespace g3d float scale = pom->getPlayerObject()->getScale(); - gom->setPosition(pos + (normal * (*lengthScaleFactor) * (block->getPositionY() - 110))); + gom->setPosition(pos + (normal * (*lengthScaleFactor) * (player->m_position.y - 110))); gom->setRotation(eulerDegrees); gom->setScale(glm::vec3( - 0.5 * (block->m_startFlipX ? -1 : 1) * (*lengthScaleFactor) * 30, - 0.5 * (block->m_startFlipY ? -1 : 1) * (*lengthScaleFactor) * 30 * scale, + 0.5 * (player->m_startFlipX ? -1 : 1) * (*lengthScaleFactor) * 30, + 0.5 * (player->m_startFlipY ? -1 : 1) * (*lengthScaleFactor) * 30 * scale, 0.5 * (*lengthScaleFactor) * 30 * scale)); } }