mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Made ViewController's launch animation to add current view's position to
center point. Fixed clipping with a scaled camera matrix.
This commit is contained in:
parent
5aeb2bc87f
commit
aad80b73fd
|
@ -87,7 +87,7 @@ void ViewController::onFileChanged(FileData* file, FileChangeType change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::launch(FileData* game, const Eigen::Vector3f& center)
|
void ViewController::launch(FileData* game, Eigen::Vector3f center)
|
||||||
{
|
{
|
||||||
if(game->getType() != GAME)
|
if(game->getType() != GAME)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +99,7 @@ void ViewController::launch(FileData* game, const Eigen::Vector3f& center)
|
||||||
game->getSystem()->getTheme()->playSound("gameSelectSound");
|
game->getSystem()->getTheme()->playSound("gameSelectSound");
|
||||||
|
|
||||||
Eigen::Affine3f origCamera = mCamera;
|
Eigen::Affine3f origCamera = mCamera;
|
||||||
|
center += mCurrentView->getPosition();
|
||||||
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), [this, origCamera, center, game]
|
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), [this, origCamera, center, game]
|
||||||
{
|
{
|
||||||
game->getSystem()->launchGame(mWindow, game);
|
game->getSystem()->launchGame(mWindow, game);
|
||||||
|
@ -175,18 +176,19 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
|
||||||
{
|
{
|
||||||
Eigen::Affine3f trans = mCamera * parentTrans;
|
Eigen::Affine3f trans = mCamera * parentTrans;
|
||||||
|
|
||||||
|
// camera position, position + size
|
||||||
|
Eigen::Vector3f viewStart = trans.inverse().translation();
|
||||||
|
Eigen::Vector3f viewEnd = trans.inverse() * Eigen::Vector3f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight(), 0);
|
||||||
|
|
||||||
// draw systems
|
// draw systems
|
||||||
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
|
for(auto it = mSystemViews.begin(); it != mSystemViews.end(); it++)
|
||||||
{
|
{
|
||||||
// clipping
|
// clipping
|
||||||
Eigen::Vector3f pos = it->second->getPosition();
|
Eigen::Vector3f guiStart = it->second->getPosition();
|
||||||
Eigen::Vector2f size = it->second->getSize();
|
Eigen::Vector3f guiEnd = it->second->getPosition() + Eigen::Vector3f(it->second->getSize().x(), it->second->getSize().y(), 0);
|
||||||
|
|
||||||
Eigen::Vector3f camPos = -trans.translation();
|
if(guiEnd.x() >= viewStart.x() && guiEnd.y() >= viewStart.y() &&
|
||||||
Eigen::Vector2f camSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
guiStart.x() <= viewEnd.x() && guiStart.y() <= viewEnd.y())
|
||||||
|
|
||||||
if(pos.x() + size.x() >= camPos.x() && pos.y() + size.y() >= camPos.y() &&
|
|
||||||
pos.x() <= camPos.x() + camSize.x() && pos.y() <= camPos.y() + camSize.y())
|
|
||||||
it->second->render(trans);
|
it->second->render(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
|
|
||||||
// Plays a nice launch effect and launches the game at the end of it.
|
// Plays a nice launch effect and launches the game at the end of it.
|
||||||
// Once the game terminates, plays a return effect.
|
// Once the game terminates, plays a return effect.
|
||||||
void launch(FileData* game, const Eigen::Vector3f& centerCameraOn = Eigen::Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
void launch(FileData* game, Eigen::Vector3f centerCameraOn = Eigen::Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
|
|
Loading…
Reference in a new issue