summaryrefslogtreecommitdiff
path: root/apps/opencs/view/render/cellwater.hpp
blob: 47e5867071cb0fdf7aa806e285740aa5c9b5f103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef CSV_RENDER_CELLWATER_H
#define CSV_RENDER_CELLWATER_H

#include <string>

#include <osg/ref_ptr>

#include <QObject>
#include <QModelIndex>

#include "../../model/world/record.hpp"

namespace osg
{
    class Geode;
    class Geometry;
    class Group;
    class PositionAttitudeTransform;
}

namespace CSMWorld
{
    struct Cell;
    class CellCoordinates;
    class Data;
}

namespace CSVRender
{
    /// For exterior cells, this adds a patch of water to fit the size of the cell. For interior cells with water, this
    /// adds a large patch of water much larger than the typical size of a cell.
    class CellWater : public QObject
    {
            Q_OBJECT

        public:

            CellWater(CSMWorld::Data& data, osg::Group* cellNode, const std::string& id,
                const CSMWorld::CellCoordinates& cellCoords);

            ~CellWater();

            void updateCellData(const CSMWorld::Record<CSMWorld::Cell>& cellRecord);

            void reloadAssets();

        private slots:

            void cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);

        private:

            void recreate();

            static const int CellSize;

            CSMWorld::Data& mData;
            std::string mId;

            osg::Group* mParentNode;

            osg::ref_ptr<osg::PositionAttitudeTransform> mWaterTransform;
            osg::ref_ptr<osg::Geode> mWaterNode;
            osg::ref_ptr<osg::Geometry> mWaterGeometry;

            bool mDeleted;
            bool mExterior;
            bool mHasWater;
    };
}

#endif