Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _SCENE_GRAPH_H_
#define _SCENE_GRAPH_H_

#include "Octree.h"
#include "Scenes/Headers/SceneComponent.h"
#include "Rendering/Headers/FrameListener.h"

namespace Divide {
class Ray;
class SceneState;

namespace Attorney {
    class SceneGraphSGN;
};

class SceneGraph : private NonCopyable,
                   public FrameListener,
                   public SceneComponent
{

    friend class Attorney::SceneGraphSGN;
   public:
    explicit SceneGraph(Scene& parentScene);
    ~SceneGraph();

    void unload();

    inline const SceneGraphNode& getRoot() const {
        return *_root;
    }

    inline SceneGraphNode& getRoot() {
        return *_root;
    }

    inline SceneGraphNode* findNode(const stringImpl& name, bool sceneNodeName = false) const {
        if (sceneNodeName ? _root->getNode()->getName().compare(name) == 0
                          : _root->getName().compare(name) == 0) {
            return _root;
        }

        return _root->findChild(name, sceneNodeName, true);
    }

    inline SceneGraphNode* findNode(I64 guid) const {
        if (_root->getGUID() == guid) {
            return _root;
        }

        return _root->findChild(guid, true);
    }

    inline Octree& getOctree() {
        return *_octree;
    }

    inline const Octree& getOctree() const {
        return *_octree;
    }

    /// Update all nodes. Called from "updateSceneState" from class Scene
    void sceneUpdate(const U64 deltaTimeUS, SceneState& sceneState);

    void idle();

    void intersect(const Ray& ray, F32 start, F32 end, vectorImpl<I64>& selectionHits) const;

    // If this function returns true, the node was successfully removed (or queued for removal)
    bool removeNode(I64 guid);
    bool removeNode(SceneGraphNode* node);
    // If this function returns true, nodes of the specified type were successfully removed (or queued for removal)
    bool removeNodesByType(SceneNodeType nodeType);

    void onCameraUpdate(const Camera& camera);
    void onCameraChange(const Camera& camera);
    void onNetworkSend(U32 frameCount);

    void postLoad();

    const vectorImpl<SceneGraphNode*>& getNodesByType(SceneNodeType type) const;

   protected:
    void onNodeDestroy(SceneGraphNode& oldNode);
    void onNodeAdd(SceneGraphNode& newNode);
    void onNodeTransform(SceneGraphNode& node);

    void unregisterNode(I64 guid, SceneGraphNode::UsageContext usage);

    bool frameStarted(const FrameEvent& evt);
    bool frameEnded(const FrameEvent& evt);

   private:
    bool _loadComplete;
    bool _octreeChanged;
    SceneRoot_ptr _rootNode;
    SceneGraphNode* _root;
    std::shared_ptr<Octree> _octree;
    std::atomic_bool _octreeUpdating;
    vectorImpl<SceneGraphNode*> _allNodes;
    vectorImpl<SceneGraphNode*> _orderedNodeList;

    std::array<vectorImpl<SceneGraphNode*>, to_base(SceneNodeType::COUNT)> _nodesByType;
};

namespace Attorney {
class SceneGraphSGN {
   private:
    static void onNodeAdd(SceneGraph& sceneGraph, SceneGraphNode& newNode) {
        sceneGraph.onNodeAdd(newNode);
    }

    static void onNodeDestroy(SceneGraph& sceneGraph, SceneGraphNode& oldNode) {
        sceneGraph.onNodeDestroy(oldNode);
    }

    static void onNodeUsageChange(SceneGraph& sceneGraph, 
                                  SceneGraphNode& node,
                                  SceneGraphNode::UsageContext oldUsage,
                                  SceneGraphNode::UsageContext newUsage)
    {
        ACKNOWLEDGE_UNUSED(oldUsage);
        ACKNOWLEDGE_UNUSED(newUsage);

        sceneGraph.unregisterNode(node.getGUID(), node.usageContext());

    }

    static void onNodeTransform(SceneGraph& sceneGraph, SceneGraphNode& node)
    {
        sceneGraph.onNodeTransform(node);
    }
             
    friend class Divide::SceneGraphNode;
};

};  // namespace Attorney

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Graphs/Headers/SceneGraph.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

1026 Diff Diff IonutCava picture IonutCava Mon 29 Jan, 2018 17:43:26 +0000

[Ionut]
- More work on editor:
— Initial implementation of component listing and editing

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

990 Diff Diff IonutCava picture IonutCava Tue 05 Dec, 2017 17:20:10 +0000

[Ionut]
- Some SceneGraph and SceneGraphNode cleanup

968 Diff Diff IonutCava picture IonutCava Tue 07 Nov, 2017 17:32:31 +0000

[Ionut]
- Consistent naming between timing variables

957 Diff Diff IonutCava picture IonutCava Tue 31 Oct, 2017 17:15:51 +0000

[Ionut]
- Some SGN node search refactoring
- typedef PlayerIndex

950 Diff Diff IonutCava picture IonutCava Sun 22 Oct, 2017 22:25:05 +0000

[Ionut]
- Revamp camera management
- More work on improving the command buffer system:
— Performance tweaks
— Validation
— Debug features
- Some code cleanup for Object3D stuff (preRender/onRender changes)

Still haven’t fixed random flashing issue

949 Diff Diff IonutCava picture IonutCava Thu 19 Oct, 2017 21:48:37 +0000

[Ionut]
- More command buffer refactoring

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

886 IonutCava picture IonutCava Wed 29 Mar, 2017 23:36:51 +0000

[Ionut]
- Initial code for multiple water block support (position + length/width/depth)