Added a new World class and made Viewport inherit from it.

This commit is contained in:
Relintai 2022-08-29 18:40:38 +02:00
parent b886d14cf5
commit aba4e9db3c
6 changed files with 42 additions and 6 deletions

View File

@ -1,5 +1,6 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
/*************************************************************************/
/* viewport.h */
/*************************************************************************/
@ -30,6 +31,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "world.h"
#include "core/math/transform_2d.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
@ -87,8 +89,8 @@ public:
~ViewportTexture();
};
class Viewport : public Node {
GDCLASS(Viewport, Node);
class Viewport : public World {
GDCLASS(Viewport, World);
public:
enum UpdateMode {

12
scene/main/world.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "world.h"
World::World() {
}
World::~World() {
}
void World::_notification(int p_what) {
}
void World::_bind_methods() {
}

19
scene/main/world.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef WORLD_H
#define WORLD_H
#include "node.h"
class World : public Node {
GDCLASS(World, Node);
public:
World();
~World();
protected:
void _notification(int p_what);
static void _bind_methods();
};
#endif

View File

@ -133,6 +133,7 @@
#include "scene/main/resource_preloader.h"
#include "scene/main/scene_tree.h"
#include "scene/main/timer.h"
#include "scene/main/world.h"
#include "scene/main/viewport.h"
#include "scene/resources/audio_stream_sample.h"
#include "scene/resources/bit_map.h"
@ -277,6 +278,7 @@ void register_scene_types() {
ClassDB::register_class<Node>();
ClassDB::register_virtual_class<InstancePlaceholder>();
ClassDB::register_class<World>();
ClassDB::register_class<Viewport>();
ClassDB::register_class<ViewportTexture>();
ClassDB::register_class<HTTPRequest>();

View File

@ -1,5 +1,6 @@
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#ifndef ENVIRONMENT_3D_H
#define ENVIRONMENT_3D_H
/*************************************************************************/
/* environment.h */
/*************************************************************************/
@ -418,4 +419,4 @@ VARIANT_ENUM_CAST(Environment3D::DOFBlurQuality)
VARIANT_ENUM_CAST(Environment3D::SSAOQuality)
VARIANT_ENUM_CAST(Environment3D::SSAOBlur)
#endif // ENVIRONMENT_H
#endif // ENVIRONMENT_3D_H

View File

@ -87,4 +87,4 @@ public:
~World3D();
};
#endif // WORLD_H
#endif // WORLD_3D_H