Use forward declarations in game/camera

Forward declaration improves compilation time at the cost of some
verbosity.
This commit is contained in:
Vsevolod Kremianskii 2021-06-12 19:08:10 +07:00
parent 7f7bc412b4
commit 4480914dc5
11 changed files with 58 additions and 36 deletions

View file

@ -18,9 +18,8 @@
#include "animatedcamera.h"
#include "../../graphics/types.h"
#include "../../graphics/model/models.h"
#include "../../resource/resources.h"
#include "../../scene/node/cameranode.h"
#include "../../scene/node/modelnode.h"
using namespace std;
@ -70,12 +69,12 @@ bool AnimatedCamera::isAnimationFinished() const {
return _model ? _model->isAnimationFinished() : false;
}
void AnimatedCamera::setModel(const shared_ptr<Model> &model) {
void AnimatedCamera::setModel(shared_ptr<Model> model) {
if ((_model && _model->model() == model) ||
(!_model && !model)) return;
if (model) {
_model = make_unique<ModelSceneNode>(model, ModelUsage::Camera, _sceneGraph);
_model = make_unique<ModelSceneNode>(move(model), ModelUsage::Camera, _sceneGraph);
_model->attach("camerahook", _sceneNode);
} else {
_model.reset();

View file

@ -17,15 +17,22 @@
#pragma once
#include "../../scene/node/modelnode.h"
#include "../../scene/scenegraph.h"
#include "../types.h"
#include "camera.h"
namespace reone {
namespace graphics {
class Model;
}
namespace scene {
class ModelSceneNode;
}
namespace game {
const float kDefaultAnimCamFOV = 55.0f;
@ -40,7 +47,7 @@ public:
bool isAnimationFinished() const;
void setModel(const std::shared_ptr<graphics::Model> &model);
void setModel(std::shared_ptr<graphics::Model> model);
void setFieldOfView(float fovy);
private:

View file

@ -17,10 +17,15 @@
#pragma once
#include "../../scene/node/cameranode.h"
namespace reone {
namespace scene {
class CameraSceneNode;
class SceneGraph;
}
namespace game {
class Camera {

View file

@ -17,10 +17,14 @@
#pragma once
#include "../../resource/2da.h"
namespace reone {
namespace resource {
class TwoDA;
}
namespace game {
struct CameraStyle {

View file

@ -17,6 +17,9 @@
#include "dialogcamera.h"
#include "../../graphics/types.h"
#include "../../scene/node/cameranode.h"
using namespace std;
using namespace reone::graphics;
@ -31,16 +34,16 @@ DialogCamera::DialogCamera(float aspect, const CameraStyle &style, SceneGraph *s
_sceneNode = make_shared<CameraSceneNode>("", move(projection), sceneGraph);
}
void DialogCamera::setSpeakerPosition(const glm::vec3 &position) {
void DialogCamera::setSpeakerPosition(glm::vec3 position) {
if (_speakerPosition != position) {
_speakerPosition = position;
_speakerPosition = move(position);
updateSceneNode();
}
}
void DialogCamera::setListenerPosition(const glm::vec3 &position) {
void DialogCamera::setListenerPosition(glm::vec3 position) {
if (_listenerPosition != position) {
_listenerPosition = position;
_listenerPosition = move(position);
updateSceneNode();
}
}
@ -52,8 +55,8 @@ void DialogCamera::setVariant(Variant variant) {
}
}
void DialogCamera::setFindObstacle(const function<bool(const glm::vec3 &, const glm::vec3 &, glm::vec3 &)> &fn) {
_findObstacle = fn;
void DialogCamera::setFindObstacle(function<bool(const glm::vec3 &, const glm::vec3 &, glm::vec3 &)> fn) {
_findObstacle = move(fn);
}
void DialogCamera::updateSceneNode() {

View file

@ -17,8 +17,6 @@
#pragma once
#include "../../scene/scenegraph.h"
#include "../types.h"
#include "camera.h"
@ -40,10 +38,10 @@ public:
DialogCamera(float aspect, const CameraStyle &style, scene::SceneGraph *sceneGraph);
void setSpeakerPosition(const glm::vec3 &position);
void setListenerPosition(const glm::vec3 &position);
void setSpeakerPosition(glm::vec3 position);
void setListenerPosition(glm::vec3 position);
void setVariant(Variant variant);
void setFindObstacle(const std::function<bool(const glm::vec3 &, const glm::vec3 &, glm::vec3 &)> &fn);
void setFindObstacle(std::function<bool(const glm::vec3 &, const glm::vec3 &, glm::vec3 &)> fn);
private:
glm::vec3 _speakerPosition { 0.0f };

View file

@ -18,6 +18,7 @@
#include "firstperson.h"
#include "../../graphics/types.h"
#include "../../scene/node/cameranode.h"
using namespace std;

View file

@ -44,9 +44,10 @@ private:
bool _moveRight { false };
bool handleMouseMotion(const SDL_MouseMotionEvent &event);
void updateSceneNode();
bool handleKeyDown(const SDL_KeyboardEvent &event);
bool handleKeyUp(const SDL_KeyboardEvent &event);
void updateSceneNode();
};
} // namespace game

View file

@ -17,6 +17,8 @@
#include "thirdperson.h"
#include "../../scene/node/cameranode.h"
#include "../game.h"
using namespace std;
@ -173,8 +175,8 @@ void ThirdPersonCamera::stopMovement() {
_mouseLookMode = false;
}
void ThirdPersonCamera::setTargetPosition(const glm::vec3 &position) {
_targetPosition = position;
void ThirdPersonCamera::setTargetPosition(glm::vec3 position) {
_targetPosition = move(position);
updateSceneNode();
}
@ -187,8 +189,8 @@ void ThirdPersonCamera::setFindObstacle(const function<bool(const glm::vec3 &, c
_findObstacle = fn;
}
void ThirdPersonCamera::setStyle(const CameraStyle &style) {
_style = style;
void ThirdPersonCamera::setStyle(CameraStyle style) {
_style = move(style);
updateSceneNode();
}

View file

@ -17,8 +17,6 @@
#pragma once
#include "../types.h"
#include "camera.h"
#include "camerastyle.h"
@ -36,10 +34,10 @@ public:
void update(float dt) override;
void stopMovement() override;
void setTargetPosition(const glm::vec3 &position);
void setTargetPosition(glm::vec3 position);
void setFacing(float facing);
void setFindObstacle(const std::function<bool(const glm::vec3 &, const glm::vec3 &, glm::vec3 &)> &fn);
void setStyle(const CameraStyle& style);
void setStyle(CameraStyle style);
private:
Game *_game;

View file

@ -17,10 +17,14 @@
#pragma once
#include "../audio/stream.h"
namespace reone {
namespace audio {
class AudioStream;
}
namespace game {
constexpr int kNpcPlayer = -1;