Skip to content

Commit

Permalink
Fix backwards compatibility of camera system if compatibility mode is…
Browse files Browse the repository at this point in the history
… enabled
  • Loading branch information
Hammie committed Oct 6, 2024
1 parent cf592c7 commit 37cf3ff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/libs/location/src/location_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "sea_base.h"
#include "shared/messages.h"

#include <storm/renderer/scene.hpp>

//#define CAMERA_VIEW_TEST_ENABLE
#define CAMERA_VIEW_TEST_R 3
#define CAMERA_VIEW_TEST_ANG 30
Expand Down Expand Up @@ -89,6 +91,10 @@ bool LocationCamera::Init()
// core.LayerCreate("realize", true, false);
core.SetLayerType(REALIZE, layer_type_t::realize);

if (core.GetTargetEngineVersion() <= storm::ENGINE_VERSION::TO_EACH_HIS_OWN) {
storm::Scene::GetDefaultScene().SetActiveCamera(this);
}

// The sea
sea = core.GetEntityId("sea");

Expand Down
2 changes: 2 additions & 0 deletions src/libs/renderer/include/storm/renderer/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Scene : public Entity {

uint64_t ProcessMessage(MESSAGE &msg) override;

static Scene& GetDefaultScene();

private:
entid_t activeCamera_ = invalid_entity;
};
Expand Down
18 changes: 17 additions & 1 deletion src/libs/renderer/src/storm/renderer/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ void Scene::ProcessStage(Stage stage, uint32_t delta)

Scene &Scene::SetActiveCamera(Camera *camera)
{
activeCamera_ = camera->GetId();
if (camera == nullptr) {
activeCamera_ = invalid_entity;
}
else {
activeCamera_ = camera->GetId();
}
return *this;
}

Expand All @@ -72,4 +77,15 @@ uint64_t Scene::ProcessMessage(MESSAGE &msg)
return 0;
}

Scene &Scene::GetDefaultScene()
{
entid_t scene_id = core.GetEntityId("Scene");
if (scene_id == invalid_entity) {
scene_id = core.CreateEntity("Scene");
core.AddToLayer(EXECUTE, scene_id, 0);
core.AddToLayer(SEA_EXECUTE, scene_id, 0);
}
return *dynamic_cast<Scene*>(core.GetEntityPointerSafe(scene_id) );
}

} // namespace storm
7 changes: 6 additions & 1 deletion src/libs/sea_cameras/src/sea_cameras.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "sea_cameras.h"
#include "deck_camera.h"
#include "free_camera.h"
#include "ship_camera.h"
#include "shared/sea_ai/script_defines.h"
#include "ship_camera.h"

#include <storm/renderer/scene.hpp>

CREATE_CLASS(SEA_CAMERAS)

Expand Down Expand Up @@ -68,6 +70,9 @@ uint64_t SEA_CAMERAS::ProcessMessage(MESSAGE &message)
}
pCamera->SetActive(bActive);
pCamera->SetCharacter(pACharacter);
if (core.GetTargetEngineVersion() <= storm::ENGINE_VERSION::TO_EACH_HIS_OWN) {
storm::Scene::GetDefaultScene().SetActiveCamera(pCamera);
}
}
break;
case AI_MESSAGE_SEASAVE: {
Expand Down

0 comments on commit 37cf3ff

Please sign in to comment.