Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_SCENE_H_
34#define DVD_SCENE_H_
35
36#include "SceneState.h"
37#include "SceneInput.h"
38
44
45namespace Divide {
46
47class Sky;
48class GUI;
49class Light;
50class Project;
51class Object3D;
52class LoadSave;
53class ByteBuffer;
54class IMPrimitive;
55class ParticleData;
56class ParamHandler;
57class ProjectManager;
58class SceneGraphNode;
59class ParticleEmitter;
60class PlatformContext;
61class SceneShaderData;
62class RenderPassManager;
64class EnvironmentProbeComponent;
65
66struct SceneEntry;
67struct ResourceDescriptorBase;
68
73FWD_DECLARE_MANAGED_CLASS(SceneGUIElements);
75
76namespace AI {
78}
79
80namespace GFX
81{
82 class CommandBuffer;
83 struct MemoryBarrierCommand;
84}
85
86namespace Attorney {
87 class SceneProjectManager;
88 class SceneGraph;
89 class SceneRenderPass;
90 class SceneLoadSave;
91 class SceneGUI;
92 class SceneInput;
93 class SceneEnvironmentProbeComponent;
94}
95
97{
98 static constexpr U8 MAX_SELECTIONS = 254u;
99
100 std::array<I64, MAX_SELECTIONS> _selections = create_array<MAX_SELECTIONS, I64>(-1);
102};
103
105{
108 bool _isDragging = false;
109};
110
112{
114};
115
117using PlayerList = eastl::array<Player_ptr, Config::MAX_LOCAL_PLAYER_COUNT>;
118
124 friend class Attorney::SceneGUI;
127
128 public:
129 static constexpr U32 SUN_LIGHT_TAG = 0xFFF0F0;
130
132
134 {
135 Sky* _skyInstance = nullptr;
140 SimpleTime _time = { 14u, 30u };
141 SimpleLocation _location = { 51.4545f, -2.5879f };
142 bool _resetTime = true;
143 };
144
146 [[nodiscard]] static ResourcePath GetSceneFullPath( const Scene& scene );
148 [[nodiscard]] static ResourcePath GetSceneRootFolder( const Project& project );
149
150 protected:
151 static bool OnStartup(PlatformContext& context);
152 static bool OnShutdown(PlatformContext& context);
153 static string GetPlayerSGNName(PlayerIndex idx);
154
155 public:
156
158 virtual ~Scene() override;
159
161 [[nodiscard]] bool idle();
162
163 [[nodiscard]] inline Project& parent() noexcept { return _parent; }
164 [[nodiscard]] inline const Project& parent() const noexcept { return _parent; }
165
166#pragma region Logic Loop
168 virtual void processInput(PlayerIndex idx, U64 gameDeltaTimeUS, U64 appDeltaTimeUS );
170 virtual void processTasks( U64 gameDeltaTimeUS, U64 appDeltaTimeUS );
171 virtual void processGUI(U64 gameDeltaTimeUS, U64 appDeltaTimeUS);
173 virtual void onChangeFocus(bool hasFocus);
174 virtual void updateSceneStateInternal(U64 deltaTimeUS);
176 void updateSceneState(U64 deltaTimeUS);
177
178#pragma endregion
179
180#pragma region Task Management
181 void registerTask(Task& taskItem, bool start = true, TaskPriority priority = TaskPriority::DONT_CARE);
182 void clearTasks();
183 void removeTask(const Task& task);
184#pragma endregion
185
186#pragma region Object Picking
187 [[nodiscard]] const Selections& getCurrentSelection(const PlayerIndex index = 0) const;
188 [[nodiscard]] bool findSelection(PlayerIndex idx, bool clearOld);
189
190 [[nodiscard]] bool resetSelection(PlayerIndex idx, const bool resetIfLocked);
191 void setSelected(PlayerIndex idx, const vector<SceneGraphNode*>& SGNs, bool recursive);
192
193 void beginDragSelection(PlayerIndex idx, vec2<I32> mousePos);
194 void endDragSelection(PlayerIndex idx, bool clearSelection);
195#pragma endregion
196
197#pragma region Entity Management
198 void addMusic(MusicType type, const std::string_view name, const ResourcePath& srcFile);
199 [[nodiscard]] SceneGraphNode* addSky(SceneGraphNode* parentNode, const boost::property_tree::ptree& pt, const Str<64>& nodeName = "");
200 [[nodiscard]] SceneGraphNode* addInfPlane(SceneGraphNode* parentNode, const boost::property_tree::ptree& pt, const Str<64>& nodeName = "");
201 void addWater(SceneGraphNode* parentNode, const boost::property_tree::ptree& pt, const Str<64>& nodeName = "");
202 void addTerrain(SceneGraphNode* parentNode, const boost::property_tree::ptree& pt, const Str<64>& nodeName = "");
203 [[nodiscard]] SceneGraphNode* addParticleEmitter(const std::string_view name, std::shared_ptr<ParticleData> data,SceneGraphNode* parentNode);
204#pragma endregion
205
206#pragma region Time Of Day
207 void initDayNightCycle(Sky& skyInstance, DirectionalLightComponent& sunLight) noexcept;
208
210 void setDayNightCycleTimeFactor(F32 factor) noexcept;
211 [[nodiscard]] F32 getDayNightCycleTimeFactor() const noexcept;
212
213 void setTimeOfDay(const SimpleTime& time) noexcept;
214 [[nodiscard]] const SimpleTime& getTimeOfDay() const noexcept;
215
216 void setGeographicLocation(const SimpleLocation& location) noexcept;
217 [[nodiscard]] const SimpleLocation& getGeographicLocation() const noexcept;
218
219 [[nodiscard]] vec3<F32> getSunPosition() const;
220 [[nodiscard]] vec3<F32> getSunDirection() const;
221 [[nodiscard]] SunInfo getCurrentSunDetails() const noexcept;
222 [[nodiscard]] Atmosphere getCurrentAtmosphere() const noexcept;
223 void setCurrentAtmosphere(const Atmosphere& atmosphere) const noexcept;
224#pragma endregion
225
226#pragma region Player Camera
227 [[nodiscard]] Camera* playerCamera(const bool skipOverride = false) const;
228 [[nodiscard]] Camera* playerCamera(U8 index, const bool skipOverride = false) const;
229 bool lockCameraToPlayerMouse(PlayerIndex index, bool lockState) const noexcept;
230#pragma endregion
231
233 PROPERTY_R(SceneState_uptr, state);
234 PROPERTY_RW(bool, dayNightCycleEnabled, true);
236 PROPERTY_R(SceneGraph_uptr, sceneGraph);
237 PROPERTY_R(AI::AIManager_uptr, aiManager);
238 PROPERTY_R(SceneGUIElements_uptr, GUI);
239 PROPERTY_R(LightPool_uptr, lightPool);
240 PROPERTY_R(SceneInput_uptr, input);
241 PROPERTY_R(SceneEnvironmentProbePool_uptr, envProbePool);
242 PROPERTY_R_IW(bool, loadComplete, false);
243 PROPERTY_R_IW(U64, sceneRuntimeUS, 0ULL);
245 PROPERTY_R(U8, playerCount, 0u);
246
247 protected:
248 enum class TimerClass : U8
249 {
250 GAME_TIME = 0,
251 APP_TIME,
252 COUNT
253 };
254
255 virtual void onSetActive();
256 virtual void onRemoveActive();
257 [[nodiscard]] virtual bool frameStarted();
258 [[nodiscard]] virtual bool frameEnded();
259
261 [[nodiscard]] virtual U16 registerInputActions();
262
263 void onNodeDestroy(SceneGraphNode* node);
264 void loadAsset(const Task* parentTask, const XML::SceneNode& sceneNode, SceneGraphNode* parent);
265
267 virtual void debugDraw(GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
269 virtual void drawCustomUI( const Rect<I32>& targetViewport, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
271 [[nodiscard]] virtual bool mouseMoved(const Input::MouseMoveEvent& arg);
272
273#pragma region Save Load
274 [[nodiscard]] virtual bool save(ByteBuffer& outputBuffer) const;
275 [[nodiscard]] virtual bool load(ByteBuffer& inputBuffer);
276
278 [[nodiscard]] virtual bool saveXML(const DELEGATE<void, std::string_view>& msgCallback, const DELEGATE<void, bool>& finishCallback) const;
279
280 [[nodiscard]] bool saveNodeToXML(const SceneGraphNode* node) const;
281 [[nodiscard]] bool loadNodeFromXML(SceneGraphNode* node) const;
282 [[nodiscard]] virtual bool loadXML();
283
284 [[nodiscard]] virtual bool load();
285 [[nodiscard]] virtual bool unload();
286 [[nodiscard]] virtual bool postLoad();
288 virtual void postLoadMainThread();
289#pragma endregion
290
291#pragma region Player Management
292 void findHoverTarget(PlayerIndex idx, vec2<I32> aimPos);
295
296 void addPlayerInternal(bool queue);
298 void onPlayerAdd(const Player_ptr& player);
299 void onPlayerRemove(const Player_ptr& player);
301
302 [[nodiscard]] U8 getSceneIndexForPlayer(PlayerIndex idx) const;
303 [[nodiscard]] Player* getPlayerForIndex(PlayerIndex idx) const;
304 [[nodiscard]] U8 getPlayerIndexForDevice(U8 deviceIndex) const;
305#pragma endregion
306
307 void addGuiTimer( TimerClass intervalClass, U64 intervalUS, DELEGATE<void, U64/*elapsed time*/> cbk);
308 void addTaskTimer( TimerClass intervalClass, U64 intervalUS, DELEGATE<void, U64/*elapsed time*/> cbk);
309
310 private:
312 {
317 DELEGATE<void, U64/*elapsed time US*/> _cbk;
318 };
319
320 private:
321 void processInternalTimers( U64 appDeltaUS, U64 gameDeltaUS, vector<TimerStruct>& timers );
323 bool updateCameraControls(PlayerIndex idx) const;
325 [[nodiscard]] bool checkCameraUnderwater(PlayerIndex idx) const;
326 [[nodiscard]] bool checkCameraUnderwater(const Camera& camera) const noexcept;
327
328 protected:
330
332
333 std::atomic_uint _loadingTasks{0u};
337
338 std::array<Selections, Config::MAX_LOCAL_PLAYER_COUNT> _currentSelection;
339 std::array<Selections, Config::MAX_LOCAL_PLAYER_COUNT> _tempSelection;
340 std::array<I64, Config::MAX_LOCAL_PLAYER_COUNT> _currentHoverTarget;
341 std::array<DragSelectData, Config::MAX_LOCAL_PLAYER_COUNT> _dragSelectData;
342 std::array<SceneGraphNode*, Config::MAX_LOCAL_PLAYER_COUNT> _flashLight;
343 std::array<U32, Config::MAX_LOCAL_PLAYER_COUNT> _cameraUpdateListeners;
344
345 private:
349
352};
353
354namespace Attorney {
356{
357 private:
358 static bool loadComplete(Scene* scene) noexcept
359 {
360 return scene->loadComplete();
361 }
362
363 static void onPlayerAdd(Scene* scene, const Player_ptr& player) {
364 scene->onPlayerAdd(player);
365 }
366
367 static void onPlayerRemove(Scene* scene, const Player_ptr& player) {
368 scene->onPlayerRemove(player);
369 }
370
371 static void currentPlayerPass(Scene* scene, const PlayerIndex idx) {
372 scene->currentPlayerPass(idx);
373 }
374
375 static void debugDraw(Scene* scene, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut ) {
376 scene->debugDraw(bufferInOut, memCmdInOut);
377 }
378
379 static void drawCustomUI(Scene* scene, const Rect<I32>& targetViewport, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut ) {
380 scene->drawCustomUI(targetViewport, bufferInOut, memCmdInOut);
381 }
382
383 static bool frameStarted(Scene* scene) {
384 return scene->frameStarted();
385 }
386
387 static bool frameEnded(Scene* scene) {
388 return scene->frameEnded();
389 }
390
391 static bool load(Scene* scene) {
392 return scene->load();
393 }
394
395 static bool unload(Scene* scene) {
396 return scene->unload();
397 }
398
399 static void postLoadMainThread(Scene* scene) {
400 scene->postLoadMainThread();
401 }
402
403 static void onSetActive(Scene* scene) {
404 scene->onSetActive();
405 }
406
407 static void onRemoveActive(Scene* scene)
408 {
409 scene->onRemoveActive();
410 }
411
412 static bool onStartup(PlatformContext& context) {
413 return Scene::OnStartup(context);
414 }
415
416 static bool onShutdown(PlatformContext& context) {
417 return Scene::OnShutdown(context);
418 }
419
420 static SceneGUIElements* gui(Scene* scene) noexcept {
421 return scene->_GUI.get();
422 }
423
424 static bool resetSelection(Scene* scene, const PlayerIndex idx, const bool resetIfLocked) {
425 return scene->resetSelection(idx, resetIfLocked);
426 }
427
428 static void setSelected(Scene* scene, const PlayerIndex idx, const vector<SceneGraphNode*>& sgns, const bool recursive) {
429 scene->setSelected(idx, sgns, recursive);
430 }
431
432 static void clearHoverTarget(Scene* scene, const Input::MouseMoveEvent& arg) {
433 scene->clearHoverTarget(scene->input()->getPlayerIndexForDevice(arg._deviceIndex));
434 }
435
437 return scene->_envProbePool.get();
438 }
439
440 [[nodiscard]] static PlayerList& getPlayers( Scene* scene) noexcept
441 {
442 return scene->_scenePlayers;
443 }
444
445 friend class Divide::Project;
447};
448
451 {
452 return scene->_envProbePool.get();
453 }
454
455 friend class Divide::RenderPass;
457};
458
460{
461 static void registerProbe(Scene* scene, EnvironmentProbeComponent* probe);
462 static void unregisterProbe(Scene* scene, const EnvironmentProbeComponent* const probe);
463
465};
466
468 static bool save(const Scene* scene, ByteBuffer& outputBuffer) {
469 return scene->save(outputBuffer);
470 }
471
472 static bool load(Scene* scene, ByteBuffer& inputBuffer) {
473 return scene->load(inputBuffer);
474 }
475
476 static bool saveNodeToXML(Scene* scene, const SceneGraphNode* node) {
477 return scene->saveNodeToXML(node);
478 }
479
480 static bool loadNodeFromXML(Scene* scene, SceneGraphNode* node) {
481 return scene->loadNodeFromXML(node);
482 }
483
484 static bool saveXML(Scene* scene, const DELEGATE<void, std::string_view>& msgCallback, const DELEGATE<void, bool>& finishCallback ) {
485 return scene->saveXML(msgCallback, finishCallback);
486 }
487
488 friend class Divide::LoadSave;
489};
490
492 static void onNodeDestroy(Scene* scene, SceneGraphNode* node) {
493 scene->onNodeDestroy(node);
494 }
495
497 return scene->_envProbePool.get();
498 }
499
500 static LightPool* getLightPool(Scene* scene) noexcept {
501 return scene->lightPool().get();
502 }
503
504 static void addSceneGraphToLoad(Scene* scene, const XML::SceneNode&& rootNode) {
505 scene->_xmlSceneGraphRootNode = rootNode;
506 }
507
508 friend class Divide::SceneGraph;
509};
510
511class SceneGUI {
512 static SceneGUIElements* guiElements(Scene* scene) noexcept {
513 return scene->_GUI.get();
514 }
515
516 friend class Divide::GUI;
517};
518
520 static bool mouseMoved(Scene* scene, const Input::MouseMoveEvent& arg) {
521 return scene->mouseMoved(arg);
522 }
523
524 friend class Divide::SceneInput;
525};
526
527} // namespace Attorney
528
529#pragma region Scene Factory
530namespace SceneList {
531 template<typename T>
532 using SharedPtrFactory = boost::factory<std::shared_ptr<T>>;
533 using ScenePtrFactory = std::function<std::shared_ptr<Scene>(PlatformContext& context, Project& parent, const SceneEntry& name)>;
534 using SceneFactoryMap = std::unordered_map<U64, ScenePtrFactory>;
535 using SceneNameMap = std::unordered_map<U64, Str<256>>;
536
537 void registerSceneFactory(const char* name, const ScenePtrFactory& factoryFunc);
538
539 template<typename T>
540 inline void registerScene(const char* name, const SharedPtrFactory<T>& scenePtr) {
541 registerSceneFactory(name, scenePtr);
542 }
543}
544
545#define STRUCT_NAME(M) BOOST_PP_CAT(M, RegisterStruct)
546#define REGISTER_SCENE(SceneName) \
547class SceneName; \
548static struct STRUCT_NAME(SceneName) { \
549 STRUCT_NAME(SceneName)() \
550 { \
551 SceneList::registerScene(#SceneName, SceneList::SharedPtrFactory<SceneName>()); \
552 } \
553} BOOST_PP_CAT(SceneName, RegisterVariable);
554#define BEGIN_SCENE(SceneName) \
555REGISTER_SCENE(SceneName); \
556class SceneName final : public Scene { \
557 public:
558#define END_SCENE(SceneName) };
559#pragma endregion
560
561} // namespace Divide
562
563#endif //DVD_SCENE_H
#define FWD_DECLARE_MANAGED_CLASS(T)
static void unregisterProbe(Scene *scene, const EnvironmentProbeComponent *const probe)
Definition: Scene.cpp:2419
static void registerProbe(Scene *scene, EnvironmentProbeComponent *probe)
Definition: Scene.cpp:2412
static SceneGUIElements * guiElements(Scene *scene) noexcept
Definition: Scene.h:512
static LightPool * getLightPool(Scene *scene) noexcept
Definition: Scene.h:500
static void onNodeDestroy(Scene *scene, SceneGraphNode *node)
Definition: Scene.h:492
static void addSceneGraphToLoad(Scene *scene, const XML::SceneNode &&rootNode)
Definition: Scene.h:504
static SceneEnvironmentProbePool * getEnvProbes(Scene *scene) noexcept
Definition: Scene.h:496
static bool mouseMoved(Scene *scene, const Input::MouseMoveEvent &arg)
Definition: Scene.h:520
static bool saveXML(Scene *scene, const DELEGATE< void, std::string_view > &msgCallback, const DELEGATE< void, bool > &finishCallback)
Definition: Scene.h:484
static bool load(Scene *scene, ByteBuffer &inputBuffer)
Definition: Scene.h:472
static bool save(const Scene *scene, ByteBuffer &outputBuffer)
Definition: Scene.h:468
static bool saveNodeToXML(Scene *scene, const SceneGraphNode *node)
Definition: Scene.h:476
static bool loadNodeFromXML(Scene *scene, SceneGraphNode *node)
Definition: Scene.h:480
static bool onShutdown(PlatformContext &context)
Definition: Scene.h:416
static void postLoadMainThread(Scene *scene)
Definition: Scene.h:399
static void drawCustomUI(Scene *scene, const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Definition: Scene.h:379
static bool resetSelection(Scene *scene, const PlayerIndex idx, const bool resetIfLocked)
Definition: Scene.h:424
static void onSetActive(Scene *scene)
Definition: Scene.h:403
static bool load(Scene *scene)
Definition: Scene.h:391
static bool frameEnded(Scene *scene)
Definition: Scene.h:387
static bool onStartup(PlatformContext &context)
Definition: Scene.h:412
static PlayerList & getPlayers(Scene *scene) noexcept
Definition: Scene.h:440
static bool loadComplete(Scene *scene) noexcept
Definition: Scene.h:358
static bool unload(Scene *scene)
Definition: Scene.h:395
static void onPlayerRemove(Scene *scene, const Player_ptr &player)
Definition: Scene.h:367
static void onPlayerAdd(Scene *scene, const Player_ptr &player)
Definition: Scene.h:363
static void onRemoveActive(Scene *scene)
Definition: Scene.h:407
static bool frameStarted(Scene *scene)
Definition: Scene.h:383
static SceneEnvironmentProbePool * getEnvProbes(Scene *scene) noexcept
Definition: Scene.h:436
static void currentPlayerPass(Scene *scene, const PlayerIndex idx)
Definition: Scene.h:371
static void debugDraw(Scene *scene, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Definition: Scene.h:375
static SceneGUIElements * gui(Scene *scene) noexcept
Definition: Scene.h:420
static void clearHoverTarget(Scene *scene, const Input::MouseMoveEvent &arg)
Definition: Scene.h:432
static void setSelected(Scene *scene, const PlayerIndex idx, const vector< SceneGraphNode * > &sgns, const bool recursive)
Definition: Scene.h:428
static SceneEnvironmentProbePool * getEnvProbes(Scene *scene) noexcept
Definition: Scene.h:450
Graphical User Interface.
Definition: GUI.h:81
IMPrimitive replaces immediate mode calls to VB based rendering.
Definition: IMPrimitive.h:58
PlatformContext & context() noexcept
User controlled Unit.
Definition: Player.h:45
virtual bool save(ByteBuffer &outputBuffer) const
Definition: Scene.cpp:2347
PROPERTY_R(SceneGraph_uptr, sceneGraph)
static bool OnStartup(PlatformContext &context)
Definition: Scene.cpp:110
PROPERTY_R(LightPool_uptr, lightPool)
static I64 DEFAULT_SCENE_GUID
Definition: Scene.h:131
PROPERTY_R_IW(DayNightData, dayNightData)
void removeTask(const Task &task)
Definition: Scene.cpp:1649
IMPrimitive * _linesPrimitive
Definition: Scene.h:335
void setSelected(PlayerIndex idx, const vector< SceneGraphNode * > &SGNs, bool recursive)
Definition: Scene.cpp:2086
vec3< F32 > getSunPosition() const
Definition: Scene.cpp:2300
virtual ~Scene() override
Definition: Scene.cpp:102
bool resetSelection(PlayerIndex idx, const bool resetIfLocked)
Definition: Scene.cpp:2060
void updateSceneState(U64 deltaTimeUS)
Update animations, network data, sounds, triggers etc.
Definition: Scene.cpp:1585
virtual void postLoadMainThread()
Gets called on the main thread when the scene finishes loading (e.g. used by the GUI system)
Definition: Scene.cpp:1353
PROPERTY_R(SceneState_uptr, state)
Contains all game related info for the scene (wind speed, visibility ranges, etc)
std::array< Selections, Config::MAX_LOCAL_PLAYER_COUNT > _currentSelection
Definition: Scene.h:338
static ResourcePath GetSceneRootFolder(const Project &project)
Return the full path to the location of Scenes folder in the project (e.g. ./Projects/Foo/Scenes/ for...
Definition: Scene.cpp:128
const SimpleTime & getTimeOfDay() const noexcept
Definition: Scene.cpp:2284
vector< size_t > _selectionCallbackIndices
Definition: Scene.h:336
Player * getPlayerForIndex(PlayerIndex idx) const
Definition: Scene.cpp:1523
virtual void debugDraw(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Draw debug entities.
Definition: Scene.cpp:1868
const Project & parent() const noexcept
Definition: Scene.h:164
PROPERTY_RW(bool, dayNightCycleEnabled, true)
U8 getSceneIndexForPlayer(PlayerIndex idx) const
Definition: Scene.cpp:1509
std::array< U32, Config::MAX_LOCAL_PLAYER_COUNT > _cameraUpdateListeners
Definition: Scene.h:343
PROPERTY_R(SceneInput_uptr, input)
virtual bool frameEnded()
Definition: Scene.cpp:138
vector< TimerStruct > _taskTimers
Definition: Scene.h:350
bool findSelection(PlayerIndex idx, bool clearOld)
Definition: Scene.cpp:2105
vector< TimerStruct > _guiTimers
Definition: Scene.h:351
virtual void drawCustomUI(const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Draw custom ui elements.
Definition: Scene.cpp:1857
void onNodeDestroy(SceneGraphNode *node)
Definition: Scene.cpp:2031
PROPERTY_R_IW(U64, sceneRuntimeUS, 0ULL)
virtual void processTasks(U64 gameDeltaTimeUS, U64 appDeltaTimeUS)
Update the scene based on the inputs.
Definition: Scene.cpp:1724
virtual void processGUI(U64 gameDeltaTimeUS, U64 appDeltaTimeUS)
Definition: Scene.cpp:1719
void toggleFlashlight(PlayerIndex idx)
Definition: Scene.cpp:706
virtual bool postLoad()
Definition: Scene.cpp:1344
void addTaskTimer(TimerClass intervalClass, U64 intervalUS, DELEGATE< void, U64 > cbk)
Definition: Scene.cpp:1682
void addGuiTimer(TimerClass intervalClass, U64 intervalUS, DELEGATE< void, U64 > cbk)
Definition: Scene.cpp:1667
vector< Task * > _tasks
Definition: Scene.h:347
bool saveNodeToXML(const SceneGraphNode *node) const
Definition: Scene.cpp:181
void findHoverTarget(PlayerIndex idx, vec2< I32 > aimPos)
Definition: Scene.cpp:1908
static ResourcePath GetSceneFullPath(const Scene &scene)
Return the full path to the scene's location on disk. It's equivalent to GetSceneRootFolder(scene....
Definition: Scene.cpp:123
static constexpr U32 SUN_LIGHT_TAG
Definition: Scene.h:129
std::array< SceneGraphNode *, Config::MAX_LOCAL_PLAYER_COUNT > _flashLight
Definition: Scene.h:342
vec3< F32 > getSunDirection() const
Definition: Scene.cpp:2309
void updateSelectionData(PlayerIndex idx, DragSelectData &data)
Definition: Scene.cpp:2162
virtual bool frameStarted()
Definition: Scene.cpp:133
void loadAsset(const Task *parentTask, const XML::SceneNode &sceneNode, SceneGraphNode *parent)
Definition: Scene.cpp:417
Atmosphere getCurrentAtmosphere() const noexcept
Definition: Scene.cpp:2329
std::array< Selections, Config::MAX_LOCAL_PLAYER_COUNT > _tempSelection
Definition: Scene.h:339
virtual bool mouseMoved(const Input::MouseMoveEvent &arg)
Return true if input was consumed.
Definition: Scene.cpp:1533
void addWater(SceneGraphNode *parentNode, const boost::property_tree::ptree &pt, const Str< 64 > &nodeName="")
Definition: Scene.cpp:776
SceneGraphNode * addParticleEmitter(const std::string_view name, std::shared_ptr< ParticleData > data, SceneGraphNode *parentNode)
Definition: Scene.cpp:629
bool updateCameraControls(PlayerIndex idx) const
Returns true if the camera was moved/rotated/etc.
Definition: Scene.cpp:1562
virtual void onRemoveActive()
Definition: Scene.cpp:1414
void removePlayerInternal(PlayerIndex idx)
Definition: Scene.cpp:1469
void setCurrentAtmosphere(const Atmosphere &atmosphere) const noexcept
Definition: Scene.cpp:2339
Project & parent() noexcept
Definition: Scene.h:163
Project & _parent
Definition: Scene.h:329
virtual void onChangeFocus(bool hasFocus)
The application has lost or gained focus.
Definition: Scene.cpp:1601
void onPlayerRemove(const Player_ptr &player)
Definition: Scene.cpp:1488
PROPERTY_R(U8, playerCount, 0u)
virtual bool load()
Definition: Scene.cpp:1214
const Selections & getCurrentSelection(const PlayerIndex index=0) const
Definition: Scene.cpp:2100
void endDragSelection(PlayerIndex idx, bool clearSelection)
Definition: Scene.cpp:2232
virtual void updateSceneStateInternal(U64 deltaTimeUS)
Definition: Scene.cpp:1597
void addPlayerInternal(bool queue)
Definition: Scene.cpp:1432
virtual bool loadXML()
Definition: Scene.cpp:315
std::array< DragSelectData, Config::MAX_LOCAL_PLAYER_COUNT > _dragSelectData
Definition: Scene.h:341
SceneGraphNode * addInfPlane(SceneGraphNode *parentNode, const boost::property_tree::ptree &pt, const Str< 64 > &nodeName="")
Definition: Scene.cpp:799
const SimpleLocation & getGeographicLocation() const noexcept
Definition: Scene.cpp:2295
void beginDragSelection(PlayerIndex idx, vec2< I32 > mousePos)
Definition: Scene.cpp:2146
void addMusic(MusicType type, const std::string_view name, const ResourcePath &srcFile)
Definition: Scene.cpp:167
Camera * playerCamera(const bool skipOverride=false) const
Definition: Scene.cpp:2402
PROPERTY_R(AI::AIManager_uptr, aiManager)
virtual void onSetActive()
Definition: Scene.cpp:1383
virtual bool load(ByteBuffer &inputBuffer)
Definition: Scene.cpp:2364
bool lockCameraToPlayerMouse(PlayerIndex index, bool lockState) const noexcept
Definition: Scene.cpp:1183
U8 getPlayerIndexForDevice(U8 deviceIndex) const
Definition: Scene.cpp:1528
void setTimeOfDay(const SimpleTime &time) noexcept
Definition: Scene.cpp:2278
void setGeographicLocation(const SimpleLocation &location) noexcept
Definition: Scene.cpp:2289
virtual bool saveXML(const DELEGATE< void, std::string_view > &msgCallback, const DELEGATE< void, bool > &finishCallback) const
Can save at any time, I guess?
Definition: Scene.cpp:191
PROPERTY_R(SceneEntry, entry)
SunInfo getCurrentSunDetails() const noexcept
Definition: Scene.cpp:2319
void onPlayerAdd(const Player_ptr &player)
Definition: Scene.cpp:1480
PROPERTY_R(SceneEnvironmentProbePool_uptr, envProbePool)
PROPERTY_R(SceneGUIElements_uptr, GUI)
static bool OnShutdown(PlatformContext &context)
Definition: Scene.cpp:117
bool loadNodeFromXML(SceneGraphNode *node) const
Definition: Scene.cpp:186
bool checkCameraUnderwater(PlayerIndex idx) const
Definition: Scene.cpp:1877
SharedMutex _tasksMutex
Definition: Scene.h:346
virtual void processInput(PlayerIndex idx, U64 gameDeltaTimeUS, U64 appDeltaTimeUS)
Get all input commands from the user.
Definition: Scene.cpp:1663
SceneGraphNode * addSky(SceneGraphNode *parentNode, const boost::property_tree::ptree &pt, const Str< 64 > &nodeName="")
Definition: Scene.cpp:747
XML::SceneNode _xmlSceneGraphRootNode
Definition: Scene.h:334
void registerTask(Task &taskItem, bool start=true, TaskPriority priority=TaskPriority::DONT_CARE)
Definition: Scene.cpp:1624
PlayerList _scenePlayers
Definition: Scene.h:331
void clearTasks()
Definition: Scene.cpp:1636
void initDayNightCycle(Sky &skyInstance, DirectionalLightComponent &sunLight) noexcept
Definition: Scene.cpp:2250
static string GetPlayerSGNName(PlayerIndex idx)
Definition: Scene.cpp:1359
void setDayNightCycleTimeFactor(F32 factor) noexcept
Negative values should work.
Definition: Scene.cpp:2268
void clearHoverTarget(PlayerIndex idx)
Definition: Scene.cpp:2015
PROPERTY_R_IW(bool, loadComplete, false)
vector< SGNRayResult > _sceneSelectionCandidates
Definition: Scene.h:348
void processInternalTimers(U64 appDeltaUS, U64 gameDeltaUS, vector< TimerStruct > &timers)
Definition: Scene.cpp:1697
std::array< I64, Config::MAX_LOCAL_PLAYER_COUNT > _currentHoverTarget
Definition: Scene.h:340
bool idle()
Scene is rendering, so add intensive tasks here to save CPU cycles.
Definition: Scene.cpp:143
void currentPlayerPass(PlayerIndex idx)
Definition: Scene.cpp:1364
virtual U16 registerInputActions()
Returns the first available action ID.
Definition: Scene.cpp:825
virtual bool unload()
Definition: Scene.cpp:1303
void addTerrain(SceneGraphNode *parentNode, const boost::property_tree::ptree &pt, const Str< 64 > &nodeName="")
Definition: Scene.cpp:667
F32 getDayNightCycleTimeFactor() const noexcept
Definition: Scene.cpp:2273
std::atomic_uint _loadingTasks
Definition: Scene.h:333
void registerSceneFactory(const char *name, const ScenePtrFactory &factoryFunc)
Definition: ScenePool.cpp:27
std::unordered_map< U64, ScenePtrFactory > SceneFactoryMap
Definition: Scene.h:534
std::unordered_map< U64, Str< 256 > > SceneNameMap
Definition: Scene.h:535
void registerScene(const char *name, const SharedPtrFactory< T > &scenePtr)
Definition: Scene.h:540
boost::factory< std::shared_ptr< T > > SharedPtrFactory
Definition: Scene.h:532
std::function< std::shared_ptr< Scene >(PlatformContext &context, Project &parent, const SceneEntry &name)> ScenePtrFactory
Definition: Scene.h:533
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
DELEGATE_STD< Ret, Args... > DELEGATE
eastl::array< Player_ptr, Config::MAX_LOCAL_PLAYER_COUNT > PlayerList
Definition: Scene.h:117
vector< SceneEntry > SceneEntries
Definition: Scene.h:116
uint8_t U8
std::shared_mutex SharedMutex
Definition: SharedMutex.h:43
DirectionalLightComponent(SceneGraphNode *sgn, PlatformContext &context)
eastl::vector< Type > vector
Definition: Vector.h:42
TaskPriority
Definition: Task.h:41
Project & parent
Definition: DefaultScene.h:41
uint16_t U16
int64_t I64
uint32_t U32
Project const SceneEntry & entry
Definition: DefaultScene.h:41
uint64_t U64
vec2< I32 > _endDragPos
Definition: Scene.h:107
vec2< I32 > _startDragPos
Definition: Scene.h:106
SimpleLocation _location
Definition: Scene.h:141
DirectionalLightComponent * _sunLight
Definition: Scene.h:136
DELEGATE< void, U64 > _cbk
Definition: Scene.h:317
const TimerClass _timerClass
Definition: Scene.h:316
const U64 _callbackIntervalUS
Definition: Scene.h:315
Definition: Scene.h:112
Str< 256 > _name
Definition: Scene.h:113
std::array< I64, MAX_SELECTIONS > _selections
Definition: Scene.h:100
static constexpr U8 MAX_SELECTIONS
Definition: Scene.h:98